Have you considered using the $SERVICEPROBLEMID$ and $HOSTPROBLEMID$ in nagios for tracking? These are unique numbers that track problems internally in nagios.
http://nagios.sourceforge.net/docs/3_0/macrolist.html
Error with custom service macros and event handling.
Re: Error with custom service macros and event handling.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Error with custom service macros and event handling.
Well, progress has been made!
Here are the services:
Here is command definition:
Here is the script that takes in all the variables - restartserviceMaximo2.sh
And here is the output:
Thanks!
- Jim
Here are the services:
Code: Select all
_SERVICE restart_sw114
_CLASSIFICATIONID SC_WORKFLOW_PORTAL
_HIERARCHYPATH SC_APP_SYS "\\" SC_WORKFLOW_PORTAL
_CLASSSTRUCTUREID 5642
_DESCRIP 'sw114 DeltaSession Manager has stopped running.'
_FR1CODE 'Unknown - code issue.'
_FR2CODE 'Restart standalone java process.'
_PROBLEMCODE 'Standalone sw114 process terminated on its own.'
_IMPACT 3
_INTERNALPRIORITY 4
_REPORTEDPRIORITY 3
_URGENCY 3
_OWNER AR333
_OWNERGROUP WASTEAM
Code: Select all
define command {
command_name restart-service-maximo
command_line /usr/bin/printf "%b" "$NAGIOS_SERVICESTATE\n$NAGIOS_HOSTADDRESS\n\"$NAGIOS__SERVICECLASSIFICATIONID\"\n\"$NAGIOS__SERVICEHIERARCHYPATH\"\n\"$NAGIOS__SERVICECLASSSTRUCTUREID\"\n\"$NAGIOS__SERVICEDESCRIP\"\n\"$NAGIOS__SERVICEFR1CODE\"\n\"$NAGIOS__SERVICEFR2CODE\"\n\"$NAGIOS__SERVICEPROBLEMCODE\"\n\"$NAGIOS__SERVICEIMPACT\"\n\"$NAGIOS__SERVICEINTERNALPRIORITY\"\n\"$NAGIOS__SERVICEREPORTEDPRIORITY\"\n\"$NAGIOS__SERVICEURGENCY\"\n\"$NAGIOS__SERVICEOWNER\"\n\"$NAGIOS__SERVICEOWNERGROUP\"\n$NAGIOS_SERVICEPROBLEMID" | $USER1$/restartserviceMaximo2.sh
}
Code: Select all
#!/bin/bash
ARRAY=()
while read -r LINE
do
ARRAY+=("$LINE")
done
SERVICESTATE=${ARRAY[0]}
HOSTADDRESS=${ARRAY[1]}
SERVICECLASSIFICATIONID=${ARRAY[2]}
HIERARCHYPATH=${ARRAY[3]}
CLASSSTRUCTUREID=${ARRAY[4]}
DESCRIPTION=${ARRAY[5]}
FR1CODE=${ARRAY[6]}
FR2CODE=${ARRAY[7]}
PROBLEMCODE=${ARRAY[8]}
IMPACT=${ARRAY[9]}
INTERNALPRIORITY=${ARRAY[10]}
REPORTEDPRIORITY=${ARRAY[11]}
URGENCY=${ARRAY[12]}
OWNER=${ARRAY[13]}
OWNERGROUP=${ARRAY[14]}
SVCPROBLEMID=${ARRAY[15]}
case "$SERVICESTATE" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
echo "$SERVICESTATE $HOSTADDRESS $SERVICECLASSIFICATIONID $HIERARCHYPATH $CLASSSTRUCTUREID $DESCRIPTION $FR1CODE $FR2CODE $PROBLEMCODE $IMPACT $INTERNALPRIORITY $REPORTEDPRIORITY $URGENCY $OWNER $OWNERGROUP $SVCPROBLEMID" > /tmp/newvars2.txt
#for LINE in "${ARRAY[@]}"
#do
# echo "$LINE" >> /tmp/newvars2.txt
#done
;;
esac
exit 0;
The only thing that isn't coming across is the last field in the command - $NAGIOS_SERVICEPROBLEMID. I've tried $NAGIOS_SERVICEPROBLEMID, $NAGIOS__SERVICEPROBLEMID and $SERVICEPROBLEMID and nothing is coming across. Any suggestions for getting the $SERVICEPROBLEMID to come across?CRITICAL 10.14.172.238 "SC_WORKFLOW_PORTAL" "SC_APP_SYS \ SC_WORKFLOW_PORTAL" "5642" "sw114 DeltaSession Manager has stopped running." "Unknown - code issue." "Restart standalone java process." "Standalone sw114 process terminated on its own." "3" "4" "3" "3" "AR333" "WASTEAM"
Thanks!
- Jim
Re: Error with custom service macros and event handling.
As these are built-in macros, you should be able to add them to the command like so:
Note the bookended "$": $SERVICEPROBLEMID$
Code: Select all
define command {
command_name restart-service-maximo
command_line /usr/bin/printf "%b" "$NAGIOS_SERVICESTATE\n$NAGIOS_HOSTADDRESS\n\"$NAGIOS__SERVICECLASSIFICATIONID\"\n\"$NAGIOS__SERVICEHIERARCHYPATH\"\n\"$NAGIOS__SERVICECLASSSTRUCTUREID\"\n\"$NAGIOS__SERVICEDESCRIP\"\n\"$NAGIOS__SERVICEFR1CODE\"\n\"$NAGIOS__SERVICEFR2CODE\"\n\"$NAGIOS__SERVICEPROBLEMCODE\"\n\"$NAGIOS__SERVICEIMPACT\"\n\"$NAGIOS__SERVICEINTERNALPRIORITY\"\n\"$NAGIOS__SERVICEREPORTEDPRIORITY\"\n\"$NAGIOS__SERVICEURGENCY\"\n\"$NAGIOS__SERVICEOWNER\"\n\"$NAGIOS__SERVICEOWNERGROUP\"\n$SERVICEPROBLEMID$" | $USER1$/restartserviceMaximo2.sh
}Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.