Notification with 2 command

Nicola Paltani npaltani at alteanet.it
Wed Oct 11 14:20:26 CEST 2006


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

AVVISO DI RISERVATEZZA: questo messaggio ed i suoi allegati possono contenere informazioni riservate. Se avete ricevuto il messaggio per errore, vi informiamo che ogni utilizzo del suo contenuto e' proibito, pertanto, per cortesia, provvedete a cancellarlo ed informate immediatamente il mittente.

CONFIDENTIALITY NOTICE: this message and its attachments may contain confidential information. If you have received this message by mistake, be informed that any use of the content hereof is prohibited, therefore, please inform immediately the sender and delete the message, immediately.

-------------------------------------------------------------------------
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