Nagios
NOTE: For Nagios3 configuration see here.
Install NRPE On Ubuntu
Method 1 - Official Repo Version (not always latest)
sudo apt-get install nagios-nrpe-server nagios-plugins
https://tecadmin.net/install-nrpe-on-ubuntu/
Method 2 - Official Source Version (latest)
https://support.nagios.com/kb/article/nrpe-how-to-install-nrpe-8.html
https://support.nagios.com/kb/article.php?id=515
Ubuntu 16.04 Startup Script for SystemD
$ sudo nano /etc/systemd/system/nrpe.service [Unit] Description=Nagios NRPE Agent After=syslog.target network.target [Service] Type=simple ExecStart=/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d ExecReload=/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target
$ sudo systemctl enable nrpe.service $ sudo systemctl start nrpe.service $ sudo systemctl status nrpe.service
Disk Space Check
Latest Version Downloads
https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
https://www.nagios.org/downloads/nagios-core/thanks/?t=1472236127
How To Upgrade Nagios Core
sudo -i cd /tmp/ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz tar xzf nagios-4.4.6.tar.gz cd nagios-4.4.6 ./configure --with-command-group=nagcmd make all make install /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg service nagios restart exit
https://www.nagios.org/downloads/nagios-core/thanks/?skip=1&product_download=nagioscore-source
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/upgrading.html
Change Date Format
sudo nano /usr/local/nagios/etc/nagios.cfg date_format=iso8601 sudo service nagios restart
Thanks - https://theezitguy.wordpress.com/2015/07/09/nagios-change-date-format/
HOWTO: Only Send 1 Notification Alert
notification_interval 0
HOWTO: SETUP: Windows Monitoring
Download the software for Windows.
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/monitoring-windows.html
HOWTO: FIX: Apache mod_security denied
/etc/nagios/objects/servers.cfg
define host { use linux-server name www.domain.com host_name www.domain.com alias www.domain.com address 123.456.789.0 check_command check-host-alive passive_checks_enabled 1 active_checks_enabled 1 flap_detection_enabled 1 contact_groups linux-admins }
/etc/nagios/objects/commands.cfg
# 'check_http' command definition define command{ command_name check_http # command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$ -t 20 command_line $USER1$/check_http -H $HOSTALIAS$ -I $HOSTADDRESS$ -k "Accept: text/html" -t 20 }
http://www.mhaller.de/archives/145-Nagios,-mod_security-and-check_http.html
Check Host without Ping
http://www.htmlgraphic.com/nagios-check-host-without-ping/
check_command check_ssh
send_nsca Test
echo "test;test;0;test-output" | /usr/lib/nagios/plugins/send_nsca -H server.with.nagios.com -p 5667 -c /etc/nagios/send_nsca.cfg -d ";" 1 data packet(s) sent to host successfully.
Passive Checks
Troubleshooting / Help
Disk Space Usage
Lots of space is used by the log archive. Get rid of it.
sudo service nagios stop sudo rm -rfv /usr/local/nagios/var/archives/* sudo nano /usr/local/nagios/etc/nagios.cfg log_rotation_method=w log_archive_path=/dev/null use_syslog=0 sudo service nagios start
Checking Configuration
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!
usermod -a -G nagios www-data
Error: Could not open command file '/var/nagios/rw/nagios.cmd' for update
Permissions on the command file are correct, but the web server cannot use them. The solution is to add apache to the nagios group.
gpasswd -a apache nagios usermod -a -G nagios www-data
Hosts Stay At Status PENDING
Your hosts stay at a pending status because they have no check definition. If you want the hosts to be checked, you should define a check command for them, as in:-
define host { host_name server.domain.com check_command check-host-alive-ping .... }
Then, Nagios will be able to check your hosts.
FIX: Socket timeout after 10 seconds
Open one of nagios' configs where check commands are defined (usually it’s /etc/nagios/commands.cfg file) and find there a block named check_nrpe or check_http, add “-t 20″ to the end of its command_line so it will look like below...
define command { command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 20 }
define command { command_name check_http command_line $USER1$/check_http -H $HOSTADDRESS$ -c $ARG1$ -t 20 }
...and restart Nagios.
http://www.linuxscrew.com/2012/03/16/nagios-timeout/