3 # Collect statistics from myops db on node downtimes.
4 # For every node that goes down we need:
10 # then for each node, order events by time
11 # for each event sequence extract sub-sequences like:
13 # for each such sub-sequence extract
14 # time between down and up
16 from monitor.database.info.model import *
19 from datetime import datetime, timedelta
20 from monitor.common import *
22 if len(sys.argv) > 1 and sys.argv[1] == "--pcu":
30 for index,node in enumerate(FindbadNodeRecord.query.all()):
33 if not node.plc_pcuid:
34 # NOTE: if we're looking for nodes with pcus, then skip the ones that don't have them.
38 # NOTE: if we're not looking for nodes with pcus, then skip those that have them
41 print >>sys.stderr, index, node.hostname
43 for v in node.versions:
45 # we should be guaranteed that the node has pcuids here, but it could be deleted or added later
46 pcu = FindbadPCURecord.get_by(plc_pcuid=v.plc_pcuid)
48 v_pcu = pcu.get_as_of(v.timestamp)
50 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'])
52 print "%s,%s,%s,%s,%s" % (Time.dt_to_ts(v.timestamp), v.hostname, v.observed_status, "NOPCU", "NONE")
55 print "%s,%s,%s,%s,%s" % (Time.dt_to_ts(v.timestamp), v.hostname, v.observed_status, "NOPCU", "NONE")