Script Xplat

SCOM 2012 – Try Linux Nagios Plugins e.g. File Age Check

You might remember MacGyver – a guy who could build a NASA rocket out of some explosives, matches and a steel tube. He was my hero back then but today you could also be a MacGyver by just using the tools you have and just plug it the right way together. That means MacGyver used the enemy’s weapons/tools to accomplish his mission and we are going to do the same thing. Like MacGyver we will use other source to accomplish our mission. Ok let’s start…

As you know there are many other monitoring tools out there which are far behind of SCOM but in some cases we can use their mechanic in SCOM. Let’s say you would like to monitor certain parts of Linux but you don’t know much about shell scripting then it is time to check out the Nagios plugins. These plugins are a bunch of scripts and binaries we might could use if we need to build a custom monitor for Linux.

You can find more about these plugins here or as I am going to show you in my post in some cases they are already on your Linux system and you just need to install them.

Installation

In my lab I have a SUSE Enterprise 11.1 installation which I am monitoring with SCOM 2012. On the SUSE machine start “YaST” from the start menu…

image

Choose “Software”/”Add-On Products”…

image

“Run Software Manager”…

image

Go to “Search” type “Nagios” and press “Search”. After that you will have plugins you could install. I choose “nagios-plugins” and hit “Accept”…

image

After a while your plugins are silently installed under “/usr/lib/nagios/plugins”. If you analyze these plugins a bit more, you will find out that there are different kind of plugins. Some are written in Perl, other in a shell script language e.g. bash and others are binaries.

image

I am not going to show every plugin in detail but I want to show you how it works and you get the idea behind,

Often there is a need to get the file age of a certain file. For Windows OS you mostly use a script monitor and VBScript. The nice thing is, that the Nagios plugin already has a script which we are going to use now.

File Age Script

If you run the script with a “- -help” you will see some details about the script…

image

I created a file “/tmp/test” and I will run now this script using the parameter to get a warning if the file is older than 3600 seconds or critical if the file is older than 10800 seconds. If you look at the output you see we will get a long string with a lot of information.

image

Now let’s open the script in an editor. On the top we can identify that it uses Perl to run….

image

If we scroll down, you see the line which sends the output…

image

Because we want to have just few criteria to distinguish if something is healthy or not I am going to adjust the output so we can just compare ONE expression OK/WARNING/CRITICAL…

image

If we run the script now we will see the new output…

image

Because we have now a clear output we just need to build a three-state monitor in SCOM…

Three-State Monitor

Choose “UNIX/Linux Shell Command Three State Monitor”…

image

Select a name and target…

image

Choose schedule (just for testing 1 minute)…

image

Set the command…

Note: I am providing the path to Perl first “/usr/bin/perl” and after that I will provide the path to the script because I am calling a Perl script.

image

Provide the error expression…

image

Provide the warning expression…

image

And finally the healthy expression…

image

I leave the states as they are…

image

Now I want to receive an alert and see the output in the description field…

image

If you wait long enough you will receive a warning or error.

Look closer at these pre-written plugins and you can see there are some which check hardware, Oracle connections, DNS etc. I think it is a good source to start with.

Have fun…

4 Replies to “SCOM 2012 – Try Linux Nagios Plugins e.g. File Age Check

  1. Can you use all nagios plugins with SCOM? I have some that monitor our IBM Bladecenter that id love to integrate into SCOM. (Trying to phase out nagios.)

    Thanks!

    1. Hi

      I have tried few of them, but as Long you get a return value which you can use in a monitor or rule (e.g like 0=Critical, 1=Warning, 2=Healthy) that you would be able to match to a health state it will work.

      Cheers,

      Stefan

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.