summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-07-22 04:48:31 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-07-22 04:48:31 +0000
commitefd69fd03d93239463cdea4d12eb2c52dfef3b81 (patch)
tree7b641e3adbbf2554378bed1ed970d94a21a52bae
parent3cf149d0e05d91305a6e6e8957f8da9d3b28ac7c (diff)
downloadbcfg2-efd69fd03d93239463cdea4d12eb2c52dfef3b81.tar.gz
bcfg2-efd69fd03d93239463cdea4d12eb2c52dfef3b81.tar.bz2
bcfg2-efd69fd03d93239463cdea4d12eb2c52dfef3b81.zip
Add new DBstats plugin (direct to reports db)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4820 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/Plugins/DBStats.py25
-rw-r--r--src/lib/Server/Plugins/__init__.py2
-rwxr-xr-xsrc/lib/Server/Reports/importscript.py2
3 files changed, 26 insertions, 3 deletions
diff --git a/src/lib/Server/Plugins/DBStats.py b/src/lib/Server/Plugins/DBStats.py
new file mode 100644
index 000000000..410bed4d7
--- /dev/null
+++ b/src/lib/Server/Plugins/DBStats.py
@@ -0,0 +1,25 @@
+import Bcfg2.Server.Plugin
+import Bcfg2.Server.Reports.importscript
+import lxml.etree, time
+
+class DBStats(Bcfg2.Server.Plugin.StatisticsPlugin):
+ __name__ = 'DBStats'
+ __version__ = '$Id: $'
+
+ def __init__(self, core, datastore):
+ self.cpath = "%s/Metadata/clients.xml" % datastore
+ self.core = core
+
+ def StoreStatistics(self, mdata, xdata):
+ newstats = xdata.find("Statistics")
+ newstats.set('time', time.asctime(time.localtime()))
+ e = lxml.etree.Element('Node', name=mdata.hostname)
+ e.append(newstats)
+ container = lxml.etree.Element("ConfigStatistics")
+ container.append(e)
+
+ # FIXME need to build a metadata interface to expose a list of clients
+ Bcfg2.Server.Reports.importscript.load_stats(
+ self.core.metadata.clientdata, container, 0)
+
+
diff --git a/src/lib/Server/Plugins/__init__.py b/src/lib/Server/Plugins/__init__.py
index db17e5c26..00c161d64 100644
--- a/src/lib/Server/Plugins/__init__.py
+++ b/src/lib/Server/Plugins/__init__.py
@@ -2,5 +2,5 @@
__revision__ = '$Revision$'
__all__ = ['Account', 'Base', 'Bundler', 'Cfg', 'Hostbase', 'Metadata',
- 'Pkgmgr', 'Rules', 'SSHbase', 'Svcmgr', 'TCheetah',
+ 'Pkgmgr', 'Rules', 'SSHbase', 'Statistics', 'Svcmgr', 'TCheetah',
'SGenshi', 'TGenshi', 'Vhost']
diff --git a/src/lib/Server/Reports/importscript.py b/src/lib/Server/Reports/importscript.py
index fbc3c81f9..1b625deec 100755
--- a/src/lib/Server/Reports/importscript.py
+++ b/src/lib/Server/Reports/importscript.py
@@ -203,8 +203,6 @@ def load_stats(cdata, sdata, vlevel):
connection._commit()
#Clients are consistent
- raise SystemExit, 0
-
if __name__ == '__main__':
from sys import argv
verb = 0