Page 1 of 1

wrapper for check_nrpe Check_OS_Version.

Posted: Fri May 10, 2024 8:01 am
by Jenkins
The purpose of the wrapper is to decode the results for the version 2019, 2022, but the simple command returns
(Return code of 127 is out of bounds. Check if plugin exists)

Running from service returns no results.

Running from command line:

[root@nagiosxiorcl libexec]# ./check_nrpe -H 10.100.32.15 -t 60 -c Check_OS_Version -2 -a show-all
OK: Windows Server 2016 (10.0.17763)|'version'=100;50;50

[root@nagiosxiorcl libexec]# ./check_nrpe_simple.sh -H 10.100.32.15 -t 60 -c Check_OS_Version -2 -a show-all
OK: Windows Server 2016 (10.0.17763)|'version'=100;50;50

script: check_nrpe_simple.sh

#!/bin/bash
cmd='/usr/local/nagios/libexec/check_nrpe'
# run command
output=`$cmd $1 $2 $3 $4 $5 $6 $7 $8 $9 `
echo $output
exit $?

# I have code replace strings in the $output but the simple wrapper is not working.

Re: wrapper for check_nrpe Check_OS_Version.

Posted: Fri May 10, 2024 8:27 am
by Jenkins
# full script with string replacement
# sorry it is ugly code
[root@nagiosxiorcl libexec]# vi check_nrpe_wrapper_check_os.sh


#!/bin/bash
cmd='/usr/local/nagios/libexec/check_nrpe'
# run command
output=`$cmd $1 $2 $3 $4 $5 $6 $7 $8 $9 `
exittrap=$?
#
length=${#output}
#echo $length
# remove special character
short=$((length-51))
# get the correct windows version for 2016 (10.0.#####(
sub_output=${output:30:$((short))}
#sub_output=$((sub_output))
text_suboutput=${output:4:19}
#echo x${text_suboutput}x
#
# Window 2008 length is 48
#
if [ $length == 48 ]; then
echo $output
elif [[ $text_suboutput == "Windows Server 2012" ]]; then
echo $output
elif [[ $length == 56 ]]; then
# change string to number
sub_output=$((sub_output))
if [ $sub_output == 14393 ]; then
echo $output |sed -r 's/Windows Server 2016 \(10.0.14393\)/Windows Server 2016/g'
fi
if [ $sub_output == 17763 ]; then
echo $output |sed -r 's/Windows Server 2016 \(10.0.17763\)/Windows Server 2019/g'
fi
if [ $sub_output == '20348' ]; then
echo $output |sed -r 's/Windows Server 2016 \(10.0.20348\)/Windows Server 2022/g'
fi
else
echo "$output"
fi
exit $exittrap

Re: wrapper for check_nrpe Check_OS_Version.

Posted: Fri May 10, 2024 8:53 am
by Jenkins
Resolved:
Command definition was defined to run remote.
It needed to run local.

# runs on local host
$USER1$/check_nrpe_wrapper_check_os.sh -H $HOSTADDRESS$ -t 60 -c $ARG1$ $ARG2$
# runs on remote host
$USER1/check_nrpe_wrapper_check_os.sh -H $HOSTADDRESS$ -t 60 -c $ARG1$ $ARG2$

I had not seen this in the documentation but it is working now.

Re: wrapper for check_nrpe Check_OS_Version.

Posted: Fri May 10, 2024 9:09 am
by sgardil
Jenkins wrote: Fri May 10, 2024 8:53 am Resolved:
Command definition was defined to run remote.
It needed to run local.

# runs on local host
$USER1$/check_nrpe_wrapper_check_os.sh -H $HOSTADDRESS$ -t 60 -c $ARG1$ $ARG2$
# runs on remote host
$USER1/check_nrpe_wrapper_check_os.sh -H $HOSTADDRESS$ -t 60 -c $ARG1$ $ARG2$

I had not seen this in the documentation but it is working now.
Hey @Jenkins

Glad you were able to find a fix for the issue. Do you happen to have a link to the documentation that you are referencing so we can get that fixed. If any other questions come up feel free to reach out.