Unable to execute a application specific cmd using check_nrp

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Unable to execute a application specific cmd using check

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
diwakar0304
Posts: 28
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Post 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 3542 times
Same error on performance part.
jfrickson

Re: Unable to execute a application specific cmd using check

Post 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.
diwakar0304
Posts: 28
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Post 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 366 times
BR///
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Unable to execute a application specific cmd using check

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
diwakar0304
Posts: 28
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Post by diwakar0304 »

Thanks every one for your efforts and support. Please lock this thread.
Locked