Page 1 of 2

Linux newbie - help with nagios configuration/permissions

Posted: Fri Mar 16, 2012 11:33 am
by alceryes
With the good install instructions found around the web I've got the latest ubuntu server/nagios installed. However, I am having two issues and I think I'm a little over my head on fixing them.
First issue - when I try to change notification settings for services or host I get a 'Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!'
Second issue - in trying to fix issue one I ran several commands including:
ps aux|grep -i httpd
chown httpd:httpd /var/spool/nagios/rw/nagios.cmd
(chown: invalid user:httpd:httpd)
chown httpd:httpd /usr/local/nagios/var/rw/nagios.cmd
(chown: invalid user:httpd:httpd)
chmod g+rwx /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw
chown nagios /usr/local/nagios/var/rw

...and now all my service checks for my test host are being refused (in addition to my original issue).

Any help/insight would be appreciated. I know these are change ownership commands but I'm unsure how they affect nagios in context.

TIA!

Re: Linux newbie - help with nagios configuration/permission

Posted: Fri Mar 16, 2012 12:40 pm
by mguthrie
I don't think the issue is permission, Nagios thinks this file is in a different place. Nagios is looking for:
/usr/local/nagios/var/rw/nagios.cmd

and you have this at:

/var/spool/nagios/rw/nagios.cmd

You probably just need to update the location of this file in the nagios.cfg file. Then restart the nagios process which will recreate that file with the right permissions. Try adding your apache user (either apache or www-data) to the nagios group, and the nagcmd group.

Re: Linux newbie - help with nagios configuration/permission

Posted: Fri Mar 16, 2012 2:40 pm
by alceryes
Thanks mguthrie.
I just completely uninstalled and reinstalled nagios and am getting the same 'connection refused' error. I changed the host to a different one to see if is was something on the host side but no dice. Local host checks are fine. The connection to my test host was working fine before I killed it somehow. Maybe I messed up an ubuntu config(?) In addition to the commands in my first post here are some other commands I ran -
ps aux|grep -i httpd
chown nagios.nagioscmd /usr/local/nagios/var/rw
awk -F":" '{ print "username: " $1 "\t\tuid:" $3 }' /etc/passwd
chown nagios /usr/local/nagios/var/rw
chown httpd /usr/local/nagios/var/rw
chown nagios.nagios /usr/local/nagios/rw
chown nagios.nagios /usr/local/nagios/var/rw

I'm pretty sure one of these killed the host checks. I'm wondering if I changed something on the apache side? I'm really a novice at linux but with the good instructions from forums and other sites I was doing okay until I hit this snag. I really don't want to completely reinstall ubuntu...

Thanks again for your help.

Re: Linux newbie - help with nagios configuration/permission

Posted: Fri Mar 16, 2012 11:13 pm
by mguthrie
Ok, first, no more reinstalling things, now we have to start over in troubleshooting ; )

Second, don't bother with changing permissions on the nagios.cmd pipe, Nagios recreates that file with the appropriate permissions every time it restarts. Change your groups, not that file.
I just completely uninstalled and reinstalled nagios and am getting the same 'connection refused' error.
This seems like a different issue than what you were experiencing with the nagios.cmd file, these issues are unrelated. I'm assuming you're having an issue getting NRPE working between a client machine and the nagios server?

Check firewall rules, if the client machine can't accept connections on port 5666 you'll get that error.
Check the "allowed hosts" on the client machine, either with the nrpe.cfg, or the xinetd.d/nrpe.cfg file, depending on how you set it up. (If you could tell us how you set up the client machine that would help as well).
Disable SELinux, it's sole purpose in the world is to break things.

Re: Linux newbie - help with nagios configuration/permission

Posted: Mon Mar 19, 2012 7:20 pm
by alceryes
thanks mguthrie!
okay, I got the ability to make changes in the GUI working with -

sudo /etc/init.d/nagios stop
sudo dpkg-statoverride --update --add nagios www-data 2710 /usr/local/nagios/var/rw
sudo dpkg-statoverride --update --add nagios nagios 751 /usr/local/nagios/var
sudo /etc/init.d/nagios start

2 problems remain -
First, any windows host that I try to check returns 'connection refused' (localhost checks fine). The nsclient++ is installed and is pointing to the nagios server.

Second, We have a vSMTP windows server on the domain that we use for notifications. It doesn't require authentication. Basically, I need to tell Nagios to send email notifications there. I was following the instructions here (http://www.howtoforge.com/nagios-instal ... id-lynx-p3) but I don't think the postfix configuration is right for my environment.

Also, I completely disabled the firewall using several iptables commands and we don't have an nrpe.cfg file. Could it be that we are connecting a different way? I looked at another clients and there's no nrpe.cfg there either.

Thank you very much for any suggestions.


**UPDATE**
Following these (http://www.thegeekstuff.com/2008/07/how ... -on-linux/) instructions I was able to get my windows servers checks going...Woohoo!!! It was an error in my NSC.ini
Now I just need to get email going...

Oh, I took a snapshot this time (vmware) I'm not going through another reinstall :)

Re: Linux newbie - help with nagios configuration/permission

Posted: Tue Mar 20, 2012 9:48 am
by mguthrie
Second, We have a vSMTP windows server on the domain that we use for notifications. It doesn't require authentication. Basically, I need to tell Nagios to send email notifications there. I was following the instructions here (http://www.howtoforge.com/nagios-instal ... id-lynx-p3) but I don't think the postfix configuration is right for my environment.
This comes down to your notification command that's defined for your contacts. A typical one looks like this, which uses sendmail:

notify-host-by-mail

Code: Select all

/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
I would try some command-line tests with your mailer first to make sure it's doing what you want and that you can actually get mail to where you want. Once you get a hard-coded test working, you can create a notification command based on those tests.

Re: Linux newbie - help with nagios configuration/permission

Posted: Tue Mar 20, 2012 10:34 am
by alceryes
I have sent a test email successfully via telnet from the linux box.
My host and service commands are in the commands.cfg not contacts.cfg. It looks like the issue is that it's trying to send to /bin/mail but I don't even have that directory. I installed postfix but I am unsure how to call it (or point nagios to it).

Re: Linux newbie - help with nagios configuration/permission

Posted: Tue Mar 20, 2012 11:32 am
by mguthrie
Type:

Code: Select all

whereis postfix
and also

Code: Select all

man postfix 
To see how it works. I've always used the plain /bin/mail (sendmail), so I'm not much help with postfix.

Re: Linux newbie - help with nagios configuration/permission

Posted: Tue Mar 20, 2012 1:57 pm
by alceryes
I just installed postfix because it was part of the instructions I was following. If I can get it working with sendmail that'd be just as good.

Do you have instructions for installing and configuring sendmail? I just want to send straight to my SMTP server without any authentication (we have access restricted by IP on the vSMTP).

Thanks!

Re: Linux newbie - help with nagios configuration/permission

Posted: Fri Mar 23, 2012 2:55 pm
by alceryes
FINALLY!!! I needed to install 'mailutils' package.

# apt-get install mailutils

After that email notifications started working.