zabbix通過IPMI監控硬件環境(溫度和風扇)



通過IPMItools達到收集數據的目的,然後通過與zabbix的結合實現數據統計和報警。


1.IPMI的配置:

1.1介紹

IPMIIntelligent 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 系統通過內核對 OpenIPMIipmi 驅動)的支持來提供對 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

上述命令的含義爲:建立id12,用戶名爲monitor,密碼爲test_ipmi123$%^,權限爲User(對應2)的用戶

#  ipmitool user list 1   #打印出用戶相關信息


ipmitool-H10.127.70.35  -Umonitor -L USERsensor  list   #測試是否有聯通性,在zabbix server端進行測試,前提條件安裝ipmitool


1.4在監控端arp被監控機的IPMIIP地址和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-R410IPMI監控模板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)}&gt;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接口

主機配置中添加IPMIInterfacesIP 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.22.32.4配置完後,點擊保存。

至此IPMI溫度和風扇的監控添加完成,下圖爲檢測到的數據,還有圖形顯示可以登陸查看。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章