diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2012-11-09 15:00:17 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-30 01:29:29 +0100 |
commit | c038f0ceca6779fa429d6f74f0c794498a826c7e (patch) | |
tree | fce40412aac397aca265aa7ff1d2072bd52eccc1 /src/sbin/bcfg2-ping-sweep | |
parent | 6bb0a83e06db94fe1d0446cb07e1446369dfa137 (diff) | |
download | bcfg2-c038f0ceca6779fa429d6f74f0c794498a826c7e.tar.gz bcfg2-c038f0ceca6779fa429d6f74f0c794498a826c7e.tar.bz2 bcfg2-c038f0ceca6779fa429d6f74f0c794498a826c7e.zip |
pingdata.xml: add new file for dynamic ping data of the clients
bcfg2-ping-sweep saved the pingdata into clients.xml. This is problematic
if the repository is tracked by a vcs. Now the dynamic data is saved into
pingdata.xml and the DBStat plugin reads the data from there. So the
pingdata.xml could be ignored by the vcs.
Diffstat (limited to 'src/sbin/bcfg2-ping-sweep')
-rwxr-xr-x | src/sbin/bcfg2-ping-sweep | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/sbin/bcfg2-ping-sweep b/src/sbin/bcfg2-ping-sweep index 70f718690..585e1cc11 100755 --- a/src/sbin/bcfg2-ping-sweep +++ b/src/sbin/bcfg2-ping-sweep @@ -20,6 +20,7 @@ if __name__ == '__main__': cfpath = setup['configfile'] clientdatapath = "%s/Metadata/clients.xml" % setup['repo'] + pingdatapath = "%s/Metadata/pingdata.xml" % setup['repo'] clientElement = lxml.etree.parse(clientdatapath) hostlist = [client.get('name') @@ -32,6 +33,7 @@ if __name__ == '__main__': #/bin/ping on linux /sbin/ping on os x osname = uname()[0] + container = lxml.etree.Element("PingStatistics") while hostlist or pids: if hostlist and len(list(pids.keys())) < 15: host = hostlist.pop() @@ -58,15 +60,17 @@ if __name__ == '__main__': continue chost = pids[cpid] del pids[cpid] - elm = clientElement.xpath("//Client[@name='%s']" % chost)[0] + elm = lxml.etree.Element('Client', name=chost) if status == 0: elm.set("pingable", 'Y') elm.set("pingtime", str(time.time())) else: elm.set("pingable", 'N') + container.append(elm) - fout = open(clientdatapath, 'w') - fout.write(lxml.etree.tostring(clientElement.getroot(), + fout = open(pingdatapath, 'w') + fout.write(lxml.etree.tostring(container, encoding='UTF-8', - xml_declaration=True)) + xml_declaration=True, + pretty_print=True)) fout.close() |