背景
近期,随着机房迁移的进行,为了提升电力保障并确保设备的持续运行,我们在原有基础上新增了多台山特UPS电源作为备用电源。这些UPS电源的主要作用是在电力中断时为机房设备提供足够的电力支持,确保设备有充足的时间进行正常关机,避免由于突然断电带来的数据丢失或硬件损坏。
然而,UPS电源本身并未进行有效的监控,这使得我们无法实时掌握UPS的工作状态、电池电量等关键信息,从而错失可能出现故障的早期预警。因此,为了提高机房电力管理的智能化水平,确保UPS电源的稳定性与可靠性,我们决定对这些UPS电源进行全面的监控。
目的
通过构建一个完整的UPS监控方案,不仅能及时发现UPS的故障或异常状态,还能够在电池电量不足等紧急情况下,提前做出预警,避免对机房设备造成不必要的影响。
监控目标
- 监控UPS状态:实时获取UPS的运行状态,如是否正常、是否有故障等。
- 监控UPS电池容量:确保电池容量健康,避免突然断电。
- 监控UPS输入电压:确保UPS接收到的电压符合标准。
- 提高运维效率:通过自动化监控,减少人工检查和干预。
操作步骤
1. 配置山特UPS客户端
为了使Zabbix能够监控山特UPS电源,我们需要从UPS系统中获取相关数据。假设山特UPS的IP为192.168.81.11
,并且它支持通过HTTP接口输出状态数据(比如通过REST API获取JSON格式的数据)。接下来,我们将编写一个Shell脚本,通过调用UPS的API接口,提取数据并交给Zabbix监控。
关于监控软件的安装:
下载软件:https://www.santak.com.cn/page/santak-downloads.html
软件名:Winpower_setup_LinuxAMD64.tar.gz
连接COM线并转为USB插入到负责监控的服务器,当前启动监控软件的服务器为192.168.81.11
安装:
tar zxf Winpower_setup_LinuxAMD64.tar.gz
cd Winpower_setup_LinuxAMD64/LinuxAMD64/
./setup_console.bin # 一路回车即可
# 启动agent
cd /opt/MonitorSoftware/
./agent start
配置:
# 需要安装图形化界面
startx
# 启动管理软件
cd /opt/MonitorSoftware/
./monitor
配置USB接口:系统->成为系统管理员(默认没有密码,直接确认即可)->通讯口设定->输入/dev/ttyUSB1增加→输入/dev/ttyUSB2增加→确定
扫描设备:系统→自动搜索设备,完成后即可在页面显示对应的UPS状态信息
配置https端口:远程监控->Web服务器控制->停止->远程监控->Web服务器控制→修改端口为10086->开始->确定
打开网页
2. 测试数据
访问
0 代表ups的位置,假如有三台,则是:0 1 2
地址:https://192.168.96.200:8888/0/json
{
"key": "COM3/C6K",
"version": "",
-"device": {
"key": "COM3/C6K",
"id": 0,
"protocol": 18,
"portIndex": 1,
"ip": null,
"status": "",
"upsIndex": 0,
"statusIcon": "online",
"hasWarn": false
},
"status": "正常",
"model": "C6K",
"loadPercentMax": 16,
"loadSegment2State": "",
"loadSegment1State": "",
"redundantNumber": "",
"inVolt": "231.6V",
"bypassFreq": "",
"workMode": 3,
"loadPercent": "16%",
"lsCounter": -1,
"extStatus": 0,
"oidType": 0,
"outFreq": "50.0Hz",
"warning": "",
"noModule": false,
"batCapacity": "100%",
"batTimeRemain": "",
"bypassVolt": "",
"inFreq": "50.0Hz",
"iStatus": 0,
"outVolt": "219.5V",
"abmState": "",
"emdAlarm1": "",
"cfgBatNumber": "",
"cfgKVA": "",
"emdAlarm2": "",
"batTemp": "",
"emdHumidity": "",
"emdTemp": "",
"lastEvent1": "",
"statusColor": 0,
"supportTest": true,
"upsTemp": "27.2C",
"lastEvent2": "2025/01/15 17:34:54 Agent启动",
"batV": "201.9V",
"outVA": "0.9KVA",
"ls1": -1,
"outW": "0.6KW",
"ls2": -1,
"outA": ""
}
3. 安装Zabbix Agent并配置
在监控服务器上,我们首先需要安装Zabbix Agent,Zabbix Agent是用来采集数据并将其传递给Zabbix Server的工具。假设监控服务器IP为192.168.82.12
,我们将在此服务器上进行安装并配置Zabbix Agent。
安装Zabbix Agent
如果您使用的是基于Debian/Ubuntu的操作系统,可以使用以下命令来安装Zabbix Agent:
sudo apt update
sudo apt install zabbix-agent
对于RedHat/CentOS系统:
sudo yum install zabbix-agent
安装完成后,启动Zabbix Agent:
sudo systemctl start zabbix-agent
sudo systemctl enable zabbix-agent
编写UPS监控脚本
在Zabbix Agent所在的服务器上,创建一个新的监控脚本。我们将在/etc/zabbix/zabbix_agentd.d/script/ups-monitor/ups.sh
路径下创建脚本:
#!/bin/bashnum=$2
if [ "$num" = "0" ];thendata=$(curl --connect-timeout 3 -k -s https://192.168.81.11:10086/1/json -w "|%{http_code}")
elif [ "$num" = "1" ];thendata=$(curl --connect-timeout 3 -k -s https://192.168.81.11:10086/0/json -w "|%{http_code}")
elif [ "$num" = "2" ];thendata=$(curl --connect-timeout 3 -k -s https://192.168.81.10:10086/0/json -w "|%{http_code}")
ficase $1 instatus)echo "$data"|awk -F'|' '{print $1}'|jq '.["status"]'|sed 's/"//g';;batCapacity)echo "$data"|awk -F'|' '{print $1}'|jq '.["batCapacity"]'|sed 's/"//g;s/%//g';;inVolt)echo "$data"|awk -F'|' '{print $1}'|jq '.["inVolt"]'|sed 's/"//g;s/V//g';;apiStatus)echo "$data"|awk -F'|' '{print $2}';;*)
esac
此脚本根据不同的参数(status
, batCapacity
, inVolt
)来获取UPS设备的不同数据项。它通过curl
命令访问UPS的API接口,并使用jq
解析JSON格式的数据。
配置Zabbix Agent
在Zabbix Agent的配置文件中(通常位于/etc/zabbix/zabbix_agentd.conf
),我们需要添加自定义监控项,使Zabbix能够调用上面创建的脚本来获取UPS相关的数据。
在zabbix_agentd.conf
文件中,添加以下行:
自定义监控项:192.168.82.12:/etc/zabbix/zabbix_agentd.d/userparameter_ups.conf
UserParameter=ups.status[*],/usr/bin/bash /etc/zabbix/zabbix_agentd.d/script/ups-monitor/ups.sh status $1
UserParameter=ups.batCapacity[*],/usr/bin/bash /etc/zabbix/zabbix_agentd.d/script/ups-monitor/ups.sh batCapacity $1
UserParameter=ups.inVolt[*],/usr/bin/bash /etc/zabbix/zabbix_agentd.d/script/ups-monitor/ups.sh inVolt $1
UserParameter=ups.apiStatus[*],/usr/bin/bash /etc/zabbix/zabbix_agentd.d/script/ups-monitor/ups.sh apiStatus $1
保存配置文件并重新启动Zabbix Agent:
sudo systemctl restart zabbix-agent
3. 配置Zabbix Server
接下来,我们需要在Zabbix Server中配置相应的监控项,以便能够收集和显示UPS的相关数据。
3.1 创建监控项
在Zabbix前端,进入“Configuration” -> “Hosts”,选择您的监控主机,然后点击“Items”选项卡,创建以下监控项:
- 监控UPS状态:类型选择“Zabbix agent (active)”,键值输入
ups.status
。 - 监控电池容量:类型选择“Zabbix agent (active)”,键值输入
ups.batCapacity
。 - 监控输入电压:类型选择“Zabbix agent (active)”,键值输入
ups.inVolt
。
设置合适的数据收集周期,并保存监控项。
模板文件
Template UPS.xml
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export><version>4.0</version><date>2022-03-31T10:04:22Z</date><groups><group><name>FJF Dev VM UPS</name></group></groups><templates><template><template>Template UPS</template><name>Template UPS</name><description/><groups><group><name>FJF Dev VM UPS</name></group></groups><applications><application><name>UPS</name></application></applications><items><item><name>UPS[0]接口状态</name><type>0</type><snmp_community/><snmp_oid/><key>ups.apiStatus[0]</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>3</value_type><allowed_hosts/><units/><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[1]接口状态</name><type>0</type><snmp_community/><snmp_oid/><key>ups.apiStatus[1]</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>3</value_type><allowed_hosts/><units/><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[2]接口状态</name><type>0</type><snmp_community/><snmp_oid/><key>ups.apiStatus[2]</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>3</value_type><allowed_hosts/><units/><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[0]电池剩余电量</name><type>0</type><snmp_community/><snmp_oid/><key>ups.batCapacity[0]</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>3</value_type><allowed_hosts/><units>%</units><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[1]电池剩余电量</name><type>0</type><snmp_community/><snmp_oid/><key>ups.batCapacity[1]</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>3</value_type><allowed_hosts/><units>%</units><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[2]电池剩余电量</name><type>0</type><snmp_community/><snmp_oid/><key>ups.batCapacity[2]</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>3</value_type><allowed_hosts/><units>%</units><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[0]电源输入电压</name><type>0</type><snmp_community/><snmp_oid/><key>ups.inVolt[0]</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units>V</units><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[1]电源输入电压</name><type>0</type><snmp_community/><snmp_oid/><key>ups.inVolt[1]</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units>V</units><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[2]电源输入电压</name><type>0</type><snmp_community/><snmp_oid/><key>ups.inVolt[2]</key><delay>30s</delay><history>90d</history><trends>365d</trends><status>0</status><value_type>0</value_type><allowed_hosts/><units>V</units><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[0]电源状态</name><type>0</type><snmp_community/><snmp_oid/><key>ups.status[0]</key><delay>30s</delay><history>90d</history><trends>0</trends><status>0</status><value_type>4</value_type><allowed_hosts/><units/><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[1]电源状态</name><type>0</type><snmp_community/><snmp_oid/><key>ups.status[1]</key><delay>30s</delay><history>90d</history><trends>0</trends><status>0</status><value_type>4</value_type><allowed_hosts/><units/><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item><item><name>UPS[2]电源状态</name><type>0</type><snmp_community/><snmp_oid/><key>ups.status[2]</key><delay>30s</delay><history>90d</history><trends>0</trends><status>0</status><value_type>4</value_type><allowed_hosts/><units/><snmpv3_contextname/><snmpv3_securityname/><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authprotocol>0</snmpv3_authprotocol><snmpv3_authpassphrase/><snmpv3_privprotocol>0</snmpv3_privprotocol><snmpv3_privpassphrase/><params/><ipmi_sensor/><authtype>0</authtype><username/><password/><publickey/><privatekey/><port/><description/><inventory_link>0</inventory_link><applications><application><name>UPS</name></application></applications><valuemap/><logtimefmt/><preprocessing/><jmx_endpoint/><timeout>3s</timeout><url/><query_fields/><posts/><status_codes>200</status_codes><follow_redirects>1</follow_redirects><post_type>0</post_type><http_proxy/><headers/><retrieve_mode>0</retrieve_mode><request_method>0</request_method><output_format>0</output_format><allow_traps>0</allow_traps><ssl_cert_file/><ssl_key_file/><ssl_key_password/><verify_peer>0</verify_peer><verify_host>0</verify_host><master_item/></item></items><discovery_rules/><httptests/><macros/><templates/><screens/></template></templates><triggers><trigger><expression>{Template UPS:ups.apiStatus[0].last()}<>200</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.apiStatus[0].last()}=200</recovery_expression><name>UPS-API[0]接口异常</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.apiStatus[1].last()}<>200</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.apiStatus[1].last()}=200</recovery_expression><name>UPS-API[1]接口异常</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.apiStatus[2].last()}<>200</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.apiStatus[2].last()}=200</recovery_expression><name>UPS-API[2]接口异常</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.status[0].str(零火线接反)}=0 and {Template UPS:ups.status[0].str(正常)}=0</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.status[0].str(零火线接反)}=1 or {Template UPS:ups.status[0].str(正常)}=1</recovery_expression><name>UPS[0]状态异常</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.batCapacity[0].last()}<90</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.batCapacity[0].last()}>90</recovery_expression><name>UPS[0]电池剩余电量小于90%</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.inVolt[0].avg(#3)}<200</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.inVolt[0].avg(#3)}>200</recovery_expression><name>UPS[0]输入电压异常</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.status[1].str(正常)}=0</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.status[1].str(正常)}=1</recovery_expression><name>UPS[1]状态异常</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.batCapacity[1].last()}<90</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.batCapacity[1].last()}>90</recovery_expression><name>UPS[1]电池剩余电量小于90%</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.inVolt[1].avg(#3)}<200</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.inVolt[1].avg(#3)}>200</recovery_expression><name>UPS[1]输入电压异常</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.status[2].str(正常)}=0</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.status[2].str(正常)}=1</recovery_expression><name>UPS[2]状态异常</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.batCapacity[2].last()}<90</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.batCapacity[2].last()}>90</recovery_expression><name>UPS[2]电池剩余电量小于90%</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger><trigger><expression>{Template UPS:ups.inVolt[2].avg(#3)}<200</expression><recovery_mode>1</recovery_mode><recovery_expression>{Template UPS:ups.inVolt[2].avg(#3)}>200</recovery_expression><name>UPS[2]输入电压异常</name><correlation_mode>0</correlation_mode><correlation_tag/><url/><status>0</status><priority>4</priority><description/><type>0</type><manual_close>0</manual_close><dependencies/><tags/></trigger></triggers>
</zabbix_export>
监控项:
3.2 配置触发器
为了及时发现UPS故障,您可以设置触发器。例如,如果UPS的状态变为“故障”或电池容量低于某个阈值时,触发告警。根据您的需求,可以设置以下触发器:
- UPS状态故障触发器:当
ups.status
的值为“Fault”时,触发告警。 - 电池容量低触发器:当
ups.batCapacity
小于某个阈值(例如20%
)时,触发告警。
触发器:
4. 验证与测试
完成上述配置后,Zabbix Server将开始定期从Zabbix Agent中获取UPS的状态数据。您可以通过Zabbix前端查看UPS的状态、剩余电池容量和输入电压等信息,并根据设置的触发器在出现异常时收到告警。