Trying to setup SSH for Nagios on Ubuntu is quite maddening. So, for those thinking that since they have familiarity with ssh, ssh-keygen, that using check_by_ssh would be a breeze, don't! Use NRPE instead.
These plugins are needed to monitor things like load, procs, on remote machines such as might exist in a small home network.
Assuming a localhost that is running the Nagios monitoring server, and a remotehost that we need to monitor load, procs, here are the simple steps to get NRPE up and running on Ubuntu or Fedora:
This assumes that a base Nagios server is up and running on localhost, and remotehost does not have Nagios installed.
On remotehost, run:
sudo apt-get install nagios-nrpe-server (Ubuntu)
su -c "yum install nrpe.i386 nagios-plugins-procs.i386" (Fedora FC7)
To find appropriate names of packages to install, use:
On remotehost, run:
apt-cache search nagios (Ubuntu)
yum search nagios (Fedora)
Make sure all required plugins are installed on the remotehost also - things like check_load, check_procs, etc in /usr/lib/nagios/plugins/ or appropriate folder on remotehost.
Next, edit the config file /etc/nagios/nrpe.cfg - replace .. with the IP address of localhost that is running the Nagios monitoring server:
/etc/nagios/nrpe.cfg:
allowed_hosts=127.0.0.1, ...
In the same file, check the hardcode commands, such as check_load and check_total_procs, those might be sufficient for many uses.
Finally, restart nrpe on remote host:
sudo /etc/init.d/nagios-nrpe-server restart (Ubuntu)
su -c "service nrpe restart" (Fedora)
Now, back to localhost. Install the nrpe-plugin here:
sudo apt-get install nagios-nrpe-plugin (Ubuntu)
Test it - from locahost, run:
/usr/lib/nagios/plugins/check_nrpe -H remotehost (this should output remote NRPE version)