Getting error in plugin
Getting error in plugin
Hi,
I'm getting below error in the plugin check.
[/usr/local/nagios/libexec/check_rdpusers.sh: line 5: [: : integer expression expected
/usr/local/nagios/libexec/check_rdpusers.sh: line 11: [: : integer expression expected
/usr/local/nagios/libexec/check_rdpusers.sh: line 15: [: : integer expression expected]
But when i manually do a run check command, it works fine.
Can you please assist me here?
# cat /usr/local/nagios/libexec/check_rdpusers.sh
#!/bin/bash
result=`/usr/local/nagios/libexec/check_nrpe -H $1 -t 60 -c "check_get_rdp_info"| grep Active | awk {'print $5'} | cut -b 11-20`
if [ "$result" -ge $2 ] ; then
if [ "$result" -lt $3 ] ; then
echo "WARNING - Remote users logged in is "$result""
exit 1
fi
fi
if [ "$result" -ge $3 ] ; then
echo "CRITICAL - Remote users logged in is "$result""
exit 2
fi
if [ "$result" -lt $2 ] ; then
echo "OK - Remote users logged in is "$result""
exit 0
fi
I'm getting below error in the plugin check.
[/usr/local/nagios/libexec/check_rdpusers.sh: line 5: [: : integer expression expected
/usr/local/nagios/libexec/check_rdpusers.sh: line 11: [: : integer expression expected
/usr/local/nagios/libexec/check_rdpusers.sh: line 15: [: : integer expression expected]
But when i manually do a run check command, it works fine.
Can you please assist me here?
# cat /usr/local/nagios/libexec/check_rdpusers.sh
#!/bin/bash
result=`/usr/local/nagios/libexec/check_nrpe -H $1 -t 60 -c "check_get_rdp_info"| grep Active | awk {'print $5'} | cut -b 11-20`
if [ "$result" -ge $2 ] ; then
if [ "$result" -lt $3 ] ; then
echo "WARNING - Remote users logged in is "$result""
exit 1
fi
fi
if [ "$result" -ge $3 ] ; then
echo "CRITICAL - Remote users logged in is "$result""
exit 2
fi
if [ "$result" -lt $2 ] ; then
echo "OK - Remote users logged in is "$result""
exit 0
fi
Re: Getting error in plugin
FYI..
Line 5 : if [ "$result" -ge $2 ]; then
Line 11: if [ "$result" -ge $3 ]; then
Line 15: if [ "$result" -lt $2 ]; then
Line 5 : if [ "$result" -ge $2 ]; then
Line 11: if [ "$result" -ge $3 ]; then
Line 15: if [ "$result" -lt $2 ]; then
Re: Getting error in plugin
PFA screenshot, the same check runs fine with the other hosts, not sure why it gives this error for other hosts. When i run a check command manually on those servers it works fine.
You do not have the required permissions to view the files attached to this post.
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Getting error in plugin
Hello, @bosecorp. You said the check command works, right? Can you run:
/usr/local/nagios/libexec/check_nrpe -H $1 -t 60 -c "check_get_rdp_info"| grep Active | awk {'print $5'} | cut -b 11-20
And demonstrate us the output.
Thanks.
/usr/local/nagios/libexec/check_nrpe -H $1 -t 60 -c "check_get_rdp_info"| grep Active | awk {'print $5'} | cut -b 11-20
And demonstrate us the output.
Thanks.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Getting error in plugin
# /usr/local/nagios/libexec/check_nrpe -H usmacssrdsh12.bose.com $1 -t 60 -c "check_get_rdp_info"| grep Active | awk {'print $5'} | cut -b 11-20
17
17
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Getting error in plugin
@ bosecorp, I think whatever result nrpe returns is a string. You may need to convert the "result" to an integer before passing it forward to the IF functions. Also, printing out the output of the $result inside the plugin may be useful during the troubleshooting process.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Getting error in plugin
i tried declaring the variable as interger
declare -i result
But it didnt worked. Not sure why the nagios check is throwing up that error. The scirpt when we run manually works fine.
# bash -x check_rdpusers.sh xxx.bose.com 25 30
+ declare -i result
++ /usr/local/nagios/libexec/check_nrpe -H xxx.bose.com -t 60 -c check_get_rdp_info
++ grep Active
++ awk '{print $5}'
++ cut -b 11-20
+ result=15
+ '[' 15 -ge 25 ']'
+ '[' 15 -ge 30 ']'
+ '[' 15 -lt 25 ']'
+ echo 'OK - Remote users logged in is 15'
OK - Remote users logged in is 15
+ exit 0
declare -i result
But it didnt worked. Not sure why the nagios check is throwing up that error. The scirpt when we run manually works fine.
# bash -x check_rdpusers.sh xxx.bose.com 25 30
+ declare -i result
++ /usr/local/nagios/libexec/check_nrpe -H xxx.bose.com -t 60 -c check_get_rdp_info
++ grep Active
++ awk '{print $5}'
++ cut -b 11-20
+ result=15
+ '[' 15 -ge 25 ']'
+ '[' 15 -ge 30 ']'
+ '[' 15 -lt 25 ']'
+ echo 'OK - Remote users logged in is 15'
OK - Remote users logged in is 15
+ exit 0
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Getting error in plugin
@bosecorp, Can you run the following commands on your plugin to make sure it has the right permissions?
Code: Select all
cd /usr/local/nagios/libexec/
chown apache:nagios check_rdpusers.sh
chmod +x check_rdpusers.shAs of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Getting error in plugin
I do not see any issues with the permission.
# ls -l check_rdpusers.sh
-rwxrwxr-x 1 apache nagios 518 Dec 12 15:10 check_rdpusers.sh
Please see the attachment in my previous comments, there you can clearly see that it works from most of the servers, but fails on some.
# ls -l check_rdpusers.sh
-rwxrwxr-x 1 apache nagios 518 Dec 12 15:10 check_rdpusers.sh
Please see the attachment in my previous comments, there you can clearly see that it works from most of the servers, but fails on some.
Re: Getting error in plugin
The script works fine when you run it manually as a root user. Does it also work, when you run it as nagios user?
What is the OS/architecture of the "failing" servers, and the version of bash that is installed on them? Is nagios added to sudoers?
What is the OS/architecture of the "failing" servers, and the version of bash that is installed on them? Is nagios added to sudoers?
Be sure to check out our Knowledgebase for helpful articles and solutions!