Check_by_ssh configuration in nagios

– First you need to configure ssh password less authentication.
– Then configure nagios accordantly.

Setup password less authentication:-

Let Nagios server: – 192.168.43.131 and
       Target server:- 192.168.43.128

Step 1: Create Authentication SSH-Kegen Keys on – (192.168.43.131)

# ssh-keygen -t rsa

This will generate a pair of public keys.

Step 2: Create .ssh Directory on 192.168.43.128

#ssh nagios@192.168.143.128 mkdir -p .ssh

Step 3: Upload Generated Public Keys to – 192.168.43.128

#cat .ssh/id_rsa.pub | ssh nagios@192.168.43.128 ‘cat >> .ssh/authorized_keys’

Step 4: Set Permissions on – 192.168.43.128

#ssh nagios@192.168.43.128 “chmod 700 .ssh; chmod 640 .ssh/authorized_keys”

Step 5: Login from 192.168.43.131 to 192.168.43.128 Server without Password

#ssh nagios@192.168.43.128

Configure nagios for check_by_ssh.

– 1st you check required plug-in are present or not in bellow location if not then install 1st.

/usr/local/nagios/libexec/check_by_ssh

– after that create command in “commands.cfg” (/usr/local/nagios/etc/objects/)

define command{
command_name check_remote_procs
command_line $USER1$/check_by_ssh -H $HOSTADDRESS$ -t 60 -l nagios -C “/home/nagios/check_procs -C $ARG1$ -w 1:20 -c 1:50”
}

– copy required plug-in or script on target server. In this example I use “check_procs” plug-in and copy in “/home/nagios”.

[nagios@localhost ~]$ ll /home/nagios/
total 96
-rwxr-xr-x 1 nagios nagios 89660 Jul 18 10:30 check_procs

– After that add new check in “linux.cfg” or main check file.

define service{
use local-service ; Name of service template to use
host_name cntos
service_description Process
check_command check_remote_procs!httpd
}

save and reload nagios service.

#/etc/init.d/nagios reload

after some resubmit it’s ok

– Cross check you’re plug-in by bellow command.

[nagios@localhost ~]$ /usr/local/nagios/libexec/check_by_ssh -H 192.168.43.128 -t 60 -l nagios -C “/home/nagios/check_procs -C httpd -w 1:20 -c 1:50”

PROCS OK: 9 processes with command name ‘httpd’

Leave a Reply