diff options
author | Rob Austein <sra@hactrn.net> | 2012-05-13 22:47:53 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2012-05-13 22:47:53 +0000 |
commit | 562b484fbd74a69505c35744602acdc36d4a2148 (patch) | |
tree | ac6fc7beaf1a2353750bee4cb5bc09e8c4ee8eda /scripts/rrd-rcynic-history.py | |
parent | 97204f318b77297d8642bab169a78e9cdae25626 (diff) |
Fix fatal typo. Don't overwrite existing .rrd files. Rework to pipe
all commands to a single copy of rrdtool (much faster).
Graph commands still need a lot of work.
svn path=/trunk/; revision=4490
Diffstat (limited to 'scripts/rrd-rcynic-history.py')
-rw-r--r-- | scripts/rrd-rcynic-history.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/rrd-rcynic-history.py b/scripts/rrd-rcynic-history.py index 989554d2..fa8717d3 100644 --- a/scripts/rrd-rcynic-history.py +++ b/scripts/rrd-rcynic-history.py @@ -74,7 +74,7 @@ class Host(object): field_table = (("timestamp", None, None, None), ("connections", "GAUGE", "Connections", "FF0000"), ("objects", "GAUGE", "Objects", "00FF00"), - ("elapsed", "GAGUE", "Fetch Time", "0000FF"), + ("elapsed", "GAUGE", "Fetch Time", "0000FF"), ("failed", "ABSOLUTE", "Failed", "00FFFF")) @property @@ -105,6 +105,7 @@ class Session(dict): """ def __init__(self, timestamp): + dict.__init__(self) self.timestamp = timestamp @property @@ -134,6 +135,10 @@ class RRDTable(dict): of the maildir too once we're dealing with current data. We'll see. """ + def __init__(self, rrdtool = sys.stdout): + dict.__init__(self) + self.rrdtool = rrdtool + def add(self, hostname, data): if hostname not in self: self[hostname] = [] @@ -154,16 +159,17 @@ class RRDTable(dict): ds_list = Host.field_ds_specifiers() ds_list.extend(self.rras) for hostname in self: - print "rrdtool create %s.rrd --start %s --step 3600 %s" % (hostname, start, " ".join(ds_list)) + if not os.path.exists("%s.rrd" % hostname): + self.rrdtool("create %s.rrd --start %s --step 3600 %s\n" % (hostname, start, " ".join(ds_list))) def update(self): for hostname, data in self.iteritems(): for datum in data: - print "rrdtool update %s.rrd %s" % (hostname, ":".join(str(d) for d in datum)) + self.rrdtool("update %s.rrd %s\n" % (hostname, ":".join(str(d) for d in datum))) def graph(self): for hostname in self: - print "rrdtool graph %s.png --start -90d %s" % (hostname, " ".join(Host.field_graph_specifiers(hostname))) + self.rrdtool("graph %s.png --start -90d %s\n" % (hostname, " ".join(Host.field_graph_specifiers(hostname)))) mb = mailbox.Maildir("/u/sra/rpki/rcynic-xml", factory = None, create = False) @@ -189,9 +195,6 @@ for i, key in enumerate(mb.iterkeys(), 1): sys.stderr.write("\n") -print -print - rrdtable.create() rrdtable.sort() rrdtable.update() |