From 9f6bc110ab59108d24cb71bc3d866f44cc0248c6 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Thu, 17 Mar 2011 10:09:21 -0500 Subject: man: Add man page for bcfg2-ping-sweep (#997) Signed-off-by: Sol Jerome --- man/bcfg2-ping-sweep.8 | 20 ++++++++++++++++++++ src/sbin/bcfg2-ping-sweep | 21 +++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 man/bcfg2-ping-sweep.8 diff --git a/man/bcfg2-ping-sweep.8 b/man/bcfg2-ping-sweep.8 new file mode 100644 index 000000000..54eaa8e76 --- /dev/null +++ b/man/bcfg2-ping-sweep.8 @@ -0,0 +1,20 @@ +.TH "bcfg2-ping-sweep" 8 +.SH NAME +bcfg2-ping-sweep \- Update pingable and pingtime attributes in +clients.xml +.SH SYNOPSIS +.B bcfg2-ping-sweep +.SH "DESCRIPTION" +.PP +\fBbcfg2-ping-sweep\fR traverses the list of clients in +Metadata/clients.xml and updates their pingable/pingtime attributes. The +pingtime value is set to the last time the client was pinged (not the +RTT value). +.SH OPTIONS +.PP +.B None +.SH "SEE ALSO" +.BR bcfg(1), +.BR bcfg2-server(8) +.SH "BUGS" +None currently known diff --git a/src/sbin/bcfg2-ping-sweep b/src/sbin/bcfg2-ping-sweep index 4082cad8b..718ad69d0 100755 --- a/src/sbin/bcfg2-ping-sweep +++ b/src/sbin/bcfg2-ping-sweep @@ -8,7 +8,7 @@ __revision__ = '$Revision$' from os import dup2, execl, fork, uname, wait import sys import time -import lxml.etree +import lxml.etree import Bcfg2.Options @@ -20,9 +20,10 @@ if __name__ == '__main__': cfpath = setup['configfile'] clientdatapath = "%s/Metadata/clients.xml" % setup['repo'] - + clientElement = lxml.etree.parse(clientdatapath) - hostlist = [client.get('name') for client in clientElement.findall("Client")] + hostlist = [client.get('name') + for client in clientElement.findall("Client")] pids = {} null = open('/dev/null', 'w+') @@ -31,7 +32,6 @@ if __name__ == '__main__': #/bin/ping on linux /sbin/ping on os x osname = uname()[0] - while hostlist or pids: if hostlist and len(pids.keys()) < 15: host = hostlist.pop() @@ -47,7 +47,7 @@ if __name__ == '__main__': execl('/sbin/ping', 'ping', '-t', '5', '-c', '1', host) elif osname == 'SunOS': execl('/usr/sbin/ping', 'ping', host, '56', '1') - else: #default + else: # default execl('/bin/ping', 'ping', '-w', '5', '-c', '1', host) else: pids[pid] = host @@ -58,14 +58,15 @@ if __name__ == '__main__': continue chost = pids[cpid] del pids[cpid] - elm = clientElement.xpath("//Client[@name='%s']"%chost)[0] + elm = clientElement.xpath("//Client[@name='%s']" % chost)[0] if status == 0: - elm.set("pingable",'Y') + elm.set("pingable", 'Y') elm.set("pingtime", str(time.time())) else: - elm.set("pingable",'N') + elm.set("pingable", 'N') fout = open(clientdatapath, 'w') - fout.write(lxml.etree.tostring(clientElement.getroot(), encoding='UTF-8', xml_declaration=True)) + fout.write(lxml.etree.tostring(clientElement.getroot(), + encoding='UTF-8', + xml_declaration=True)) fout.close() - -- cgit v1.2.3-1-g7c22