notification not working

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
henry.zhang87
Posts: 1
Joined: Wed Apr 10, 2013 9:48 am

notification not working

Post by henry.zhang87 »

Hi there,

I wrote a simple plugin in perl called "check_temperature.pl", and placed this plugin on both the
nagios monitor (localhost) and a remotehost. The check_temperature is called through check_nrpe as shown in the following service
definition

Code: Select all

define service{
        use                                    generic-service         ; Name of service template to use
        host_name                         remotehost
        service_description            check temperatures      ; just try to simulate
        contact_groups                  admins
        check_command                check_nrpe!check_temperature
        check_interval                   5
        notifications_enabled         1
        notification_options           w,c
        notification_period            24x7
        notification_interval          5
        register                            1
        }

On the web interface, I can see the status changes from OK to CRITICAL, however, the Last Notification shown as N/A (notification 0).
However, if I define the "check_local_temperature" on the local machine, I got email notification. On the remotehost, I got email
notification for some other services such as check_disk. Below is the simple plugin. Could someone enlighten me why the
notification is not working? Thanks a lot!

Code: Select all

#!/usr/bin/perl
use Nagios::Plugin;

#
#set up
#
$np=Nagios::Plugin->new(
   shortname=>"Temperature",
   usage=>"Usage: %s [-w warning] [-c critital] [-h host]"
);

$np->add_arg(
   spec=>"critical|c=s",
   help=>"-c, --critical=RANGE",
);

$np->add_arg(
  spec=>"warning|w=s",
  help=>"-w, --warning=RANGE",
);

$np->add_arg(
   spec=>"host|h=s",
   help=>"-h, --host=host\n. the host to be monitored",
   required=>1,
);

$np->getopts;

#
#get data
#
$celsius=int rand(100);
$host=$np->opts->host;

#------------------------------------------------------
#calculate and set the performance data
#  uom=>s,ms,us,%, B,KB,MB,TB,c or none
#  warning=>...
#  critical=>...

$np->add_perfdata(
   label=>"celsius",
   value=>$celsius,
   threshold=>$np->set_thresholds(warning=>20,critical=>$np->opts->critical),
);

#------------------------------------------------------------------
#exit with status based on the performance data. the output
#is best to be single line with less than 80 characters.
# $np->nagios_exit(CRITICAL,...)
# $np->nagios_exit(OK,...)
# $np->nagios_exit(WARNING,...)
# $np->nagios_exit(UNKNOWN,...)
np->nagios_exit(
 return_code=>$np->check_threshold($celsius),
 message=>"Temperature $celsius degrees at " . $host,
);
Last edited by mguthrie on Wed Apr 10, 2013 1:57 pm, edited 1 time in total.
Reason: use code tags please
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: notification not working

Post by mguthrie »

The notification issue wouldn't depend on the plugin, it's most likely an issue with how you've configured contacts for that service.

Can you test this service by assigning a single test contact to it and then staging a warning or critical notification?

Could this contact have an issue with the notification command being used?
Locked