summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Pellin <bpellin@mcs.anl.gov>2005-01-11 20:00:33 +0000
committerBrian Pellin <bpellin@mcs.anl.gov>2005-01-11 20:00:33 +0000
commit67edea979075c69c24e7a53ae9815859356f96d7 (patch)
treee9f445440fe0df79179f7ff58f710a6f199ec5c8
parente621e7335198a57ae28f4c02b37afb361994e6f4 (diff)
downloadbcfg2-67edea979075c69c24e7a53ae9815859356f96d7.tar.gz
bcfg2-67edea979075c69c24e7a53ae9815859356f96d7.tar.bz2
bcfg2-67edea979075c69c24e7a53ae9815859356f96d7.zip
Made changes to generate more interesting statistics to send to the server.
(Logical change 1.186) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@794 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Client/Toolset.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py
index ec41620b7..1e2286704 100644
--- a/src/lib/Client/Toolset.py
+++ b/src/lib/Client/Toolset.py
@@ -1,5 +1,5 @@
'''This is the basic toolset class for the Bcfg2 client'''
-__revision__ = '$Revision$'
+__revision__ = '$Revision: 1.39 $'
from binascii import a2b_base64
from grp import getgrgid, getgrnam
@@ -101,19 +101,40 @@ class Toolset(object):
self.modified = [key for (key, val) in self.structures.iteritems() if not val]
[self.InstallEntry(key) for (key, val) in self.states.iteritems() if not val]
- def GenerateStats(self):
+ def GenerateStats(self, client_version):
'''Generate XML summary of execution statistics'''
stats = Element("Statistics")
- SubElement(stats, "Structures", good=str(len([key for key, val in
- self.structures.iteritems() if val])), \
- bad=str(len([key for key, val in self.structures.iteritems() if not val])))
- SubElement(stats, "Entries", good=str(len([key for key, val in self.states.iteritems() if val])), \
- bad=str(len([key for key, val in self.states.iteritems() if not val])))
+
+ # Calculate number of total bundles and structures
+ total = len(self.structures) + len(self.states)
+ stats.set('total',str(total))
+ # Calculate number of good bundles and structures
+ good = len([key for key, val in self.structures.iteritems() if val]) + \
+ len([key for key, val in self.states.iteritems() if val])
+ stats.set('good', str(good))
+ stats.set('version', '2.0')
+ stats.set('client_version', client_version)
+
+
if len([key for key, val in self.structures.iteritems() if not val]) == 0:
stats.set('state', 'clean')
else:
stats.set('state', 'dirty')
- stats.set('time', asctime(localtime()))
+ #stats.set('time', asctime(localtime()))
+
+ # List bad elements of the configuration
+ bad_elms = SubElement(stats, "Bad")
+ for elm in [key for key,val in self.states.iteritems() if not val]:
+ if elm.get('name') == None:
+ SubElement(bad_elms, elm.tag)
+ else:
+ SubElement(bad_elms, elm.tag, name=elm.get('name'))
+ for elm in [key for key,val in self.structures.iteritems() if not val]:
+ if elm.get('name') == None:
+ SubElement(bad_elms, elm.tag)
+ else:
+ SubElement(bad_elms, elm.tag, name=elm.get('name'))
+
return stats
# the next two are dispatch functions