Use ping to check connection statistics for a remote host.
Usage:check_ping -H -w ,% -c ,%
[-p packets] [-t timeout] [-4|-6]
Options:
-h, –help
Print detailed help screen
-V, –version
Print version information
-4, –use-ipv4
Use IPv4 connection
-6, –use-ipv6
Use IPv6 connection
-H, –hostname=HOST
host to ping
-w, –warning=THRESHOLD
warning threshold pair
-c, –critical=THRESHOLD
critical threshold pair
-p, –packets=INTEGER
number of ICMP ECHO packets to send (Default: 5)
-L, –link
show HTML in the plugin output (obsoleted by urlize)
-t, –timeout=INTEGER
Seconds before connection times out (default: 10)
—————————————————————————————–
然后我们在contacts.cfg文件中定义联系人和联系人组,在timeperiods.cfg中定义监控时间段。最后我们在服务器监控配置文件中引用前面定义的元素来监控服务器状态。
=======================================
下面引用配置文件中部分配置做说明:
vi /usr/local/nagios/etc/resource.cfg
# 定义$USER1$变量,设置插件路径
$USER1$=/usr/local/nagios/libexec
vi /usr/local/nagios/etc/objects/commands.cfg
# 定义check-host-alive命令
define command{
command_name check-host-alive # 命令名称
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
# 上面的$USER1$和$HOSTADDRESS$引用自已定义的配置文件。变量不需现定义才能被引用。
#########################################################################
# 2008.11.18 add by Stone
# NRPE COMMAND
# 自己定义check_nrpe命令,此命令后接必需接一个参数,用于告诉远程服务器上的NRPE daemon需要监控的内容,如check_swap参数为监控远程机器的交换分区。
########################################################################
# ‘check_nrpe ‘ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
vi /usr/local/nagios/etc/objects/contacts.cfg
# 定义联系人,可同时定义多个联系人
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email test@gmaile.com ;