Script help pliz

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mocosoft
Posts: 2
Joined: Sat Feb 27, 2021 4:01 am
Contact:

Script help pliz

Post by mocosoft »

Hi, I am running a powershell script which stops and starts a service, it is a very simple one that stops a service, waits a number of seconds then restarts the service and sends an email as below

Service enters critical state

Calls this command
$USER1$/check_ncpa.py -H $HOSTADDRESS$ -t 'mytoken' -P 5693 -M 'plugins/myscript.ps1' -q "args=-servicename myservice -waittorestart 5"

Which in turn calls myscript.ps1

stop-Service $servicename
start-sleep $waittorestart
start-Service $servicename
postie -host:my host -to:my to email address -from:my from email address -s:"My subject" -msg:"my message here"

My issue is when I call this script it seems to run and restart the service when the check enters critical and then runs again when it changes back to OK from critical

Can anyone assist me please

Thanks in advance
IPOInS
Posts: 25
Joined: Tue Jan 14, 2020 6:08 am

Re: Script help pliz

Post by IPOInS »

This sounds like an event handler issue based on the change of HARD state. How is the script actually called?

This documentation shows how you can perform conditional actions based on the state e.g. only if it's HARD and CRITICAL do something.
https://assets.nagios.com/downloads/nag ... dlers.html
Locked