summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9b345c2)
raw | patch | inline | side by side (parent: 9b345c2)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 19 May 2008 21:14:36 +0000 (21:14 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 19 May 2008 21:14:36 +0000 (21:14 +0000) |
* info call isnnow aequivalent to rrdtool info (the same as in the perl and ruby bindings)
* graphv and updatev calls added
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1372 a5681a0c-68f1-0310-ab6d-d61299d08faa
* graphv and updatev calls added
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1372 a5681a0c-68f1-0310-ab6d-d61299d08faa
diff --git a/program/NEWS b/program/NEWS
index 2d2abf789e59bb12c268f2dacf9fe3f8911bb480..f4b51115ad77bac0972e6ada782ab7f007c27047 100644 (file)
--- a/program/NEWS
+++ b/program/NEWS
RRDTOOL NEWS
============
+
+#####################################
Major Changes between 1.2.x and 1.3.x
+-------------------------------------
RRdtool dump / restore Incompatibilities
----------------------------------------
available on your system. Use the configure option --disable-libintl if
you want to disable this feature
-Misc
-----
+Language Bindings
+-----------------
* ruby rrd_fetch will return step as a last property -- Mike Perham
+* python rrdtool.info does now conform with the data structure returned
+ by the other language bindings. This is incompatible with the
+ previous (broken) version --tobi
+
+* python bindings got updatev support --tobi
+
+* ruby, perl, python bindings support the new graphv interface --tobi
+
Locale Independent Numeric Input
--------------------------------
* Regardles of locale you are in, rrdtool always expects input to be numbers
(LC_NUMERIC) in C or POSIX locale for numbers. (not 1,1 but 1.1) this is
necessary to make things like RPN work as it uses , as a separator.
-RRDTOOL NEWS
-============
+######################################################################################
Major Changes between 1.0.x and 1.2.x
-
+======================================================================================
Graphing
--------
index 265244f9a2fc7d652d16f1f05abf4633e8cd3e06..c234a6bbd88288e42fdc7a8b597e9bbe2e61de63 100644 (file)
-Python-RRDtool 0.2.1
---------------------
+Based on Python-RRDtool 0.2.1
+-----------------------------
The python-rrdtool provides a interface to rrdtool, the wonderful
graphing and logging utility. This wrapper implementation has
Users & Hackers py-rrdtool-users@nongnu.org
-Author
-------
+Original Author
+---------------
Hye-Shik Chang <perky@FreeBSD.org>
Any comments, suggestions, and/or patches are very welcome.
Thank you for using py-rrdtool!
+
+
+CHANGES
+-------
+2008-05-19 - tobi
+* rewrote the info method to conform to rrdtool info standard
diff --git a/program/bindings/python/rrd_extra.h b/program/bindings/python/rrd_extra.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * This file is part of RRDtool.
- *
- * RRDtool is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * RRDtool is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*****************************************************************************
- * RRDtool 1.0.37 Copyright Tobias Oetiker, 1997 - 2000
- *****************************************************************************
- * rrd_tool.h Common Header File
- *****************************************************************************
- * Id: rrd_tool.h,v 1.1.1.1 2002/02/26 10:21:37 oetiker Exp
- * Log: rrd_tool.h,v
- * Revision 1.1.1.1 2002/02/26 10:21:37 oetiker
- * Intial Import
- *
- *****************************************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _RRD_EXTRA_H
-#define _RRD_EXTRA_H
-
-#include "rrd_format.h"
-
-#ifndef WIN32
-#ifndef isnan /* POSIX */
- int isnan(
- double value);
-#endif
-#else /* Windows only */
-#include <float.h>
-#define isnan _isnan
-#endif
-
- void rrd_free(
- rrd_t *rrd);
- void rrd_init(
- rrd_t *rrd);
-
- int rrd_open(
- char *file_name,
- rrd_t *rrd,
- int rdwr);
- int readfile(
- char *file,
- char **buffer,
- int skipfirst);
-
-#define RRD_READONLY 0
-#define RRD_READWRITE 1
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
index f82973436a8c23063567247d845d36832243d2e7..37810f7c08fc47edb560ba9cd08c19d74d6a490e 100644 (file)
static const char *__version__ = "$Revision: 1.14 $";
#include "Python.h"
-#include "rrd.h"
-#include "rrd_extra.h"
+#include "../../src/rrd_tool.h"
+//#include "rrd.h"
+//#include "rrd_extra.h"
static PyObject *ErrorObject;
extern int optind;
return r;
}
+static PyObject *PyDict_FromInfo(
+ info_t *data)
+{
+ PyObject *r;
+ r = PyDict_New();
+ while (data){
+ PyObject *val = NULL;
+ switch (data->type) {
+ case RD_I_VAL:
+ val = isnan(data->value.u_val)
+ ? (Py_INCREF(Py_None), Py_None)
+ : PyFloat_FromDouble(data->value.u_val);
+ break;
+ case RD_I_CNT:
+ val = PyLong_FromUnsignedLong(data->value.u_cnt);
+ break;
+ case RD_I_INT:
+ val = PyLong_FromLong(data->value.u_int);
+ break;
+ case RD_I_STR:
+ val = PyString_FromString(data->value.u_str);
+ break;
+ case RD_I_BLO:
+ val = PyString_FromStringAndSize((char*)data->value.u_blo.ptr, data->value.u_blo.size);
+ break;
+ }
+ if (val){
+ PyDict_SetItemString(r,data->key,val);
+ }
+ data = data->next;
+ }
+ return r;
+}
+
static char PyRRD_info__doc__[] =
"info(filename): extract header information from an rrd";
PyObject UNUSED(*self),
PyObject * args)
{
- PyObject *r, *t, *ds;
- rrd_t rrd;
- char *filename;
- unsigned long i, j;
+ PyObject *r;
+ int argc;
+ char **argv;
+ info_t *data;
- if (!PyArg_ParseTuple(args, "s:info", &filename))
+ if (create_args("info", args, &argc, &argv) < 0)
return NULL;
-
- if (!rrd_open(filename, &rrd, RRD_READONLY) == -1) {
+
+ if ((data = rrd_info(argc, argv)) == NULL) {
PyErr_SetString(ErrorObject, rrd_get_error());
rrd_clear_error();
return NULL;
}
-#define DICTSET_STR(dict, name, value) \
- t = PyString_FromString(value); \
- PyDict_SetItemString(dict, name, t); \
- Py_DECREF(t);
-
-#define DICTSET_CNT(dict, name, value) \
- t = PyInt_FromLong((long)value); \
- PyDict_SetItemString(dict, name, t); \
- Py_DECREF(t);
-
-#define DICTSET_VAL(dict, name, value) \
- t = isnan(value) ? (Py_INCREF(Py_None), Py_None) : \
- PyFloat_FromDouble((double)value); \
- PyDict_SetItemString(dict, name, t); \
- Py_DECREF(t);
-
- r = PyDict_New();
-
- DICTSET_STR(r, "filename", filename);
- DICTSET_STR(r, "rrd_version", rrd.stat_head->version);
- DICTSET_CNT(r, "step", rrd.stat_head->pdp_step);
- DICTSET_CNT(r, "last_update", rrd.live_head->last_up);
-
- ds = PyDict_New();
- PyDict_SetItemString(r, "ds", ds);
- Py_DECREF(ds);
-
- for (i = 0; i < rrd.stat_head->ds_cnt; i++) {
- PyObject *d;
-
- d = PyDict_New();
- PyDict_SetItemString(ds, rrd.ds_def[i].ds_nam, d);
- Py_DECREF(d);
-
- DICTSET_STR(d, "ds_name", rrd.ds_def[i].ds_nam);
- DICTSET_STR(d, "type", rrd.ds_def[i].dst);
- DICTSET_CNT(d, "minimal_heartbeat",
- rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt);
- DICTSET_VAL(d, "min", rrd.ds_def[i].par[DS_min_val].u_val);
- DICTSET_VAL(d, "max", rrd.ds_def[i].par[DS_max_val].u_val);
- DICTSET_STR(d, "last_ds", rrd.pdp_prep[i].last_ds);
- DICTSET_VAL(d, "value", rrd.pdp_prep[i].scratch[PDP_val].u_val);
- DICTSET_CNT(d, "unknown_sec",
- rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt);
- }
-
- ds = PyList_New(rrd.stat_head->rra_cnt);
- PyDict_SetItemString(r, "rra", ds);
- Py_DECREF(ds);
-
- for (i = 0; i < rrd.stat_head->rra_cnt; i++) {
- PyObject *d, *cdp;
+ r = PyDict_FromInfo(data);
+ info_free(data);
+ return r;
+}
- d = PyDict_New();
- PyList_SET_ITEM(ds, i, d);
+static char PyRRD_graphv__doc__[] =
+ "graphv is called in the same manner as graph";
- DICTSET_STR(d, "cf", rrd.rra_def[i].cf_nam);
- DICTSET_CNT(d, "rows", rrd.rra_def[i].row_cnt);
- DICTSET_CNT(d, "pdp_per_row", rrd.rra_def[i].pdp_cnt);
- DICTSET_VAL(d, "xff", rrd.rra_def[i].par[RRA_cdp_xff_val].u_val);
+static PyObject *PyRRD_graphv(
+ PyObject UNUSED(*self),
+ PyObject * args)
+{
+ PyObject *r;
+ int argc;
+ char **argv;
+ info_t *data;
- cdp = PyList_New(rrd.stat_head->ds_cnt);
- PyDict_SetItemString(d, "cdp_prep", cdp);
- Py_DECREF(cdp);
+ if (create_args("graphv", args, &argc, &argv) < 0)
+ return NULL;
+
+ if ((data = rrd_graph_v(argc, argv)) == NULL) {
+ PyErr_SetString(ErrorObject, rrd_get_error());
+ rrd_clear_error();
+ return NULL;
+ }
+ r = PyDict_FromInfo(data);
+ info_free(data);
+ return r;
+}
- for (j = 0; j < rrd.stat_head->ds_cnt; j++) {
- PyObject *cdd;
+static char PyRRD_updatev__doc__[] =
+ "updatev is called in the same manner as update";
- cdd = PyDict_New();
- PyList_SET_ITEM(cdp, j, cdd);
+static PyObject *PyRRD_updatev(
+ PyObject UNUSED(*self),
+ PyObject * args)
+{
+ PyObject *r;
+ int argc;
+ char **argv;
+ info_t *data;
- DICTSET_VAL(cdd, "value",
- rrd.cdp_prep[i * rrd.stat_head->ds_cnt +
- j].scratch[CDP_val].u_val);
- DICTSET_CNT(cdd, "unknown_datapoints",
- rrd.cdp_prep[i * rrd.stat_head->ds_cnt +
- j].scratch[CDP_unkn_pdp_cnt].u_cnt);
- }
+ if (create_args("updatev", args, &argc, &argv) < 0)
+ return NULL;
+
+ if ((data = rrd_update_v(argc, argv)) == NULL) {
+ PyErr_SetString(ErrorObject, rrd_get_error());
+ rrd_clear_error();
+ return NULL;
}
-
- rrd_free(&rrd);
-
+ r = PyDict_FromInfo(data);
+ info_free(data);
return r;
}
meth("last", PyRRD_last, PyRRD_last__doc__),
meth("resize", PyRRD_resize, PyRRD_resize__doc__),
meth("info", PyRRD_info, PyRRD_info__doc__),
+ meth("graphv", PyRRD_graphv, PyRRD_graphv__doc__),
+ meth("updatev", PyRRD_updatev, PyRRD_updatev__doc__),
{NULL, NULL, 0, NULL}
};
index dc329ecaf85c7e6562a48e9ba55b4237a20cf4ed..d504deb47bef903264abaf269abc24d18463fa1a 100644 (file)
=head1 EXAMPLE
+ import sys
sys.path.append('/path/to/rrdtool/lib/python2.3/site-packages/')
import rrdtool, tempfile