Changeset 8319 in genesis for nodes/status-monitoring.py
- Timestamp:
- Aug 12, 2010, 2:32:45 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/status-monitoring.py
r8318 r8319 246 246 status = stored_status['nmap_status'] 247 247 248 # Data store format used for nodemap generation 249 nodemap_status_file = '/tmp/nodemap_status.yaml' 250 nodemap = { 'node' : {}, 'link' : {}} 251 252 # XXX: Pushed back till we actually store the MAC in the config files automatically 253 #configmac_to_host = dict() 254 #for host,config in configs.iteritems(): 255 # for iface_key in gformat.get_interface_keys(config): 256 # configmac_to_host[config[iface_key]['mac']] = host 257 248 258 # List of hosts which has some kind of problem 249 259 for host in list(set(configs.keys()) - set(host_processed.keys())): 250 print "# Problem in host '%s'" % host 260 config = configs[host] 261 print "# Problems in host '%s'" % host 262 host_down = True 263 for ip in gformat.get_used_ips([config]): 264 if status[ip]['state'] == "up": 265 host_down = False 266 print "## - ", ip, status[ip]['state'] 267 if host_down: 268 print "## HOST is DOWN!" 269 nodemap['node'][host] = gformat.DOWN 270 else: 271 print "## SNMP problems (not reachable, deamon not running, etc)" 272 nodemap['node'][host] = gformat.UNKNOWN 273 274 251 275 252 276 # Correlation mapping 253 277 for host, details in host_processed.iteritems(): 278 nodemap['node'][host] = gformat.OK 254 279 print "# Working on %s" % host 255 280 for ip, arpmac in details['arpmac'].iteritems(): … … 261 286 else: 262 287 print "## Interlink %s - %s" % (host, mac_to_host[arpmac]) 263 288 nodemap['link'][(host,mac_to_host[arpmac])] = gformat.OK 289 290 stream = file(nodemap_status_file,'w') 291 yaml.dump(nodemap, stream, default_flow_style=False) 292 print "# Wrote nodemap status to '%s'" % nodemap_status_file 264 293 265 294 def usage(): … … 310 339 if not opt_force_range: 311 340 configs = gformat.get_all_configs() 312 iplist = gformat.get_used_ips(configs )341 iplist = gformat.get_used_ips(configs.values()) 313 342 else: 314 343 iplist = sys.argv[1:] … … 330 359 nmap_status = stored_status['nmap_status'] 331 360 361 # Save the MAC -> HOST mappings, by default as it helps indentifing the 362 # 'unknown links' 363 mac_to_host = {} 364 if stored_status: 365 mac_to_host = stored_status['mac_to_host'] 366 332 367 # Do SNMP discovery 333 368 if opt_snmp_scan: … … 335 370 else: 336 371 snmp_status = stored_status 372 373 # Include our saved MAC -> HOST mappings 374 mac_to_host.update(snmp_status['mac_to_host']) 375 snmp_status['mac_to_host'] = mac_to_host 337 376 338 377 # Store changed data to disk
Note:
See TracChangeset
for help on using the changeset viewer.