I've worked with someone to create a PowerShell script to perform a specific check. Testing from the command line and using the API Endpoint returns the value just as it should. Running the service within the Nagios interface returns the value as it should as well.
I'd like for warning or critical to be set based on the value returned but cannot get it to work so far (it always returns ok, I assume because the script executed ok).
Here's the syntax that I've used on the service:
check_p8_queue_count_system_utility!-t <redacted>-q '' -w '25' -c '50'
What am I missing or doing wrong?
Check Value from PowerShell Script/Set Warning or Critical
Re: Check Value from PowerShell Script/Set Warning or Critic
This is almost certainly what's going on. In your Powershell script, I assume you have a section to parse the -w and -c switches? In the logic that handles whether or not the result has breached the warning/critical thresholds, I would recommend having a variable that is your script's exit code. If the result goes above the warning threshold, the variable is set to 1, if the result goes above the critical threshold, the variable is set to 2.it always returns ok, I assume because the script executed ok
Then at the bottom of the script, you can write-host whatever message you would like to be displayed, and the very last line will be
Code: Select all
exit $yourexitvariablehttps://exchange.nagios.org/directory/U ... s1/details
Otherwise, a lot of people exit the script wherever the script is in its processing. Personally, I like having a single place where the script will exit, and the logic handles things like setting an exit message and exit code.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Check Value from PowerShell Script/Set Warning or Critic
I did set up condition checking on exit and it does work fine now, thank you.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Check Value from PowerShell Script/Set Warning or Critic
Great!mbishop4 wrote:I did set up condition checking on exit and it does work fine now, thank you.
Locking thread