5、监控添加
1)先在commands.cfg中添加命令
[root@nagioslibexec]# vim /usr/local/nagios/etc/objects/commands.cfg
#check_esxi_hardware.py
define command {
command_name check_esxi_hardware
command_line $USER1$/check_esxi_hardware.py -H $HOSTADDRESS$ -U $ARG1$ -P $ARG2$ -V $ARG3$ -I isolutions -p -t 20
}
#check_esx3.pl
define command{
command_name check_esx3_cpu_usage
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -l cpu -s usage -w $ARG3$ -c $ARG4$
}
define command{
command_name check_esx3_mem_usage
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -l mem -s usage -w $ARG3$ -c $ARG4$
}
define command{
command_name check_esx3_swap_usage
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -l mem -s swap -w $ARG3$ -c $ARG4$
}
define command{
command_name check_esx3_net_usage
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -l net -s usage -w $ARG3$ -c $ARG4$
}
define command{
command_name check_esx3_vmfs
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -l vmfs -x EQ_LUN9,EQ_LUN8 -s $ARG3$ -w $ARG4$ -c $ARG5$ #-w 80%: -c 90%: 小于80% 不检测EQ_LUN8 EQ_LUN9
}
define command{
command_name check_esx3_runtime_status
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -l runtime -s status
}
define command{
command_name check_esx3_runtime_issues
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -l runtime -s issues
}
define command{
command_name check_esx3_dc_cpu_usage
command_line $USER1$/check_esx3.pl -D $ARG1$ -u $ARG2$ -p $ARG3$ -H $HOSTALIAS$ -l cpu -s usage -w $ARG4$ -c $ARG5$
}
define command{
command_name check_esx3_dc_mem_usage
command_line $USER1$/check_esx3.pl -D $ARG1$ -u $ARG2$ -p $ARG3$ -H $HOSTALIAS$ -l mem -s usage -w $ARG4$ -c $ARG5$
}
参考地址:https://nagios-plugins.org/doc/guidelines.html#THRESHOLDFORMAT
2)设置监控主机和服务
[root@nagioslibexec]# vim /usr/local/nagios/etc/10.10.2.233.cfg
define host{
use linux-server
host_name vSphere3
alias vSphere Host3(SSB412)
address 10.2.1.153
hostgroups ESX
icon_image vmware.png
icon_image_alt VMware vSphere (SSB412)
vrml_image vmware.jpg
statusmap_image vmware.gd2
2d_coords 800,900
parents RackSW_PDC_1
}
define service{
use generic-service
host_name VM-ESXi-01,VM-ESXi-02,vSphere1,vSphere2,vSphere3
service_description CPU Usage
check_command check_esx3_cpu_usage!nagios!password!100!110
}
define service{
use generic-service
host_name VM-ESXi-01,VM-ESXi-02,vSphere1,vSphere2,vSphere3
service_description Memory Usage
check_command check_esx3_mem_usage!nagios!password!100!110
}
以上大家做为参考,请以实际环境为准
如果是用的nagiosql,需要先在命令项里定义命令,类似command.cfg文件
再到监督-服务里定义服务
最后到监督-hosts里添加监控主机,选择要监控的服务
扩展:
check_esxi_hardware.py 检测时候有时候会提示Service Check Timed Out,命令里加了-t 也会报timeout,后来查看check_esxi_hardware.py里timeout=0 修改成60后好像不会报timeout了,后面继续观察。
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-05/143842.htm