From: Stephen Soltesz Date: Tue, 27 Jul 2010 20:53:16 +0000 (+0000) Subject: rename db data collection X-Git-Tag: monitor-3.1-1~9 X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=commitdiff_plain;h=9fc85e489ba906d8535348a69b0ad124041f6890 rename db data collection --- diff --git a/statistics/dump_db_m3.py b/statistics/dump_db_m3.py new file mode 100755 index 0000000..279cb16 --- /dev/null +++ b/statistics/dump_db_m3.py @@ -0,0 +1,55 @@ +#!/usr/bin/python + +# Collect statistics from myops db on node downtimes. +# For every node that goes down we need: +# * node down time +# * node reboot time +# * node notice time +# * node up time + +# then for each node, order events by time +# for each event sequence extract sub-sequences like: +# down xx up +# for each such sub-sequence extract +# time between down and up + +from monitor.database.info.model import * +from math import * +import sys +from datetime import datetime, timedelta +from monitor.common import * + +if len(sys.argv) > 1 and sys.argv[1] == "--pcu": + args = sys.argv[2:] + find_pcu = True +else: + args = sys.argv[1:] + find_pcu = False + + +for index,node in enumerate(FindbadNodeRecord.query.all()): + + if find_pcu: + if not node.plc_pcuid: + # NOTE: if we're looking for nodes with pcus, then skip the ones that don't have them. + continue + else: + if node.plc_pcuid: + # NOTE: if we're not looking for nodes with pcus, then skip those that have them + continue + + print >>sys.stderr, index, node.hostname + + for v in node.versions: + if find_pcu: + # we should be guaranteed that the node has pcuids here, but it could be deleted or added later + pcu = FindbadPCURecord.get_by(plc_pcuid=v.plc_pcuid) + if pcu: + v_pcu = pcu.get_as_of(v.timestamp) + if v_pcu: + print "%s,%s,%s,%s,%s" % (Time.dt_to_ts(v.timestamp), v.hostname, v.observed_status, v_pcu.reboot_trial_status, v_pcu.plc_pcu_stats['model']) + else: + print "%s,%s,%s,%s,%s" % (Time.dt_to_ts(v.timestamp), v.hostname, v.observed_status, "NOPCU", "NONE") + + else: + print "%s,%s,%s,%s,%s" % (Time.dt_to_ts(v.timestamp), v.hostname, v.observed_status, "NOPCU", "NONE")