summaryrefslogtreecommitdiffstats
path: root/src
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
commitcbdcdd6c8486231988aa784c3803d2e8b024ce2d (patch)
treeac2829e3107521bf4c643528bdee1a024a0f3b7c /src
parent1e9b70e2d70724c6f357c752fede6e4cc1fa54cf (diff)
downloadbcfg2-cbdcdd6c8486231988aa784c3803d2e8b024ce2d.tar.gz
bcfg2-cbdcdd6c8486231988aa784c3803d2e8b024ce2d.tar.bz2
bcfg2-cbdcdd6c8486231988aa784c3803d2e8b024ce2d.zip
Added statistics hooks.
(Logical change 1.186) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@792 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/sbin/Bcfg2Server22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/sbin/Bcfg2Server b/src/sbin/Bcfg2Server
index 8e03aa033..9ed19ce66 100644
--- a/src/sbin/Bcfg2Server
+++ b/src/sbin/Bcfg2Server
@@ -16,6 +16,7 @@ from elementtree.ElementTree import Element
from Bcfg2.Server.Core import Core
from Bcfg2.Server.Metadata import MetadataStore
+from Bcfg2.Server.Statistics import Statistics
from sss.daemonize import daemonize
from sss.server import Server
@@ -61,6 +62,7 @@ class BcfgServer(Server):
mpath = c.get('server','metadata')
self.core = Core(repo, structures, generators)
self.metadata = MetadataStore("%s/metadata.xml"%(mpath), self.core.fam)
+ self.stats = Statistics("%s/statistics.xml"%(mpath))
self.__progress__()
def __progress__(self):
@@ -70,8 +72,18 @@ class BcfgServer(Server):
self.core.RunCronTasks()
except:
self.LogFailure("Cron")
+
+ try:
+ self.stats.WriteBack()
+ except:
+ self.LogFailure("Statistics")
+
return 0
+ def __shutdown__(self):
+ # Update Statistics on shutdown
+ self.stats.WriteBack()
+
def BuildConfig(self, xml, (peer, port)):
'''Build Client Config'''
if setup['client']:
@@ -134,6 +146,16 @@ class BcfgServer(Server):
def HandleStats(self, xml, (peer, port)):
'''Act on statistics upload'''
e = xml.find(".//Statistics")
+ # Versioned stats to prevent tied client/server upgrade
+ if e.get('version') >= '2.0':
+ try:
+ client = gethostbyaddr(peer)[0].split('.')[0]
+ except herror:
+ return Element("error", type='host resolution error')
+
+ # Update statistics
+ self.stats.updateStats(xml, client)
+
syslog(LOG_INFO, "Client %s reported state %s"%(peer, e.attrib['state']))
return Element("ok")