Index: nodes/gformat.py
===================================================================
--- nodes/gformat.py	(revision 8316)
+++ nodes/gformat.py	(revision 8317)
@@ -277,4 +277,30 @@
 
   return datadump
+
+
+
+def get_all_configs():
+  """ Get dict with key 'host' with all configs present """
+  configs = dict()
+  for host in get_hostlist():
+    datadump = get_yaml(host)
+    configs[host] = datadump
+  return configs
+
+
+
+def get_used_ips(configs):
+    """ Return array of all IPs used in config files"""
+    ip_list = []
+    for host,config in configs.iteritems():
+      ip_list.append(config['masterip'])
+      iface_keys = [elem for elem in config.keys() if (elem.startswith('iface_') and not "lo0" in elem)]
+      for iface_key in iface_keys:
+        l = config[iface_key]['ip']
+        addr, mask = l.split('/')
+        # Special case do not process
+        if addr not in ["0.0.0.0"]:
+           ip_list.append(addr)
+    return sorted(ip_list)
 
 
Index: nodes/status-monitoring.py
===================================================================
--- nodes/status-monitoring.py	(revision 8316)
+++ nodes/status-monitoring.py	(revision 8317)
@@ -1,3 +1,5 @@
 #!/usr/bin/env python
+# vim:ts=2:et:sw=2:ai
+#
 # Scan Wireless Leiden Network and report status of links and nodes
 #
@@ -6,4 +8,5 @@
 from pprint import pprint
 from xml.dom.minidom import parse, parseString
+import gformat
 import os.path
 import re
@@ -15,5 +18,7 @@
 SCAN_RANGE='172.16.0.0/21'
 
-
+#
+# BEGIN nmap XML parser
+# XXX: Should properly go to seperate class/module
 def get_attribute(node,attr):
   return node.attributes[attr].value
@@ -58,41 +63,50 @@
       status[scan['addr']] = scan
   return status
-
-
-def _run_nmap(command, result_file="-"):
+#
+# END nmap parser
+#
+
+
+
+def _do_nmap_scan(command, iphosts, result_file=None):
   """ Run/Read nmap XML with various choices"""
-
-  command = "nmap -n -oX - %s" %(command)
-  dom = None
-  if result_file == "-":
-    print "# New run '%s' results not saved" % (command)
-    dom = parseString(subprocess.Popen(command.split(),
-            stdout=subprocess.PIPE).communicate()[0])
-  elif os.path.exists(result_file) and os.path.getsize(result_file) > 0:
+  # Return stored file if exists
+  if result_file and os.path.exists(result_file) and os.path.getsize(result_file) > 0:
     print "# Reading stored NMAP results from '%s'" % (result_file)
     dom = parse(result_file)
-  else:
-    print "# New run '%s' saving results in %s" % (command, result_file)
-    print "# Waiting for nmap run to complete"
-    f = open(result_file,'w')
-    p = subprocess.Popen(command.split(),stdout=f)
-    while p.poll() == None:
-      print ".",
-      sys.stdout.flush()
-      time.sleep(1)
-    print "DONE"
-    if p.returncode != 0:
-      print "# ERROR in nmap command"
-      sys.exit(1) 
+    return dom
+
+  command = "nmap -n -iL - -oX - %s" %(command)
+  print "# New run '%s', can take a while to complete" % (command)
+  p = subprocess.Popen(command.split(),
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+        stdin=subprocess.PIPE, bufsize=-1)
+
+  (stdoutdata, stderrdata) = p.communicate("\n".join(iphosts.split(" ")))
+  if p.returncode != 0:
+    print "# [ERROR] nmap failed to complete '%s'" % stderrdata
+    sys.exit(1) 
+
+  if result_file:
+    print "# Saving results in %s" % (result_file)
+    f = file(result_file,'w')
+    f.write(stdoutdata)
     f.close()
-    dom = parse(result_file)
+
+  dom = parseString(stdoutdata)
   return parse_nmap(dom)
 
-def do_nmap(command, iphosts, result_file="-"):
-  """ Wrapper around _run_nmap to get listing of all hosts"""
+
+
+def do_nmap_scan(command, iphosts, result_file="-"):
+  """ Wrapper around _run_nmap to get listing of all hosts, the default nmap
+      does not return results for failed hosts"""
   # Get all hosts to be processed
