check_by_ssh plugin

Nagios server

su - nagios
ssh-keygen
scp -p /usr/local/nagios/libexec/* <server>:/home/nagios/bin            # or install nagios plugins on the client
/usr/local/nagios/libexec/check_by_ssh -H <server> -C "/home/nagios/bin/check_http -H localhost"

Nagios client

useradd nagios 
su - nagios 
mkdir .ssh 
chmod 700 .ssh 
cd .ssh/
vi authorized_keys          # paste the public SSH key from Nagios server (cat /home/nagios/.ssh/id_rsa.pub)
chmod 600 authorized_keys 
  1. Edit the commands config file on the Nagios server:

vi /usr/local/nagios/etc/objects/commands.cfg

# 'check_ssh_load' command definition
define command 
        command_name    check_ssh_load
        command_line    $USER1$/check_by_ssh -H $HOSTADDRESS$ -C "/home/nagios/bin/check_load -w $ARG1$ -c $ARG2$"
}

# 'check_ssh_disk' command definition
define command
        command_name    check_ssh_disk
        command_line    $USER1$/check_by_ssh -H $HOSTADDRESS$ -C "/home/nagios/bin/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$"
}
  1. Edit object config for the machine:

vi /usr/local/nagios/etc/objects/servers.cfg

define service{
        use                             local-service 
        host_name                       <server name>
        service_description             Current Load
        check_command                   check_ssh_load!5.0,4.0,3.0!10.0,6.0,4.0
        }

define service{
        use                             local-service 
        host_name                       <server name>
        service_description             Root Partition
        check_command                   check_ssh_disk!20%!10%!/
        }