{"action":"created","issue":{"url":"https://api.github.com/repos/influxdata/telegraf/issues/4226","repository_url":"https://api.github.com/repos/influxdata/telegraf","labels_url":"https://api.github.com/repos/influxdata/telegraf/issues/4226/labels{/name}","comments_url":"https://api.github.com/repos/influxdata/telegraf/issues/4226/comments","events_url":"https://api.github.com/repos/influxdata/telegraf/issues/4226/events","html_url":"https://github.com/influxdata/telegraf/issues/4226","id":328863851,"node_id":"MDU6SXNzdWUzMjg4NjM4NTE=","number":4226,"title":"SNMP Pulling Data from Multiple MIBs","user":{"login":"scollora","id":39676385,"node_id":"MDQ6VXNlcjM5Njc2Mzg1","avatar_url":"https://avatars0.githubusercontent.com/u/39676385?v=4","gravatar_id":"","url":"https://api.github.com/users/scollora","html_url":"https://github.com/scollora","followers_url":"https://api.github.com/users/scollora/followers","following_url":"https://api.github.com/users/scollora/following{/other_user}","gists_url":"https://api.github.com/users/scollora/gists{/gist_id}","starred_url":"https://api.github.com/users/scollora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scollora/subscriptions","organizations_url":"https://api.github.com/users/scollora/orgs","repos_url":"https://api.github.com/users/scollora/repos","events_url":"https://api.github.com/users/scollora/events{/privacy}","received_events_url":"https://api.github.com/users/scollora/received_events","type":"User","site_admin":false},"labels":[{"id":194687831,"node_id":"MDU6TGFiZWwxOTQ2ODc4MzE=","url":"https://api.github.com/repos/influxdata/telegraf/labels/question","name":"question","color":"d4d7dd","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-06-03T21:29:45Z","updated_at":"2018-06-07T22:36:34Z","closed_at":"2018-06-05T22:41:30Z","author_association":"NONE","body":"Hi there,\r\n\r\nI have a wireless LAN controller where there's an AP table and a client table in two different MIBS.  I am trying to construct a query (grafana) that will show how many clients are connected to APs in any particular group.  The AP table contains the MAC address of the APs in a group, and from there, I would like to look in the client table and count the number of clients across those APs.   \r\n\r\nDoes this happen as a function of the telegraf configuration, or later on in the database queries?  I would like to have each line have everything I need in it.  As you can see, I get different series:\r\n\r\nThe AP table results in this:\r\n```\r\nWLC-CLIENTS,AP\\ Group=default-group,agent_host=172.16.5.222,bsnAPDot3MacAddress=00:fe:c8:e0:13:40,host=telegraf,index=0.254.200.224.19.64 bsnAPLocation=\"default location\",bsnAPBootVersion=\"15.2.4.0\",bsnAPPortNumber=1i,bsnAPCertificateType=1i,bsnAPEthernetMacAddress=\"00:fe:c8:b9:9b:20\",bsnAPAdminStatus=1i,bsnAPStatsTimer=180i,bsnAPSerialNumber=\"FCW1948P5GC\",bsnAPRemoteModeSupport=1i,bsnAPGroupVlanName=\"default-group\",bsnAPName=\"LivingRoom\",bsnAPMonitorOnlyMode=0i,bsnAPSoftwareVersion=\"8.5.110.0\",bsnAPModel=\"AIR-CAP3702I-A-K9\",bsnAPClearConfig=0i,bsnAPIsStaticIP=0i,bsnAPOperationStatus=1i,bsnAPReset=0i,bsnAPMirrorMode=0i,bsnAPType=40i,bsnAPIOSVersion=\"15.3(3)JF4$\",bsnAPBridgingSupport=0i,bsnAPNumOfSlots=2i,bsnApIpAddress=\"172.16.5.189\",bsnAPNetmask=\"255.255.255.0\",bsnAPGateway=\"172.16.5.1\",bsnAPStaticIPAddress=\"172.16.5.189\" 1528060114000000000\r\n```\r\n\r\n\r\nThe client table results in this:\r\n\r\n```\r\nWLC-CLIENTS,AirespaceMAC=b4:18:d1:03:07:73,agent_host=172.16.5.222,bsnMobileStationMacAddress=b4:18:d1:03:07:73,host=telegraf bsnMobileStationInterface=\"management\",bsnMobileStationSsid=\"CNS\",bsnMobileStationChannelAgilityEnabled=0i,bsnMobileStationPolicyManagerState=\"RUN\",bsnMobileStationReasonCode=1i,bsnMobileStationAnchorAddress=\"0.0.0.0\",bsnMobileStationPortNumber=1i,bsnMobileStationSecurityPolicyStatus=0i,bsnMobileStationEncryptionCypher=0i,bsnMobileStationAPIfSlotId=1i,bsnMobileStationMobilityStatus=1i,bsnMobileStationWepState=1i,bsnMobileStationEapType=7i,bsnMobileStationE2eVersion=0i,bsnMobileStationAID=1i,bsnMobileStationPolicyType=2i,bsnMobileStationEssIndex=1i,bsnMobileStationPBCCOptionImplemented=0i,bsnMobileStationSessionTimeout=0i,bsnMobileStationAuthenticationAlgorithm=0i,bsnMobileStationMirrorMode=0i,bsnMobileStationAPMacAddr=\"00:fe:c8:d2:de:b0\",bsnMobileStationCFPollable=0i,bsnMobileStationVlanId=0i,bsnMobileStationCcxVersion=0i,bsnMobileStationStatusCode=0i,bsnMobileStationIpAddress=\"172.16.5.151\",bsnMobileStationCFPollRequest=0i,bsnMobileStationShortPreambleOptionImplemented=0i,bsnMobileStationDeleteAction=0i,bsnMobileStationProtocol=7i,bsnMobileStationApMode=0i,bsnMobileStationStatus=3i 1528060058000000000\r\n```\r\n\r\nThere's no crossover.  Can a combination be done with some combination of \"inherit_tags\" in the configuration file so that everything is combined into a single result?  Sorry if I seem new to this, but I am new to this."},"comment":{"url":"https://api.github.com/repos/influxdata/telegraf/issues/comments/395587396","html_url":"https://github.com/influxdata/telegraf/issues/4226#issuecomment-395587396","issue_url":"https://api.github.com/repos/influxdata/telegraf/issues/4226","id":395587396,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTU4NzM5Ng==","user":{"login":"scollora","id":39676385,"node_id":"MDQ6VXNlcjM5Njc2Mzg1","avatar_url":"https://avatars0.githubusercontent.com/u/39676385?v=4","gravatar_id":"","url":"https://api.github.com/users/scollora","html_url":"https://github.com/scollora","followers_url":"https://api.github.com/users/scollora/followers","following_url":"https://api.github.com/users/scollora/following{/other_user}","gists_url":"https://api.github.com/users/scollora/gists{/gist_id}","starred_url":"https://api.github.com/users/scollora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scollora/subscriptions","organizations_url":"https://api.github.com/users/scollora/orgs","repos_url":"https://api.github.com/users/scollora/repos","events_url":"https://api.github.com/users/scollora/events{/privacy}","received_events_url":"https://api.github.com/users/scollora/received_events","type":"User","site_admin":false},"created_at":"2018-06-07T22:36:34Z","updated_at":"2018-06-07T22:36:34Z","author_association":"NONE","body":"I wound up doing it list this.  Python script:\r\n\r\n```\r\nfrom pysnmp.entity.rfc3413.oneliner import cmdgen\r\nfrom pysmi import debug\r\nimport collections\r\n# debug.setLogger(debug.Debug('reader', 'searcher', 'compiler'))\r\n\r\n# Grab the AP Table\r\ncmdGen = cmdgen.CommandGenerator()\r\n\r\nerrorIndication, errorStatus, errorIndex, APTable = cmdGen.nextCmd(\r\n    cmdgen.CommunityData('public'),\r\n    cmdgen.UdpTransportTarget(('172.16.5.222', 161)),\r\n    # cmdgen.MibVariable('CISCO-LWAPP-AP-MIB', 'cLApGroupTable').addAsn1MibSource('/usr/share/mibs'),\r\n    # cmdgen.MibVariable('AIRESPACE-WIRELESS-MIB', 'bsnAPTable').addAsn1MibSource('/usr/share/mibs'),\r\n    '1.3.6.1.4.1.14179.2.2.1.1.30',\r\n    lookupNames=False, lookupValues=False\r\n)\r\n\r\n#Grab the Client Table\r\ncmdGen = cmdgen.CommandGenerator()\r\n\r\nerrorIndication, errorStatus, errorIndex, ClientTable = cmdGen.nextCmd(\r\n    cmdgen.CommunityData('public'),\r\n    cmdgen.UdpTransportTarget(('172.16.5.222', 161)),\r\n    # cmdgen.MibVariable('CISCO-LWAPP-DOT11-CLIENT-MIB', 'cldcClientTable').addAsn1MibSource('/usr/share/mibs'),\r\n    '1.3.6.1.4.1.9.9.599.1.3.1.1.8',\r\n    lookupNames=False, lookupValues=False\r\n)\r\n\r\n\r\nif errorIndication:\r\n    print(errorIndication)\r\nelse:\r\n    if errorStatus:\r\n        print('%s at %s' % (\r\n            errorStatus.prettyPrint(),\r\n            errorIndex and ClientTable[-1][int(errorIndex)-1] or '?'\r\n            )\r\n        )\r\n    else:\r\n        myline={}\r\n        myrecord = {}\r\n\r\n        for Client in ClientTable:\r\n            for clientmacoid, apmacfromclient in Client:\r\n                field = str(clientmacoid).split('.')\r\n                field1hex = format(int(field[14]),'x')\r\n                field2hex = format(int(field[15]),'x')\r\n                field3hex = format(int(field[16]),'x')\r\n                field4hex = format(int(field[17]),'x')\r\n                field5hex = format(int(field[18]),'x')\r\n                field6hex = format(int(field[19]),'x')\r\n                clientmacouihex = field1hex+field2hex+field3hex+field4hex+field5hex+field6hex\r\n                apmacvalue = (apmacfromclient.prettyPrint())[-12:]\r\n\r\n                # for varBindTableRow in APTable:\r\n                for AP in APTable:\r\n                    for macoid, group in AP:\r\n                        field = str(macoid).split('.')\r\n                        f1 = format(int(field[12]),'02x')\r\n                        f2 = format(int(field[13]),'02x')\r\n                        f3 = format(int(field[14]),'02x')\r\n                        f4 = format(int(field[15]),'02x')\r\n                        f5 = format(int(field[16]),'02x')\r\n                        f6 = format(int(field[17]),'02x')\r\n                        apmac = f1+f2+f3+f4+f5+f6\r\n\r\n                        if apmacvalue == apmac:\r\n                            \r\n                            # print 'APGroupMap,APGroup=' + group + ',APMac=' + apmacvalue + ' ClientMAC=\\\"'+clientmacouihex+'\\\"'\r\n                            myline={\"APGroup\":str(group),\"APMac\":str(apmacvalue)}\r\n                            # print myline\r\n                            myrecord.update({clientmacouihex:myline})\r\n                            \r\n                            \r\n\r\n                # print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))\r\n        #print myrecord\r\n        lst = [value[\"APMac\"] for value in myrecord.values()]\r\n        #print collections.Counter(lst)\r\n\r\n        counter_obj = collections.Counter(lst)\r\n        for i in counter_obj:\r\n            for AP in APTable:\r\n                    for macoid, group in AP:\r\n                        field = str(macoid).split('.')\r\n                        f1 = format(int(field[12]),'02x')\r\n                        f2 = format(int(field[13]),'02x')\r\n                        f3 = format(int(field[14]),'02x')\r\n                        f4 = format(int(field[15]),'02x')\r\n                        f5 = format(int(field[16]),'02x')\r\n                        f6 = format(int(field[17]),'02x')\r\n                        apmac = f1+f2+f3+f4+f5+f6\r\n                        if i == apmac:\r\n                            print 'APGroupMap,APGroup=' + group + ',APMac=\\\"' + apmac + '\\\" Counter=' + counter_obj[i]\r\n```\r\n\r\nResults in this data:\r\n\r\n```\r\nlinuxadmin@telegraf:~$ python apstuff.py \r\nAPGroupMap,APGroup=Upstairs,APMac=\"00fec8d2deb0\" Counter=1\r\nAPGroupMap,APGroup=Downstairs,APMac=\"00fec8c95140\" Counter=3\r\nAPGroupMap,APGroup=Downstairs,APMac=\"00fec8e01340\" Counter=2\r\n```\r\n\r\nWith this config file:\r\n\r\n```\r\n[[inputs.exec]]\r\n  ## Commands array\r\n  commands = [\"/usr/bin/python /home/linuxadmin/apstuff.py\"]\r\n  interval = \"15s\"\r\n  ## Data format to consume.\r\n  ## Each data format has its own unique set of configuration options, read\r\n  ## more about them here:\r\n  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md\r\n  data_format = \"influx\"\r\n```\r\n\r\nAnd this query:\r\n\r\n```\r\nSELECT sum(\"Counter\") FROM \"APGroupMap\" WHERE $timeFilter GROUP BY time(15s), \"APGroup\" fill(null)\r\n```\r\nResults in this beauty:\r\n\r\n![image](https://user-images.githubusercontent.com/39676385/41129738-5a9323d2-6a68-11e8-8e73-9a41ece7aeed.png)\r\n"}}
{"actor":{"display_login":"scollora"}}