Zabbix监控- Aruba AP运行数据(MM架构)

网友投稿 735 2022-09-08


Zabbix监控- Aruba AP运行数据(MM架构)

前一篇文章中(非MM架构AP监控) 介绍了如何在非MM架构中,如何获取Aruba AP的运行数据。但是在Aruba MM架构中,AC的工作方式由之前的主备变成了双活负载模式。

在双活模式下,监控就要复杂一些了。 需要分别获取两台AC上承载的AP数据,进行加工处理后,在trapper到zabbix。

获取AP名称列表

push_ap.py

#!/usr/bin/env python #-*- coding:UTF-8 -*- #--------AP DISCOVYER 2020-12-24-------- import os import json ap_json = {"data": []} ap_sets = os.popen("snmpwalk -v 2c -c commu 172.16.202.x 1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3 | awk -F ':' '{print $4}'|awk -F '\"' '{print $2}'") ap_list = ap_sets.read().splitlines() ap_sets.close() for ap in ap_list: if ap != "bc" and ap != "e8": ap_json["data"].append({"{#AP_NAME}": ap}) push_data = json.dumps(ap_json) print push_data #"/bin/zabbix_sender -z 172.16.7.x -p 10051 -s office-aruba-bj-t2-11-MM-10 -k ap.discovery -o '%s'" %push_data os.system("/bin/zabbix_sender -z 172.16.7.x -p 10051 -s office-aruba-bj-t2-11-MM-10 -k ap.discovery -o '%s'" %push_data)

获取AP运行数据(分别snmpwalk两台AC)

push_data.py

#!/usr/bin/env python #-*- coding:utf-8 -*- import os import commands prefix_ap_oid = '1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3' prefix_radio_clients_oid = '1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.7' prefix_channel_oid = '1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.6' prefix_double5G_oid = '1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.48' prefix_ap_status_oid = '1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.19' ap_names_dict = {} # key存储AP名字,值存储AP索引 double_5G = [] #开启双5G的AP列表.开启双5G的AP,radio0客户端数量准确,radio1的客户端数量需要除以2. snmpwalk_ap_datas = os.popen("snmpwalk -v 2c -c commu 172.16.202.x %s" %prefix_ap_oid) #ap_disabled_list = ['AP-01', 'T2-F19-AP04', 'T1-F16-AP30'] ap_disabled_list = [] def get_ap_dic_fun(dict): for ap_names in snmpwalk_ap_datas.readlines(): ap_name = ap_names.split('"')[1] ap_index = (ap_names.split('=')[0]).split('1.4.1.3')[1].rstrip() dict[ap_name] = ap_index return dict def trapper_channel_util(dict_ap): for ap_name in dict_ap.keys(): try: output = commands.getstatusoutput("snmpwalk -v 2c -c commu 172.16.202.x %s%s" % (prefix_channel_oid,dict_ap[ap_name])) if "INTEGER" in output[1]: #判断AP在哪台AC上,Radio1:5G Radio0:2.4G snmpwalk_ap_radio0 = os.popen("snmpwalk -v 2c -c commu 172.16.202.x %s%s.2" % (prefix_channel_oid, dict_ap[ap_name])) snmpwalk_ap_radio1 = os.popen("snmpwalk -v 2c -c commu 172.16.202.x %s%s.1" % (prefix_channel_oid, dict_ap[ap_name])) else: snmpwalk_ap_radio0 = os.popen("snmpwalk -v 2c -c commu 172.16.202.y %s%s.2" % (prefix_channel_oid, dict_ap[ap_name])) snmpwalk_ap_radio1 = os.popen("snmpwalk -v 2c -c commu 172.16.202.y %s%s.1" % (prefix_channel_oid, dict_ap[ap_name])) channel0_data_source = snmpwalk_ap_radio0.read() channel1_data_source = snmpwalk_ap_radio1.read() radio0_util_percent = int(channel0_data_source.split(':')[-1]) radio1_util_percent = int(channel1_data_source.split(':')[-1]) # print radio0_util_percent # print type(radio0_util_percent) os.system("/bin/zabbix_sender -z 172.16.7.x -vv -s office-aruba-bj-t2-11-MM-10 -k uti_radio0.[%s] -o %s" %(ap_name, radio0_util_percent)) os.system("/bin/zabbix_sender -z 172.16.7.x -vv -s office-aruba-bj-t2-11-MM-10 -k uti_radio1.[%s] -o %s" %(ap_name, radio1_util_percent)) except Exception, e: print e def check_double_5G(dict_ap): for ap_name in dict_ap.keys(): datas = os.popen("snmpwalk -v 2c -c commu 172.16.202.x %s%s" % (prefix_double5G_oid, dict_ap[ap_name])).read() value = int(datas.split(':')[-1]) if value == 1: #值为1,已启用双5G.值为0,未启用. double_5G.append(ap_name) def trapper_clients_ap(dict_ap): for ap_name in dict_ap.keys(): output = commands.getstatusoutput("snmpwalk -v 2c -c commu 172.16.202.x %s%s" % (prefix_radio_clients_oid,dict_ap[ap_name])) if "INTEGER" in output[1]: #判断AP在哪台AC上 radio0_datas = os.popen("snmpwalk -v 2c -c commu 172.16.202.x %s%s.2" % (prefix_radio_clients_oid, dict_ap[ap_name])).read() radio1_datas = os.popen("snmpwalk -v 2c -c commu 172.16.202.x %s%s.1" % (prefix_radio_clients_oid, dict_ap[ap_name])).read() else: radio0_datas = os.popen("snmpwalk -v 2c -c commu 172.16.202.y %s%s.2" % (prefix_radio_clients_oid, dict_ap[ap_name])).read() radio1_datas = os.popen("snmpwalk -v 2c -c commu 172.16.202.y %s%s.1" % (prefix_radio_clients_oid, dict_ap[ap_name])).read() clients_radio1 = int(radio1_datas.split(':')[-1]) if ap_name in double_5G: clients_radio0 = int(radio0_datas.split(':')[-1]) / 2 else: clients_radio0 = int(radio0_datas.split(':')[-1]) clients_sum = clients_radio0 + clients_radio1 os.system("/bin/zabbix_sender -z 172.16.7.x -vv -s office-aruba-bj-t2-11-MM-10 -k clients.radio0.[%s] -o %s" % (ap_name, clients_radio0)) os.system("/bin/zabbix_sender -z 172.16.7.x -vv -s office-aruba-bj-t2-11-MM-10 -k clients.radio1.[%s] -o %s" % (ap_name, clients_radio1)) os.system("/bin/zabbix_sender -z 172.16.7.x -vv -s office-aruba-bj-t2-11-MM-10 -k clients.[%s] -o %s" %(ap_name,clients_sum)) if __name__ == '__main__': get_ap_dic_fun(ap_names_dict) # ap_names_dict.pop('e8:26:89:c0:f3:32') # ap_names_dict.pop('bc:9f:e4:ca:69:e6') snmpwalk_ap_datas.close() # trapper_ap_status(ap_names_dict) # remove_disabled_ap(ap_names_dict) trapper_channel_util(ap_names_dict) check_double_5G(ap_names_dict) trapper_clients_ap(ap_names_dict)

附上cisco平台的监控脚本下载链接: https://github.com/allenshi86/Zabbix/tree/master/CISCO%20Wireless


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:携手推进国产化发展,未来智安与麒麟软件完成兼容互认证
下一篇:WebSocket简介与消息推送
相关文章

 发表评论

暂时没有评论,来抢沙发吧~