标签:schedule sys entity mon 包括 lan ieee jar 直接
豆子今天想把VMware ESXi的监控也加入Nagios里面。关于对ESXi的监控,可以实现的方法有很多,豆子的第一反应是用PowerShellCLi,第二个反应是SNMP,第三个反应是找找有没有现成的脚本,就不用重复造轮子了~~这个脚本本身很容易,自己通过get-stat就可以获取对应的信息。比如说我打算查看一下某台主机的内存状态, 第一个是ballon的状态,第二个是实际使用的内存,第三个是使用率,第四个是分配的内存,这个结果和VCenter上面查看是一致的
VCenter上面查看
脚本可以获取信息了,那么剩下的配置步骤就不赘述了,可以参考Nagios如何监控VEEAM的备份状态 http://blog.51cto.com/beanxyz/1981136
ESXi上面打开SNMP的方法一般是通过esxcli来实现。简单的说就是设置community 字符串,打开snmp服务,允许防火墙访问,我这里就用最简单snmp v2, 允许所有IP访问
esxcli system snmp set --communities public
esxcli system snmp set --enable true
esxcli network firewall ruleset set --ruleset-id snmp --allowed-all true
[esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart
可以通过VCenter的图形界面确认
然后下载ESXi SNMP对应的MIB文件,下载后解压到
/usr/share/snmp/mibs
[root@sydnagios mibs]# pwd
/usr/share/snmp/mibs
[root@sydnagios mibs]# ls
AGENTX-MIB.txt IEEE8021-TC-MIB.mib NET-SNMP-EXTEND-MIB.txt SNMP-NOTIFICATION-MIB.txt UCD-SNMP-MIB.txt
BRIDGE-MIB.mib IEEE8023-LAG-MIB.mib NET-SNMP-MIB.txt SNMP-PROXY-MIB.txt UDP-MIB.mib
BRIDGE-MIB.txt IF-INVERTED-STACK-MIB.txt NET-SNMP-PASS-MIB.txt SNMP-TARGET-MIB.txt UDP-MIB.txt
DISMAN-EVENT-MIB.txt IF-MIB.mib NET-SNMP-TC.txt SNMP-USER-BASED-SM-MIB.txt UUID-TC-MIB.mib
DISMAN-SCHEDULE-MIB.txt IF-MIB.txt NET-SNMP-VACM-MIB.txt SNMP-USM-AES-MIB.txt VMWARE-CIMOM-MIB.mib
DISMAN-SCRIPT-MIB.txt INET-ADDRESS-MIB.mib NETWORK-APPLIANCE-MIB.txt SNMP-USM-DH-OBJECTS-MIB.txt VMWARE-ENV-MIB.mib
ENTITY-MIB.mib INET-ADDRESS-MIB.txt NETWORK-SERVICES-MIB.txt SNMPv2-CONF.mib VMWARE-ESX-AGENTCAP-MIB.mib
EtherLike-MIB.txt IP-FORWARD-MIB.mib NOTIFICATION-LOG-MIB.txt SNMPv2-CONF.txt VMWARE-HEARTBEAT-MIB.mib
geist_bb_mib.mib IP-FORWARD-MIB.txt notifications.txt SNMPv2-MIB.mib VMWARE-NSX-MANAGER-AGENTCAP-MIB.mib
geist_mib.txt IP-MIB.mib P-BRIDGE-MIB.mib SNMPv2-MIB.txt VMWARE-NSX-MANAGER-MIB.mib
HCNUM-TC.txt IP-MIB.txt Q-BRIDGE-MIB.mib
然后就可以试试看了。
snmpwalk -m ALL -c public -v 2c sydesx1 hrStorage
HOST-RESOURCES-MIB::hrMemorySize.0 = INTEGER: 234845392 KBytes
HOST-RESOURCES-MIB::hrStorageIndex.1 = INTEGER: 1
HOST-RESOURCES-MIB::hrStorageIndex.2 = INTEGER: 2
HOST-RESOURCES-MIB::hrStorageIndex.3 = INTEGER: 3
HOST-RESOURCES-MIB::hrStorageIndex.4 = INTEGER: 4
HOST-RESOURCES-MIB::hrStorageIndex.5 = INTEGER: 5
HOST-RESOURCES-MIB::hrStorageIndex.6 = INTEGER: 6
HOST-RESOURCES-MIB::hrStorageIndex.7 = INTEGER: 7
HOST-RESOURCES-MIB::hrStorageIndex.8 = INTEGER: 8
HOST-RESOURCES-MIB::hrStorageIndex.9 = INTEGER: 9
HOST-RESOURCES-MIB::hrStorageIndex.10 = INTEGER: 10
HOST-RESOURCES-MIB::hrStorageIndex.11 = INTEGER: 11
HOST-RESOURCES-MIB::hrStorageType.1 = OID: HOST-RESOURCES-TYPES::hrStorageRamDisk
HOST-RESOURCES-MIB::hrStorageType.2 = OID: HOST-RESOURCES-TYPES::hrStorageRamDisk
HOST-RESOURCES-MIB::hrStorageType.3 = OID: HOST-RESOURCES-TYPES::hrStorageRamDisk
HOST-RESOURCES-MIB::hrStorageType.4 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageType.5 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageType.6 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageType.7 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageType.8 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageType.9 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageType.10 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageType.11 = OID: HOST-RESOURCES-TYPES::hrStorageRam
HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: /vmfs/volumes/5d0548ee-62126bd1-5537-30262a317523
HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: /vmfs/volumes/becccae6-27d8d5c6-e47a-6ef1babf5cc6
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: /vmfs/volumes/595c571e-a107b89c-252c-ac162d6e2444
HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /vmfs/volumes/5a13b818-ebf86368-5680-ac162d6e2444
HOST-RESOURCES-MIB::hrStorageDescr.5 = STRING: /vmfs/volumes/5a13b834-323b0b4e-290f-ac162d6e2444
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: /vmfs/volumes/5a13b867-e07e81d4-2acd-ac162d6e2444
HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: /vmfs/volumes/5a13b880-8baabbf8-d6ff-ac162d6e2444
HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: /vmfs/volumes/5a13cff4-1e80a610-63b2-ac162d6e2444
HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: /vmfs/volumes/5a1e48c8-6b5eefc4-f04e-ac162d6e1c38
HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: /vmfs/volumes/5a28dcf3-45c2e884-a6cb-ac162d6e2444
HOST-RESOURCES-MIB::hrStorageDescr.11 = STRING: Real Memory
HOST-RESOURCES-MIB::hrStorageAllocationUnits.1 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.2 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.3 = INTEGER: 8192 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.4 = INTEGER: 1048576 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.5 = INTEGER: 1048576 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.6 = INTEGER: 1048576 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.7 = INTEGER: 1048576 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.8 = INTEGER: 1048576 Bytes
...
SNMP成功了 后面的就可以用现成的check_snmp来写Nagios命令了。这里不赘述了
可以参考这个博文,网上有人用perl写了个脚本,我们之间下载之后 直接调用就行了。当然请确保相关的模块都已安装了
http://www.bujarra.com/nagios-monitorizando-hosts-esxi/?lang=en
这个也很容易,常见的cpu,内存,存储,网络的监控都包括了
[root@sydnagios check_vmware_api-master]# ./check_vmware_api.pl -H sydesx1 -f check_vmware_api.auth -l mem -s usage -w 80 -c 90
CHECK_VMWARE_API.PL OK - mem usage=60.00 % | mem_usage=60.00%;80;90
[root@sydnagios check_vmware_api-master]# ./check_vmware_api.pl -H sydesx1 -f check_vmware_api.auth -l cpu -s usage -w 80 -c 90
CHECK_VMWARE_API.PL OK - cpu usage=10.56 % | cpu_usage=10.56%;80;90
标签:schedule sys entity mon 包括 lan ieee jar 直接
原文地址:http://blog.51cto.com/beanxyz/2059287