Nagios scripting question

Marc Powell marc at ena.com
Fri Feb 20 21:50:38 CET 2004


 

________________________________

From: Neil Lehouillier [mailto:NLehouillier at comptonpetroleum.com] 
Sent: Friday, February 20, 2004 2:14 PM
To: nagios-users at lists.sourceforge.net
Subject: [Nagios-users] Nagios scripting question



Hi all, 

I just a have a question that hopefully somebody knows the answer to. 

I'm trying to monitor SMART on unix box using the check_smart.pl script.
I have got it to work but it always reports "No Output!".  The way I
have set it up to work is like the following:

In my services.cfg file I have it setup like this: 

define service { 
host_name                      Sentry 
service_description            S.M.A.R.T - Status 
register                       1 
max_check_attempts             1 
normal_check_interval          3 
retry_check_interval           1 
check_period                   24x7 
notification_interval          0 
notification_period            24x7 
notification_options           w,u,c,r 
contact_groups                 ntadmins 
check_command                  "/usr/local/nagios/etc/scheck.sh SMART" 
} 

and in the scheck.sh file: 

if [ $1 = 'SMART' ] ; then 
/usr/local/nagios/libexec/check_smart.pl -t -d /dev/hda 
fi 

This works fine but it show up as NO OUTPUT within nagios.  I want to be
able to see the results of this command with Nagios.  Does anyone know
how to do this?

--------

Nagios is telling you exactly the right thing. It's not getting any
output from the command. I believe that you are going about this the
wrong way. To start with, your check_command in the service definition
isn't right. It should be a shortname for a command definition that you
have elsewhere. Nagios isn't going to be able to interpret what you have
above since there is no matching command definition.

define service { 
host_name                      Sentry 
service_description            S.M.A.R.T - Status 
register                       1 
max_check_attempts             1 
normal_check_interval          3 
retry_check_interval           1 
check_period                   24x7 
notification_interval          0 
notification_period            24x7 
notification_options           w,u,c,r 
contact_groups                 ntadmins 
check_command                  check_smart 
} 

With a check_smart command definition like so (using your example
above)--

define command{
        command_name    check_smart
        command_line    /usr/local/nagios/etc/scheck.sh SMART
        }

_However_, this is still going to give you problems because your
scheck.sh script a) doesn't output anything for nagios to read and b)
doesn't exit with the proper exit codes.

A better way of doing it would be to call check_smart.pl as it was
designed to be called --

define command{
        command_name    check_smart
        command_line    $USER1$/check_smart.pl -t -d /dev/hda
        }

I'm not familiar with check_smart.pl itself but I presume that the
command above is going to give you disk utilization for "/dev/hda". If
that's all you're interested in then great. If you wanted to generalize
it so you could check different partitions then you could use something
like this:

define command{
        command_name    check_smart
        command_line    $USER1$/check_smart.pl -t -d $ARG1$
        }

And then service definitions like such:

define service { 
host_name                      Sentry 
service_description            S.M.A.R.T - Status hda
register                       1 
max_check_attempts             1 
normal_check_interval          3 
retry_check_interval           1 
check_period                   24x7 
notification_interval          0 
notification_period            24x7 
notification_options           w,u,c,r 
contact_groups                 ntadmins 
check_command                  check_smart!/dev/hda
} 

define service { 
host_name                      Sentry 
service_description            S.M.A.R.T - Status hdb
register                       1 
max_check_attempts             1 
normal_check_interval          3 
retry_check_interval           1 
check_period                   24x7 
notification_interval          0 
notification_period            24x7 
notification_options           w,u,c,r 
contact_groups                 ntadmins 
check_command                  check_smart!/dev/hdb
} 


You could probably generalize the command definition even more by
passing all the arguments from the service definition. Everything above
is documented very well in the main Nagios documentation. If you want to
continue to use your scheck.sh as a wrapper, I would encourage you to
read the plugin Developer Guidelines at
http://nagiosplug.sourceforge.net/. They tell you exactly what and how
much you need to return to Nagios and how to exit properly so that
Nagios knows what the status is.

--
Marc


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list