通过IPMItools达到收集数据的目的,然后通过与zabbix的结合实现数据统计和报警。
1.IPMI的配置:
1.1介绍
IPMI(Intelligent PlatformManagement Interface)即智能平台管理接口是使硬件管理具备“智能化”的新一代通用接口标准。用户可以利用 IPMI 监视服务器的物理特征,如温度、电压、电扇工作状态、电源供应以及机箱入侵等。Ipmi 最大的优势在于它是独立于 CPU BIOS 和 OS 的,所以用户无论在开机还是关机的状态下,只要接通电源就可以实现对服务器的监控。Ipmi 是一种规范的标准,其中最重要的物理部件就是BMC(Baseboard Management Controller 如图1),一种嵌入式管理微控制器,它相当于整个平台管理的“大脑”,通过它 ipmi 可以监控各个传感器的数据并记录各种事件的日志。
图 1
ipmitool 是一种可用在 linux 系统下的命令行方式的ipmi 平台管理工具,它支持 ipmi 1.5 规范(最新的规范为ipmi 2.0),通过它可以实现获取传感器的信息、显示系统日志内容、网络远程开关机等功能。Ipmitool 有两种使用方式(如表1)
表 1
使用 ipmi 的先决条件
想要实现对服务器的 ipmi 管理,必须在硬件、OS、管理工具等几个方面都满足:
a.服务器硬件本身提供对 ipmi 的支持
目前惠普、戴尔和 NEC 等大多数厂商的服务器都支持IPMI 1.5,但并不是所有服务器都支持,所以应该先通过产品手册或在 BIOS 中确定服务器是否支持 ipmi,也就是说服务器在主板上要具有 BMC 等嵌入式的管理微控制器。
b.操作系统提供相应的 ipmi 驱动
通过操作系统监控服务器自身的 ipmi 信息时需要系统内核提供相应的支持,linux 系统通过内核对 OpenIPMI(ipmi 驱动)的支持来提供对 ipmi 的系统接口。
IPMI有两种配置方法,第一种是开机BIOS配置,另一种是服务器运行状态下配置,此次配置是第二种情况。
1.2配置地址(服务器已经有ILO/iDRAC配置,无需做此项配置)
# ipmitool lan set 1 ipaddr 10.127.70.35
# ipmitool lan set 1 netmask 255.255.255.0
# ipmitool lan set 1 defgw ipaddr 10.127.70.254
# ipmitool lan print 1
# ipmitool lan set 1 access on # 开启IPMI Over LAN
1.3配置用户
# ipmitool user set name 12 吧啦吧啦
# ipmitool user set password 12 吧啦吧啦吧啦
# ipmitool user enable 12
# ipmitool user priv 12 2 1
上述命令的含义为:建立id为12,用户名为monitor,密码为test_ipmi123$%^,权限为User(对应2)的用户
# ipmitool user list 1 #打印出用户相关信息
ipmitool-H10.127.70.35 -Umonitor -L USERsensor list #测试是否有联通性,在zabbix server端进行测试,前提条件安装ipmitool
1.4在监控端arp被监控机的IPMI的IP地址和MAC地址
有时报错:无法连接到目标服务器,需要做如下操作:
# arp -s 10.127.70.35 <MAC地址> #MAC地址信息可以从ipmitool lan print 1中查看
2.Zabbix-agent端数据收集、配置修改
两种方法:添加IPMI的监控模板(Zabbix安装时要带--with-openipmi参数);或者在被监控端先收集数据,再通脚本将数据传给zabbix。选择了第一种方法:添加IPMI的监控模板。
2.1 IPMI模板
IPMI数据名称不统一,所以不同型号的机器需要不同的模板。下面是DELL-R410的IPMI监控模板zbx_templates_DELL_R410.xml。
<?xmlversion="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>2.0</version>
<date>2013-08-27T03:25:46Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>Template DellPowerEdge R410</template>
<name>Template Dell PowerEdgeR410</name>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name>传感器</name>
</application>
</applications>
<items>
<item>
<name>Ambient Temp</name>
<type>12</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ipmi.sensor.Ambient_Temp</key>
<delay>60</delay>
<history>90</history>
<trends>90</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>C</units>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor>AmbientTemp</ipmi_sensor>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>传感器</name>
</application>
</applications>
<valuemap/>
</item>
<item>
<name>FAN MOD 1ARPM</name>
<type>12</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ipmi.sensor.FAN_MOD_1A_RPM</key>
<delay>1800</delay>
<history>7</history>
<trends>90</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>rpm</units>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor>Fan 1ATach</ipmi_sensor>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>传感器</name>
</application>
</applications>
<valuemap/>
</item>
<item>
<name>FAN MOD 1BRPM</name>
<type>12</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ipmi.sensor.FAN_MOD_1B_RPM</key>
<delay>1800</delay>
<history>7</history>
<trends>90</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>rpm</units>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor>Fan 1BTach</ipmi_sensor>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>传感器</name>
</application>
</applications>
<valuemap/>
</item>
<item>
<name>FAN MOD 2ARPM</name>
<type>12</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ipmi.sensor.FAN_MOD_2A_RPM</key>
<delay>1800</delay>
<history>7</history>
<trends>90</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>rpm</units>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor>Fan 2ATach</ipmi_sensor>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>传感器</name>
</application>
</applications>
<valuemap/>
</item>
<item>
<name>FAN MOD 2BRPM</name>
<type>12</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ipmi.sensor.FAN_MOD_2B_RPM</key>
<delay>1800</delay>
<history>7</history>
<trends>90</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>rpm</units>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor>Fan 2BTach</ipmi_sensor>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>传感器</name>
</application>
</applications>
<valuemap/>
</item>
<item>
<name>FAN MOD 3ARPM</name>
<type>12</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ipmi.sensor.FAN_MOD_3A_RPM</key>
<delay>1800</delay>
<history>7</history>
<trends>90</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>rpm</units>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor>Fan 3ATach</ipmi_sensor>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>传感器</name>
</application>
</applications>
<valuemap/>
</item>
<item>
<name>FAN MOD 3B RPM</name>
<type>12</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>ipmi.sensor.FAN_MOD_3B_RPM</key>
<delay>1800</delay>
<history>7</history>
<trends>90</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>rpm</units>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor>Fan 3BTach</ipmi_sensor>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>传感器</name>
</application>
</applications>
<valuemap/>
</item>
</items>
<discovery_rules/>
<macros/>
<templates/>
<screens>
<screen>
<name>DELL传感器</name>
<hsize>1</hsize>
<vsize>2</vsize>
<screen_items>
<screen_item>
<resourcetype>0</resourcetype>
<width>500</width>
<height>100</height>
<x>0</x>
<y>1</y>
<colspan>1</colspan>
<rowspan>1</rowspan>
<elements>0</elements>
<valign>0</valign>
<halign>0</halign>
<style>0</style>
<url/>
<dynamic>0</dynamic>
<sort_triggers>0</sort_triggers>
<resource>
<name>Ambient Temp</name>
<host>Template Dell PowerEdge R410</host>
</resource>
</screen_item>
<screen_item>
<resourcetype>0</resourcetype>
<width>500</width>
<height>100</height>
<x>0</x>
<y>0</y>
<colspan>1</colspan>
<rowspan>1</rowspan>
<elements>0</elements>
<valign>0</valign>
<halign>0</halign>
<style>0</style>
<url/>
<dynamic>0</dynamic>
<sort_triggers>0</sort_triggers>
<resource>
<name>FANSRPM</name>
<host>Template Dell PowerEdge R410</host>
</resource>
</screen_item>
</screen_items>
</screen>
</screens>
</template>
</templates>
<triggers>
<trigger>
<expression>{Template DellPowerEdge R410:ipmi.sensor.Ambient_Temp.last(0)}>40</expression>
<name>服务器温度近超过40度</name>
<url/>
<status>0</status>
<priority>3</priority>
<description/>
<type>0</type>
<dependencies/>
</trigger>
</triggers>
<graphs>
<graph>
<name>AmbientTemp</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>2</drawtype>
<color>C80000</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>TemplateDell PowerEdge R410</host>
<key>ipmi.sensor.Ambient_Temp</key>
</item>
</graph_item>
</graph_items>
</graph>
<graph>
<name>FANS RPM</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>2</drawtype>
<color>00C800</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>TemplateDell PowerEdge R410</host>
<key>ipmi.sensor.FAN_MOD_1A_RPM</key>
</item>
</graph_item>
<graph_item>
<sortorder>1</sortorder>
<drawtype>2</drawtype>
<color>0000C8</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>TemplateDell PowerEdge R410</host>
<key>ipmi.sensor.FAN_MOD_1B_RPM</key>
</item>
</graph_item>
<graph_item>
<sortorder>2</sortorder>
<drawtype>2</drawtype>
<color>C800C8</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>TemplateDell PowerEdge R410</host>
<key>ipmi.sensor.FAN_MOD_2A_RPM</key>
</item>
</graph_item>
<graph_item>
<sortorder>3</sortorder>
<drawtype>2</drawtype>
<color>00C8C8</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>TemplateDell PowerEdge R410</host>
<key>ipmi.sensor.FAN_MOD_2B_RPM</key>
</item>
</graph_item>
<graph_item>
<sortorder>4</sortorder>
<drawtype>2</drawtype>
<color>C8C800</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>TemplateDell PowerEdge R410</host>
<key>ipmi.sensor.FAN_MOD_3A_RPM</key>
</item>
</graph_item>
<graph_item>
<sortorder>5</sortorder>
<drawtype>2</drawtype>
<color>C8C8C8</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>TemplateDell PowerEdge R410</host>
<key>ipmi.sensor.FAN_MOD_3B_RPM</key>
</item>
</graph_item>
</graph_items>
</graph>
</graphs>
</zabbix_export>
将这个主机模板导入到zabbixserver中,导入方法:系统配置—模板—导入(右上角)--选择要导入的文件—点击导入,如下图2-1。
图2-1
2.2 添加IPMI接口
主机配置中添加IPMIInterfaces,IP 10.127.70.35 (ILO IP),端口:623(默认)。如下图2-2。
图2-2
2.3 为主机添加监控模板
系统配置—主机—选择要配置的机器—模板—添加模板(Template Dell PowerEdge R410),如图2-3。
图2-3
2.4 设置IPMI用户名和密码
系统配置—主机—选择要配置的机器—IPMI,认证规则选“默认”,Privilege level(权限等级)选“用户”,输入用户名和密码,如图2-4。
图2-4
步骤2.2、2.3、2.4配置完后,点击保存。
至此IPMI温度和风扇的监控添加完成,下图为检测到的数据,还有图形显示可以登陆查看。