Nagios & ServiceDesk integration
Posted: Fri Jul 01, 2011 4:37 am
Hello,
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:
- im just trying to test it, so its very simple, i got only 1 service which is monitored atm, command should only get its name and state and write it to the files: name.not and status.not, it works ok
Next i created script which is executed everytime when notification is generated by Nagios, skrypt.sh:
- the idea of the script (so far) is to check to what the service status in Nagios has changed to, and if it is CRITICAL, it will send email to Service Desk to open a new inccident ticket and then write down its ID to the file, and if the status has changed to OK, then it will send the mail to Service Desk in order to close this inccident, if else it will create an error file.
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
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.shNext 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 [email protected] < /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 [email protected] < /usr/local/nagios/etc/mail.not
else
touch /usr/local/nagios/etc/ARGGH.ERROR
fiThe 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