From 1d22382ac948c1198c919319bd1e2988ab6c7e0d Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Fri, 18 Jan 2013 05:20:36 +1100 Subject: [PATCH] Add --utc to graph option. Allow to generate a graph as if the current timezone was UTC (e.g set TZ=UTC). This allows to easily calculate daily average ranging from midgnight to midnight rather than say the last 24 hours. --- bindings/python/rrdtoolmodule.c | 5 +-- doc/rrdgraph.pod | 5 +++ src/rrd_graph.c | 63 +++++++++++++++++++++++---------- src/rrd_graph.h | 7 ++-- src/rrd_tool.c | 1 + 5 files changed, 58 insertions(+), 23 deletions(-) diff --git a/bindings/python/rrdtoolmodule.c b/bindings/python/rrdtoolmodule.c index f0205820..1ab46358 100644 --- a/bindings/python/rrdtoolmodule.c +++ b/bindings/python/rrdtoolmodule.c @@ -582,6 +582,7 @@ static char _rrdtool_graph__doc__[] = "Create a graph based on one or more " \ [-b|--base value]\n\ [-W|--watermark string]\n\ [-Z|--use-nan-for-all-missing-data]\n\ + [--utc]\n\ DEF:vname=rrdfile:ds-name:CF[:step=step][:start=time][:end=time]\n\ CDEF:vname=RPN expression\n\ VDEF=vname:RPN expression\n\n\ @@ -1094,7 +1095,7 @@ _rrdtool_lastupdate(PyObject *Py_UNUSED(self), PyObject *args) } PyDict_SetItemString(ds_dict, ds_names[i], val); - + if (val != Py_None) Py_DECREF(val); @@ -1204,7 +1205,7 @@ _rrdtool_fetch_cb_wrapper( rrd_set_error("expected 'start' key in callback return value to be " "of type int"); goto gil_release_err; - } else if (PyObject_RichCompareBool(tmp, tmp_min_ts, Py_EQ) || + } else if (PyObject_RichCompareBool(tmp, tmp_min_ts, Py_EQ) || PyObject_RichCompareBool(tmp, po_start, Py_LT)) { rrd_set_error("expected 'start' value in callback return dict to be " "equal or earlier than passed start timestamp"); diff --git a/doc/rrdgraph.pod b/doc/rrdgraph.pod index 71ee3d85..ad13726f 100644 --- a/doc/rrdgraph.pod +++ b/doc/rrdgraph.pod @@ -562,6 +562,11 @@ If one DS is missing, either because the RRD is not available or because it does not contain the requested DS name, just assume that we got empty values instead of raising a fatal error. +[B<--utc>] + +Force the timezone to be UTC. Equivalent to doing TZ=UTC rrdtool graph .... +This is useful to calculate daily average ranging from midnight to midnight rather than say the last 24 hours. + =head2 Data and variables BIB<=>IB<:>IB<:>I[B<:step=>I][B<:start=>I