Page 4 of 4

Re: Unable to execute a application specific cmd using check

Posted: Thu May 04, 2017 3:42 pm
by tgriep
Edit the check_by_ssh_watchque command in the nagios config file and change the command_line from

Code: Select all

command_line    $USER1$/check_by_ssh -z -E -S -t 20 -H $HOSTADDRESS$ -C "/usr/local/nagios/libexec/check_watchque"
to

Code: Select all

command_line    $USER1$/check_by_ssh -z -E -t 20 -H $HOSTADDRESS$ -C "/usr/local/nagios/libexec/check_watchque"
Save the changes and restart nagios


Then edit the /usr/local/nagios/libexec/check_watchque on the remote system and change this line from

Code: Select all

MsgRate=`/bin/cat /tmp/watchqueue_1.txt  | /bin/grep 'Total UDP Messages' | /bin/awk '{print $9}' | /bin/sed 's/(//g'`
to

Code: Select all

MsgRate=`/bin/cat /tmp/watchqueue_1.txt  | /bin/grep 'Total UDP Messages' | /bin/awk '{print $9}' | /bin/sed 's/\x1b[\[(0-9a-zA-Z;]*//g'`
Save the file

If the plugin returns valid data and also valid performance data, You can check that by selecting the service from the GUI, then the graph should start to populate.
With all of the changes, you may have to delete the .xml and .rrd files so the graph will rebuild itself with valid data.

Re: Unable to execute a application specific cmd using check

Posted: Fri May 05, 2017 5:11 am
by diwakar0304
Current code as per your advice:

Code: Select all

#!/bin/bash

EPOC1=`/bin/date +%s`
sudo /<Path to cmd>/watchqueue 1
EPOC2=`/bin/cat /tmp/watchqueue_1.txt | /bin/grep shm | /usr/bin/head -1 | /bin/awk '{print $7}' | /bin/sed 's/(//g;s/)//g'1`
        if [ "$EPOC2" -ge "$EPOC1" ]
          then
               #MsgRate=`/bin/cat /tmp/watchqueue_1.txt  | /bin/grep 'Total UDP Messages' | /bin/awk '{print $9}' | /bin/sed 's/(//g'`
               MsgRate=`/bin/cat /tmp/watchqueue_1.txt  | /bin/grep 'Total UDP Messages' | /bin/awk '{print $9}' | /bin/sed 's/\x1b[\[(0-9a-zA-Z;]*//g'`
                   /bin/echo -e "Ok: Message rate is $MsgRate | $MsgRate"
                   exit 0
           else
               /bin/echo -e "Critical: File /tmp/watchqueue_1.txt is not generated with current time"
                   exit 2
        fi
output on CLI:

Code: Select all

[nagios@NVMBRCPGNAT006VM3 ~]$  /usr/local/nagios/libexec/check_by_ssh -v -E -z -H <Remote server IP> -C "/usr/local/nagios/libexec/check_watchque"
Command: /usr/bin/ssh
Argument 1: -tt
Argument 2: <Remote server IP>
Argument 3: /usr/local/nagios/libexec/check_watchque
Ok: Message rate is (3 | (3
Nagios UI output:
Snap_nagios_ui.PNG
Snap_nagios_ui.PNG (5.61 KiB) Viewed 3585 times
Same error on performance part.

Re: Unable to execute a application specific cmd using check

Posted: Fri May 05, 2017 8:57 am
by jfrickson
It looks like some of that output is from the line sudo /<Path to cmd>/watchqueue 1 at the top. Try changing that to sudo /<Path to cmd>/watchqueue 1 &>/dev/null and see how that works.

If that works, try changing the sed command back and try it again.

Re: Unable to execute a application specific cmd using check

Posted: Sat May 06, 2017 1:03 am
by diwakar0304
&>/dev/null works!!!!!
Till this time sed command was like this

Code: Select all

MsgRate=`/bin/cat /tmp/watchqueue_1.txt  | /bin/grep 'Total UDP Messages' | /bin/awk '{print $9}' | /bin/sed 's/(//g'`

Then I have added suggested sed command

Code: Select all

MsgRate=`/bin/cat /tmp/watchqueue_1.txt  | /bin/grep 'Total UDP Messages' | /bin/awk '{print $9}' | /bin/sed 's/\x1b[\[(0-9a-zA-Z;]*//g'`
and getting below output:

Code: Select all

Ok: Message rate is (1 | (1
To remove brackets, I added one more sed option next to your suggested one:

Code: Select all

MsgRate=`/bin/cat /tmp/watchqueue_1.txt  | /bin/grep 'Total UDP Messages' | /bin/awk '{print $9}' | /bin/sed 's/\x1b[\[(0-9a-zA-Z;]*//g;s/(//g'`

But still not getting performance output. /usr/local/pnp4nagios/var/perfdata/<hostname> file for msg_rate itself is not getting generate. All other service are properly updating in this directory./
Strace_performance_not.txt
(6.47 KiB) Downloaded 370 times
BR///

Re: Unable to execute a application specific cmd using check

Posted: Mon May 08, 2017 11:34 am
by tgriep
I just want to verify but when the check is run, is this the output that is printed to the screen, or something simular?
Ok: Message rate is 0 | 0\r\n", 27Ok: Message rate is 0 | 0
If so, the output for the performance data is not formatted correctly and that is why the graphs are not getting created.
Take a look at this link to see how the performance data needs to be formatted.
https://nagios-plugins.org/doc/guidelines.html#AEN200

Re: Unable to execute a application specific cmd using check

Posted: Fri Feb 23, 2018 5:06 am
by diwakar0304
Thanks every one for your efforts and support. Please lock this thread.