Unable to execute a application specific cmd using check_nrp
-
- Posts: 28
- Joined: Tue Nov 04, 2014 4:19 am
Re: Unable to execute a application specific cmd using check
Thanks for patience and response.
/tmp/watchqueue_1.txt itself not generating. Which suppose to be generated after running "watchqueue 1" command.
How ever I feel it is something related to tty session.
As I have shown output from check_by_ssh, if tty is unknown then /tmp/watchqueue_1.txt file is not generated. If there any tty assigned then script works perfectly.
/tmp/watchqueue_1.txt itself not generating. Which suppose to be generated after running "watchqueue 1" command.
How ever I feel it is something related to tty session.
As I have shown output from check_by_ssh, if tty is unknown then /tmp/watchqueue_1.txt file is not generated. If there any tty assigned then script works perfectly.
Re: Unable to execute a application specific cmd using check
Did you add the following line to the /etc/sudoers file?
Also, uncomment this option in the sudoers file as well.
Try that and see if that works for you.
Code: Select all
Defaults:nagios !requiretty
Code: Select all
Defaults !visiblepw
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 28
- Joined: Tue Nov 04, 2014 4:19 am
Re: Unable to execute a application specific cmd using check
sudoer file:
command executed:
Logs:
Code: Select all
Defaults:nagios !requiretty
Defaults !visiblepw
Defaults always_set_home
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:
root ALL=(ALL) ALL
nagios ALL=(ALL) NOPASSWD:ALL
Code: Select all
Logapp nagios:~ 0$ /usr/local/nagios/libexec/check_nrpe -H localhost -c check_watchque
Critical: File /tmp/watchqueue_1.txt is not generated with current time
Code: Select all
<31>Apr 27 09:06:21 localhost nrpe[24192]: Connection from 127.0.0.1 port 28582
<31>Apr 27 09:06:21 localhost nrpe[24192]: Host address is in allowed_hosts
<31>Apr 27 09:06:21 localhost nrpe[24192]: Host 127.0.0.1 is asking for command 'check_watchque' to be run...
<31>Apr 27 09:06:21 localhost nrpe[24192]: Running command: /usr/local/nagios/libexec/check_watchque
<85>Apr 27 09:06:21 localhost sudo: nagios : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/<path to command>/watchqueue 1
<31>Apr 27 09:06:21 localhost nrpe[24192]: Command completed with return code 2 and output: Critical: File /tmp/watchqueue_1.txt is not generated with current time
<31>Apr 27 09:06:21 localhost nrpe[24192]: Return Code: 2, Output: Critical: File /tmp/watchqueue_1.txt is not generated with current time
<31>Apr 27 09:06:21 localhost nrpe[24192]: Connection from 127.0.0.1 closed.
Last edited by diwakar0304 on Wed May 03, 2017 12:58 pm, edited 1 time in total.
Re: Unable to execute a application specific cmd using check
If the path to the watchqueue command is an environment variable and not actually in the check_watchque script, that could be the issue because the environment variable it not available when the command it run by NRPE.
Can you put in the full path to the command and see if that works?
Can you put in the full path to the command and see if that works?
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 28
- Joined: Tue Nov 04, 2014 4:19 am
Re: Unable to execute a application specific cmd using check
In my all post I always mention /<path to cmd>/watchqueue is actually complete path with command in all instance. Same is mentioned in script since starting. I had tried to pass command with path or without path in both
- tacolover101
- Posts: 432
- Joined: Mon Apr 10, 2017 11:55 am
Re: Unable to execute a application specific cmd using check
jumping in late, but what i would do is debug your variables before exiting so you can see what they're equal to so you can check the internal logic of your script.
Code: Select all
`/bin/cat /tmp/watchqueue_1.txt | /bin/grep shm | /usr/bin/head -1 | /bin/awk '{print $7}' | /bin/sed 's/(//g;s/)//g'` -ge `/bin/date +%s`
Re: Unable to execute a application specific cmd using check
Without knowing what the requirements are for running the watchqueue command, it is hard to guess how to fix it.
Another thing to try is to add this line to your /etc/sudoers file and see if this helps.
Also, can you run the following commands on your remote server and post the output?
Another thing to try is to add this line to your /etc/sudoers file and see if this helps.
Code: Select all
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_watchque
Code: Select all
change -l nagios
grep nag /etc/passwd
grep nag /etc/group
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 28
- Joined: Tue Nov 04, 2014 4:19 am
Re: Unable to execute a application specific cmd using check
@tacolover101 : If you want further debug than on bash shell, strace output attached with my previous post.
Logapp nagios:~/libexec 0$ bash -xxx /usr/local/nagios/libexec/check_watchque
@tgriep :
Same result, no success for below attempt:
as per your required output:
Now to understand, I am uploading the watchqueue 1 command strace output.
I hope this will help you to understand the requirement to run this command. BR//
Logapp nagios:~/libexec 0$ bash -xxx /usr/local/nagios/libexec/check_watchque
Code: Select all
+ sudo /<Path to command>/watchqueue 1
++ /bin/cat /tmp/watchqueue_1.txt
++ /bin/grep shm
++ /usr/bin/head -1
++ /bin/awk '{print $7}'
++ /bin/sed 's/(//g;s/)//g1'
+ EPOC2=1493533427
++ /bin/cat /tmp/watchqueue_1.txt
++ /bin/grep shm
++ /usr/bin/head -1
++ /bin/awk '{print $7}'
++ /bin/sed 's/(//g;s/)//g'
++ /bin/date +%s
+ '[' 1493533427 -ge 1493533427 ']'
++ /bin/cat /tmp/watchqueue_1.txt
++ /bin/grep 'Total UDP Messages'
++ /bin/awk '{print $9}'
++ /bin/sed 's/(//g'
+ MsgRate=7
+ /bin/echo 'Ok: Message rate is 7 | 7'
Ok: Message rate is 7 | 7
+ exit 0
Same result, no success for below attempt:
Code: Select all
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_watchque
I hope this will help you to understand the requirement to run this command. BR//
Re: Unable to execute a application specific cmd using check
I am seeing a lot of "ENOENT (No such file or directory" errors for the libraries the application is trying to use.
Make sure the paths for your libraries are in the ld.so.conf file and that the ld.so.cache file is rebuilt by running ldconfig on the server as root.
Also, does that script try and open/run xterm?
That could be another issue as NRPE is running without a terminal and it cannot execute it.
Make sure the paths for your libraries are in the ld.so.conf file and that the ld.so.cache file is rebuilt by running ldconfig on the server as root.
Also, does that script try and open/run xterm?
Code: Select all
access("/usr/local/nagios/.terminfo/x/xterm", R_OK) = -1 ENOENT (No such file or directory)
access("/<Path to application directory>/share/terminfo/x/xterm", R_OK) = 0
open("/<Path to application directory>/share/terminfo/x/xterm", O_RDONLY) = 3
read(3, "\32\0010\0&\0\17\0\235\1&\5", 12) = 12
read(3, "xterm|xterm terminal emulator (X"..., 48) = 48
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 28
- Joined: Tue Nov 04, 2014 4:19 am
Re: Unable to execute a application specific cmd using check
Strace output shared was for successful execution only, you can see it's opens a file /tmp/watchqueue_1.txt.
No issue for ENOENT in strace.
Since starting I am trying to point out on terminal issue while executing check_script. To achieve same I switch to check_by_ssh with force tty option.
Post implementing the check_by_ssh in nagios, it's not pulling correct value. I have attached output for same in my previous post too.
No issue for ENOENT in strace.
Since starting I am trying to point out on terminal issue while executing check_script. To achieve same I switch to check_by_ssh with force tty option.
Post implementing the check_by_ssh in nagios, it's not pulling correct value. I have attached output for same in my previous post too.