im trying to do an integration of Nagios with ManageEngine ServiceDesk Plus.
The idea is to send custom email notification from Nagios, that will be parsed by ServiceDesk in order to create tickets, and close them automaticly if reported service/host returns to OK state.
Therefor, i reedited Nagios notification commandline to get required information and parse it using a bash script. However i cannot make it work properly nad im lost at current point.
This is my edited notify-service-by-email:
Code: Select all
/usr/bin/printf "%b" "$SERVICESTATE$\n" > /usr/local/nagios/etc/status.not|/usr/bin/printf "%b" "$SERVICEDESC$\n" > /usr/local/nagios/etc/name.not|/usr/local/nagios/etc/skrypt.sh
Next i created script which is executed everytime when notification is generated by Nagios, skrypt.sh:
Code: Select all
name=$(cat /usr/local/nagios/etc/name.not)
status=$(cat /usr/local/nagios/etc/status.not)
if [[$status==*CRITICAL*]];
then
topic=@SDP@$(cat /usr/local/nagios/etc/status.not)
echo @@OPERATION=AddRequest@@ > /usr/local/nagios/etc/mail.not
mail -s $topic mailaddress@xxx.com < /usr/local/nagios/etc/mail.not
sleep 70
mysql -h <sql IP> -u root -P 33366 --skip-column-names --execute="select WORKORDERID from workorder where title='CRITICAL' order by workorderid desc limit 1;" servicedesk > /usr/local/nagios/etc/id.request
elif [[$status==*OK*]];
then
id=$(cat /usr/local/nagios/etc/id.request)
topic=@SDP@
echo @@OPERATION=CloseRequest@@ > /usr/local/nagios/etc/mail.not
echo @@REQUESTID=$id@@ >> /usr/local/nagios/etc/mail.not
mail -s $topic mailaddress@xxx.com < /usr/local/nagios/etc/mail.not
else
touch /usr/local/nagios/etc/ARGGH.ERROR
fi
The script works just fine when i run it manualy on Nagios server and put desired status into file status.not manualy, however if its run through Nagios, it executes the "ELSE" condition of the script and generates ARGGH.ERROR file no matter what is the status. I completely do not understand why its doing so, it seems like its not reading variables correctly?
Please advice.
Nagios Core 3.2.3 running on Ubuntu 11.04