Featured image of post Zabbix监控山特UPS电源:实现高效监控与告警

Zabbix监控山特UPS电源:实现高效监控与告警

近期,随着机房迁移的进行,为了提升电力保障并确保设备的持续运行,我们在原有基础上新增了多台山特UPS电源作为备用电源。这些UPS电源的主要作用是在电力中断时为机房设备提供足够的电力支持,确保设备有充足的时间进行正常关机,避免由于突然断电带来的数据丢失或硬件损坏。 然而,UPS电源本身并未进行有效的监控,这使得我们无法实时掌握UPS的工作状态、电池电量等关键信息,从而错失可能出现故障的早期预警。因此,为了提高机房电力管理的智能化水平,确保UPS电源的稳定性与可靠性,我们决定对这些UPS电源进行全面的监控。通过

背景

近期,随着机房迁移的进行,为了提升电力保障并确保设备的持续运行,我们在原有基础上新增了多台山特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 安装:

1
2
3
4
5
6
tar zxf Winpower_setup_LinuxAMD64.tar.gz
cd Winpower_setup_LinuxAMD64/LinuxAMD64/
./setup_console.bin # 一路回车即可
# 启动agent
cd /opt/MonitorSoftware/
./agent start

配置:

1
2
# 需要安装图形化界面
startx

在这里插入图片描述

1
2
3
# 启动管理软件
cd /opt/MonitorSoftware/
./monitor

配置USB接口:系统->成为系统管理员(默认没有密码,直接确认即可)->通讯口设定->输入/dev/ttyUSB1增加→输入/dev/ttyUSB2增加→确定

扫描设备:系统→自动搜索设备,完成后即可在页面显示对应的UPS状态信息 在这里插入图片描述 配置https端口:远程监控->Web服务器控制->停止->远程监控->Web服务器控制→修改端口为10086->开始->确定

在这里插入图片描述 打开网页 在这里插入图片描述 在这里插入图片描述

2. 测试数据

访问

1
2
0 代表ups的位置,假如有三台,则是:0 1 2
地址:https://192.168.96.200:8888/0/json
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
"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:

1
2
sudo apt update
sudo apt install zabbix-agent

对于RedHat/CentOS系统:

1
sudo yum install zabbix-agent

安装完成后,启动Zabbix Agent:

1
2
sudo systemctl start zabbix-agent
sudo systemctl enable zabbix-agent

编写UPS监控脚本

在Zabbix Agent所在的服务器上,创建一个新的监控脚本。我们将在/etc/zabbix/zabbix_agentd.d/script/ups-monitor/ups.sh路径下创建脚本:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash

 
num=$2
if [ "$num" = "0" ];then
  data=$(curl --connect-timeout 3 -k -s https://192.168.81.11:10086/1/json -w "|%{http_code}")
elif [ "$num" = "1" ];then
  data=$(curl --connect-timeout 3 -k -s https://192.168.81.11:10086/0/json -w "|%{http_code}")
elif [ "$num" = "2" ];then
  data=$(curl --connect-timeout 3 -k -s https://192.168.81.10:10086/0/json -w "|%{http_code}")
fi
 
 
case $1 in
  status)
    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

1
2
3
4
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:

1
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

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
<?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()}&lt;&gt;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()}&lt;&gt;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()}&lt;&gt;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()}&lt;90</expression>
            <recovery_mode>1</recovery_mode>
            <recovery_expression>{Template UPS:ups.batCapacity[0].last()}&gt;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)}&lt;200</expression>
            <recovery_mode>1</recovery_mode>
            <recovery_expression>{Template UPS:ups.inVolt[0].avg(#3)}&gt;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()}&lt;90</expression>
            <recovery_mode>1</recovery_mode>
            <recovery_expression>{Template UPS:ups.batCapacity[1].last()}&gt;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)}&lt;200</expression>
            <recovery_mode>1</recovery_mode>
            <recovery_expression>{Template UPS:ups.inVolt[1].avg(#3)}&gt;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()}&lt;90</expression>
            <recovery_mode>1</recovery_mode>
            <recovery_expression>{Template UPS:ups.batCapacity[2].last()}&gt;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)}&lt;200</expression>
            <recovery_mode>1</recovery_mode>
            <recovery_expression>{Template UPS:ups.inVolt[2].avg(#3)}&gt;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的状态、剩余电池容量和输入电压等信息,并根据设置的触发器在出现异常时收到告警。 在这里插入图片描述 在这里插入图片描述

未来的你,会感谢今天仍在努力奋斗的你