Changeset 10081 in genesis for tools/check-batch-cmd


Ignore:
Timestamp:
Mar 10, 2012, 2:21:41 PM (13 years ago)
Author:
rick
Message:

New bridges found using snmp queries (much faster).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/check-batch-cmd

    r10075 r10081  
    77#
    88import gformat
     9import netsnmp
     10import paramiko
     11import socket
    912import sys
    10 import socket
    11 import paramiko
     13
     14netsnmp.verbose = 0
    1215
    1316class CmdError(Exception):
     
    3033
    3134def get_bridge_type(host):
    32   import netsnmp
    33   netsnmp.verbose = 0
    34   var_list = netsnmp.VarList(netsnmp.Varbind('.1.2.840.10036.3.1.2.1.3.6'))
     35  """ Both NS and NS Mx uses a slighly different OID"""
     36  var_list = netsnmp.VarList(
     37   *map(lambda x: netsnmp.Varbind(x),
     38    ['.1.2.840.10036.3.1.2.1.3.6', '.1.2.840.10036.3.1.2.1.3.7']))
    3539 
    3640  sess = netsnmp.Session(Version=1, DestHost=host, Community='public', Timeout=2 * 100000, Retries=0)
     
    3842  if sess.ErrorInd < 0:
    3943    raise CmdError('[%(ErrorInd)s] %(ErrorStr)s' % vars(sess))
    40   return retval[0]
     44  return filter(None, retval)[0]
    4145
    4246
     
    6670  if sys.argv[1:]:
    6771    for host in sys.argv[1:]:
    68       check_host(host)
    69   main()
     72      print get_bridge_type(host)
     73  else:
     74    main()
Note: See TracChangeset for help on using the changeset viewer.