summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-08-06 18:18:28 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-08-06 18:18:28 +0000
commitd4ff3f2fb292e0dcf437af6b8b5e2d5ba79be895 (patch)
tree73e084879f996ec6fe2bb1cde14f11362ddb1f9e /src/lib
parent42f9ed9421fdcdf72acdc8727ef3bc28345d9f0e (diff)
downloadbcfg2-d4ff3f2fb292e0dcf437af6b8b5e2d5ba79be895.tar.gz
bcfg2-d4ff3f2fb292e0dcf437af6b8b5e2d5ba79be895.tar.bz2
bcfg2-d4ff3f2fb292e0dcf437af6b8b5e2d5ba79be895.zip
Switch dbstats to using fast reports importer
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4858 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Plugins/DBStats.py2
-rwxr-xr-xsrc/lib/Server/Reports/importscript.py11
2 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/Server/Plugins/DBStats.py b/src/lib/Server/Plugins/DBStats.py
index 410bed4d7..b0d6779a6 100644
--- a/src/lib/Server/Plugins/DBStats.py
+++ b/src/lib/Server/Plugins/DBStats.py
@@ -20,6 +20,6 @@ class DBStats(Bcfg2.Server.Plugin.StatisticsPlugin):
# 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)
+ self.core.metadata.clientdata, container, 0, True)
diff --git a/src/lib/Server/Reports/importscript.py b/src/lib/Server/Reports/importscript.py
index 1b625deec..3816435a9 100755
--- a/src/lib/Server/Reports/importscript.py
+++ b/src/lib/Server/Reports/importscript.py
@@ -46,7 +46,7 @@ def build_reason_kwargs(r_ent):
current_diff=rc_diff)
-def load_stats(cdata, sdata, vlevel):
+def load_stats(cdata, sdata, vlevel, quick=False):
cursor = connection.cursor()
clients = {}
cursor.execute("SELECT name, id from reports_client;")
@@ -110,7 +110,7 @@ def load_stats(cdata, sdata, vlevel):
for (xpath, obj, tablename) in pattern:
for x in statistics.findall(xpath):
kargs = build_reason_kwargs(x)
- if '-O3' not in sys.argv:
+ if not quick:
rls = Reason.objects.filter(**kargs)
else:
rls = []
@@ -124,7 +124,7 @@ def load_stats(cdata, sdata, vlevel):
rr.save()
if vlevel > 0:
print "Created reason: %s" % rr.id
- if '-O3' not in sys.argv:
+ if not quick:
links = obj.objects.filter(name=x.get('name'),
kind=x.tag,
reason=rr)
@@ -151,7 +151,7 @@ def load_stats(cdata, sdata, vlevel):
for times in statistics.findall('OpStamps'):
for metric, value in times.items():
- if '-O3' not in sys.argv:
+ if not quick:
mmatch = Performance.objects.filter(metric=metric, value=value)
else:
mmatch = []
@@ -273,4 +273,5 @@ if __name__ == '__main__':
print("StatReports: Failed to parse %s"%(clientspath))
raise SystemExit, 1
- load_stats(clientsdata, statsdata, verb)
+ q = '-O3' in sys.argv
+ load_stats(clientsdata, statsdata, verb, quick=q)