Notification with 2 command
Dan Hopkins
dan.hopkins at uk.easynet.net
Wed Oct 11 15:36:48 CEST 2006
On Wed, 2006-10-11 at 14:20 +0200, Nicola Paltani wrote:
> Hi list
>
> I'm checking a big number of printers with my nagios server (more then
> 300) , in detail i'm checking the toner level through snmp , what i need
> is to send a notification via mail when the toner is law but this
> message it must contain the model of the printers form which I get the
> error , so i have made this notification command
>
> snmpwalk -v 1 -c public -Ov $HOSTADDRESS$
> HOST-RESOURCES-MIB::hrDeviceDescr.1 >
> /usr/local/nagios/libexec/printername |
>
> mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is
> $SERVICESTATE$ **" < /usr/local/nagios/libexec/printername $CONTACTEMAIL$
>
> the first command create a file with the printer model and the second
> send an email having as body the contents of the file
>
> but unluckely it doesn't work , i have discovered that the “ | ” create
> some problem , with this command i receive an empty body it ignore the
> file (printername) generated, but if i divide the command in 2 separate
> and associate all of them to a specific user it works
>
> command 1 (to create a file containing the printer model
>
> snmpwalk -v 1 -c public -Ov $HOSTADDRESS$
> HOST-RESOURCES-MIB::hrDeviceDescr.1 > /usr/local/nagios/libexec/printername
>
> command 2 (send an email which have as body the contents of printername)
>
> mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is
> $SERVICESTATE$ **" < /usr/local/nagios/libexec/printername $CONTACTEMAIL$
>
> The problem that i have is that it execute first the command 2 and than
> number 1 (i always receive the printer model of the previuos signaling),
> i have tried to change the name of the 2 command place a sleep in front
> of the 2nd command but with no results
>
> how i can merge the 2 command or at least tell nagios to execute first
> command 1 and then 2
Why not just create a plugin that queries both the toner level and the
printer name and includes the name in the plugin output?
Dan
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
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