I did, i run the script from windows CMD, and i added the screenshot on my previous posts.scottwilkerson wrote:as I had stated, we are not familiar with the plugin, you need to test it to see if it works from the Windows command line, if you cannot successfully do that, I would try something different.lpereira wrote:Does this script work? or should i need to find a different one.
Check_reg_key.vbs "folder not found"
Re: Check_reg_key.vbs "folder not found"
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Check_reg_key.vbs "folder not found"
It needs to run SUCCESSFULLY, the screenshots are errorslpereira wrote:I did, i run the script from windows CMD, and i added the screenshot on my previous posts.
Re: Check_reg_key.vbs "folder not found"
That's why i opened this post, i'm not able to get it working properly.scottwilkerson wrote:It needs to run SUCCESSFULLY, the screenshots are errorslpereira wrote:I did, i run the script from windows CMD, and i added the screenshot on my previous posts.
anyway... did you know any other scritp that might do what i need? (checking the REG_SZ value for changes)
thanks.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Check_reg_key.vbs "folder not found"
I don't know of one that does what you describe, but there is a post showing what could be put in a batch file to get some return
https://support.nagios.com/forum/viewto ... 35#p172512
This could be parsed and turned into a plugin if you added some logic.
https://support.nagios.com/forum/viewto ... 35#p172512
This could be parsed and turned into a plugin if you added some logic.
Re: Check_reg_key.vbs "folder not found"
I Finally asked a partner to create a PS1 for this. This Scritp, check diferences between 3 registry keys with 3 different plain texts, if the registry is different then will notify.scottwilkerson wrote:I don't know of one that does what you describe, but there is a post showing what could be put in a batch file to get some return
https://support.nagios.com/forum/viewto ... 35#p172512
This could be parsed and turned into a plugin if you added some logic.
this is the output for check with errors (each no error represents a folder, file, and extension):
Code: Select all
PS C:\Program Files\NSClient++\scripts> C:\Program Files\NSClient++\scripts\Check_reg.ps1
NO ERROR
NO ERROR
Registry File Modified
1 exit 1Code: Select all
PS C:\Program Files\NSClient++\scripts> C:\Program Files\NSClient++\scripts\Check_reg.ps1
NO ERROR
NO ERROR
NO ERROR
0 exit 0Re: Check_reg_key.vbs "folder not found"
Can you talk to your partner again? This is a bit out of scope of what we can support since it is a custom plugin that sounds like it needs modification. Our plugin guidelines should help with that.
Former Nagios employee
Re: Check_reg_key.vbs "folder not found"
tmcdonald wrote:Can you talk to your partner again? This is a bit out of scope of what we can support since it is a custom plugin that sounds like it needs modification. Our plugin guidelines should help with that.
i Have made a modification on the script. Now it only returns a 0 when the records are equal, and 2 when there is a modification. i have added con CCM the options "-a 0" IN $ARG1$ and 2 in $ARG2$ (as you can see on the images below). however i'm still having a "service ok" even if the output is 2. Please i need to know how to parse the outputs correctly on CCM
Thanks!
You do not have the required permissions to view the files attached to this post.
Re: Check_reg_key.vbs "folder not found"
As @tmcdonald pointed out, we can't do custom plugins, it's out of the scope of support.
I can explain briefly what I think your issue is. The output you see in the interface comes from whatever your plugin returns to the screen - in your example it was a 0 or a 2. The actual status of the plugin (OK, WARNING, CRITICAL) is based on the exit code of the plugin. This is why you're getting a 2 as the output and OK as the status.
I can explain briefly what I think your issue is. The output you see in the interface comes from whatever your plugin returns to the screen - in your example it was a 0 or a 2. The actual status of the plugin (OK, WARNING, CRITICAL) is based on the exit code of the plugin. This is why you're getting a 2 as the output and OK as the status.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Check_reg_key.vbs "folder not found"
I will give you a very simple example of a PS script that returns 0 or 2 exit codes (OK or CRITICAL).
example.ps1
In the nsclient.ini
Testing from the CLI on the Nagios XI server:
1. Checking a file older than one day.
2. Checking the updated file (newer than one day).
Hope this helps.
example.ps1
Code: Select all
$LastExitCode = 0
$output = ""
$crit = (Get-Date).AddDays(-1).toString("yyyy-M-dd")
$MyTimeStamp = Get-Item c:\TEMP\test1.txt | Foreach {$_.LastWriteTime}
$MyTimeStamp = $MyTimeStamp.toString("yyyy-M-dd")
$Message = "The timestamp on my file is: $MyTimeStamp"
if ($MyTimeStamp -lt $crit)
{
$LastExitCode = 2
echo "Critical: $Message"
exit 2
} else {
$LastExitCode = 0
echo "OK: $Message"
exit 0
}Code: Select all
check_timestamp = cmd /c echo scripts\example.ps1; exit $LastExitCode | powershell.exe -command -1. Checking a file older than one day.
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_timestamp
Critical: The timestamp on my file is: 2018-4-27
echo $?
2Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_timestamp
OK: The timestamp on my file is: 2018-7-13
echo $?
0You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Check_reg_key.vbs "folder not found"
THANKS!!! that did the joblmiltchev wrote:I will give you a very simple example of a PS script that returns 0 or 2 exit codes (OK or CRITICAL).
example.ps1In the nsclient.iniCode: Select all
$LastExitCode = 0 $output = "" $crit = (Get-Date).AddDays(-1).toString("yyyy-M-dd") $MyTimeStamp = Get-Item c:\TEMP\test1.txt | Foreach {$_.LastWriteTime} $MyTimeStamp = $MyTimeStamp.toString("yyyy-M-dd") $Message = "The timestamp on my file is: $MyTimeStamp" if ($MyTimeStamp -lt $crit) { $LastExitCode = 2 echo "Critical: $Message" exit 2 } else { $LastExitCode = 0 echo "OK: $Message" exit 0 }Testing from the CLI on the Nagios XI server:Code: Select all
check_timestamp = cmd /c echo scripts\example.ps1; exit $LastExitCode | powershell.exe -command -
1. Checking a file older than one day.2. Checking the updated file (newer than one day).Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_timestamp Critical: The timestamp on my file is: 2018-4-27 echo $? 2Hope this helps.Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_timestamp OK: The timestamp on my file is: 2018-7-13 echo $? 0
Thank you!