Changeset 8328 in genesis for nodes/get-network-status.py
- Timestamp:
- Aug 12, 2010, 9:07:52 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/get-network-status.py
r8324 r8328 90 90 91 91 92 def do_nmap_scan(command, iphosts, result_file=None ):92 def do_nmap_scan(command, iphosts, result_file=None, forced_scan=False): 93 93 """ Wrapper around _run_nmap to get listing of all hosts, the default nmap 94 94 does not return results for failed hosts""" … … 97 97 98 98 # Return stored file if exists 99 if result_file and os.path.exists(result_file) and os.path.getsize(result_file) > 0: 99 if not forced_scan and result_file and os.path.exists(result_file) \ 100 and os.path.getsize(result_file) > 0: 100 101 print "# Reading stored NMAP results from '%s'" % (result_file) 101 102 status = parse_nmap(parse(result_file)) … … 137 138 # 138 139 # Gather SNMP data from hosts 139 for host, scan in status.iteritems(): 140 for host in iphosts: 141 # Status might be containing old hosts as well and visa-versa 142 if not status.has_key(host): 143 print "## [ERROR] No nmap result found" 144 continue 145 146 scan = status[host] 140 147 if scan['state'] != "up": 141 continue142 143 # Filter set? use it144 if iphosts and not host in iphosts:145 print "## IP '%s' not in specified filter" % host146 148 continue 147 149 … … 298 300 299 301 def usage(): 300 print "Usage: %s <all|force|stored|host HOST1 [HOST2 ...]>" % sys.argv[0] 302 print "Usage: %s <arguments>" 303 print "Arguments:" 304 print "\tall = scan all known ips, using cached nmap" 305 print "\tnmap-only = scan all known ips, using nmap only" 306 print "\tsnmp-only = scan all known ips, using snmp only" 307 print "\tforce = scan all known ips, no cache used" 308 print "\tforced-snmp = scan all known ips, no snmp cache" 309 print "\tstored = generate status file using stored entries" 310 print "\thost <HOST1> [HOST2 ...] = generate status file using stored entries" 311 print "\tmerge <FILE1> [FILE2 ...] = merge status file with other status files" 301 312 sys.exit(0) 302 313 … … 360 371 if not opt_store_scan: 361 372 nmap_result_file = None 362 nmap_status = do_nmap_scan("-p T:ssh,U:domain,T:80,T:ntp,U:snmp,T:8080 -sU -sT ",iplist, nmap_result_file) 373 nmap_status = do_nmap_scan( 374 "-p T:ssh,U:domain,T:80,T:ntp,U:snmp,T:8080 -sU -sT ", 375 iplist,nmap_result_file, opt_force_scan) 376 363 377 else: 364 378 nmap_status = stored_status['nmap_status']
Note:
See TracChangeset
for help on using the changeset viewer.