June 20, 2021

Nagios sytem monitoring Howto

Nagios monitors systems and then e-mails you if there’s an outage, it does a lot more, but that’s the usual use.

this is a down and dirty cut/paste howto, if you need background on what we’re doing here there are plenty of resouces, this is a cliff notes. If you comment I MAY have time to answer them, just depends.

Install on Server (Debian Squeeze)


apt-get remove exim4
apt-get install nagios3 nagios-images nagios-snmp-plugins nagvis nagios3-doc lm-sensors php-pear postfix bsd-mailx htop telnet nagios-nrpe-plugin
enter password
WORKGROUP
vi /etc/aliases
- root: yourusernamealias (add to end of root: line if there's nothing there)
- yourusernamealias: you@yourdomain.com (add this line next)
newaliases
vi /etc/nagios3/conf.d/contacts_nagios2.conf
- replace all instances of "root" with "yourusernamealias"

set up the web interface, usually it’ll be at http://your.ip.or.hostname/nagios3 , which I find harder to remember than, say http://your.ip.or.hostname/monitor , so that’s what we’re doing here

vi /etc/nagios3/apache2.conf
- ScriptAlias /monitor/cgi-bin /usr/lib/cgi-bin/nagios3
- Alias /monitor/stylesheets /etc/nagios3/stylesheets
- Alias /nagios3 /usr/share/nagios3/htdocs (change nagios3 to whatever's easier to remember)
- vi /etc/nagios3/cgi.cfg
- url_html_path=/monitor (or whatever your new name is)
- authorized_for_system_information=nagiosadmin,yourusernamealias (add you to the end of the line)
- authorized_for_configuration_information=nagiosadmin,yourusernamealias
- authorized_for_system_commands=nagiosadmin,yourusernamealias
- authorized_for_all_services=nagiosadmin,yourusernamealias
- authorized_for_all_hosts=nagiosadmin,yourusernamealias
- authorized_for_all_service_commands=nagiosadmin,yourusernamealias
- authorized_for_all_host_commands=nagiosadmin,yourusernamealias
/etc/nagios3/htpasswd htpasswd.users yourusernamealias (adds you the web authentication you'll see when you visit the page)
- type a password 2x
/etc/init.d/apache2 reload
http://your.ip.or.hostname/monitor

you should see the nagios control panel after you enter your username/password

monitor remote computers

login to your remote computer you want to monitor and do:


apt-get install nagios-nrpe-server
workgroup name WORKGROUP (not on lenny)
Modify smb.conf to use WINS settings from DHCP? (not on lenny)
vi /etc/nagios/nrpe.cfg
- allowed_hosts=127.0.0.1, (add last part, it's not there)
- command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/whereveryourrootpartitionis_maybe_sda1
/etc/init.d/nagios-nrpe-server restart

now go back to your nagios server and check to see if it sees the remote computer


/usr/lib/nagios/plugins/check_nrpe -H ip.of.remote.client
- NRPE v2.12 (or version name)
/usr/lib/nagios/plugins/check_nrpe -H ip.of.remote.client -c check_users
- USERS OK - 0 users currently logged in |users=0;5;10;0
vi /etc/nagios-plugin/config/check_nrpe.cfg
- command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ (delete the last part, make it look like)
- command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
/etc/init.d/nagios reload

Leave a Reply

Your email address will not be published.