

Zabbix监控- Aruba AP运行数据
source link: https://blog.51cto.com/magic3/5411879
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

本文档中AP运行数据指: Aruba MM平台下,AP每Radio连接数量和总连接数量,Channel使用率。
早期是通过shell来实现数据获取,然后trapper到zabbix server.但是有个明显缺点: AP的名称不是LLD实现的,也就是说近百个AP都是人工手动创建的监控主机。
为了解决这个问题,将代码使用Python进行了重写。
概念&难点
在控制器中,每项数据都会有自己的OID,我们要将这些OID和AP关联起来,毕竟预期Zabbix中显示的是每个AP的相关信息。
- Radio: 射频。双频AP有Radio0和Radio1。 Aruba对应的索引编号分别是 2和1(CISCO有差异).
- Channel: 信道。 启用双频后,通常使用两个信道(当然也可以捆绑多个)。 Aruba对应的索引编号同样分别是2和1。
- Radio0 : SnmpWalk值为0是2.4G,值为1时为5G,表示启用了双5G。值位2时,未发射射频。
- Radio1: 值为1时指5G;值为2时,未发射射频。不能为0.
- Radio0: 值为1时,SnmpWalk获取到的终端数并不是实际的数量,需要除以2. 值为0时,为实际终端数量。所以计算时,需要注意。
- 未射频的AP需要单独排除,否则SnmpWalk射频和信道会报错。
- 获取AP名字Trapper到Zabbix Server.
1.zabbix创建LLD模板

创建监控项:

2.Python获取AP名字trapper到Zabbix.
push_ap.py :
#!/usr/bin/env python
#-*- coding:UTF-8 -*-
import os
import json
ap_json = {"data": []}
ap_sets = os.popen("snmpwalk -v 2c -c mm the IP_Aruba_MM .1.3.6.1.4.1.14823.2.2.1.5.2.1.4 | grep -i ap | awk -F ':' '{print $4}'|awk -F '\"' '{print $2}'")
ap_list = ap_sets.read().splitlines()
ap_sets.close()
for ap in ap_list:
ap_json["data"].append({"{#AP_NAME}": ap})
push_data = json.dumps(ap_json)
os.system("/bin/zabbix_sender -z Zabbix_Server_IP -p 10051 -s office-aruba-bj-t2-11-ac-10 -k ap.discovery -o '%s'" %push_data)
- 获取AP运行数据Trapper到Zabbix.
push_data_of_ap.py:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#------ push ap radio utilization and number of clients to zabbix-----
import os
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.10'
ap_names_dict = {} # key存储AP名字,值存储AP索引
double_5G = [] #开启双5G的AP列表.开启双5G的AP,radio0客户端数量准确,radio1的客户端数量需要除以2.
snmpwalk_ap_datas = os.popen("snmpwalk -v 2c -c mm IP_Aruba_MM %s" %prefix_ap_oid)
#ap_disabled_list = ['AP-01', 'T2-F19-AP04', 'T1-F16-AP30']
ap_disabled_list = []
def get_ap_dic_fun(dict): #获取AP名字和索引字符串并别存入字典的key: value。
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_ap_status(dict_ap):
for ap_name in dict_ap.keys():
snmpwalk_status_datas = os.popen("snmpwalk -v 2c -c mm IP_Aruba_MM %s%s" % (prefix_ap_status_oid, dict_ap[ap_name]))
ap_status = int(snmpwalk_status_datas.read().split(':')[-1])
os.system("/bin/zabbix_sender -z Zabbix_Server_IP -vv -s office-aruba-bj-t2-11-ac-10 -k status.[%s] -o %s" % (ap_name, ap_status))
def remove_disabled_ap(dict_ap): #判断AP状态,1为在线。不为1,则从字典中移除,并加入禁用ap列表。
for ap_name in dict_ap.keys():
snmpwalk_status_datas = os.popen("snmpwalk -v 2c -c mm IP_Aruba_MM %s%s" % (prefix_ap_status_oid, dict_ap[ap_name]))
ap_status = int(snmpwalk_status_datas.read().split(':')[-1])
if ap_status != 1:
dict_ap.pop(ap_name)
ap_disabled_list.append(ap_name)
def trapper_channel_util(dict_ap): #trapper 信道使用率
for ap_name in dict_ap.keys():
try:
snmpwalk_ap_radio0 = os.popen("snmpwalk -v 2c -c mm IP_Aruba_MM %s%s.2" % (prefix_channel_oid, dict_ap[ap_name]))
snmpwalk_ap_radio1 = os.popen("snmpwalk -v 2c -c mm IP_Aruba_MM %s%s.1" % (prefix_channel_oid, dict_ap[ap_name]))
channel0_data_source = snmpwalk_ap_radio0.read()
channel1_data_source = snmpwalk_ap_radio1.read()
if ap_name != 'AP-01' and ap_name != 'T2-F19-AP04' and ap_name != 'T1-F16-AP30':
radio0_util_percent = int(channel0_data_source.split(':')[-1])
radio1_util_percent = int(channel1_data_source.split(':')[-1])
os.system("/bin/zabbix_sender -z Zabbix_Server_IP -vv -s office-aruba-bj-t2-11-ac-10 -k uti_radio0.[%s] -o %s" %(ap_name, radio0_util_percent))
os.system("/bin/zabbix_sender -z Zabbix_Server_IP -vv -s office-aruba-bj-t2-11-ac-10 -k uti_radio1.[%s] -o %s" %(ap_name, radio1_util_percent))
except Exception as e:
print e
def check_double_5G(dict_ap): #判断AP是否开启双5G。1为开启,后续Radio0客户端数量除以2。
for ap_name in dict_ap.keys():
datas = os.popen("snmpwalk -v 2c -c mm IP_Aruba_MM %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): #trapper 每个射频客户端数量,并计算AP终端总数量。
for ap_name in dict_ap.keys():
radio0_datas = os.popen("snmpwalk -v 2c -c mm IP_Aruba_MM %s%s.2" % (prefix_radio_clients_oid, dict_ap[ap_name])).read()
radio1_datas = os.popen("snmpwalk -v 2c -c mm IP_Aruba_MM %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 Zabbix_Server_IP -vv -s office-aruba-bj-t2-11-ac-10 -k clients.radio0.[%s] -o %s" %(ap_name,clients_radio0))
os.system("/bin/zabbix_sender -z Zabbix_Server_IP -vv -s office-aruba-bj-t2-11-ac-10 -k clients.radio1.[%s] -o %s" %(ap_name,clients_radio1))
os.system("/bin/zabbix_sender -z Zabbix_Server_IP -vv -s office-aruba-bj-t2-11-ac-10 -k clients.[%s] -o %s" %(ap_name,clients_sum))
if __name__ == '__main__':
get_ap_dic_fun(ap_names_dict)
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)
- Zabbix控制台:


