Windows top Resource - Using Eventhandler - Notification
Posted: Sun Jun 19, 2016 11:33 am
Hi ,
We need to get the Top CPU and Memory consuming processes of Windows servers whenever the memory or cpu crosses the threshold level.
We have created Powershell script and added that with event handler. This works fine whenever the service gets into "Critical" and it sends us separate mail notification with the top resource details .
But we need to have the output of powershell script in the main nagios xi alert notification itself. Kindly assist.
Eventhandler script :
#!/bin/bash
SERVICEDISPLAYNAME=$2
SERVICESTATE=$3
SERVICESTATETYPE=$4
HOSTNAME=$5
DATE=$6
TIME=$7
SERVICENOTES=$8
SERVICEPERFDATA=$9
if [[ "$SERVICESTATE" == "CRITICAL" && "$SERVICESTATETYPE" == HARD ]]; then
/usr/local/nagios/libexec/check_nrpe -H $HOSTNAME -t 120 -p 5666 -c check_top >> /tmp/.event_handler_test_output.txt
mail -s event_handler_output_test [email protected] < /tmp/.event_handler_test_output.txt
exit 0
else
exit 0
fi
Powershell script :
check_top
Eventhandler command :
Name : event_handler_test
Command line : $USER1$/event_handler_test.sh $SERVICEDISPLAYNAME$ $SERVICESTATE$ $SERVICESTATETYPE$ $HOSTNAME$ $DATE$ $TIME$ $SERVICENOTES$ $SERVICEPERFDATA$
We need to get the Top CPU and Memory consuming processes of Windows servers whenever the memory or cpu crosses the threshold level.
We have created Powershell script and added that with event handler. This works fine whenever the service gets into "Critical" and it sends us separate mail notification with the top resource details .
But we need to have the output of powershell script in the main nagios xi alert notification itself. Kindly assist.
Eventhandler script :
#!/bin/bash
SERVICEDISPLAYNAME=$2
SERVICESTATE=$3
SERVICESTATETYPE=$4
HOSTNAME=$5
DATE=$6
TIME=$7
SERVICENOTES=$8
SERVICEPERFDATA=$9
if [[ "$SERVICESTATE" == "CRITICAL" && "$SERVICESTATETYPE" == HARD ]]; then
/usr/local/nagios/libexec/check_nrpe -H $HOSTNAME -t 120 -p 5666 -c check_top >> /tmp/.event_handler_test_output.txt
mail -s event_handler_output_test [email protected] < /tmp/.event_handler_test_output.txt
exit 0
else
exit 0
fi
Powershell script :
check_top
Eventhandler command :
Name : event_handler_test
Command line : $USER1$/event_handler_test.sh $SERVICEDISPLAYNAME$ $SERVICESTATE$ $SERVICESTATETYPE$ $HOSTNAME$ $DATE$ $TIME$ $SERVICENOTES$ $SERVICEPERFDATA$