4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cisco WLC クライアント数を Kibana で可視化

Posted at

PI とか使えば可視化されますが、Kibana で見たいので SSID ごとのクライアント数を取得し、json で吐き出すスクリプトを書きました。

from pysnmp.entity.rfc3413.oneliner import cmdgen
import json

wlc_host  = "WLC HOSTNAME"
snmp_comm = "WLC SNMP COMMUNITY"
SSIDs     = [ "SSID1","SSID2","SSID3" ]

cmdGen = cmdgen.CommandGenerator()

count  = {}
result = {}

errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
            cmdgen.CommunityData(snmp_comm),
            cmdgen.UdpTransportTarget((wlc_host, 161)),
            '1.3.6.1.4.1.14179.2.1.4.1.7',
            )

for varBindTableRow in varBindTable:
    for name, val in varBindTableRow:
        if val in count:
            count[str(val)] = count[str(val)] + 1
        else:
            count[str(val)] = 1

for SSID in SSIDs:
    if SSID in count:
        result.update({ SSID:count[SSID]})
    else:
        result.update({ SSID:0 })

print json.dumps(result, sort_keys=True,)

実行結果はこんな感じ

{"SSID1": 5, "SSID2": 128, "SSID3": 0}

これを curl で ElasticSearch に POST すると Kibana で見られます。

JSON=`/usr/bin/python Clients.py`
/usr/bin/curl -X POST -d "json=$JSON" http://localhost:8080/wifi.clients
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?