Nagios

Installing Nagios on a VPS
This document is about how to set up a Dreamhost VPS to use Nagios for purposes of monitoring your DB, website, and other critical services.

Monitoring Host
A business typically has one monitoring host watching all of its equipment. You build one once and upgrade it every few years.

I've built 3 monitoring hosts over the years. It usually takes 2 hours or so to install the Apache, PHP, etc. and get a couple hosts up and running with a basic set of tests. Then you'll spend the rest of the day adding your notification lists and such, and a couple weeks of an hour or day or so fine-tuning all the notifications and whatever other fancy stuff you're interested in. --Jhannah 20:48, 2 February 2011 (UTC)

The Ubuntu Quickstart guide is handy.

Remote Hosts
Every machine a company uses is a "host" in Nagios. Usually adding a host is very simple, taking 20 minutes or less. The nutshell version is:

/usr/sbin/adduser nagios apt-get install nagios-nrpe-server vi /etc/nagios/nrpe.cfg allowed_hosts= /etc/init.d/nagios-nrpe-server restart

That's it -- you're done. :)

Alas, DreamHost requires some quirks on this procedure.

xinetd
The procedure above plugs NRPE into. But our VPS wasn't using xinetd nor inetd. Not sure why, but it's not. So any service needs to run as its own daemon. Which normally, perhaps, is no big deal -- you just set up the appropriate  files and make sure that your daemon starts on restart and hopefully you're all set. The daemon is:

/usr/local/bin/nrpe -c /etc/nrpe.cfg -d

port 5666
When you try to run on the standard port all of these agree:

/var/log/syslog lsof -i TCP netstat -at | grep nrpe

that the daemon

/usr/local/bin/nrpe -c /etc/nrpe.cfg -d

is bound to port 5666 and listening. But you still can't telnet to that port, on any IP address, even from the local host. When we switch to a non-standard port suddenly everything magically works:

/etc/nrpe.cfg: debug=1 server_address=< OUR IP ADDRESS > server_port=3101
 * 1) I have no idea why the standard port doesn't work on DreamHost:  --jhannah 20110201
 * 2) server_port=5666

SSL
Usually SSL "Just Works" and it's the default. But, for whatever reason I don't understand, even though OpenSSL appears to be installed on our server, SSL simply doesn't work connecting to our DreamHost server. It times out. So the work-around is to use the  switch whenever invoking. To tell the Nagios monitoring host to always use this switch we set up a special Nagios  which works around the DreamHost troubles with the standard port and SSL.

/usr/local/nagios/etc/objects/commands.cfg: define command{ command_name  check_nrpe_no_ssl command_line  /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -p 3101 -n -c $ARG1$ }

Nagios Monitoring Host on a VPS (by cornernote)
If you want to use your DreamHost VPS as the monitor box, configuration is fairly straight forward with a few exceptions. This is how I achieved it on a fresh VPS.

DreamHost uses Nagios internally. You'll need to uninstall some of their packages, but please ask support for help with this, as they will need to turn off thier own checks on the machine.

After this is complete, you will need to update your packages:

apt-get upgrade apt-get update

Next, uninstall some dreamhost things that you won't need.

dpkg -r ndn-netsaint-plugins /etc/init.d/httpd2 stop update-rc.d -f httpd2 remove

Install apache, nagios and nrpe.

apt-get install -y apache2 nagios3 nagios-nrpe-plugin

Setup a nagiosadmin web user password.

htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin

Add nagios to www-data so that you can control nagios from the webpage.

chmod g+rx /var/lib/nagios3/rw usermod -a -G nagios www-data /etc/init.d/apache2 restart /etc/init.d/nagios3 restart

Now visit http://your.com/nagios3 and login with the password you just set.