Index: tools/check-batch-cmd
===================================================================
--- tools/check-batch-cmd	(revision 10433)
+++ tools/check-batch-cmd	(revision 10434)
@@ -51,17 +51,23 @@
   pass
 
+class ConnectError(Exception):
+  pass
+
 
 
 def host_ssh_cmd(hostname, cmd):
-  ssh = paramiko.SSHClient()
-  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
-  ssh.connect(hostname, username='root', password=SSHPASS,timeout=3)
-  stdin, stdout, stderr = ssh.exec_command(cmd)
-  stdout = stdout.readlines()
-  stderr = stderr.readlines()
-  ssh.close()
-  if stderr:
-    raise CmdError((stderr, stdout))
-  return stdout
+  try:
+    ssh = paramiko.SSHClient()
+    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+    ssh.connect(hostname, username='root', password=SSHPASS,timeout=3)
+    stdin, stdout, stderr = ssh.exec_command(cmd)
+    stdout = stdout.readlines()
+    stderr = stderr.readlines()
+    ssh.close()
+    if stderr:
+      raise CmdError((stderr, stdout))
+    return stdout
+  except socket.error, e:
+    raise ConnectError(e)
 
 def parse_ini(lines):
@@ -168,4 +174,5 @@
   parser = argparse.ArgumentParser(prog='Various WL management tools')
   parser.add_argument('--ask-pass', dest="ask_pass", action='store_true', help='Ask password if SSHPASS is not found')
+  parser.add_argument('--filter', dest="use_filter", action='store_true', help='Thread the host definition as an filter')
   subparsers = parser.add_subparsers(help='sub-command help')
   
@@ -189,18 +196,26 @@
       SSHPASS = getpass.getpass("WL root password: ")
 
-  # XXX: We need this loop when using filters
-  #for host in gformat.get_hostlist():
-  #  if filters and not any([f.lower() in host.lower() for f in filters]):
-  #    continue
-
-
-  if args.func == 'bridge':
-    if args.action == 'keys':
-      ubnt_keys(args.host)
-    elif args.action == 'snmp':
-      ubnt_snmp(args.host)
-    elif args.action == 'probe':
-      ubnt_probe(args.host)
-  elif args.func == 'node':
-    if args.action == 'check':
-      node_check(args.host)
+
+  if args.use_filter:
+    hosts = []
+    for host in gformat.get_hostlist():
+      if args.host in host:
+        hosts.append(host)
+  else:
+    hosts = [args.host]
+
+
+  for host in hosts:
+    try:
+      if args.func == 'bridge':
+        if args.action == 'keys':
+          ubnt_keys(host)
+        elif args.action == 'snmp':
+          ubnt_snmp(host)
+        elif args.action == 'probe':
+          ubnt_probe(host)
+      elif args.func == 'node':
+        if args.action == 'check':
+          node_check(host)
+    except ConnectError:
+      print "#ERR: Connection failed to host %s" % host
