One way to create a custom Nagios service check on CentOS-
1) Create new script file in /etc/nagios/scripts. It will contains a shell command to check if a specific script is running on a remote host. It should look like this-
#!/bin/sh
#
#2012Feb11
#
/usr/bin/ssh -p 1132 user@10.99.20.15 'if ! pgrep -f '/[r]oot/scripts/cfg/scriptssh.cfg.server01'; then echo 'Process not running!'; exit 1; fi'
2) Add new code block to /etc/nagios/servers/main.server.cfg. It will contain-
define service{
use generic-service
host_name some.server
service_description process check
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_interval 960
notification_period 24x7
check_command process_check
}
3) Add new code block to /etc/nagios/objects/command.cfg. It will contain-
# 'check_processes' command definition
define command{
command_name process.check
command_line /etc/nagios/scripts/./process.check.sh
}
4)Reload Nagios-
nagios -v /etc/nagios/nagios.cfg
->Fix any errors. If none, then continue.
nagios service reload
No comments:
Post a Comment