Skip to content

Conversation

@coreypenford
Copy link

@coreypenford coreypenford commented Feb 7, 2019

With the current recommended PowerShell wrapping, if it cannot run the script (due to a missing script or bad script i.e. misplaced characters/bad syntax), it returns 0 and fails silently. This is due to $lastexitcode returning a 0 when it is unable to even start to run a script.

Failing silently is never a good default for monitoring software, and this can be a big issue when mass deploying custom checks as it is impractical to manually verify each one.

This PR updates the how-to documentation to include a Try/Catch block on the PS wrappings. This way if powershell is unable to run the script, it exits with a 3 and reports the $error. Otherwise, the script will run and return it's $lastexitcode.

Testing and discussion occurred here originally. https://support.nagios.com/forum/viewtopic.php?f=6&t=51591

I looked if the default nsclient.ini included the wrapping and it did not, so it appears the documentation is the only thing that needs to be updated. While updating the documentation I fixed some wording and a few typos as well, hope you don't mind. Feel free to make any changes you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant