script help needed

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
localit
Posts: 40
Joined: Thu Oct 29, 2020 12:50 pm

script help needed

Post by localit »

I am using check_nrpe to run a script/batch file to return a registry value.

The values that is possible to be returned can be 4 different values

Values:
0x0
0x1
0x2
0x3

My goal is when the values 0x0,0x2, and 0x3 is present it should be at critical state, 0x1 should be ok state. i also want to add a message to the critical alert for example 0x0 = critical state the message i want to add is "host is in disabled mode" or is it easier to add this to my returned value?

here is my current script.

@echo off
for /F "tokens=3" %%A in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\swin\Parameters" /v "RTEMode"') DO (ECHO %%A)
exit 0


any help is appreciated.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: script help needed

Post by gsmith »

Hi

Could you please verify the registry path:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\swin\Parameters


I am not seeing it.

Thanks
localit
Posts: 40
Joined: Thu Oct 29, 2020 12:50 pm

Re: script help needed

Post by localit »

gsmith wrote:Hi

Could you please verify the registry path:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\swin\Parameters


I am not seeing it.

Thanks

gsmith this is a mcafee application we run(you prob dont run this application), I am able to get the value into nagios, but i want the additional parameters added like the criticle alert and the message/text describing the value.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: script help needed

Post by gsmith »

Hi

Here's some psuedocode:

Code: Select all

@echo off
if "0x1" == "0x1" echo "OK"
EXIT /B 0
if (warning condition) echo "WARNING"
EXIT /B 1
if  (value is one of: 0x0,0x2,0x3) echo "CRITICAL"
EXIT /B 2
if  (unknown condition) echo "UNKNOWN"
EXIT /B 3
The return codes Nagios recognizes are:
0 for OK
1 for Warning
2 for Critical
3 for Unknown

You can "echo" anything you want.

Does this help?

Thanks
Locked