Hello all,
I havent came across a windows topic about being able to pass a dynamically set variable in windows to nagios so hoping to find some direction. I have a script that generates a system var and then want to send that system var value to nagios to be used as part of a file path. When I use that variable in the passive config file, the variable is not translated, it is read as literal text. Is there a method to extract the value and send to nagios to be part of the file name that the nagios log plugin looks for?
Windows passing dynamic file name to nagios plugin
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Windows passing dynamic file name to nagios plugin
Hello @mrjsokol,
Thanks,
Benjamin
I think this would be a good application for a simple wrapper script for the plugin you are using, so instead of directly running the plugin, you configure Nagios to call the wrapper script which feeds the system var into the file path for your check command. Let me know how that sounds. Also, if you can post the passive configuration for this check so we can review the command, that would be very helpful.I have a script that generates a system var and then want to send that system var value to nagios to be used as part of a file path
Thanks,
Benjamin
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!
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Windows passing dynamic file name to nagios plugin
Hello @mrjsokol,
Thanks,
Benjamin
I think this would be a good application for a simple wrapper script for the plugin you are using, so instead of directly running the plugin, you configure Nagios to call the wrapper script which feeds the system var into the file path for your check command. Let me know how that sounds. Also, if you can post the passive configuration for this check so we can review the command, that would be very helpful.I have a script that generates a system var and then want to send that system var value to nagios to be used as part of a file path
Thanks,
Benjamin
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!
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Windows passing dynamic file name to nagios plugin
Hello @mrjsokol,
Thanks,
Benjamin
I think this would be a good application for a simple wrapper script for the plugin you are using, so instead of directly running the plugin, you configure Nagios to call the wrapper script which feeds the system var into the file path for your check command. Let me know how that sounds. Also, if you can post the passive configuration for this check so we can review the command, that would be very helpful.I have a script that generates a system var and then want to send that system var value to nagios to be used as part of a file path
Thanks,
Benjamin
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: Windows passing dynamic file name to nagios plugin
The passive config command sent to nagios is: %HOSTNAME%|logic_Log|60 = plugins/check_log3.exe?match=search&args=-l %CurrlogicName% --pattern=Exception|Offline|Error %Y-%m-%d.trace
Do you think you could provide an example of what this wrapper class would look like and how would it interface with nagios? would it be directly included in the passive file or would this wrapper class be called in a different manner?
Do you think you could provide an example of what this wrapper class would look like and how would it interface with nagios? would it be directly included in the passive file or would this wrapper class be called in a different manner?
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Windows passing dynamic file name to nagios plugin
HI,
So normally, you would just call another simple script, and then that would run the plugins modify the behavior or output as required. Sor for example, the would-be something like:
Then this script would run the check_log3.exe program and feeding the appropriate arguments and return valid results to send to Nagios XI. In this case, the script would have to generate the dynamic system var. Hopefully, that would be possible but I'm not 100% on the setup here. Which variable is the one not getting passed correctly, %CurrlogicName%?
The following page has some good information about configuring Windows plugin scripts with NCPA.
https://support.nagios.com/kb/article/n ... a-722.html
Reference:
How to write a bash script wrapper
So normally, you would just call another simple script, and then that would run the plugins modify the behavior or output as required. Sor for example, the would-be something like:
Code: Select all
%HOSTNAME%|logic_Log|60 = plugins/wrapper.ps1
The following page has some good information about configuring Windows plugin scripts with NCPA.
https://support.nagios.com/kb/article/n ... a-722.html
Reference:
How to write a bash script wrapper
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: Windows passing dynamic file name to nagios plugin
Code: Select all
%HOSTNAME%|logic_Log|60 = plugins/wrapper.ps1Code: Select all
# Change $Env:PATH to $Env:YOUR_ENVIRONMENTAL_VARIABLE
# Change 'echo $IDENTIFIER' to your check command, use $IDENTIFIER variable in the check
$IDENTIFIER = $Env:PATH
$OUTPUT = cmd /c echo $IDENTIFIER 2`>`&1
$EXIT_CODE = $LASTEXITCODE
Write-Host "$OUTPUT"
exit $EXIT_CODEhttps://assets.nagios.com/downloads/nag ... inapi.html
https://nagios-plugins.org/doc/guidelines.html
Let us know if you have any questions.
Thank you!
Re: Windows passing dynamic file name to nagios plugin
Hey Guys thanks for the help! Got a solution implemented. This thread can be locked.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Windows passing dynamic file name to nagios plugin
Great!mrjsokol wrote:Hey Guys thanks for the help! Got a solution implemented. This thread can be locked.
Locking thread