summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 25c2a62)
raw | patch | inline | side by side (parent: 25c2a62)
author | Sven Trenkel <collectd@semidefinite.de> | |
Thu, 11 Nov 2010 14:19:15 +0000 (15:19 +0100) | ||
committer | Sven Trenkel <collectd@semidefinite.de> | |
Thu, 11 Nov 2010 14:19:15 +0000 (15:19 +0100) |
src/cpython.h | patch | blob | history | |
src/python.c | patch | blob | history | |
src/pyvalues.c | patch | blob | history |
diff --git a/src/cpython.h b/src/cpython.h
index 46e2301a1874f566098c15d54774fb1925b786de..4b8aa72143167864ff575147c5ef19949997ab50 100644 (file)
--- a/src/cpython.h
+++ b/src/cpython.h
PluginData data;
PyObject *values; /* Sequence */
PyObject *meta; /* dict */
- int interval;
+ double interval;
} Values;
PyTypeObject ValuesType;
#define Values_New() PyObject_CallFunctionObjArgs((PyObject *) &ValuesType, (void *) 0)
diff --git a/src/python.c b/src/python.c
index 8772cd1fc23623d52f8ab8d96042ee86b18bc2bb..a3027e0dd36212cbdc6845b85cabaf0f878f398c 100644 (file)
--- a/src/python.c
+++ b/src/python.c
@@ -435,8 +435,8 @@ static int cpy_write_callback(const data_set_t *ds, const value_list_t *value_li
sstrncpy(v->data.type_instance, value_list->type_instance, sizeof(v->data.type_instance));
sstrncpy(v->data.plugin, value_list->plugin, sizeof(v->data.plugin));
sstrncpy(v->data.plugin_instance, value_list->plugin_instance, sizeof(v->data.plugin_instance));
- v->data.time = value_list->time;
- v->interval = value_list->interval;
+ v->data.time = CDTIME_T_TO_DOUBLE(value_list->time);
+ v->interval = CDTIME_T_TO_DOUBLE(value_list->interval);
Py_CLEAR(v->values);
v->values = list;
Py_CLEAR(v->meta);
@@ -465,7 +465,7 @@ static int cpy_notification_callback(const notification_t *notification, user_da
sstrncpy(n->data.type_instance, notification->type_instance, sizeof(n->data.type_instance));
sstrncpy(n->data.plugin, notification->plugin, sizeof(n->data.plugin));
sstrncpy(n->data.plugin_instance, notification->plugin_instance, sizeof(n->data.plugin_instance));
- n->data.time = notification->time;
+ n->data.time = CDTIME_T_TO_DOUBLE(notification->time);
sstrncpy(n->message, notification->message, sizeof(n->message));
n->severity = notification->severity;
ret = PyObject_CallFunctionObjArgs(c->callback, n, c->data, (void *) 0); /* New reference. */
diff --git a/src/pyvalues.c b/src/pyvalues.c
index cc7e296c020e0a7df6706f432a374371caeb7219..36a717e9bfec401b54d8e2b629f110a01a303d7a 100644 (file)
--- a/src/pyvalues.c
+++ b/src/pyvalues.c
if (self->time != 0) {
CPY_STRCAT(&ret, l_time);
- tmp = PyInt_FromLong(self->time);
+ tmp = PyFloat_FromDouble(self->time);
CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
CPY_STRCAT_AND_DEL(&ret, tmp);
}
@@ -351,14 +351,13 @@ static PyObject *Values_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int Values_init(PyObject *s, PyObject *args, PyObject *kwds) {
Values *self = (Values *) s;
- int interval = 0;
- double time = 0;
+ double interval = 0, time = 0;
PyObject *values = NULL, *meta = NULL, *tmp;
const char *type = "", *plugin_instance = "", *type_instance = "", *plugin = "", *host = "";
static char *kwlist[] = {"type", "values", "plugin_instance", "type_instance",
"plugin", "host", "time", "interval", "meta", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetdiO", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetddO", kwlist,
NULL, &type, &values, NULL, &plugin_instance, NULL, &type_instance,
NULL, &plugin, NULL, &host, &time, &interval, &meta))
return -1;
@@ -485,8 +484,7 @@ static PyObject *Values_dispatch(Values *self, PyObject *args, PyObject *kwds) {
value_t *value;
value_list_t value_list = VALUE_LIST_INIT;
PyObject *values = self->values, *meta = self->meta;
- double time = self->data.time;
- int interval = self->interval;
+ double time = self->data.time, interval = self->interval;
const char *host = self->data.host;
const char *plugin = self->data.plugin;
const char *plugin_instance = self->data.plugin_instance;
@@ -495,7 +493,7 @@ static PyObject *Values_dispatch(Values *self, PyObject *args, PyObject *kwds) {
static char *kwlist[] = {"type", "values", "plugin_instance", "type_instance",
"plugin", "host", "time", "interval", "meta", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetdiO", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetddO", kwlist,
NULL, &type, &values, NULL, &plugin_instance, NULL, &type_instance,
NULL, &plugin, NULL, &host, &time, &interval, &meta))
return NULL;
@@ -559,8 +557,8 @@ static PyObject *Values_dispatch(Values *self, PyObject *args, PyObject *kwds) {
value_list.values = value;
value_list.meta = cpy_build_meta(meta);
value_list.values_len = size;
- value_list.time = time;
- value_list.interval = interval;
+ value_list.time = DOUBLE_TO_CDTIME_T(time);
+ value_list.interval = DOUBLE_TO_CDTIME_T(interval);
sstrncpy(value_list.host, host, sizeof(value_list.host));
sstrncpy(value_list.plugin, plugin, sizeof(value_list.plugin));
sstrncpy(value_list.plugin_instance, plugin_instance, sizeof(value_list.plugin_instance));
value_t *value;
value_list_t value_list = VALUE_LIST_INIT;
PyObject *values = self->values, *meta = self->meta;
- double time = self->data.time;
- int interval = self->interval;
+ double time = self->data.time, interval = self->interval;
const char *host = self->data.host;
const char *plugin = self->data.plugin;
const char *plugin_instance = self->data.plugin_instance;
static char *kwlist[] = {"destination", "type", "values", "plugin_instance", "type_instance",
"plugin", "host", "time", "interval", "meta", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetdiO", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetddO", kwlist,
NULL, &type, &values, NULL, &plugin_instance, NULL, &type_instance,
NULL, &plugin, NULL, &host, &time, &interval, &meta))
return NULL;
}
value_list.values = value;
value_list.values_len = size;
- value_list.time = time;
- value_list.interval = interval;
+ value_list.time = DOUBLE_TO_CDTIME_T(time);
+ value_list.interval = DOUBLE_TO_CDTIME_T(interval);
sstrncpy(value_list.host, host, sizeof(value_list.host));
sstrncpy(value_list.plugin, plugin, sizeof(value_list.plugin));
sstrncpy(value_list.plugin_instance, plugin_instance, sizeof(value_list.plugin_instance));
ret = cpy_common_repr(s);
if (self->interval != 0) {
CPY_STRCAT(&ret, l_interval);
- tmp = PyInt_FromLong(self->interval);
+ tmp = PyFloat_FromDouble(self->interval);
CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
CPY_STRCAT_AND_DEL(&ret, tmp);
}
@@ -864,7 +861,7 @@ static PyObject *Notification_dispatch(Notification *self, PyObject *args, PyObj
return NULL;
}
- notification.time = t;
+ notification.time = DOUBLE_TO_CDTIME_T(t);
notification.severity = severity;
sstrncpy(notification.message, message, sizeof(notification.message));
sstrncpy(notification.host, host, sizeof(notification.host));
@@ -873,8 +870,8 @@ static PyObject *Notification_dispatch(Notification *self, PyObject *args, PyObj
sstrncpy(notification.type, type, sizeof(notification.type));
sstrncpy(notification.type_instance, type_instance, sizeof(notification.type_instance));
notification.meta = NULL;
- if (notification.time < 1)
- notification.time = time(0);
+ if (notification.time == 0)
+ notification.time = cdtime();
if (notification.host[0] == 0)
sstrncpy(notification.host, hostname_g, sizeof(notification.host));
if (notification.plugin[0] == 0)