ESXI主机VMware公司企业级虚拟化的解决方案Vsphere的重要组件,也是虚拟机的宿主机,对其监控有着重要的意义,下边介绍二种方发对其监控。
方法一:通过修改服务端的控制项来进行监控。
虚拟机监控分两个步骤完成。首先,Zabbix 是通过 vmware collector 进程来监控虚拟机。这些进程通过 SOAP 协议从 VMware Web 服务获取必要的信息,对其进行预处理并存储到 Zabbix server 共享内存中。然后,zabbix pollers 通过 zabbix 简单检查 VMware keys 来检索这些数据。
从 Zabbix 2.4.4 开始,收集的数据分为两种类型:VMware 配置数据和 VMware 性能数据。这两种类型都由 vmware collectors 进程独立收集。因此,建议启用比受监控的 VMware 服务更多的收集器。否则,检索 VMware 性能统计信息可能会由于检索 VMware 配置数据而延迟(比较大型的环境,需要一段时间)。
目前基于 VMware 性能统计信息只有数据存储,网络接口和磁盘设备统计信息和自定义性能计数器项。
------来自zabbix官方文档(https://www.zabbix.com/documentation/3.4/zh/manual/vm_monitoring)
(一),修改zabbix 服务端的配置
1,通过修改zabbix_server.conf配置来进行收集VMware的相关信息。
[root@zabbix ~]# vim /usr/local/zabbix/etc/zabbix_server.conf
### Option: StartVMwareCollectors
# Number of pre-forked vmware collector instances.
#
# Mandatory: no
# Range: 0-250
# Default:
# StartVMwareCollectors=0
StartVMwareCollectors=10
### Option: VMwareFrequency
# How often Zabbix will connect to VMware service to obtain a new data.
#
# Mandatory: no
# Range: 10-86400
# Default:
# VMwareFrequency=60
VMwareFrequency=60
### Option: VMwarePerfFrequency
# How often Zabbix will connect to VMware service to obtain performance data.
#
# Mandatory: no
# Range: 10-86400
# Default:
# VMwarePerfFrequency=60
### Option: VMwareCacheSize
# Size of VMware cache, in bytes.
# Shared memory size for storing VMware data.
# Only used if VMware collectors are started.
#
# Mandatory: no
# Range: 256K-2G
# Default:
# VMwareCacheSize=8M
VMwareCacheSize=200M
备注:
StartVMwareCollectors(0-250) 只有大于0时才能是该功能生效,意为预先配置的vmware监控实例数量。
VMwareCacheSize(256K-2G)内存中维护的vmware集群结构的大小,建议80M。
VMwareFrequency(10-864000)zabbix获取更新vmware集群结构的最小间隔时间,单位为分钟。
2,重启服务并查看VMware monitoring 是否为YES正常
[root@zabbix ~]# /etc/init.d/zabbix_server start
Starting zabbix_server (via systemctl): [ 确定 ]
[root@zabbix ~]# tail -f /tmp/zabbix_server.log
31758:20171103:143357.746 Starting Zabbix Server. Zabbix 3.4.3 (revision 73588).
31758:20171103:143357.746 ****** Enabled features ******
31758:20171103:143357.746 SNMP monitoring: YES
31758:20171103:143357.746 IPMI monitoring: NO
31758:20171103:143357.746 Web monitoring: YES
31758:20171103:143357.746 VMware monitoring: YES
31758:20171103:143357.746 SMTP authentication: YES
31758:20171103:143357.746 Jabber notifications: NO
31758:20171103:143357.746 Ez Texting notifications: YES
31758:20171103:143357.746 ODBC: NO
31758:20171103:143357.746 SSH2 support: NO
31758:20171103:143357.746 IPv6 support: YES
31758:20171103:143357.746 TLS support: NO
31758:20171103:143357.746 ******************************
3,登录zabbix的web界面进行添加监控的Vcenter主机。具体步骤日下:配置–主机–创建主机
4 ,添加相关的主机的信息。注意端口信息要使用80端口。
5,添加zabbix自带的模板。
6,修改系统自带的宏。添加三个宏,{KaTeX parse error: Expected 'EOF', got '}' at position 9: PASSWORD}̲,{URL},{$USERNAME}。
注意:中间的{$URL}是esxi主机的真实登录地址,在浏览器中输入https://192.168.113.209/,选择进行登录如下图,就能查看esxi主机的相关信息了
7,保存,如果不相等的话,修改自动发现的时间,过一段时间会出现大量的自动发现主机。
8,由于没有图形,需要手工创建,具体步骤如下:任一虚拟机–图形–创建图形–填写相关信息–添加相关的items。
其中:
cpu cores 24:cpu核数
cpu frequency 2.2GHz: cpu主频
cpu thread 48: cpu线程,从此可看出为超线程
cpu usage 25GHZ: cpu使用情况,由此可计算: 25/(24*2.2)=47.3%,cpu使用率为47.3%。计算时以cpu核数为准,不要以超线程的数量为准
9,相关的图形效果如下
10cpu使用情况监控
网络使用情况
Cpu的使用率
Configuration–>Templates–>Template Virt VMware Hypervisor–>items–>create item
name:
hypervisor_cpu_used_percent
type:
Calculated #计算类型
key:
vmware.hv.cpu[usedpercent]
Formula:
100*last(“vmware.hv.cpu.usage[{KaTeX parse error: Expected 'EOF', got '}' at position 4: URL}̲,{HOST.HOST}]")…URL},{HOST.HOST}]”)*last(“vmware.hv.hw.cpu.num[{$URL},{HOST.HOST}]”))
Applications:
CPU
11,添加触发器,当cpu使用率大于80%报警。
内存使用率监控
内存使用率
1.创建item
Configuration–>Templates–>Template Virt VMware Hypervisor–>items–>create item
name:
hypervisor_cpu_used_percent
type:
Calculated #计算类型
key:
vmware.hv.memory[usedpercent]
Formula:
100*last(“vmware.hv.memory.used[{KaTeX parse error: Expected 'EOF', got '}' at position 4: URL}̲,{HOST.HOST}]")…URL},{HOST.HOST}]”)
Applications:
memory
内存使用超过80%报警