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 Comments

  1. Pingback: “Migrating” from Nagios to SCOM | Perhaps this is useful

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s