-  status = _run_nmap("-sL " + iphosts)
-  status.update(_run_nmap("%s %s" % (command, iphosts), result_file))
+  status = _do_nmap_scan("-sL",iphosts)
+  status.update(_do_nmap_scan(command, iphosts, result_file))
   return status
+
+
 
 def do_snmpwalk(host, oid):
@@ -108,4 +122,6 @@
 
 
+
+
 def run_scan(host_filter=None):
   """ Big working processing all scanning work"""
@@ -113,10 +129,10 @@
   if host_filter:
     iphosts = " ".join(host_filter)
-    result_file = "-"
+    result_file = None
   else:
     iphosts = SCAN_RANGE
     result_file = '/tmp/test.xml'
 
-  status = do_nmap("-p T:ssh,U:domain,T:80,T:ntp,U:snmp,T:8080 -sU -sT ",iphosts, result_file)
+  status = do_nmap_scan("-p T:ssh,U:domain,T:80,T:ntp,U:snmp,T:8080 -sU -sT ",iphosts, result_file)
   mac_to_host = dict()
   host_processed = dict()
@@ -228,42 +244,50 @@
     sys.exit(0)
 
-stored_status = dict()
-stored_status_file = '/tmp/stored_status.yaml'
-if len(sys.argv) > 1:
-  if sys.argv[1] == "all":
-    stored_status = run_scan()
-    stream = file(stored_status_file,'w')
-    print "##Stored data hints to '%' " % stored_status
-    stored_status = yaml.dump(stored_status, stream, default_flow_style=False)
-  elif sys.argv[1] == "force":
-    stored_status = run_scan()
-  elif sys.argv[1] == "host":
-    stored_status = run_scan(sys.argv[2:])
-  elif sys.argv[1] == "stored":
-    # Load data hints from previous run if exists
-    if os.path.exists(stored_status_file) and os.path.getsize(stored_status_file) > 0:
-      stream = file(stored_status_file,'r')
-      stored_status = yaml.load(stream)
+
+def generate_status(stored_status):
+  """ Generate result file from stored_status """
+  host_processed = stored_status['host_processed']
+  mac_to_host = stored_status['mac_to_host']
+  # Correlation mapping
+  for host, details in host_processed.iteritems():
+    print "# Working on %s" % host
+    for ip, arpmac in details['arpmac'].iteritems():
+      if arpmac in details['mac'].keys():
+        # Local MAC address
+        continue
+      if not mac_to_host.has_key(arpmac):
+        print "## [WARN] No parent host for MAC %s (%s) found" % (arpmac, ip)
+      else:
+        print "## Interlink %s - %s"  % (host, mac_to_host[arpmac])
+
+
+
+def main():
+  stored_status = dict()
+  stored_status_file = '/tmp/stored_status.yaml'
+  if len(sys.argv) > 1:
+    if sys.argv[1] == "all":
+      stored_status = run_scan(gformat.get_used_ips(gformat.get_all_configs()))
+      stream = file(stored_status_file,'w')
+      print "##Stored data hints to '%' " % stored_status
+      stored_status = yaml.dump(stored_status, stream, default_flow_style=False)
+    elif sys.argv[1] == "force":
+      stored_status = run_scan()
+    elif sys.argv[1] == "host":
+      stored_status = run_scan(sys.argv[2:])
+    elif sys.argv[1] == "stored":
+      # Load data hints from previous run if exists
+      if os.path.exists(stored_status_file) and os.path.getsize(stored_status_file) > 0:
+        stream = file(stored_status_file,'r')
+        stored_status = yaml.load(stream)
+      else:
+        print "[ERROR] '%s' does not exists" % stored_status_file
     else:
-      print "[ERROR] '%s' does not exists" % stored_status_file
+      usage()
   else:
-    usage()
-else:
-   usage()
-
-
-host_processed = stored_status['host_processed']
-mac_to_host = stored_status['mac_to_host']
-# Correlation mapping
-for host, details in host_processed.iteritems():
-  print "# Working on %s" % host
-  for ip, arpmac in details['arpmac'].iteritems():
-    if arpmac in details['mac'].keys():
-      # Local MAC address
-      continue
-    if not mac_to_host.has_key(arpmac):
-      print "## [WARN] No parent host for MAC %s (%s) found" % (arpmac, ip)
-    else:
-      print "## Interlink %s - %s"  % (host, mac_to_host[arpmac])
-        
-    
+     usage()
+
+
+
+if __name__ == "__main__":
+  main()
