Unable to execute a application specific cmd using check_nrp

This forum is intended for the discussion of Nagios Core development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagios-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Re: Unable to execute a application specific cmd using check

Postby tgriep » Thu May 04, 2017 3:42 pm

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!
User avatar
tgriep
Madmin
 
Posts: 6078
Joined: Thu Oct 30, 2014 9:02 am

Re: Unable to execute a application specific cmd using check

Postby diwakar0304 » Fri May 05, 2017 5:11 am

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 470 times


Same error on performance part.
diwakar0304
 
Posts: 25
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Postby jfrickson » Fri May 05, 2017 8:57 am

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.
Former Nagios Employee
jfrickson
Developer
 
Posts: 188
Joined: Wed Jul 22, 2015 9:58 am

Re: Unable to execute a application specific cmd using check

Postby diwakar0304 » Sat May 06, 2017 1:03 am

&>/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 35 times


BR///
diwakar0304
 
Posts: 25
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Postby tgriep » Mon May 08, 2017 11:34 am

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!
User avatar
tgriep
Madmin
 
Posts: 6078
Joined: Thu Oct 30, 2014 9:02 am

Previous

Return to Nagios Core Development

Who is online

Users browsing this forum: No registered users and 11 guests