LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Nagios config ? (http://www.linuxquestions.org/questions/linux-networking-3/nagios-config-429200/)

MikeFoo1 03-28-2006 03:20 AM

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 :-).

ckoniecny 03-28-2006 07:53 PM

Post your config files and post the error your getting.

MikeFoo1 03-30-2006 11:41 PM

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:

Error: Could not stat() command file '/usr/local/nagios/var/rw/nagios.cmd'!
.

I think I have setup my permissions correclty:




Quote:

drwxrws--- 2 nagios nagcmd 4.0K Mar 29 10:25 rw


prw-rw---- 1 nagios nagcmd 0 Mar 29 10:25 nagios.cmd
and

Quote:

nagios:x:501:
nagcmd:x:502:apache,nagios

any suggestions ?

timmeke 03-31-2006 04:27 AM

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?

natter 08-12-2007 12:18 AM

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/

junaid18183 11-06-2008 10:50 PM

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

fngreno 12-22-2008 06:05 PM

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!

jkoo 10-08-2009 02:15 AM

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

Zenaku 10-08-2009 11:50 AM

Quote:

Originally Posted by MikeFoo1 (Post 2177147)
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:

Error: Could not stat() command file '/usr/local/nagios/var/rw/nagios.cmd'!
.

Dude, i got the same problem here, but I check the /usr/local/nagios/var/rw and the nagios.cmd doesn't exist, so much in the folder as in the whole PC.

EDIT: I got the problem. Make sure you have installed postfix.

amonamarth 09-12-2010 12:11 PM

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?

Dave Barnett 10-19-2010 09:38 AM

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?

tarrall 04-09-2011 03:08 PM

Quote:

Originally Posted by amonamarth (Post 4095251)
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?

This will help with the SElinux issue without disabling SElinux entirely:
Code:

sudo chcon -R -t httpd_sys_script_rw_t /usr/local/nagios/var/rw

vijay60 04-28-2011 08:26 PM

Quote:

Originally Posted by tarrall (Post 4319403)
This will help with the SElinux issue without disabling SElinux entirely:
Code:

sudo chcon -R -t httpd_sys_script_rw_t /usr/local/nagios/var/rw

Hi

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

vyncynt 11-13-2011 10:16 PM

Quote:

Originally Posted by jkoo (Post 3711941)
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


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.

glenn.e.harrison 12-01-2011 05:39 PM

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 12:06 PM.