Page 1 of 1

script help needed

Posted: Wed Aug 04, 2021 1:15 pm
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.

Re: script help needed

Posted: Thu Aug 05, 2021 9:55 am
by gsmith
Hi

Could you please verify the registry path:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\swin\Parameters


I am not seeing it.

Thanks

Re: script help needed

Posted: Thu Aug 05, 2021 11:27 am
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.

Re: script help needed

Posted: Fri Aug 06, 2021 9:34 am
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