====== Nagios ======
====== Installation ======
- Create the nagios group and user:
groupadd -g 213 nagios
useradd -u 213 -d /dev/null -s /bin/false -g nagios nagios
- Add the 'apache' user to the 'nagios' group, so that it can write to the ''/var/nagios/rw'' directory ('a' option prevents the user to be removed from other groups, the member of which he is already):
usermod -aG nagios apache
- Install the Nagios::Plugin Perl module:
cpan -i Monitoring::Plugin
- Use [[http://sbopkg.org/|sbopkg]] or install the individual packages using scripts from [[http://slackbuilds.org/|SlackBuilds.org]], and install the following in this order:
* RRDTool
* nagios (currently, the package which can be built using a [[http://slackbuilds.org/network/nagios/ | SlackBuilds.org script]] is nagios-4.0.8)
* nagios-plugin package
* nagios-graphing
- Edit ''/etc/nagios/nagios.conf'' and turn off the logging:
CHANGE:
use_syslog=1
TO:
use_syslog=0
CHANGE:
log_notifications=1
TO:
log_notification=0
- Edit ''/etc/httpd/extra/nagios.conf'', after the '''' line:
CHANGE:
Options None
TO:
Options FollowSymLinks
- Edit ''/etc/httpd/http.conf''
COMMENT:
LoadModule mpm_event_module lib64/httpd/modules/mod_mpm_event.so
UNCOMMENT:
#LoadModule mpm_prefork_module lib64/httpd/modules/mod_mpm_prefork.so
UNCOMMENT:
#LoadModule cgi_module lib64/httpd/modules/mod_cgi.so
(or #LoadModule cgi_module lib/httpd/modules/mod_cgi.so on 32bit installs)
CHANGE:
DirectoryIndex index.html
TO:
DirectoryIndex index.html index.php
CHANGE:
# Uncomment the following line to enable PHP:
#
# Include /etc/httpd/mod_php.conf
TO:
# Uncomment the following line to enable PHP:
#
Include /etc/httpd/mod_php.conf
RIGHT AFTER:
DocumentRoot /srv/httpd/htdocs
ADD:
Include /etc/httpd/extra/nagios.conf
- Make sure apache starts at boot and start/restart apache:
chmod 755 /etc/rc.d/rc.httpd
/etc/rc.d/rc.httpd restart
- Set the password for //nagiosadmin// :
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
- (Not sure if this is necessary but, leaving it in until I can test) \\ Make sure nagios starts at boot and start/restart nagios:
- Edit ''/etc/rc.d/rc.local'' and add:
# Start nagios:
if [ -x /etc/rc.d/rc.nagios ]; then
echo "Starting nagios..."
/etc/rc.d/rc.nagios start
fi
- Edit ''/etc/rc.d/rc.local_shutdown'' (you may have to create this file if it does not exist, and make it executable) and add:
# Stop nagios:
if [ -x /etc/rc.d/rc.nagios ]; then
echo "Stopping nagios..."
/etc/rc.d/rc.nagios stop
fi
- Make rc.nagios executable:
# chmod 755 /etc/rc.d/rc.nagios
- Start nagios:
# /etc/rc.d/rc.nagios restart
====== Check That Nagios Is Running ======
Goto **http://YOUR_MACHINE/nagios/** and you should see Nagios working.
====== Add Users ======
- Run the ''htpasswd'' command for each user:
htpasswd -c /etc/nagios/htpasswd.users bob
htpasswd -c /etc/nagios/htpasswd.users sue
- Edit ''/etc/nagios/cgi.cfg'' and add the user(s) too:
authorized_for_all_services=nagiosadmin,bob,sue
authorized_for_all_hosts=nagiosadmin,bob,sue
(or add "''*''" to allow all authenticated users)
====== TROUBLESHOOTING ======
ERROR: When browsing to the nagios webpage (as nagiosadmin) you get "You do not have permission"
HINT: Check /var/log/httpd/error_log to see what is failing.
FIX1: Make sure that /srv/www/htdocs/nagios is "drwxrwxr-x nagios nagios"
FIX2: In /etc/http/httpd.conf make sure:
UNCOMMENT: Include /etc/httpd/mod_php.conf
Do the "" change listed above.
-----
ERROR: When clicking on Nagios cgi pages, they are downloaded and not executed.
FIX: Make sure the "LoadModule cgi_module" is uncommented as described above.
-----
ERROR: "stderr: execvp(/usr/libexec/monitoring-plugins/check_ping, ...) failed. errno is 2: No such file or directory"
FIX: vi /etc/nagios/resource.cfg
CHANGE: $USER1$=/usr/libexec/monitoring-plugins
TO: $USER1$=/usr/libexec/nagios
-----
ERROR: I've done the FIXes above and it's still not working...
FIX: Didya restart httpd and/or nagios?
/etc/rc.d/rc.httpd restart
/etc/rc.d/rc.nagios restart
====== Install NRPE On A Target Machine ======
**ON THE TARGET MACHINE (as root):**
groupadd -g 213 nagios
useradd -u 213 -d /dev/null -s /bin/false -g nagios nagios
Install nagios via SBo (Required by Nagios-plugins)
Install nagios-plugins via SBo (Required by NRPE)
Install nrpe via SBo
Ignore the xinetd stuff, you have to run NRPE as a daemon on Slackware (unless you want to go through the headache of replacing inetd with xinetd)
So, start NRPE in Daemon mode:
chmod 755 /etc/rc.d/rc.nrpe
/etc/rc.d/rc.nrpe start
Test NRPE
/usr/libexec/nagios/check_nrpe -H localhost
NRPE v2.15
/usr/libexec/nagios/check_nrpe -H localhost -c check_users
USERS OK - 1 users currently logged in |users=1;5;10;0
Add your Nagios server's IP into the allowed_hosts list:
vi /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.1.77 (WHERE: 192.168.1.77 is the IP of your Nagios server)
chown nagios:nagios /etc/nagios/nrpe.cfg
-----
**ON THE NAGIOS SERVER MACHINE:**
Add the client machine into one of the .cfg files
I did this:
vi /etc/nagios/nagios.cfg
ADD:
# Definitions for monitoring a linux machine
cfg_file=/etc/nagios/objects/linux.cfg
chown nagios:nagios /etc/nagios/nagios.cfg
vi /etc/nagios/objects/linux.cfg_file
#########################################################
# Linux configuration file
#########################################################
define host {
use linux-server
host_name MyLinuxBox
alias LinuxBox1
address 192.168.1.110
register 1
}
define service{
host_name MyLinuxBox
service_description PING
check_command check_ping!100.0,20%!500.0,60%
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
#########################################################
# END OF FILE
#########################################################
chown nagios:nagios /etc/nagios/objects/linux.cfg_file
Restart Nagios
/etc/rc.d/rc.nagios restart
====== Sources ======
* Originally written by [[wiki:user:arfon | arfon]]
{{tag>howtos software nagios network_monitoring author_arfon}}