4.给Esxi主机设置只读用户
(1)先登录Esxi主机,在“本地用户和组”标签中,空白处右键“添加”,即可添加用户。

(2)将nagios用户设置成“只读角色”。在“权限”标签中,空白处右键“添加权限”,然后按下图操作

ok,只读用户nagios就添加完毕。
5.测试
[root@nagios libexec]# ./check_esxi_hardware.py -H 10.10.10.1 -U nagios -P nagios -V dell
UNKNOWN: Authentication Error
又报错了,认证失败。在网上查到原因是Esxi版本不同差异导致,例如我的本地测试机和生产环境都是5.5,但是小版本不一样,也报错了。
解决方案:
ssh登陆Esxi主机,编辑如下
~ # cat /etc/security/access.conf
# This file is autogenerated and must not be edited.
+:dcui:ALL
+:root:ALL
+:vpxuser:ALL
+:vslauser:ALL
-:nagios:ALL
-:ALL:ALL
将“-:nagios:ALL”去掉,在第二行加上“+:nagios:sfcb”
这种方式适合在不经常添加用户的情况下使用,只改一次即可;但是经常加用户可能会导致access.conf变化,需要设置计划任务添加“+:nagios:sfcb”
再测试下:
[root@nagios libexec]# ./check_esxi_hardware.py -H 10.10.10.1 -U nagios -P nagios -V dell
OK - Server: Dell Inc. PowerEdge R610 s/n: XXXXXX System BIOS: XXXXXXXXXXX
ok,监控正常。
6.下面将将其加入到监控系统中吧。
(1)先在commands.cfg中添加命令
vim /usr/local/nagios/etc/objects/commands.cfg
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
}
(2)添加服务
define service{
use local-service,srv-pnp
host_name test
service_description esxi_health
check_command check_esxi_hardware!nagios!nagios!dell
service_groups hardware_health
notifications_enabled 1
}
nagioscheck
service nagios reload
(3)监控效果图

其中href中的链接就是我们在check_esxi_hardware.py中-I参数生成,方便我们直接查找解决方案。
Nagios 的详细介绍:请点这里
Nagios 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-06/118686.htm
