Script help pliz

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

Script help pliz

Postby mocosoft » Sat Feb 27, 2021 4:13 am

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$/ -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
Posts: 2
Joined: Sat Feb 27, 2021 4:01 am

Re: Script help pliz

Postby IPOInS » Tue Mar 02, 2021 6:07 am

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. ... dlers.html
Posts: 25
Joined: Tue Jan 14, 2020 6:08 am

Return to Community Support

Who is online

Users browsing this forum: No registered users and 15 guests