-
信道使用率:
-
终端连接数:

Recommend
-
81
官网提高的python版本监控redis很久没有更新了,今天按照官网操作的一遍,出现了好多报错,后来问了一个哥们,他给了我监控配置文件和脚本。下面我分享给大家参考参考。添加zabbix-agent配置文件[root@test-mq01redis]#cat/etc/zabbix/zabbix_agentd.d/redis.confU...
-
62
Linux监控平台介绍常见开源监控软件:cacti、nagios、zabbix、smokeping、open-falcon等等,其中cacti、smokeping偏向于基础监控,成图非常漂亮。cacti、nagios、zabbix服务端监控中心,需要php环境支持,其中zabbix和cacti都需要mysql作为数据存储,nagios不用存...
-
17
Testing $HOME with Cucumber and Aruba Posted: 2014-04-15 - Last updated: 2019-06-05 Tagged
-
6
聊聊HPE Aruba及其云发展愿景 来源:Forbes 2021-04-22 13:49:54关键字: HPE 我参加了HPE Aruba举...
-
11
Aruba IAP-514 for APoS August 29, 2021 By Rowell Leave a Comment My trusty Aruba IAP-514 ha...
-
9
Aruba Country Code (CCODE) Generator 2022-05-28 03:01:41 # 网络
-
7
Convert Aruba CAP to IAP Convert Aruba CAP to IAP 2021-03-22 03:10:28 # 网络
-
5
Serial Console Cable for Aruba AP-205H Serial Console Cable for Aruba AP-205H 2022-10-17 20:19:14 #网络
-
9
HPE Aruba Networking widens net to include private 5G, SASE and data center networking
-
4
Wednesday, 10 January 2024 12:10 HPE Aruba to acquire Juniper Networks Featured By David M Wil...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK