Nagios config ?
Hi all,
I have spent most of my day trying to configure nagios and have had limited success. I got it up and running (installation, webinterface set up and authourisation) but struggling with configuration files. I know that I need to configure a number of files: nagios.cfg, hosts.cfg, hostgroups.cfg , services.cfg, contacts.cfg, contactgroups.cfg (bare minimum). I have tried to configure them but I always get some kind of errors/warnings. Could someone post a working sample of the above files ? Any help would be greatly appreciated :-). |
Post your config files and post the error your getting.
|
Hi there,
I got it working but still have a small problem. The only thing that I can't do is to use web interface to start/stop/reschedule nagios. The error I am gettin is Quote:
I think I have setup my permissions correclty: Quote:
Quote:
any suggestions ? |
Are you sure nagios.cmd doesn't need to be an executable file rather than a FIFO pipe (hence "p" at the beginning of permissions)?
But that probably isn't the problem, since "stat()" should work anyways probably. Under what user is your web interface running? Does this user have access to the nagios.cmd file and execute permission on all directories above? (so all dirs in /usr/local/nagios/var/rw/nagios.cmd)? Also, does the web interface use a chroot environment? |
resolution
I came across this thread and thought I post post to anyone who is getting this error and is certain their permissions are set correctly.
I played with this for hours and hours and hours and RTFM helped me. (I am on CentOS) The following fixed my problem: (this is right from the Nagios docs) 8) Modify SELinux Settings Fedora ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs. See if SELinux is in Enforcing mode. getenforce Put SELinux into Permissive mode. setenforce 0 To make this change permanent, you'll have to modify the settings in /etc/selinux/config and reboot. Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode: chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/ chcon -R -t httpd_sys_content_t /usr/local/nagios/share/ |
still not working for me
I got the same error, I tried with disabling the se linux setting also tried
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/ and chcon -R -t httpd_sys_content_t /usr/local/nagios/share/ but still not working for me :) Juned |
I'm having a very similar problems on CentOS. If I "setenforce 0" then I can run external Nagios commands. I tried the chcon command above without success. The problem is SELinux but configuring SELinux is more cryptic then Sendmail. Any help or suggestions is appreciated.
Thanks! |
Solution
Hi, i have had the same problem for a long time.
This might be a bit late now since the thread is over a year old but still, maybe it helps other people. for me i made an error during the starting, if you follow the nagios quick start guide (which most of you did i assume) at the end of the installation you have to start nagios with the following command: "/etc/init.d/nagios start" and if you do this twice for some reason it loads nagios twice and runs into an error because it doesnt know which of the two to restart. so just stop and start it 1. /etc/init.d/nagios stop 2. /etc/init.d/nagios start you might want to run the stop twice just to make sure both nagios are stopped again before restarting. (ofcourse you can use the reload or force-reload option but i'd rather try the stop) Greetings |
Quote:
EDIT: I got the problem. Make sure you have installed postfix. |
Nagios: Error: Could not stat() command file '/usr/local/nagios/var/rw/nagios.cmd'!
The problem with this issue is definitely with SELinux, if you temporarily set it to permissive mode, all external commands work well. The question now is: What to do so that you can set SELinux to enforcing mode while still having Nagio's external commands working?
|
I found this thread in a search, and likewise I think the problem is related to selinux - just because I've had so many other problems with selinux. But in this case I setenforce 0 and am still seeing the issue.
I compared the permissions with a "known good" instance of Nagios & they're the same: [root@monitor rw]# ls -lt total 4 prw-rw---- 1 nagios nagios 0 Oct 19 07:19 nagios.cmd [root@monitor rw]# cd /var/log/ [root@monitor log]# Also, I see that the date on the file is updated when I execute the command - so it is doing something. Any clues? |
Quote:
Code:
sudo chcon -R -t httpd_sys_script_rw_t /usr/local/nagios/var/rw |
Quote:
Thanks for your info. I was unable to modify the type to httpd_sys_script_t instead httpd_sys_script_rw_t worked. Can you let me know any other things I have to know behind this scene. I was doing this becoz errors in /var/log/messages say that it is trying to access the file as type httpd_sys_script_t |
Quote:
when I checked the location nagios.cmd was not even there. after stopping and starting the service again nagios.cmd is now present and everything went back to normal. |
nagios / chcon
The problem I have found with using the chcon command is the file context being restored to the original context upon a system relabel. I think it is best to add the changes to the selinux database with:
semanage fcontext -a -f "-p" -t httpd_sys_rw_content_t '/usr/local/nagios/var/rw/nagios.cmd' Then you can just issue: restorecon -R /usr/local/nagios/var/rw/nagios.cmd If the system performs a relabel, the file will keep the 'httpd_sys_rw_content_t' context type. If you can't find semanage, it is provided by the policycoreutils-python-* package. Just do a "yum whatprovides '*/semanage'" and install the correct package. ...Glenn... |
All times are GMT -5. The time now is 04:08 PM. |