Commands not being executed.
Commands not being executed.
Hi.
We have a local installation of Nagios Core 4.3.4 which doesn't seem to be executing any commands even though all the logs suggest the command has been run:
Log:
[Thu Nov 16 13:05:34 2017] EXTERNAL COMMAND: SEND_CUSTOM_SVC_NOTIFICATION;server;Service-Test;0;nagios.user;testing
[Thu Nov 16 13:05:34 2017] SERVICE NOTIFICATION: server;server;Service-Test;CUSTOM (CRITICAL);notifyservice-server;CRITICAL: No Recent Passive Service Checks.;nagios.user;testing
Debug:
[Thu Nov 16 13:05:34 2017.937806] [2048.1] [pid=5607] **** BEGIN MACRO PROCESSING ***********
[Thu Nov 16 13:05:34 2017.937814] [2048.1] [pid=5607] Processing: '/bin/echo "has this command worked?" > /tmp/nagios.test'
[Thu Nov 16 13:05:34 2017.937825] [2048.1] [pid=5607] Done. Final output: '/bin/echo "has this command worked?" > /tmp/nagios.test'
[Thu Nov 16 13:05:34 2017.937834] [2048.1] [pid=5607] **** END MACRO PROCESSING *************
[Thu Nov 16 13:05:34 2017.937896] [001.0] [pid=5607] process_macros_r()
[Thu Nov 16 13:05:34 2017.937907] [2048.1] [pid=5607] **** BEGIN MACRO PROCESSING ***********
[Thu Nov 16 13:05:34 2017.937916] [2048.1] [pid=5607] Processing: 'SERVICE NOTIFICATION: server;server;Service-Test;CUSTOM ($SERVICESTATE$);notifyservice-server;$SERVICEOUTPUT$;$NOTIFICATIONAUTHOR$;$NOTIFICATIONCOMMENT$
'
[Thu Nov 16 13:05:34 2017.937936] [2048.1] [pid=5607] Done. Final output: 'SERVICE NOTIFICATION: server;server;Service-Test;CUSTOM (CRITICAL);notifyservice-server;CRITICAL: No Recent Passive Service Checks.;nagios.user;testing
'
[Thu Nov 16 13:05:34 2017.937970] [2048.1] [pid=5607] **** END MACRO PROCESSING *************
In this case the /tmp/nagios.test file doesn't get created.
I have tried various different commands and, although all of them say they have been run, none of them actually do anything.
Running all the commands manually as the Nagios user work successfully.
Can anyone suggest what the problem may be?
Thanks.
We have a local installation of Nagios Core 4.3.4 which doesn't seem to be executing any commands even though all the logs suggest the command has been run:
Log:
[Thu Nov 16 13:05:34 2017] EXTERNAL COMMAND: SEND_CUSTOM_SVC_NOTIFICATION;server;Service-Test;0;nagios.user;testing
[Thu Nov 16 13:05:34 2017] SERVICE NOTIFICATION: server;server;Service-Test;CUSTOM (CRITICAL);notifyservice-server;CRITICAL: No Recent Passive Service Checks.;nagios.user;testing
Debug:
[Thu Nov 16 13:05:34 2017.937806] [2048.1] [pid=5607] **** BEGIN MACRO PROCESSING ***********
[Thu Nov 16 13:05:34 2017.937814] [2048.1] [pid=5607] Processing: '/bin/echo "has this command worked?" > /tmp/nagios.test'
[Thu Nov 16 13:05:34 2017.937825] [2048.1] [pid=5607] Done. Final output: '/bin/echo "has this command worked?" > /tmp/nagios.test'
[Thu Nov 16 13:05:34 2017.937834] [2048.1] [pid=5607] **** END MACRO PROCESSING *************
[Thu Nov 16 13:05:34 2017.937896] [001.0] [pid=5607] process_macros_r()
[Thu Nov 16 13:05:34 2017.937907] [2048.1] [pid=5607] **** BEGIN MACRO PROCESSING ***********
[Thu Nov 16 13:05:34 2017.937916] [2048.1] [pid=5607] Processing: 'SERVICE NOTIFICATION: server;server;Service-Test;CUSTOM ($SERVICESTATE$);notifyservice-server;$SERVICEOUTPUT$;$NOTIFICATIONAUTHOR$;$NOTIFICATIONCOMMENT$
'
[Thu Nov 16 13:05:34 2017.937936] [2048.1] [pid=5607] Done. Final output: 'SERVICE NOTIFICATION: server;server;Service-Test;CUSTOM (CRITICAL);notifyservice-server;CRITICAL: No Recent Passive Service Checks.;nagios.user;testing
'
[Thu Nov 16 13:05:34 2017.937970] [2048.1] [pid=5607] **** END MACRO PROCESSING *************
In this case the /tmp/nagios.test file doesn't get created.
I have tried various different commands and, although all of them say they have been run, none of them actually do anything.
Running all the commands manually as the Nagios user work successfully.
Can anyone suggest what the problem may be?
Thanks.
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Commands not being executed.
Does the nagios user have access to write to /tmp?
Also, what's the output of the following commands:
Did this work on this server with earlier versions of Core?
Also, what's the output of the following commands:
Code: Select all
ll /usr/local/nagios/var/rw
ll -d /usr/local/nagios/var/rw
sestatus
Re: Commands not being executed.
The nagios user can write to /tmp. I have tested all the commands I've tried from the command line as the nagios user, they all work fine.
Output as requested:
Output as requested:
Code: Select all
[root@nagios etc]# ll /usr/local/nagios/var/rw
total 0
srw-rw---- 1 nagios nagios 0 Nov 17 09:41 nagios.qh
Code: Select all
[root@nagios etc]# ll -d /usr/local/nagios/var/rw
drwxrwsr-x 2 nagios nagios 4096 Nov 17 09:41 /usr/local/nagios/var/rw
Code: Select all
[root@nagios etc]# sestatus
SELinux status: disabled
Re: Commands not being executed.
Hi @invade,
Please follow the steps below and attach a file with output from each step.
Step 1
Please go to your command line and run the command below:
For Centos 7...cat /usr/local/nagios/var/rw/nagios.cmd
For Centos 6...tail -f /usr/local/nagios/var/rw/nagios.cmd
Then go to your Nagios Core Web UI and submit a passive and an active check on a service as you watch the output from the command line.
Step 2
Secondly, please go to your command line and run the following command...tail -f /var/log/httpd/access_log
Then go to your Nagios Core Web UI and submit a passive check and an active check on a service as you watch the output from the command line.
Example:
Lastly, please attach a copy of your nagios.cfg file located at /usr/local/nagios/etc/nagios.cfg (or wherever you have it located).
Please follow the steps below and attach a file with output from each step.
Step 1
Please go to your command line and run the command below:
For Centos 7...cat /usr/local/nagios/var/rw/nagios.cmd
For Centos 6...tail -f /usr/local/nagios/var/rw/nagios.cmd
Then go to your Nagios Core Web UI and submit a passive and an active check on a service as you watch the output from the command line.
Step 2
Secondly, please go to your command line and run the following command...tail -f /var/log/httpd/access_log
Then go to your Nagios Core Web UI and submit a passive check and an active check on a service as you watch the output from the command line.
Example:
Lastly, please attach a copy of your nagios.cfg file located at /usr/local/nagios/etc/nagios.cfg (or wherever you have it located).
Re: Commands not being executed.
Which OS/Distro have you installed Nagios Core on?
I know that resent releases of RHEL and CentOS have a new "Security Feature": PrivateTmp
So if you are running on any of those (I do not know if other distros are "affected") you could have run into this.
For an explanation of the "Feature" see: https://access.redhat.com/blogs/766093/posts/1976243
I know that resent releases of RHEL and CentOS have a new "Security Feature": PrivateTmp
So if you are running on any of those (I do not know if other distros are "affected") you could have run into this.
For an explanation of the "Feature" see: https://access.redhat.com/blogs/766093/posts/1976243
--
D/\N
D/\N
Re: Commands not being executed.
Hi. Information as requested.dwasswa wrote:Hi @invade,
Please follow the steps below and attach a file with output from each step.
Step 1
Please go to your command line and run the command below:
For Centos 7...cat /usr/local/nagios/var/rw/nagios.cmd
For Centos 6...tail -f /usr/local/nagios/var/rw/nagios.cmd
Then go to your Nagios Core Web UI and submit a passive and an active check on a service as you watch the output from the command line.
Step 2
Secondly, please go to your command line and run the following command...tail -f /var/log/httpd/access_log
Then go to your Nagios Core Web UI and submit a passive check and an active check on a service as you watch the output from the command line.
Example:
Lastly, please attach a copy of your nagios.cfg file located at /usr/local/nagios/etc/nagios.cfg (or wherever you have it located).
Step 1. Tailing the cmd file returned no output. We are running Nagios on CentOS 6.9.
Step 2.
192.168.0.139 - user [21/Nov/2017:09:32:40 +0000] "GET /nagios/cgi-bin/extinfo.cgi?type=1&host=host HTTP/1.1" 200 12379 "http://nagios/nagios/cgi-bin/extinfo.cg ... &host=host" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
192.168.0.139 - user [21/Nov/2017:09:34:11 +0000] "GET /nagios/cgi-bin/extinfo.cgi?type=1&host=host HTTP/1.1" 200 11828 "http://nagios/nagios/cgi-bin/extinfo.cg ... &host=host" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
192.168.0.139 - user [21/Nov/2017:09:34:15 +0000] "GET /nagios/cgi-bin/cmd.cgi?cmd_typ=87&host=host HTTP/1.1" 200 3051 "http://nagios/nagios/cgi-bin/extinfo.cg ... &host=host" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
192.168.0.139 - user [21/Nov/2017:09:34:31 +0000] "POST /nagios/cgi-bin/cmd.cgi HTTP/1.1" 200 1327 "http://nagios/nagios/cgi-bin/cmd.cgi?cm ... &host=host" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
Config file attached.
Many thanks.
- Attachments
-
- nagios.cfg
- (3.39 KiB) Downloaded 415 times
Re: Commands not being executed.
Have you modified this directive?
The "default" path should be:
Try using fixing the path to the nagios.cmd in the nagios.cfg file, then restart nagios. Let us know if this helped.
Code: Select all
command_file=/var/log/nagios/nagios.cmd
Code: Select all
command_file=/usr/local/nagios/var/rw/nagios.cmd
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Commands not being executed.
Hi. I've inherited this build from someone else. To cut a long story short, I've built a new server from scratch and the commands now appear to be getting executed successfully.lmiltchev wrote:Have you modified this directive?The "default" path should be:Code: Select all
command_file=/var/log/nagios/nagios.cmd
Try using fixing the path to the nagios.cmd in the nagios.cfg file, then restart nagios. Let us know if this helped.Code: Select all
command_file=/usr/local/nagios/var/rw/nagios.cmd
Thanks to every for their assistance.
Re: Commands not being executed.
Sounds good! I'll be closing this thread!
If you have any more questions, feel free to create another thread.
Thanks for using the Nagios Support Forum!
If you have any more questions, feel free to create another thread.
Thanks for using the Nagios Support Forum!