add support for collectd_ifoctets in addition to mrtg
authorTero Marttila <terom@fixme.fi>
Sat, 30 Jan 2010 23:43:57 +0200
changeset 17 a1608b66be45
parent 16 975aa02bec04
child 18 eaf06ae5df16
add support for collectd_ifoctets in addition to mrtg
rrdweb/graph.py
--- a/rrdweb/graph.py	Sat Jan 30 23:16:35 2010 +0200
+++ b/rrdweb/graph.py	Sat Jan 30 23:43:57 2010 +0200
@@ -169,12 +169,35 @@
 
     ]        
 
-def mrtg (style, interval, title, rrd_path, out_path) :
+def collectd_data (rrd_path) :
+    """
+        Data sources for if_octets from a collectd rrd
+    """
+
+    return [
+        # data sources, bytes/s
+        r'DEF:in0=%s:rx:AVERAGE' % rrd_path,
+        r'DEF:out0=%s:tx:AVERAGE' % rrd_path,
+
+        # data, bits/s
+        'CDEF:in=in0,8,*',
+        'CDEF:out=out0,8,*',
+
+    ]        
+    
+def _graph (style, interval, title, data_func, rrd_path, out_path) :
     style_opts, style_vars = STYLE_DEFS[style]()
     interval_opts = INTERVAL_DEFS[interval](title)
 
     opts = rrd.merge_opts(common_opts(), style_opts, interval_opts)
-    data = mrtg_data(rrd_path) + style_vars
+    data = data_func(rrd_path) + style_vars
 
     return rrd.graph(out_path, *data, **opts)
+   
 
+def mrtg (style, interval, title, rrd_path, out_path) :
+    return _graph(style, interval, title, mrtg_data, rrd_path, out_path)
+
+def collectd_ifoctets (style, interval, title, rrd_path, out_path) :
+    return _graph(style, interval, title, collectd_data, rrd_path, out_path)
+