Check_reg_key.vbs "folder not found"

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Check_reg_key.vbs "folder not found"

Post by lpereira »

scottwilkerson wrote:
lpereira wrote:Does this script work? or should i need to find a different one.
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.
I did, i run the script from windows CMD, and i added the screenshot on my previous posts.
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"

Post by scottwilkerson »

lpereira wrote:I did, i run the script from windows CMD, and i added the screenshot on my previous posts.
It needs to run SUCCESSFULLY, the screenshots are errors
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Check_reg_key.vbs "folder not found"

Post by lpereira »

scottwilkerson wrote:
lpereira wrote:I did, i run the script from windows CMD, and i added the screenshot on my previous posts.
It needs to run SUCCESSFULLY, the screenshots are errors
That's why i opened this post, i'm not able to get it working properly.

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"

Post by scottwilkerson »

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.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Check_reg_key.vbs "folder not found"

Post by lpereira »

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.
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.

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 1
This is the output when there are no differences:

Code: Select all

 PS C:\Program Files\NSClient++\scripts> C:\Program Files\NSClient++\scripts\Check_reg.ps1
NO ERROR
NO ERROR
NO ERROR
0 exit 0
From nagios Side i was able to add the command, and from GUI check results ok. However i'm having issues trying to parsing the exits in order to generate the "Critical" one.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Check_reg_key.vbs "folder not found"

Post by tmcdonald »

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
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Check_reg_key.vbs "folder not found"

Post by lpereira »

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.
3.jpg
i have added con CCM the options "-a 0" IN $ARG1$ and 2 in $ARG2$ (as you can see on the images below).
1.jpg
however i'm still having a "service ok" even if the output is 2.
2.jpg
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.
jomann
Development Lead
Posts: 611
Joined: Mon Apr 22, 2013 10:06 am
Location: Nagios Enterprises

Re: Check_reg_key.vbs "folder not found"

Post by jomann »

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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Check_reg_key.vbs "folder not found"

Post by lmiltchev »

I will give you a very simple example of a PS script that returns 0 or 2 exit codes (OK or CRITICAL).

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
    }
In the nsclient.ini

Code: Select all

check_timestamp = cmd /c echo scripts\example.ps1; exit $LastExitCode | powershell.exe -command -
Testing from the CLI on the Nagios XI server:
1. Checking a file older than one day.
example01.PNG

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 $?
2
2. Checking the updated file (newer than one day).
example02.PNG

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
Hope this helps.
You 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!
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Check_reg_key.vbs "folder not found"

Post by lpereira »

lmiltchev wrote:I will give you a very simple example of a PS script that returns 0 or 2 exit codes (OK or CRITICAL).

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
    }
In the nsclient.ini

Code: Select all

check_timestamp = cmd /c echo scripts\example.ps1; exit $LastExitCode | powershell.exe -command -
Testing from the CLI on the Nagios XI server:
1. Checking a file older than one day.
example01.PNG

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 $?
2
2. Checking the updated file (newer than one day).
example02.PNG

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
Hope this helps.
THANKS!!! that did the job

Thank you!
Locked