summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f7cf0da)
raw | patch | inline | side by side (parent: f7cf0da)
author | Sven Trenkel <collectd@semidefinite.de> | |
Fri, 29 Jan 2010 14:56:38 +0000 (15:56 +0100) | ||
committer | Sven Trenkel <collectd@semidefinite.de> | |
Fri, 29 Jan 2010 14:56:38 +0000 (15:56 +0100) |
src/collectd-python.pod | patch | blob | history | |
src/pyvalues.c | patch | blob | history |
index 8742104cdc2abc33a57156e7a6160f4cde6a15c8..05a411cc25755ac6373fe149632a222cc8f46148 100644 (file)
--- a/src/collectd-python.pod
+++ b/src/collectd-python.pod
The following complex types are used to pass values between the Python plugin
and collectd:
+=head2 Signed
+
+The Signed class is just a long. It has all its methods and behaves exactly
+like any other long object. It is used to indicate if an integer was or should
+be stored as a signed or unsigned integer object.
+
+ class Signed(long)
+
+This is a long by another name. Use it in meta data dicts
+to choose the way it is stored in the meta data.
+
+=head2 Unsigned
+
+The Unsigned class is just a long. It has all its methods and behaves exactly
+like any other long object. It is used to indicate if an integer was or should
+be stored as a signed or unsigned integer object.
+
+ class Unsigned(long)
+
+This is a long by another name. Use it in meta data dicts
+to choose the way it is stored in the meta data.
+
=head2 Config
The Config class is an object which keeps the informations provided in the
exception will be raised. If the content of the sequence is not a number, a
I<TypeError> exception will be raised.
+=item meta
+These are the meta data for this Value object.
+It has to be a dictionary of numbers, strings or bools. All keys must be
+strings. I<int> and <long> objects will be dispatched as signed integers unless
+they are between 2**63 and 2**64-1, which will result in a unsigned integer.
+You can force one of these storage classes by using the classes
+B<collectd.Signed> and B<collectd.Unsigned>. A meta object received by a write
+callback will always contain B<Signed> or B<Unsigned> objects.
+
=back
=head2 Notification
diff --git a/src/pyvalues.c b/src/pyvalues.c
index a928cbc2803846b68681c18837a9f96d53f7da56..890dc4ea6c252c7f803d4b17a6d9d99cd86725b4 100644 (file)
--- a/src/pyvalues.c
+++ b/src/pyvalues.c
@@ -309,8 +309,12 @@ static char values_doc[] = "These are the actual values that get dispatched to c
"a TypeError exception will be raised.";
static char meta_doc[] = "These are the meta data for this Value object.\n"
- "It has to be a dictionary of numbers, strings or bools.\n"
- "If the dict contains anything else a TypeError exception will be raised.";
+ "It has to be a dictionary of numbers, strings or bools. All keys must be\n"
+ "strings. int and long objects will be dispatched as signed integers unless\n"
+ "they are between 2**63 and 2**64-1, which will result in a unsigned integer.\n"
+ "You can force one of these storage classes by using the classes\n"
+ "collectd.Signed and collectd.Unsigned. A meta object received by a write\n"
+ "callback will always contain Signed or Unsigned objects.";
static char dispatch_doc[] = "dispatch([type][, values][, plugin_instance][, type_instance]"
"[, plugin][, host][, time][, interval]) -> None. Dispatch a value list.\n"
return NULL;
self->values = PyList_New(0);
+ self->meta = PyDict_New();
self->interval = 0;
return (PyObject *) self;
}
tmp = self->values;
self->values = values;
- self->meta = meta;
Py_XDECREF(tmp);
+ tmp = self->meta;
+ self->meta = meta;
+ Py_XDECREF(tmp);
+
self->interval = interval;
return 0;
}
Notification_new /* tp_new */
};
+static const char Signed_doc[] = "This is a long by another name. Use it in meta data dicts\n"
+ "to choose the way it is stored in the meta data.";
+
PyTypeObject SignedType = {
CPY_INIT_TYPE
"collectd.Signed", /* tp_name */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ Signed_doc /* tp_doc */
};
+static const char Unsigned_doc[] = "This is a long by another name. Use it in meta data dicts\n"
+ "to choose the way it is stored in the meta data.";
+
PyTypeObject UnsignedType = {
CPY_INIT_TYPE
"collectd.Unsigned", /* tp_name */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ Unsigned_doc /* tp_doc */
};