Problem with Nagios check_by_ssh plugin is that it requires also the nagios-plugins to be installed on the client server. At least part of the nagios-plugins, because in the end all we need is to perform the local checks using ssh remote cmds.
So I put in a file nagiosclient.tar with the check scripts including some perl.The focus hereis to check Disk,Memory,Cpu of Linux remote servers. Without using SNMP, NRPE just plain SSH. I think its a great solution mainly because NRPE is a pain to install in Linux, in Windows its quite easy and I always try to use it combined with SNMP. SNMP is nice but its limited in what it can monitor, and sometimes it can get really messy. So lets start configuring SSH.
1. Set the SSH key authentication between Server and Client
Before we start we need the same user account and same password in both hosts!
Automatic login from host A / user b to Host B / user b. You don’t want to enter any passwords, because you want to call ssh from a within a shell script.
First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:
a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory ‘/home/a/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):
a@A:~> ssh b@B mkdir -p .ssh
Finally append a’s new public key to b@B:.ssh/authorized_keys and enter b’s password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B ‘cat >> .ssh/authorized_keys’
From now on you can log into B as b from A as a without password:
a@A:~> ssh b@B hostname
2. Download nagios.tar and setup into remote client server
# cd /home/nagios
# wget http://www.xoroz.com/files/nagiosclient.tar.gz
# tar -zxvf nagiosclient.tar.gz
Check that Files are at /home/nagios/nagios
# chmod 755 /home/nagios/nagios
# chown nagios:nagios -R /
Now test it from the Nagios Server
check_dirsize.sh check_file_size.sh check_load2 check_mem.pl check_swap utils.pm
check_disk check_load check_log check_procs check_users utils.sh