+static PyGetSetDef PluginData_getseters[] = {
+ {"host", PluginData_getstring, PluginData_setstring, host_doc, (void *) offsetof(PluginData, host)},
+ {"plugin", PluginData_getstring, PluginData_setstring, plugin_doc, (void *) offsetof(PluginData, plugin)},
+ {"plugin_instance", PluginData_getstring, PluginData_setstring, plugin_instance_doc, (void *) offsetof(PluginData, plugin_instance)},
+ {"type_instance", PluginData_getstring, PluginData_setstring, type_instance_doc, (void *) offsetof(PluginData, type_instance)},
+ {"type", PluginData_getstring, PluginData_settype, type_doc, (void *) offsetof(PluginData, type)},
+ {NULL}
+};
+
+PyTypeObject PluginDataType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* Always 0 */
+ "collectd.PluginData", /* tp_name */
+ sizeof(PluginData), /* tp_basicsize */
+ 0, /* Will be filled in later */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ PluginData_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE /*| Py_TPFLAGS_HAVE_GC*/, /*tp_flags*/
+ PluginData_doc , /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ PluginData_members, /* tp_members */
+ PluginData_getseters, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ PluginData_init, /* tp_init */
+ 0, /* tp_alloc */
+ PluginData_new /* tp_new */
+};
+
+static char interval_doc[] = "The interval is the timespan in seconds between two submits for\n"
+ "the same data source. This value has to be a positive integer, so you can't\n"
+ "submit more than one value per second. If this member is set to a\n"
+ "non-positive value, the default value as specified in the config file will\n"
+ "be used (default: 10).\n"
+ "\n"
+ "If you submit values more often than the specified interval, the average\n"
+ "will be used. If you submit less values, your graphes will have gaps.";
+
+static char values_doc[] = "These are the actual values that get dispatched to collectd.\n"
+ "It has to be a sequence (a tuple or list) of numbers.\n"
+ "The size of the sequence and the type of its content depend on the type\n"
+ "member your types.db file. For more information on this read the types.db\n"
+ "man page.\n"
+ "\n"
+ "If the sequence does not have the correct size upon dispatch a RuntimeError\n"
+ "exception will be raised. If the content of the sequence is not a number,\n"
+ "a TypeError exception will be raised.";
+
+static char dispatch_doc[] = "dispatch([type][, values][, plugin_instance][, type_instance]"
+ "[, plugin][, host][, time][, interval]) -> None. Dispatch a value list.\n"
+ "\n"
+ "Dispatch this instance to the collectd process. A values object a members\n"
+ "for each of the possible arguments for this method. For a detailed explanation\n"
+ "of these parameters see the member of the same same.\n"
+ "\n"
+ "If you do not submit a parameter the value saved in its member will be submitted.\n"
+ "If you do provide a parameter it will be used instead, without altering the member.";
+
+static char Values_doc[] = "A Values object used for dispatching values to collectd and receiving values from write callbacks.";
+
+static PyObject *Values_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
+ Values *self;
+
+ self = (Values *) PluginData_new(type, args, kwds);
+ if (self == NULL)
+ return NULL;
+
+ self->values = PyList_New(0);
+ self->interval = 0;
+ return (PyObject *) self;
+}
+
+static int Values_init(PyObject *s, PyObject *args, PyObject *kwds) {
+ Values *self = (Values *) s;
+ int interval = 0, ret;
+ double time = 0;
+ PyObject *values = NULL, *tmp;
+ const char *type = "", *plugin_instance = "", *type_instance = "", *plugin = "", *host = "";
+ static char *kwlist[] = {"type", "values", "plugin_instance", "type_instance",
+ "plugin", "host", "time", "interval", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|sOssssdi", kwlist,
+ &type, &values, &plugin_instance, &type_instance,
+ &plugin, &host, &time, &interval))
+ return -1;
+
+ tmp = Py_BuildValue("sssssd", type, plugin_instance, type_instance, plugin, host, time);
+ if (tmp == NULL)
+ return -1;
+ ret = PluginDataType.tp_init(s, tmp, NULL);
+ Py_DECREF(tmp);
+ if (ret != 0)
+ return -1;
+
+ if (values == NULL) {
+ values = PyList_New(0);
+ PyErr_Clear();
+ } else {
+ Py_INCREF(values);
+ }
+
+ tmp = self->values;
+ self->values = values;
+ Py_XDECREF(tmp);
+
+ self->interval = interval;
+ return 0;
+}
+