'--up', required=False, help='list of interfaces that should be up') args = parser.parse_args() #setup the snmp object snmp = SNMP(args.host, community=args.community) #create table of interfaces http://www.alvestrand.no/objectid/1.3.6.1.2.1.2.2.1.3.html interfaces = None try: interfaces = snmp.table('1.3.6.1.2.1.2.2.1', columns={ 1: "index", 2: "description", 8: "status", 3: "type" }, fetch_all_columns=False) except SNMPError: print('Could not reach server at ' + args.host) sys.exit(1) #print if (interfaces != None): interfacesUp = [] for index in range(0, len(interfaces.columns['description'])): if (interfaces.columns['status'][index] == IF_UP and interfaces.columns['type'][index] == 6): interfacesUp.append(interfaces.columns['description'][index])
__version__ = "1.1" #parse the arguments parser = argparse.ArgumentParser() parser.add_argument('-c', '--community', required=True, help='The community string') parser.add_argument('-H', '--host', required=True, help='The host address') parser.add_argument('-d', '--device', required=False, help='check the total device count', action='store_true') parser.add_argument('-w', '--warning', required=False, help='the client count to show a warning', type=int) args = parser.parse_args() snmp = SNMP(args.host, community=args.community) #create snmp table based on UBNT OIDs table = None try: table = snmp.table('.1.3.6.1.4.1.41112.1.6.1.2.1', columns={6: 'ssid', 8: 'clients', 9: 'radio'}) except SNMPError as e: print('error') print(e) sys.exit(1) if(table is not None): #get the available SSIDs allNames = {} index = 0 for ssid in table.columns['ssid']: if(ssid not in allNames and ssid != ''): allNames[ssid] = int(table.columns['clients'][index]) index = index + 1
'--peer', required=False, help='The peer address to look for') args = parser.parse_args() #setup the snmp object snmp = SNMP(args.host, community=args.community) #create table of peers http://www.oidview.com/mibs/9/CISCO-IPSEC-FLOW-MONITOR-MIB.html peers = None try: peers = snmp.table('1.3.6.1.4.1.9.9.171.1.2.3.1', columns={ 7: 'ip', 16: 'active_time', 20: 'in_packets', 28: 'out_packets' }) except SNMPError: print('Could not reach server at ' + args.host) sys.exit(1) #print total if peer not given if (args.peer == None): print('There are ' + str(len(peers.columns['ip'])) + ' tunnel peers connected') sys.exit(0) else: #if peer exists if (args.peer in peers.columns['ip']):