static int as_init (void)
{
kern_return_t status;
-
+
if (io_master_port != MACH_PORT_NULL)
{
mach_port_deallocate (mach_task_self (),
*ret_voltage = temp_double / 1000.0;
}
}
-
+
CFRelease (bat_root_dict);
}
# define BIND_DEFAULT_URL "http://localhost:8053/"
#endif
-/*
+/*
* Some types used for the callback functions. `translation_table_ptr_t' and
* `list_info_ptr_t' are passed to the callbacks in the `void *user_data'
* pointer.
return (0);
} /* }}} int bind_xml_read_timestamp */
-/*
+/*
* bind_parse_generic_name_value
*
* Reads statistics in the form:
return (0);
} /* }}} int bind_parse_generic_name_value */
-/*
+/*
* bind_parse_generic_value_list
*
* Reads statistics in the form:
{ /* Parse the <counters> tag {{{ */
char plugin_instance[DATA_MAX_NAME_LEN];
translation_table_ptr_t table_ptr =
- {
+ {
nsstats_translation_table,
nsstats_translation_table_length,
plugin_instance
{
char plugin_instance[DATA_MAX_NAME_LEN];
translation_table_ptr_t table_ptr =
- {
+ {
resstats_translation_table,
resstats_translation_table_length,
plugin_instance
else
{
lcc_server_t *srv;
-
+
srv = lcc_server_create (net, conf_destination, conf_service);
if (srv == NULL)
{
* DEALINGS IN THE SOFTWARE.
*
* Authors:
- * Sven Trenkel <collectd at semidefinite.de>
+ * Sven Trenkel <collectd at semidefinite.de>
**/
/* Some python versions don't include this by default. */
} while (0)
static inline void CPY_STRCAT(PyObject **a, PyObject *b) {
PyObject *ret;
-
+
if (!a || !*a)
return;
-
+
ret = PyUnicode_Concat(*a, b);
Py_DECREF(*a);
*a = ret;
return PyBytes_FromString(buf);
#else
return PyString_FromString(buf);
-#endif
+#endif
}
void cpy_log_exception(const char *context);
return (0);
} /* }}} cx_check_type */
-static xmlXPathObjectPtr cx_evaluate_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */
+static xmlXPathObjectPtr cx_evaluate_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */
xmlChar *expr)
{
xmlXPathObjectPtr xpath_obj;
{
WARNING ("curl_xml plugin: "
"relative xpath expression \"%s\" is expected to return "
- "only text/attribute node which is not the case. Skipping...",
+ "only text/attribute node which is not the case. Skipping...",
xpath->values[index].path);
xmlXPathFreeObject (values_node_obj);
return (-1);
vl->values[index].absolute = (absolute_t) strtoull (node_value,
/* endptr = */ NULL, /* base = */ 0);
break;
- case DS_TYPE_GAUGE:
+ case DS_TYPE_GAUGE:
vl->values[index].gauge = (gauge_t) strtod (node_value,
/* endptr = */ NULL);
}
static int cx_handle_base_xpath (char const *plugin_instance, /* {{{ */
char const *host,
- xmlXPathContextPtr xpath_ctx, const data_set_t *ds,
+ xmlXPathContextPtr xpath_ctx, const data_set_t *ds,
char *base_xpath, cx_xpath_t *xpath)
{
int total_nodes;
value_list_t vl = VALUE_LIST_INIT;
- base_node_obj = cx_evaluate_xpath (xpath_ctx, BAD_CAST base_xpath);
+ base_node_obj = cx_evaluate_xpath (xpath_ctx, BAD_CAST base_xpath);
if (base_node_obj == NULL)
return -1; /* error is logged already */
}
/* If base_xpath returned multiple results, then */
- /* Instance in the xpath block is required */
+ /* Instance in the xpath block is required */
if (total_nodes > 1 && xpath->instance == NULL)
{
ERROR ("curl_xml plugin: "
sstrncpy (vl.plugin, "curl_xml", sizeof (vl.plugin));
sstrncpy (vl.host, (host != NULL) ? host : hostname_g, sizeof (vl.host));
if (plugin_instance != NULL)
- sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+ sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
for (i = 0; i < total_nodes; i++)
{
} /* for (i = 0; i < total_nodes; i++) */
/* free up the allocated memory */
- xmlXPathFreeObject (base_node_obj);
+ xmlXPathFreeObject (base_node_obj);
- return (0);
+ return (0);
} /* }}} cx_handle_base_xpath */
-static int cx_handle_parsed_xml(xmlDocPtr doc, /* {{{ */
+static int cx_handle_parsed_xml(xmlDocPtr doc, /* {{{ */
xmlXPathContextPtr xpath_ctx, cx_t *db)
{
llentry_t *le;
const data_set_t *ds;
cx_xpath_t *xpath;
int status=-1;
-
+
le = llist_head (db->list);
while (le != NULL)
char *url;
url = db->url;
- db->buffer_fill = 0;
+ db->buffer_fill = 0;
status = curl_easy_perform (curl);
if (status != CURLE_OK)
{
# pragma GCC poison strcpy strcat strtok
#endif
-/*
+/*
* Special hack for the perl plugin: Because the later included perl.h defines
* a macro which is never used, but contains `sprintf', we cannot poison that
* identifies just yet. The parl plugin will do that itself once perl.h is
static int dispatch_value_plugindir (oconfig_item_t *ci)
{
assert (strcasecmp (ci->key, "PluginDir") == 0);
-
+
if (ci->values_num != 1)
return (-1);
if (ci->values[0].type != OCONFIG_TYPE_STRING)
} /* oconfig_item_t *cf_read_generic */
#endif /* !HAVE_WORDEXP_H */
-/*
+/*
* Public functions
*/
int global_option_set (const char *option, const char *value)
if (i >= cf_global_options_num)
return (NULL);
-
+
return ((cf_global_options[i].value != NULL)
? cf_global_options[i].value
: cf_global_options[i].def);
/*
* DESCRIPTION
* Remove a registered plugin from the internal data structures.
- *
+ *
* PARAMETERS
* `type' Name of the plugin (must be the same as passed to
* `plugin_register'
{
t->user_data = NULL;
}
-
+
if (*targets_head != NULL)
{
ptr = *targets_head;
int fc_default_action (const data_set_t *ds, value_list_t *vl);
-/*
+/*
* Shortcut for global configuration
*/
int fc_configure (const oconfig_item_t *ci);
pthread_mutex_lock (&md->lock);
for (e = md->head; e != NULL; e = e->next)
- ++count;
+ ++count;
if (count == 0)
{
*toc = calloc(count, sizeof(**toc));
for (e = md->head; e != NULL; e = e->next)
(*toc)[i++] = strdup(e->key);
-
+
pthread_mutex_unlock (&md->lock);
return count;
} /* }}} int meta_data_toc */
ERROR ("meta_data_get_string: md_strdup failed.");
return (-ENOMEM);
}
-
+
pthread_mutex_unlock (&md->lock);
*value = temp;
int status;
int i;
-
+
pthread_mutex_lock (&cache_lock);
now = cdtime ();
/* Reorganize the heap from bottom up. */
reheap (h, /* parent of this node = */ (index - 1) / 2, DIR_UP);
-
+
pthread_mutex_unlock (&h->lock);
return (0);
} /* int c_heap_insert */
**/
/**
* Usage:
- *
+ *
* Define plugin's global pointer variable of type ignorelist_t:
* ignorelist_t *myconfig_ignore;
* If you know the state of the global ignore (IgnoreSelected),
threshold_t *threshold_search (const value_list_t *vl);
-int ut_search_threshold (const value_list_t *vl,
+int ut_search_threshold (const value_list_t *vl,
threshold_t *ret_threshold);
#endif /* UTILS_THRESHOLD_H */
* manner is that comparing times and calculating differences is as simple as
* it is with "time_t", i.e. a simple integer comparison / subtraction works.
*/
-/*
+/*
* cdtime_t is defined in "collectd.h" */
/* typedef uint64_t cdtime_t; */
else if (src_type == DBI_TYPE_STRING)
{
const char *value;
-
+
value = dbi_result_get_string_idx (res, index);
if (value == NULL)
sstrncpy (buffer, "", buffer_size);
* </Result>
* ...
* </Query>
- *
+ *
* <Database "plugin_instance1">
* Driver "mysql"
* Interval 120
DEBUG ("CFStringCreateWithCString (%s) failed.", key);
return (-1LL);
}
-
+
/* get => we don't need to release (== free) the object */
val_obj = (CFNumberRef) CFDictionaryGetValue (dict, key_obj);
#elif KERNEL_LINUX
FILE *fh;
char buffer[1024];
-
+
char *fields[32];
int numfields;
int fieldshift = 0;
#endif
int counter;
char name[DATA_MAX_NAME_LEN];
-
+
if ((ds = sg_get_disk_io_stats(&disks)) == NULL)
return (0);
-
+
for (counter=0; counter < disks; counter++) {
strncpy(name, ds->disk_name, sizeof(name));
name[sizeof(name)-1] = '\0'; /* strncpy doesn't terminate longer strings */
int rnumdisk;
int i;
- if ((numdisk = perfstat_disk(NULL, NULL, sizeof(perfstat_disk_t), 0)) < 0)
+ if ((numdisk = perfstat_disk(NULL, NULL, sizeof(perfstat_disk_t), 0)) < 0)
{
char errbuf[1024];
WARNING ("disk plugin: perfstat_disk: %s",
}
if (numdisk != pnumdisk || stat_disk==NULL) {
- if (stat_disk!=NULL)
+ if (stat_disk!=NULL)
free(stat_disk);
stat_disk = (perfstat_disk_t *)calloc(numdisk, sizeof(perfstat_disk_t));
- }
+ }
pnumdisk = numdisk;
firstpath.name[0]='\0';
- if ((rnumdisk = perfstat_disk(&firstpath, stat_disk, sizeof(perfstat_disk_t), numdisk)) < 0)
+ if ((rnumdisk = perfstat_disk(&firstpath, stat_disk, sizeof(perfstat_disk_t), numdisk)) < 0)
{
char errbuf[1024];
WARNING ("disk plugin: perfstat_disk : %s",
return (-1);
}
- for (i = 0; i < rnumdisk; i++)
+ for (i = 0; i < rnumdisk; i++)
{
read_sectors = stat_disk[i].rblks*stat_disk[i].bsize;
write_sectors = stat_disk[i].wblks*stat_disk[i].bsize;
See: http://www.drbd.org/users-guide/ch-admin.html#s-performance-indicators
version: 8.3.11 (api:88/proto:86-96)
- srcversion: 71955441799F513ACA6DA60
+ srcversion: 71955441799F513ACA6DA60
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate B r-----
ns:64363752 nr:0 dw:357799284 dr:846902273 al:34987022 bm:18062 lo:0 \
pe:0 ua:0 ap:0 ep:1 wo:f oos:0
#include "collectd.h"
#include "common.h"
-#include "plugin.h"
+#include "plugin.h"
#include <sys/types.h>
#include <sys/stat.h>
if (dir->mtime != 0)
dir->now = time (NULL);
-
+
status = walk_directory (dir->path, fc_read_dir_callback, dir,
/* include hidden */ (dir->options & FC_HIDDEN) ? 1 : 0);
if (status != 0)
return (0);
} /* }}} int mc_receive_thread_stop */
-/*
+/*
* Config:
*
* <Plugin gmond>
{
/* `sensor_id_ptr' now points to "(123)". */
ssnprintf (sensor_name, sizeof (sensor_name),
- "%s %s", sensor_name_ptr, sensor_id_ptr);
+ "%s %s", sensor_name_ptr, sensor_id_ptr);
}
/* else: don't touch sensor_name. */
}
lcc_network_t *lcc_network_create (void);
void lcc_network_destroy (lcc_network_t *net);
-/*
+/*
* Add servers
*/
lcc_server_t *lcc_server_create (lcc_network_t *net,
for (i = 0; i < ci_copy->children_num; i++)
{
oconfig_item_t *child;
-
+
child = oconfig_clone (ci_orig->children + i);
if (child == NULL)
{
/**
- * There are several data streams provided by Madwifi plugin, some are
+ * There are several data streams provided by Madwifi plugin, some are
* connected to network interface, some are connected to each node
* associated to that interface. Nodes represents other sides in
* wireless communication, for example on network interface in AP mode,
* node_stat Node statistic counters
*
* Both statistic counters have type instances for each counter returned
- * by Madwifi. See madwifi.h for content of ieee80211_nodestats,
+ * by Madwifi. See madwifi.h for content of ieee80211_nodestats,
* ieee80211_stats and ath_stats structures. Type instances use the same
* name as fields in these structures (like ns_rx_dup). Some fields are
* not reported, because they are not counters (like ns_tx_deauth_code
* or ast_tx_rssi). Fields ns_rx_bytes and ns_tx_bytes are reported as
* node_octets data stream instead of type instance of node_stat.
* Statistics are not logged when they are zero.
- *
+ *
* There are two sets of these counters - the first 'WatchList' is a
* set of counters that are individually logged. The second 'MiscList'
* is a set of counters that are summed together and the sum is logged.
- * By default, the most important statistics are in the WatchList and
+ * By default, the most important statistics are in the WatchList and
* many error statistics are in MiscList. There are also many statistics
* that are not in any of these sets, so they are not monitored by default.
* It is possible to alter these lists using configuration options:
if (item_summed (i))
misc += val;
}
-
+
if (misc != 0)
submit_derive (dev, type_name, misc_name, mac, misc);
int status;
int num_success;
int num_fail;
-
+
if ((fh = fopen ("/proc/net/dev", "r")) == NULL)
{
WARNING ("madwifi plugin: opening /proc/net/dev failed");
/* procfs iteration is not safe because it does not check whether given
interface is madwifi interface and there are private ioctls used, which
- may do something completely different on non-madwifi devices.
+ may do something completely different on non-madwifi devices.
Therefore, it is not used unless explicitly enabled (and should be used
together with ignorelist). */
char errmsg[1024];
regerror (status, &re->re, errmsg, sizeof (errmsg));
errmsg[sizeof (errmsg) - 1] = 0;
- log_err ("Compiling regex `%s' for `%s' failed: %s.",
+ log_err ("Compiling regex `%s' for `%s' failed: %s.",
re->re_str, ci->key, errmsg);
free (re->re_str);
free (re);
static void mv_free_match (mv_match_t *m) /* {{{ */
{
size_t i;
-
+
if (m == NULL)
return;
free(m->data_sources[i]);
free(m->data_sources);
}
-
+
free (m);
} /* }}} void mv_free_match */
REG_TYPE_UINT32,
REG_TYPE_FLOAT
}; /* }}} */
-enum mb_mreg_type_e /* {{{ */
+enum mb_mreg_type_e /* {{{ */
{
MREG_HOLDING,
MREG_INPUT
modbus_free (host->connection);
#endif
}
-
+
#if LEGACY_LIBMODBUS
/* Version 2.0.3: Pass the connection struct as a pointer and pass the slave
* id to each call of "read_holding_registers". */
key = row[0];
val = atoll (row[1]);
- if (strncmp (key, "Com_",
+ if (strncmp (key, "Com_",
strlen ("Com_")) == 0)
{
if (val == 0ULL)
/* Ignore `prepared statements' */
if (strncmp (key, "Com_stmt_", strlen ("Com_stmt_")) != 0)
- counter_submit ("mysql_commands",
- key + strlen ("Com_"),
+ counter_submit ("mysql_commands",
+ key + strlen ("Com_"),
val, db);
}
- else if (strncmp (key, "Handler_",
+ else if (strncmp (key, "Handler_",
strlen ("Handler_")) == 0)
{
if (val == 0ULL)
continue;
- counter_submit ("mysql_handler",
- key + strlen ("Handler_"),
+ counter_submit ("mysql_handler",
+ key + strlen ("Handler_"),
val, db);
}
else if (strncmp (key, "Qcache_",
else if (strcmp (key, "Qcache_queries_in_cache") == 0)
qcache_queries_in_cache = (gauge_t) val;
}
- else if (strncmp (key, "Bytes_",
+ else if (strncmp (key, "Bytes_",
strlen ("Bytes_")) == 0)
{
if (strcmp (key, "Bytes_received") == 0)
else if (strcmp (key, "Bytes_sent") == 0)
traffic_outgoing += val;
}
- else if (strncmp (key, "Threads_",
+ else if (strncmp (key, "Threads_",
strlen ("Threads_")) == 0)
{
if (strcmp (key, "Threads_running") == 0)
counter_submit ("mysql_sort", "range", val, db);
else if (strcmp (key, "Sort_scan") == 0)
counter_submit ("mysql_sort", "scan", val, db);
-
+
}
}
mysql_free_result (res); res = NULL;
} /* }}} cdtime_t cna_child_get_cdtime */
-/*
+/*
* Query functions
*
* These functions are called with appropriate data returned by the libnetapp
na_elem_iter_t counter_iter;
memset (&perf_data, 0, sizeof (perf_data));
-
+
perf_data.timestamp = cna_child_get_cdtime (data);
instances = na_elem_child(na_elem_child (data, "instances"), "instance-data");
if ((cfg_disk == NULL) || (data == NULL))
return (EINVAL);
-
+
timestamp = cna_child_get_cdtime (data);
instances = na_elem_child (data, "instances");
na_elem_t *elem_instances;
na_elem_iter_t iter_instances;
na_elem_t *elem_instance;
-
+
timestamp = cna_child_get_cdtime (data);
elem_instances = na_elem_child(data, "instances");
if ((v->flags & CFG_VOLUME_USAGE_SNAP) != 0)
cna_handle_volume_snap_usage(host, v);
-
+
if ((v->flags & CFG_VOLUME_USAGE_DF) == 0)
continue;
const char *instance;
cdtime_t timestamp;
-
+
timestamp = cna_child_get_cdtime (data);
instances = na_elem_child(na_elem_child (data, "instances"), "instance-data");
&& (HAS_ALL_FLAGS (counter_flags, 0x01 | 0x02)))
submit_two_derive (hostname, instance, "disk_octets", NULL,
disk_read, disk_written, timestamp, interval);
-
+
if ((cfg_system->flags & CFG_SYSTEM_NET)
&& (HAS_ALL_FLAGS (counter_flags, 0x04 | 0x08)))
submit_two_derive (hostname, instance, "if_octets", NULL,
host->cfg_volume_perf = cfg_volume_perf;
}
cfg_volume_perf = host->cfg_volume_perf;
-
+
for (i = 0; i < ci->children_num; ++i) {
oconfig_item_t *item = ci->children + i;
-
+
/* if (!item || !item->key || !*item->key) continue; */
if (strcasecmp(item->key, "Interval") == 0)
cna_config_get_interval (item, &cfg_volume_perf->interval);
host->cfg_disk = cfg_disk;
}
cfg_disk = host->cfg_disk;
-
+
for (i = 0; i < ci->children_num; ++i) {
oconfig_item_t *item = ci->children + i;
-
+
/* if (!item || !item->key || !*item->key) continue; */
if (strcasecmp(item->key, "Interval") == 0)
cna_config_get_interval (item, &cfg_disk->interval);
for (i = 0; i < ci->children_num; ++i) {
oconfig_item_t *item = ci->children + i;
-
+
if (strcasecmp(item->key, "Interval") == 0)
cna_config_get_interval (item, &cfg_wafl->interval);
else if (!strcasecmp(item->key, "GetNameCache"))
host->cfg_volume_usage = cfg_volume_usage;
}
cfg_volume_usage = host->cfg_volume_usage;
-
+
for (i = 0; i < ci->children_num; ++i) {
oconfig_item_t *item = ci->children + i;
-
+
/* if (!item || !item->key || !*item->key) continue; */
if (strcasecmp(item->key, "Interval") == 0)
cna_config_get_interval (item, &cfg_volume_usage->interval);
static const char *nfs4_server41_procedures_names[] =
{
"backchannel_ctl",
- "bind_conn_to_session",
+ "bind_conn_to_session",
"exchange_id",
"create_session",
"destroy_session",
} /* void nfs_procedures_submit */
#if KERNEL_LINUX
-static void nfs_submit_fields (int nfs_version, const char *instance,
+static void nfs_submit_fields (int nfs_version, const char *instance,
char **fields, size_t fields_num, const char **proc_names)
{
char plugin_instance[DATA_MAX_NAME_LEN];
return (EINVAL);
}
- nfs_submit_fields (nfs_version, instance, fields, fields_num,
+ nfs_submit_fields (nfs_version, instance, fields, fields_num,
proc_names);
return (0);
}
-static int nfs_submit_nfs4_server (const char *instance, char **fields,
+static int nfs_submit_nfs4_server (const char *instance, char **fields,
size_t fields_num)
{
static int suppress_warning = 0;
if (fields_num != NFS4_SERVER40_NUM_PROC &&
- fields_num != NFS4_SERVER41_NUM_PROC)
+ fields_num != NFS4_SERVER41_NUM_PROC)
{
if (!suppress_warning)
{
}
}
- nfs_submit_fields (4, instance, fields,
+ nfs_submit_fields (4, instance, fields,
nfs4_server40_procedures_names_num,
nfs4_server40_procedures_names);
{
fields += nfs4_server40_procedures_names_num;
- nfs_submit_fields (4, instance, fields,
- nfs4_server41_procedures_names_num,
+ nfs_submit_fields (4, instance, fields,
+ nfs4_server41_procedures_names_num,
nfs4_server41_procedures_names);
}
return (0);
}
-static int nfs_submit_nfs4_client (const char *instance, char **fields,
+static int nfs_submit_nfs4_client (const char *instance, char **fields,
size_t fields_num)
{
size_t proc40_names_num, proc41_names_num;
else if (strcmp (fields[0], "proc4ops") == 0)
{
if (inst[0] == 's')
- nfs_submit_nfs4_server (inst, fields + 2,
+ nfs_submit_nfs4_server (inst, fields + 2,
(size_t) (fields_num - 2));
}
else if (strcmp (fields[0], "proc4") == 0)
{
if (inst[0] == 'c')
nfs_submit_nfs4_client (inst, fields + 2,
- (size_t) (fields_num - 2));
+ (size_t) (fields_num - 2));
}
} /* while (fgets) */
} /* void nfs_read_linux */
/* Callback to get username and password */
static int authinteract (auth_client_request_t request, char **result,
int fields, void __attribute__((unused)) *arg)
-{
+{
int i;
for (i = 0; i < fields; i++)
{
if ( !smtp_auth_set_context (session, authctx)) {
pthread_mutex_unlock (&session_lock);
ERROR ("notify_email plugin: cannot set SMTP auth context");
- return (-1);
+ return (-1);
}
pthread_mutex_unlock (&session_lock);
if (!(message = smtp_add_message (session))) {
pthread_mutex_unlock (&session_lock);
ERROR ("notify_email plugin: cannot set SMTP message");
- return (-1);
+ return (-1);
}
smtp_set_reverse_path (message, email_from);
smtp_set_header (message, "To", NULL, NULL);
(*callback) (lineno, fields_num, fields);
lineno++;
} /* while (fgets) */
-
+
return (0);
} /* }}} int olsrd_read_table */
buffer_len = strchomp (buffer);
if (buffer_len <= 0)
continue;
-
+
if (strcmp ("Table: Links", buffer) == 0)
olsrd_read_table (fh, olsrd_cb_links);
else if (strcmp ("Table: Neighbors", buffer) == 0)
} /* while (fgets) */
fclose (fh);
-
+
return (0);
} /* }}} int olsrd_read */
cred.bv_len = 0;
}
- rc = ldap_sasl_bind_s (st->ld, st->binddn, LDAP_SASL_SIMPLE, &cred,
+ rc = ldap_sasl_bind_s (st->ld, st->binddn, LDAP_SASL_SIMPLE, &cred,
NULL, NULL, NULL);
if (rc != LDAP_SUCCESS)
{
* ValuesFrom "value"
* </Result>
* </Query>
- *
+ *
* <Database "plugin_instance1">
* ConnectID "db01"
* Username "oracle"
{
ub4 param_counter = 0;
status = OCIAttrGet (oci_statement, OCI_HTYPE_STMT, /* {{{ */
- ¶m_counter, /* size pointer = */ NULL,
+ ¶m_counter, /* size pointer = */ NULL,
OCI_ATTR_PARAM_COUNT, oci_error);
if (status != OCI_SUCCESS)
{
} while (0); /* }}} */
/* Allocate the following buffers:
- *
+ *
* +---------------+-----------------------------------+
* ! Name ! Size !
* +---------------+-----------------------------------+
ub4 connection_status;
server_handle = NULL;
- status = OCIAttrGet ((void *) db->oci_service_context, OCI_HTYPE_SVCCTX,
+ status = OCIAttrGet ((void *) db->oci_service_context, OCI_HTYPE_SVCCTX,
(void *) &server_handle, /* size pointer = */ NULL,
OCI_ATTR_SERVER, oci_error);
if (status != OCI_SUCCESS)
OCIHandleFree (databases[i]->oci_service_context, OCI_HTYPE_SVCCTX);
databases[i]->oci_service_context = NULL;
}
-
+
for (i = 0; i < queries_num; i++)
{
OCIStmt *oci_statement;
udb_query_set_user_data (queries[i], NULL);
}
}
-
+
OCIHandleFree (oci_env, OCI_HTYPE_ENV);
oci_env = NULL;
const char *script)
{
pinba_statnode_t *node;
-
+
node = realloc (stat_nodes,
sizeof (*stat_nodes) * (stat_nodes_num + 1));
if (node == NULL)
node = stat_nodes + stat_nodes_num;
memset (node, 0, sizeof (*node));
-
+
/* reset strings */
node->name = NULL;
node->host = NULL;
node->script = NULL;
node->mem_peak = NAN;
-
+
/* fill query data */
strset (&node->name, name);
strset (&node->host, host);
strset (&node->server, server);
strset (&node->script, script);
-
+
/* increment counter */
stat_nodes_num++;
} /* }}} void service_statnode_add */
unsigned int index)
{
pinba_statnode_t *node;
-
+
if (stat_nodes_num == 0)
return 0;
-
+
/* begin collecting */
if (index == 0)
pthread_mutex_lock (&stat_nodes_lock);
-
+
/* end collecting */
if (index >= stat_nodes_num)
{
/* reset node */
node->mem_peak = NAN;
-
+
return (index + 1);
} /* }}} unsigned int service_statnode_collect */
unsigned int i;
pthread_mutex_lock (&stat_nodes_lock);
-
+
for (i = 0; i < stat_nodes_num; i++)
{
if ((stat_nodes[i].host != NULL)
service_statnode_process(&stat_nodes[i], request);
}
-
+
pthread_mutex_unlock(&stat_nodes_lock);
} /* }}} void service_process_request */
if (status != 0)
break;
} /* for (ai_list) */
-
+
freeaddrinfo (ai_list);
if (s->fd_num < 1)
if (!socket)
return;
-
+
for (i = 0; i < socket->fd_num; i++)
{
if (socket->fd[i].fd < 0)
close (socket->fd[i].fd);
socket->fd[i].fd = -1;
}
-
+
sfree(socket);
} /* }}} void pinba_socket_free */
static int pinba_process_stats_packet (const uint8_t *buffer, /* {{{ */
size_t buffer_size)
{
- Pinba__Request *request;
-
+ Pinba__Request *request;
+
request = pinba__request__unpack (NULL, buffer_size, buffer);
-
+
if (!request)
return (-1);
service_process_request(request);
pinba__request__free_unpacked (request, NULL);
-
+
return (0);
} /* }}} int pinba_process_stats_packet */
static int plugin_config (oconfig_item_t *ci) /* {{{ */
{
int i;
-
+
/* The lock should not be necessary in the config callback, but let's be
* sure.. */
pthread_mutex_lock (&stat_nodes_lock);
}
pthread_mutex_unlock(&stat_nodes_lock);
-
+
return (0);
} /* }}} int pinba_config */
{
value_t value;
value_list_t vl = VALUE_LIST_INIT;
-
+
vl.values = &value;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin_instance, res->name, sizeof (vl.plugin_instance));
value.derive = res->req_count;
- sstrncpy (vl.type, "total_requests", sizeof (vl.type));
+ sstrncpy (vl.type, "total_requests", sizeof (vl.type));
plugin_dispatch_values (&vl);
value.derive = float_counter_get (&res->req_time, /* factor = */ 1000);
- sstrncpy (vl.type, "total_time_in_ms", sizeof (vl.type));
+ sstrncpy (vl.type, "total_time_in_ms", sizeof (vl.type));
plugin_dispatch_values (&vl);
value.derive = res->doc_size;
- sstrncpy (vl.type, "total_bytes", sizeof (vl.type));
+ sstrncpy (vl.type, "total_bytes", sizeof (vl.type));
plugin_dispatch_values (&vl);
value.derive = float_counter_get (&res->ru_utime, /* factor = */ 100);
{
unsigned int i=0;
pinba_statnode_t data;
-
+
while ((i = service_statnode_collect (&data, i)) != 0)
{
plugin_submit (&data);
}
-
+
return 0;
} /* }}} int plugin_read */
pthread_mutex_unlock (&ping_lock);
return (-1);
}
-
+
pthread_mutex_unlock (&ping_lock);
return (0);
} /* }}} int start_thread */
log_err ("calloc failed.");
BAIL_OUT (-1);
}
-
+
for (col = 0; col < column_num; ++col) {
/* Pointers returned by `PQfname' are freed by `PQclear' via
* `BAIL_OUT'. */
#undef VALUE_OR_NULL
if( db->expire_delay > 0 && vl->time < (cdtime() - vl->interval - db->expire_delay) ) {
- log_info ("c_psql_write: Skipped expired value @ %s - %s/%s-%s/%s-%s/%s",
+ log_info ("c_psql_write: Skipped expired value @ %s - %s/%s-%s/%s-%s/%s",
params[0], params[1], params[2], params[3], params[4], params[5], params[6] );
return 0;
}
static ignorelist_t *values_list = NULL;
-/*
+/*
* Functions
*/
static void submit (const char *protocol_name,
* DEALINGS IN THE SOFTWARE.
*
* Authors:
- * Sven Trenkel <collectd at semidefinite.de>
+ * Sven Trenkel <collectd at semidefinite.de>
**/
#include <Python.h>
static PyObject *Config_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
Config *self;
-
+
self = (Config *) type->tp_alloc(type, 0);
if (self == NULL)
return NULL;
-
+
self->parent = NULL;
self->key = NULL;
self->values = NULL;
PyObject *key = NULL, *parent = NULL, *values = NULL, *children = NULL, *tmp;
Config *self = (Config *) s;
static char *kwlist[] = {"key", "parent", "values", "children", NULL};
-
+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist,
&key, &parent, &values, &children))
return -1;
-
+
if (!IS_BYTES_OR_UNICODE(key)) {
PyErr_SetString(PyExc_TypeError, "argument 1 must be str");
Py_XDECREF(parent);
Config *self = (Config *) s;
PyObject *ret = NULL;
static PyObject *node_prefix = NULL, *root_prefix = NULL, *ending = NULL;
-
+
/* This is ok because we have the GIL, so this is thread-save by default. */
if (node_prefix == NULL)
node_prefix = cpy_string_to_unicode_or_bytes("<collectd.Config node ");
ending = cpy_string_to_unicode_or_bytes(">");
if (node_prefix == NULL || root_prefix == NULL || ending == NULL)
return NULL;
-
+
ret = PyObject_Str(self->key);
CPY_SUBSTITUTE(PyObject_Repr, ret, ret);
if (self->parent == NULL || self->parent == Py_None)
else
CPY_STRCAT(&ret, node_prefix);
CPY_STRCAT(&ret, ending);
-
+
return ret;
}
* DEALINGS IN THE SOFTWARE.
*
* Authors:
- * Sven Trenkel <collectd at semidefinite.de>
+ * Sven Trenkel <collectd at semidefinite.de>
**/
#include <Python.h>
static void cpy_build_name(char *buf, size_t size, PyObject *callback, const char *name) {
const char *module = NULL;
PyObject *mod = NULL;
-
+
if (name != NULL) {
snprintf(buf, size, "python.%s", name);
return;
}
-
+
mod = PyObject_GetAttrString(callback, "__module__"); /* New reference. */
if (mod != NULL)
module = cpy_unicode_or_bytes_to_string(&mod);
-
+
if (module != NULL) {
snprintf(buf, size, "python.%s", module);
Py_XDECREF(mod);
return;
}
Py_XDECREF(mod);
-
+
snprintf(buf, size, "python.%p", callback);
PyErr_Clear();
}
int l = 0, i;
const char *typename = NULL, *message = NULL;
PyObject *type, *value, *traceback, *tn, *m, *list;
-
+
PyErr_Fetch(&type, &value, &traceback);
PyErr_NormalizeException(&type, &value, &traceback);
if (type == NULL) return;
uint64_t ui;
double d;
_Bool b;
-
+
type = meta_data_type(meta, table[i]);
if (type == MD_TYPE_STRING) {
if (meta_data_get_string(meta, table[i], &string))
char *name = NULL;
PyObject *callback = NULL, *data = NULL, *mod = NULL;
static char *kwlist[] = {"callback", "data", "name", NULL};
-
+
if (PyArg_ParseTupleAndKeywords(args, kwds, "O|Oet", kwlist, &callback, &data, NULL, &name) == 0) return NULL;
if (PyCallable_Check(callback) == 0) {
PyMem_Free(name);
int timeout = -1;
char *plugin = NULL, *identifier = NULL;
static char *kwlist[] = {"plugin", "timeout", "identifier", NULL};
-
+
if (PyArg_ParseTupleAndKeywords(args, kwds, "|etiet", kwlist, NULL, &plugin, &timeout, NULL, &identifier) == 0) return NULL;
Py_BEGIN_ALLOW_THREADS
plugin_flush(plugin, timeout, identifier);
char *name = NULL;
PyObject *callback = NULL, *data = NULL;
static char *kwlist[] = {"callback", "data", "name", NULL};
-
+
if (PyArg_ParseTupleAndKeywords(args, kwds, "O|Oet", kwlist, &callback, &data, NULL, &name) == 0) return NULL;
if (PyCallable_Check(callback) == 0) {
PyMem_Free(name);
}
cpy_build_name(buf, sizeof(buf), callback, name);
PyMem_Free(name);
-
+
Py_INCREF(callback);
Py_XINCREF(data);
char *name = NULL;
PyObject *callback = NULL, *data = NULL;
static char *kwlist[] = {"callback", "interval", "data", "name", NULL};
-
+
if (PyArg_ParseTupleAndKeywords(args, kwds, "O|dOet", kwlist, &callback, &interval, &data, NULL, &name) == 0) return NULL;
if (PyCallable_Check(callback) == 0) {
PyMem_Free(name);
}
cpy_build_name(buf, sizeof(buf), callback, name);
PyMem_Free(name);
-
+
Py_INCREF(callback);
Py_XINCREF(data);
static int cpy_shutdown(void) {
cpy_callback_t *c;
PyObject *ret;
-
+
/* This can happen if the module was loaded but not configured. */
if (state != NULL)
PyEval_RestoreThread(state);
static void *cpy_interactive(void *data) {
sigset_t sigset;
struct sigaction sig_int_action, old;
-
+
/* Signal handler in a plugin? Bad stuff, but the best way to
* handle it I guess. In an interactive session people will
* press Ctrl+C at some time, which will generate a SIGINT.
* This will cause collectd to shutdown, thus killing the
* interactive interpreter, and leaving the terminal in a
* mess. Chances are, this isn't what the user wanted to do.
- *
+ *
* So this is the plan:
* 1. Block SIGINT in the main thread.
* 2. Install our own signal handler that does nothing.
memset (&sig_int_action, '\0', sizeof (sig_int_action));
sig_int_action.sa_handler = cpy_int_handler;
sigaction (SIGINT, &sig_int_action, &old);
-
+
sigemptyset(&sigset);
sigaddset(&sigset, SIGINT);
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
PyObject *ret;
static pthread_t thread;
sigset_t sigset;
-
+
if (!Py_IsInitialized()) {
WARNING("python: Plugin loaded but not configured.");
plugin_unregister_shutdown("python");
static PyObject *cpy_oconfig_to_pyconfig(oconfig_item_t *ci, PyObject *parent) {
int i;
PyObject *item, *values, *children, *tmp;
-
+
if (parent == NULL)
parent = Py_None;
-
+
values = PyTuple_New(ci->values_num); /* New reference. */
for (i = 0; i < ci->values_num; ++i) {
if (ci->values[i].type == OCONFIG_TYPE_STRING) {
PyTuple_SET_ITEM(values, i, PyBool_FromLong(ci->values[i].value.boolean));
}
}
-
+
tmp = cpy_string_to_unicode_or_bytes(ci->key);
item = PyObject_CallFunction((void *) &ConfigType, "NONO", tmp, parent, values, Py_None);
if (item == NULL)
#else
char *argv = "";
#endif
-
+
Py_Initialize();
-
+
PyType_Ready(&ConfigType);
PyType_Ready(&PluginDataType);
ValuesType.tp_base = &PluginDataType;
for (i = 0; i < ci->children_num; ++i) {
oconfig_item_t *item = ci->children + i;
-
+
if (strcasecmp(item->key, "Interactive") == 0) {
if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN)
continue;
} else if (strcasecmp(item->key, "ModulePath") == 0) {
char *dir = NULL;
PyObject *dir_object;
-
- if (cf_util_get_string(item, &dir) != 0)
+
+ if (cf_util_get_string(item, &dir) != 0)
continue;
dir_object = cpy_string_to_unicode_or_bytes(dir); /* New reference. */
if (dir_object == NULL) {
} else if (strcasecmp(item->key, "Import") == 0) {
char *module_name = NULL;
PyObject *module;
-
- if (cf_util_get_string(item, &module_name) != 0)
+
+ if (cf_util_get_string(item, &module_name) != 0)
continue;
module = PyImport_ImportModule(module_name); /* New reference. */
if (module == NULL) {
char *name = NULL;
cpy_callback_t *c;
PyObject *ret;
-
+
if (cf_util_get_string(item, &name) != 0)
continue;
for (c = cpy_config_callbacks; c; c = c->next) {
* DEALINGS IN THE SOFTWARE.
*
* Authors:
- * Sven Trenkel <collectd at semidefinite.de>
+ * Sven Trenkel <collectd at semidefinite.de>
**/
#include <Python.h>
static PyObject *l_type = NULL, *l_type_instance = NULL, *l_plugin = NULL, *l_plugin_instance = NULL;
static PyObject *l_host = NULL, *l_time = NULL;
PluginData *self = (PluginData *) s;
-
+
if (l_type == NULL)
l_type = cpy_string_to_unicode_or_bytes("(type=");
if (l_type_instance == NULL)
l_host = cpy_string_to_unicode_or_bytes(",host=");
if (l_time == NULL)
l_time = cpy_string_to_unicode_or_bytes(",time=");
-
+
if (!l_type || !l_type_instance || !l_plugin || !l_plugin_instance || !l_host || !l_time)
return NULL;
-
+
ret = cpy_string_to_unicode_or_bytes(s->ob_type->tp_name);
CPY_STRCAT(&ret, l_type);
static PyObject *PluginData_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
PluginData *self;
-
+
self = (PluginData *) type->tp_alloc(type, 0);
if (self == NULL)
return NULL;
-
+
self->time = 0;
self->host[0] = 0;
self->plugin[0] = 0;
char *type = NULL, *plugin_instance = NULL, *type_instance = NULL, *plugin = NULL, *host = NULL;
static char *kwlist[] = {"type", "plugin_instance", "type_instance",
"plugin", "host", "time", NULL};
-
+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etetetetetd", kwlist, NULL, &type,
NULL, &plugin_instance, NULL, &type_instance, NULL, &plugin, NULL, &host, &time))
return -1;
-
+
if (type && plugin_get_ds(type) == NULL) {
PyErr_Format(PyExc_TypeError, "Dataset %s not found", type);
FreeAll();
static PyObject *PluginData_repr(PyObject *s) {
PyObject *ret;
static PyObject *l_closing = NULL;
-
+
if (l_closing == NULL)
l_closing = cpy_string_to_unicode_or_bytes(")");
-
+
if (l_closing == NULL)
return NULL;
-
+
ret = cpy_common_repr(s);
CPY_STRCAT(&ret, l_closing);
return ret;
static PyObject *PluginData_getstring(PyObject *self, void *data) {
const char *value = ((char *) self) + (intptr_t) data;
-
+
return cpy_string_to_unicode_or_bytes(value);
}
static int PluginData_setstring(PyObject *self, PyObject *value, void *data) {
char *old;
const char *new;
-
+
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete this attribute");
return -1;
static int PluginData_settype(PyObject *self, PyObject *value, void *data) {
char *old;
const char *new;
-
+
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete this attribute");
return -1;
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->meta = PyDict_New();
self->interval = 0;
char *type = NULL, *plugin_instance = NULL, *type_instance = NULL, *plugin = NULL, *host = NULL;
static char *kwlist[] = {"type", "values", "plugin_instance", "type_instance",
"plugin", "host", "time", "interval", "meta", NULL};
-
+
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;
-
+
if (type && plugin_get_ds(type) == NULL) {
PyErr_Format(PyExc_TypeError, "Dataset %s not found", type);
FreeAll();
} else {
Py_INCREF(values);
}
-
+
if (meta == NULL) {
meta = PyDict_New();
PyErr_Clear();
} else {
Py_INCREF(meta);
}
-
+
tmp = self->values;
self->values = values;
Py_XDECREF(tmp);
-
+
tmp = self->meta;
self->meta = meta;
Py_XDECREF(tmp);
int i, s;
meta_data_t *m = NULL;
PyObject *l;
-
+
if ((meta == NULL) || (meta == Py_None))
return NULL;
for (i = 0; i < s; ++i) {
const char *string, *keystring;
PyObject *key, *value, *item, *tmp;
-
+
item = PyList_GET_ITEM(l, i);
key = PyTuple_GET_ITEM(item, 0);
Py_INCREF(key);
PyObject *values = self->values, *meta = self->meta;
double time = self->data.time, interval = self->interval;
char *host = NULL, *plugin = NULL, *plugin_instance = NULL, *type = NULL, *type_instance = NULL;
-
+
static char *kwlist[] = {"type", "values", "plugin_instance", "type_instance",
"plugin", "host", "time", "interval", "meta", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetddO", kwlist,
PyObject *values = self->values, *meta = self->meta;
double time = self->data.time, interval = self->interval;
char *host = NULL, *plugin = NULL, *plugin_instance = NULL, *type = NULL, *type_instance = NULL, *dest = NULL;
-
+
static char *kwlist[] = {"destination", "type", "values", "plugin_instance", "type_instance",
"plugin", "host", "time", "interval", "meta", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|etOetetetetdiO", kwlist, NULL, &dest,
PyObject *ret, *tmp;
static PyObject *l_interval = NULL, *l_values = NULL, *l_meta = NULL, *l_closing = NULL;
Values *self = (Values *) s;
-
+
if (l_interval == NULL)
l_interval = cpy_string_to_unicode_or_bytes(",interval=");
if (l_values == NULL)
l_meta = cpy_string_to_unicode_or_bytes(",meta=");
if (l_closing == NULL)
l_closing = cpy_string_to_unicode_or_bytes(")");
-
+
if (l_interval == NULL || l_values == NULL || l_meta == NULL || l_closing == NULL)
return NULL;
-
+
ret = cpy_common_repr(s);
if (self->interval != 0) {
CPY_STRCAT(&ret, l_interval);
char *type = NULL, *plugin_instance = NULL, *type_instance = NULL, *plugin = NULL, *host = NULL;
static char *kwlist[] = {"type", "message", "plugin_instance", "type_instance",
"plugin", "host", "time", "severity", NULL};
-
+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etetetetetetdi", kwlist,
NULL, &type, NULL, &message, NULL, &plugin_instance, NULL, &type_instance,
NULL, &plugin, NULL, &host, &time, &severity))
return -1;
-
+
if (type && plugin_get_ds(type) == NULL) {
PyErr_Format(PyExc_TypeError, "Dataset %s not found", type);
FreeAll();
int severity = self->severity;
char *host = NULL, *plugin = NULL, *plugin_instance = NULL, *type = NULL, *type_instance = NULL;
char *message = NULL;
-
+
static char *kwlist[] = {"type", "message", "plugin_instance", "type_instance",
"plugin", "host", "time", "severity", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etetetetetetdi", kwlist,
static PyObject *Notification_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
Notification *self;
-
+
self = (Notification *) PluginData_new(type, args, kwds);
if (self == NULL)
return NULL;
-
+
self->message[0] = 0;
self->severity = 0;
return (PyObject *) self;
static int Notification_setstring(PyObject *self, PyObject *value, void *data) {
char *old;
const char *new;
-
+
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete this attribute");
return -1;
PyObject *ret, *tmp;
static PyObject *l_severity = NULL, *l_message = NULL, *l_closing = NULL;
Notification *self = (Notification *) s;
-
+
if (l_severity == NULL)
l_severity = cpy_string_to_unicode_or_bytes(",severity=");
if (l_message == NULL)
l_message = cpy_string_to_unicode_or_bytes(",message=");
if (l_closing == NULL)
l_closing = cpy_string_to_unicode_or_bytes(")");
-
+
if (l_severity == NULL || l_message == NULL || l_closing == NULL)
return NULL;
-
+
ret = cpy_common_repr(s);
if (self->severity != 0) {
CPY_STRCAT(&ret, l_severity);
status = ssnprintf (buffer + offset, buffer_len - offset,
":%llu", vl->values[i].counter);
}
- else if (ds->ds[i].type == DS_TYPE_GAUGE)
+ else if (ds->ds[i].type == DS_TYPE_GAUGE)
{
status = ssnprintf (buffer + offset, buffer_len - offset,
":%f", vl->values[i].gauge);
else /* if (ds->ds[i].type == DS_TYPE_ABSOLUTE) */ {
status = ssnprintf (buffer + offset, buffer_len - offset,
":%"PRIu64, vl->values[i].absolute);
-
+
}
if ((status < 1) || (status >= (buffer_len - offset)))
}
/* Update `tv_next_update' */
- if (write_rate > 0.0)
+ if (write_rate > 0.0)
{
gettimeofday (&tv_now, /* timezone = */ NULL);
tv_next_update.tv_sec = tv_now.tv_sec;
{
if (strcmp (this->filename, filename) == 0)
break;
-
+
prev = this;
this = this->next;
}
}
} /* while (c_avl_iterator_next) */
c_avl_iterator_destroy (iter);
-
+
for (i = 0; i < keys_num; i++)
{
if (c_avl_remove (cache, keys[i], (void *) &key, (void *) &rc) != 0)
while ((ptr = strtok_r (dummy, ", \t", &saveptr)) != NULL)
{
dummy = NULL;
-
+
tmp_alloc = realloc (rrdcreate_config.timespans,
sizeof (int) * (rrdcreate_config.timespans_num + 1));
if (tmp_alloc == NULL)
*
* Authors:
* Florian octo Forster <octo at collectd.org>
- *
+ *
* Lubos Stanek <lubek at users.sourceforge.net> Wed Oct 27, 2006
* - config ExtendedSensorNaming option
* - precise sensor feature selection (chip-bus-address/type-feature)
typedef struct sensors_labeltypes_s sensors_labeltypes_t;
/* finite list of known labels extracted from lm_sensors */
-static sensors_labeltypes_t known_features[] =
+static sensors_labeltypes_t known_features[] =
{
{ "fan1", SENSOR_TYPE_FANSPEED },
{ "fan2", SENSOR_TYPE_FANSPEED },
FILE *fh = NULL;
featurelist_t *last_feature = NULL;
-
+
const sensors_chip_name *chip;
int chip_num;
if (type_instance != NULL)
sstrncpy (vl.type_instance, type_instance,
sizeof (vl.type_instance));
-
+
plugin_dispatch_values (&vl);
} /* void tss2_submit_gauge */
* Receive a single line from the given file object
*/
char *temp;
-
+
/*
* fgets is blocking but much easier then doing anything else
* TODO: Non-blocking Version would be safer
char buffer[4096];
char *value;
char *endptr = NULL;
-
+
status = tss2_receive_line (read_fh, buffer, sizeof (buffer));
if (status != 0)
{
return (-1);
}
buffer[sizeof (buffer) - 1] = 0;
-
+
if (strncmp ("average_packet_loss=", buffer,
strlen ("average_packet_loss=")) == 0)
{
}
value++;
}
-
+
value = &buffer[20];
-
+
packet_loss = strtod (value, &endptr);
if (value == endptr)
{
buffer);
}
}
-
+
*ret_value = packet_loss;
return (0);
} /* int tss2_vserver_gapl */
char *key;
char *value;
char *endptr = NULL;
-
+
/* Read one line of the server's answer */
status = tss2_receive_line (read_fh, buffer, sizeof (buffer));
if (status != 0)
{
/* Server variable found */
int status;
-
+
status = tss2_add_vserver (atoi (value));
if (status != 0)
return (1);
continue;
}
}
-
+
if (success == 0)
return (-1);
return (0);
/* Get rid of the configuration */
sfree (config_host);
sfree (config_port);
-
+
return (0);
} /* int tss2_shutdown */
* Copyright (C) 2005-2007 Sebastian Harl
* Copyright (C) 2005 Niki W. Waibel
* Copyright (C) 2005-2007 Florian octo Forster
- * Copyright (C) 2008 Oleg King
+ * Copyright (C) 2008 Oleg King
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
users_submit (users);
/* #endif HAVE_GETUTXENT */
-
+
#elif HAVE_GETUTENT
unsigned int users = 0;
struct utmp *entry = NULL;
us = sg_get_user_stats ();
# endif
if (us == NULL)
- return (-1);
+ return (-1);
users_submit ((gauge_t)
# if HAVE_LIBSTATGRAB_0_90
typedef int (*udb_query_create_callback_t) (udb_query_t *q,
oconfig_item_t *ci);
-/*
+/*
* Public functions
*/
int udb_query_create (udb_query_t ***ret_query_list,
void udb_query_set_user_data (udb_query_t *q, void *user_data);
void *udb_query_get_user_data (udb_query_t *q);
-/*
+/*
* udb_query_check_version
*
* Returns 0 if the query is NOT suitable for `version' and >0 if the
* Copyright (C) 2006 Florian octo Forster
* Copyright (C) 2002 The Measurement Factory, Inc.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
buffer++;
}
}
-
+
/* Eat up trailing spaces */
while (isspace ((int) *buffer))
buffer++;
assert (sizeof (match_part->str) > len);
/* strip trailing slash */
match_part->str[len - 2] = 0;
-
+
status = regcomp (&match_part->regex, match_part->str,
/* flags = */ REG_EXTENDED);
if (status != 0)
return (EINVAL);
}
match_part->is_regex = 1;
-
+
return (0);
} /* }}} int lu_copy_ident_to_match_part */
{
user_class_list_t *ptr;
int retval = 0;
-
+
for (ptr = user_class_list; ptr != NULL; ptr = ptr->next)
{
int status;
sfree (type_copy);
return (NULL);
}
-
+
return (by_type);
} /* }}} by_type_entry_t *lu_search_by_type */
static void lu_destroy_by_type (lookup_t *obj, /* {{{ */
by_type_entry_t *by_type)
{
-
+
while (42)
{
char *plugin = NULL;
return (status);
retval += status;
}
-
+
return (retval);
} /* }}} lookup_search */
assert (expect_new_obj);
memcpy (&last_class_ident, class, sizeof (last_class_ident));
-
+
obj = malloc (sizeof (*obj));
strncpy (obj->host, vl->host, sizeof (obj->host));
strncpy (obj->plugin, vl->plugin, sizeof (obj->plugin));
if (!dmidecode) {
return NULL;
}
-
+
uuid = uuid_parse_dmidecode(dmidecode);
pclose(dmidecode);
if (fields[1] == endptr)
continue;
- /*
+ /*
* Number of pages
*
* The total number of {inst} pages, e. g dirty pages.
}
}
- /*
+ /*
* Page in and page outs. For memory and swap.
*/
else if (strcmp ("pgpgin", key) == 0)
if (proc == NULL)
{
char errbuf[1024];
- ERROR ("vserver plugin: fopen (%s): %s", PROCDIR,
+ ERROR ("vserver plugin: fopen (%s): %s", PROCDIR,
sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
len = ssnprintf (file, sizeof (file), PROCDIR "/%s", dent->d_name);
if ((len < 0) || (len >= BUFSIZE))
continue;
-
+
status = stat (file, &statbuf);
if (status != 0)
{
file, sstrerror (errno, errbuf, sizeof (errbuf)));
continue;
}
-
+
if (!S_ISDIR (statbuf.st_mode))
continue;
/*
* dbm = 10 * log_{10} (1000 * power / W)
- * power = 10^(dbm/10) * W/1000
+ * power = 10^(dbm/10) * W/1000
*/
watt = pow (10.0, (dbm / 10.0)) / 1000.0;
double quality;
double power;
double noise;
-
+
char *fields[8];
int numfields;