Changeset 10081 in genesis for tools/check-batch-cmd
- Timestamp:
- Mar 10, 2012, 2:21:41 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/check-batch-cmd
r10075 r10081 7 7 # 8 8 import gformat 9 import netsnmp 10 import paramiko 11 import socket 9 12 import sys 10 import socket 11 import paramiko 13 14 netsnmp.verbose = 0 12 15 13 16 class CmdError(Exception): … … 30 33 31 34 def 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'])) 35 39 36 40 sess = netsnmp.Session(Version=1, DestHost=host, Community='public', Timeout=2 * 100000, Retries=0) … … 38 42 if sess.ErrorInd < 0: 39 43 raise CmdError('[%(ErrorInd)s] %(ErrorStr)s' % vars(sess)) 40 return retval[0]44 return filter(None, retval)[0] 41 45 42 46 … … 66 70 if sys.argv[1:]: 67 71 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.