summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 77a6905)
raw | patch | inline | side by side (parent: 77a6905)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 5 Dec 2010 11:18:33 +0000 (12:18 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 5 Dec 2010 11:18:33 +0000 (12:18 +0100) |
This is just a beginning, other plugins will have to be changed, too.
src/apache.c | patch | blob | history | |
src/cpu.c | patch | blob | history | |
src/disk.c | patch | blob | history | |
src/fscache.c | patch | blob | history | |
src/interface.c | patch | blob | history | |
src/netapp.c | patch | blob | history | |
src/network.c | patch | blob | history | |
src/processes.c | patch | blob | history | |
src/serial.c | patch | blob | history | |
src/vmem.c | patch | blob | history | |
src/vserver.c | patch | blob | history |
diff --git a/src/apache.c b/src/apache.c
index 506ba84ec23e58d9396e9165454c3a08a6e33be3..9be32d16e1b85795d4426bf5450fb348b974367b 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
plugin_dispatch_values (&vl);
} /* void submit_value */
-static void submit_counter (const char *type, const char *type_instance,
- counter_t c, apache_t *st)
+static void submit_derive (const char *type, const char *type_instance,
+ derive_t c, apache_t *st)
{
value_t v;
- v.counter = c;
+ v.derive = c;
submit_value (type, type_instance, v, st);
-} /* void submit_counter */
+} /* void submit_derive */
static void submit_gauge (const char *type, const char *type_instance,
gauge_t g, apache_t *st)
{
if ((strcmp (fields[0], "Total") == 0)
&& (strcmp (fields[1], "Accesses:") == 0))
- submit_counter ("apache_requests", "",
+ submit_derive ("apache_requests", "",
atoll (fields[2]), st);
else if ((strcmp (fields[0], "Total") == 0)
&& (strcmp (fields[1], "kBytes:") == 0))
- submit_counter ("apache_bytes", "",
+ submit_derive ("apache_bytes", "",
1024LL * atoll (fields[2]), st);
}
else if (fields_num == 2)
diff --git a/src/cpu.c b/src/cpu.c
index 3dbe80eeb1b7f4727b491803e93e841cac09200a..12071a2ca8bae25cf86f25782a682ad1bf898846 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
/**
* collectd - src/cpu.c
- * Copyright (C) 2005-2009 Florian octo Forster
+ * Copyright (C) 2005-2010 Florian octo Forster
* Copyright (C) 2008 Oleg King
* Copyright (C) 2009 Simon Kuhnle
* Copyright (C) 2009 Manuel Sanmartin
return (0);
} /* int init */
-static void submit (int cpu_num, const char *type_instance, counter_t value)
+static void submit (int cpu_num, const char *type_instance, derive_t value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = value;
+ values[0].derive = value;
vl.values = values;
vl.values_len = 1;
continue;
}
- submit (cpu, "user", (counter_t) cpu_info.cpu_ticks[CPU_STATE_USER]);
- submit (cpu, "nice", (counter_t) cpu_info.cpu_ticks[CPU_STATE_NICE]);
- submit (cpu, "system", (counter_t) cpu_info.cpu_ticks[CPU_STATE_SYSTEM]);
- submit (cpu, "idle", (counter_t) cpu_info.cpu_ticks[CPU_STATE_IDLE]);
+ submit (cpu, "user", (derive_t) cpu_info.cpu_ticks[CPU_STATE_USER]);
+ submit (cpu, "nice", (derive_t) cpu_info.cpu_ticks[CPU_STATE_NICE]);
+ submit (cpu, "system", (derive_t) cpu_info.cpu_ticks[CPU_STATE_SYSTEM]);
+ submit (cpu, "idle", (derive_t) cpu_info.cpu_ticks[CPU_STATE_IDLE]);
#endif /* PROCESSOR_CPU_LOAD_INFO */
#if PROCESSOR_TEMPERATURE
/*
#elif defined(KERNEL_LINUX)
int cpu;
- counter_t user, nice, syst, idle;
- counter_t wait, intr, sitr; /* sitr == soft interrupt */
+ derive_t user, nice, syst, idle;
+ derive_t wait, intr, sitr; /* sitr == soft interrupt */
FILE *fh;
char buf[1024];
#elif defined(HAVE_LIBKSTAT)
int cpu;
- counter_t user, syst, idle, wait;
+ derive_t user, syst, idle, wait;
static cpu_stat_t cs;
if (kc == NULL)
if (kstat_read (kc, ksp[cpu], &cs) == -1)
continue; /* error message? */
- idle = (counter_t) cs.cpu_sysinfo.cpu[CPU_IDLE];
- user = (counter_t) cs.cpu_sysinfo.cpu[CPU_USER];
- syst = (counter_t) cs.cpu_sysinfo.cpu[CPU_KERNEL];
- wait = (counter_t) cs.cpu_sysinfo.cpu[CPU_WAIT];
+ idle = (derive_t) cs.cpu_sysinfo.cpu[CPU_IDLE];
+ user = (derive_t) cs.cpu_sysinfo.cpu[CPU_USER];
+ syst = (derive_t) cs.cpu_sysinfo.cpu[CPU_KERNEL];
+ wait = (derive_t) cs.cpu_sysinfo.cpu[CPU_WAIT];
submit (ksp[cpu]->ks_instance, "user", user);
submit (ksp[cpu]->ks_instance, "system", syst);
return (-1);
}
- submit (0, "idle", (counter_t) cs->idle);
- submit (0, "nice", (counter_t) cs->nice);
- submit (0, "swap", (counter_t) cs->swap);
- submit (0, "system", (counter_t) cs->kernel);
- submit (0, "user", (counter_t) cs->user);
- submit (0, "wait", (counter_t) cs->iowait);
+ submit (0, "idle", (derive_t) cs->idle);
+ submit (0, "nice", (derive_t) cs->nice);
+ submit (0, "swap", (derive_t) cs->swap);
+ submit (0, "system", (derive_t) cs->kernel);
+ submit (0, "user", (derive_t) cs->user);
+ submit (0, "wait", (derive_t) cs->iowait);
/* #endif HAVE_LIBSTATGRAB */
#elif defined(HAVE_PERFSTAT)
for (i = 0; i < cpus; i++)
{
- submit (i, "idle", (counter_t) perfcpu[i].idle);
- submit (i, "system", (counter_t) perfcpu[i].sys);
- submit (i, "user", (counter_t) perfcpu[i].user);
- submit (i, "wait", (counter_t) perfcpu[i].wait);
+ submit (i, "idle", (derive_t) perfcpu[i].idle);
+ submit (i, "system", (derive_t) perfcpu[i].sys);
+ submit (i, "user", (derive_t) perfcpu[i].user);
+ submit (i, "wait", (derive_t) perfcpu[i].wait);
}
#endif /* HAVE_PERFSTAT */
diff --git a/src/disk.c b/src/disk.c
index 0a90899215b8f6b827ccb147a9b648f2861474f9..697d850f662be2dde164a83397a0d0885a0c5887 100644 (file)
--- a/src/disk.c
+++ b/src/disk.c
/**
* collectd - src/disk.c
- * Copyright (C) 2005-2008 Florian octo Forster
+ * Copyright (C) 2005-2010 Florian octo Forster
* Copyright (C) 2009 Manuel Sanmartin
*
* This program is free software; you can redistribute it and/or modify it
/* This overflows in roughly 1361 years */
unsigned int poll_count;
- counter_t read_sectors;
- counter_t write_sectors;
+ derive_t read_sectors;
+ derive_t write_sectors;
- counter_t read_bytes;
- counter_t write_bytes;
+ derive_t read_bytes;
+ derive_t write_bytes;
- counter_t read_ops;
- counter_t write_ops;
- counter_t read_time;
- counter_t write_time;
+ derive_t read_ops;
+ derive_t write_ops;
+ derive_t read_time;
+ derive_t write_time;
- counter_t avg_read_time;
- counter_t avg_write_time;
+ derive_t avg_read_time;
+ derive_t avg_write_time;
struct diskstats *next;
} diskstats_t;
static void disk_submit (const char *plugin_instance,
const char *type,
- counter_t read, counter_t write)
+ derive_t read, derive_t write)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
if (ignorelist_match (ignorelist, plugin_instance) != 0)
return;
- values[0].counter = read;
- values[1].counter = write;
+ values[0].derive = read;
+ values[1].derive = write;
vl.values = values;
vl.values_len = 2;
int major = 0;
int minor = 0;
- counter_t read_sectors = 0;
- counter_t write_sectors = 0;
+ derive_t read_sectors = 0;
+ derive_t write_sectors = 0;
- counter_t read_ops = 0;
- counter_t read_merged = 0;
- counter_t read_time = 0;
- counter_t write_ops = 0;
- counter_t write_merged = 0;
- counter_t write_time = 0;
+ derive_t read_ops = 0;
+ derive_t read_merged = 0;
+ derive_t read_time = 0;
+ derive_t write_ops = 0;
+ derive_t write_merged = 0;
+ derive_t write_time = 0;
int is_disk = 0;
diskstats_t *ds, *pre_ds;
}
{
- counter_t diff_read_sectors;
- counter_t diff_write_sectors;
+ derive_t diff_read_sectors;
+ derive_t diff_write_sectors;
/* If the counter wraps around, it's only 32 bits.. */
if (read_sectors < ds->read_sectors)
/* Calculate the average time an io-op needs to complete */
if (is_disk)
{
- counter_t diff_read_ops;
- counter_t diff_write_ops;
- counter_t diff_read_time;
- counter_t diff_write_time;
+ derive_t diff_read_ops;
+ derive_t diff_write_ops;
+ derive_t diff_read_time;
+ derive_t diff_write_time;
if (read_ops < ds->read_ops)
diff_read_ops = 1 + read_ops
+ (UINT_MAX - ds->read_ops);
else
diff_read_ops = read_ops - ds->read_ops;
- DEBUG ("disk plugin: disk_name = %s; read_ops = %llu; "
- "ds->read_ops = %llu; diff_read_ops = %llu;",
+ DEBUG ("disk plugin: disk_name = %s; read_ops = %"PRIi64"; "
+ "ds->read_ops = %"PRIi64"; diff_read_ops = %"PRIi64";",
disk_name,
read_ops, ds->read_ops, diff_read_ops);
/* #endif defined(HAVE_LIBSTATGRAB) */
#elif defined(HAVE_PERFSTAT)
- counter_t read_sectors;
- counter_t write_sectors;
- counter_t read_time;
- counter_t write_time;
- counter_t read_ops;
- counter_t write_ops;
+ derive_t read_sectors;
+ derive_t write_sectors;
+ derive_t read_time;
+ derive_t write_time;
+ derive_t read_ops;
+ derive_t write_ops;
perfstat_id_t firstpath;
int rnumdisk;
int i;
diff --git a/src/fscache.c b/src/fscache.c
index dc0eb1194dcc95fdaa8292706fb3fb26bdb09638..8fbd271394e90554fcf92f1c850f6b4733242537 100644 (file)
--- a/src/fscache.c
+++ b/src/fscache.c
63 events to collect in 13 groups
*/
static void fscache_submit (const char *section, const char *name,
- counter_t counter_value)
+ value_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
- vl.values[0].counter = counter_value;
-
sstrncpy(vl.host, hostname_g, sizeof (vl.host));
sstrncpy(vl.plugin, "fscache", sizeof (vl.plugin));
sstrncpy(vl.plugin_instance, section, sizeof (vl.plugin_instance));
{
char *field_name;
char *field_value_str;
- char *endptr;
- counter_t field_value_cnt;
+ value_t field_value_cnt;
+ int status;
field_name = fields[i];
assert (field_name != NULL);
*field_value_str = 0;
field_value_str++;
- errno = 0;
- endptr = NULL;
- field_value_cnt = (counter_t) strtoull (field_value_str,
- &endptr, /* base = */ 10);
- if ((errno != 0) || (endptr == field_value_str))
+ status = parse_value (field_value_str, &field_value_cnt,
+ DS_TYPE_DERIVE);
+ if (status != 0)
continue;
fscache_submit (section, field_name, field_value_cnt);
diff --git a/src/interface.c b/src/interface.c
index 177afbaa0847b8f1db0dac2dd89bf6d6bf8bb19e..c1e28e32c962aff7a3393ae321634affb6a44be1 100644 (file)
--- a/src/interface.c
+++ b/src/interface.c
/**
* collectd - src/interface.c
- * Copyright (C) 2005-2008 Florian octo Forster
+ * Copyright (C) 2005-2010 Florian octo Forster
* Copyright (C) 2009 Manuel Sanmartin
*
* This program is free software; you can redistribute it and/or modify it
static int interface_init (void)
{
kstat_t *ksp_chain;
- unsigned long long val;
+ derive_t val;
numif = 0;
#endif /* HAVE_LIBKSTAT */
static void if_submit (const char *dev, const char *type,
- unsigned long long rx,
- unsigned long long tx)
+ derive_t rx,
+ derive_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
if (ignorelist_match (ignorelist, dev) != 0)
return;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
vl.values = values;
vl.values_len = 2;
#elif KERNEL_LINUX
FILE *fh;
char buffer[1024];
- unsigned long long incoming, outgoing;
+ derive_t incoming, outgoing;
char *device;
char *dummy;
#elif HAVE_LIBKSTAT
int i;
- unsigned long long rx;
- unsigned long long tx;
+ derive_t rx;
+ derive_t tx;
if (kc == NULL)
return (-1);
diff --git a/src/netapp.c b/src/netapp.c
index 5d100a69ca5f0eb23d5149a4f426becb6dfbd6b1..d9bd1ae520597697fc96cb1f1a540d664c571ff2 100644 (file)
--- a/src/netapp.c
+++ b/src/netapp.c
return (plugin_dispatch_values (&vl));
} /* }}} int submit_uint64 */
-static int submit_two_counters (const char *host, const char *plugin_inst, /* {{{ */
- const char *type, const char *type_inst, counter_t val0, counter_t val1,
+static int submit_two_derive (const char *host, const char *plugin_inst, /* {{{ */
+ const char *type, const char *type_inst, derive_t val0, derive_t val1,
cdtime_t timestamp, cdtime_t interval)
{
value_t values[2];
- values[0].counter = val0;
- values[1].counter = val1;
+ values[0].derive = val0;
+ values[1].derive = val1;
return (submit_values (host, plugin_inst, type, type_inst,
values, 2, timestamp, interval));
-} /* }}} int submit_two_counters */
+} /* }}} int submit_two_derive */
-static int submit_counter (const char *host, const char *plugin_inst, /* {{{ */
- const char *type, const char *type_inst, counter_t counter,
+static int submit_derive (const char *host, const char *plugin_inst, /* {{{ */
+ const char *type, const char *type_inst, derive_t counter,
cdtime_t timestamp, cdtime_t interval)
{
value_t v;
- v.counter = counter;
+ v.derive = counter;
return (submit_values (host, plugin_inst, type, type_inst,
&v, 1, timestamp, interval));
-} /* }}} int submit_counter */
+} /* }}} int submit_derive */
static int submit_two_gauge (const char *host, const char *plugin_inst, /* {{{ */
const char *type, const char *type_inst, gauge_t val0, gauge_t val1,
if (HAS_ALL_FLAGS (old_data->flags, CFG_VOLUME_PERF_IO)
&& HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_BYTES_READ | HAVE_VOLUME_PERF_BYTES_WRITE))
{
- submit_two_counters (hostname, plugin_instance, "disk_octets", /* type instance = */ NULL,
- (counter_t) new_data->read_bytes, (counter_t) new_data->write_bytes, new_data->timestamp, interval);
+ submit_two_derive (hostname, plugin_instance, "disk_octets", /* type instance = */ NULL,
+ (derive_t) new_data->read_bytes, (derive_t) new_data->write_bytes, new_data->timestamp, interval);
}
/* Check for and submit disk-operations values */
if (HAS_ALL_FLAGS (old_data->flags, CFG_VOLUME_PERF_OPS)
&& HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE))
{
- submit_two_counters (hostname, plugin_instance, "disk_ops", /* type instance = */ NULL,
- (counter_t) new_data->read_ops, (counter_t) new_data->write_ops, new_data->timestamp, interval);
+ submit_two_derive (hostname, plugin_instance, "disk_ops", /* type instance = */ NULL,
+ (derive_t) new_data->read_ops, (derive_t) new_data->write_ops, new_data->timestamp, interval);
}
/* Check for, calculate and submit disk-latency values */
na_elem_t *counter;
na_elem_iter_t counter_iter;
- counter_t disk_read = 0, disk_written = 0;
- counter_t net_recv = 0, net_sent = 0;
- counter_t cpu_busy = 0, cpu_total = 0;
+ derive_t disk_read = 0, disk_written = 0;
+ derive_t net_recv = 0, net_sent = 0;
+ derive_t cpu_busy = 0, cpu_total = 0;
uint32_t counter_flags = 0;
const char *instance;
continue;
if (!strcmp(name, "disk_data_read")) {
- disk_read = (counter_t) (value * 1024);
+ disk_read = (derive_t) (value * 1024);
counter_flags |= 0x01;
} else if (!strcmp(name, "disk_data_written")) {
- disk_written = (counter_t) (value * 1024);
+ disk_written = (derive_t) (value * 1024);
counter_flags |= 0x02;
} else if (!strcmp(name, "net_data_recv")) {
- net_recv = (counter_t) (value * 1024);
+ net_recv = (derive_t) (value * 1024);
counter_flags |= 0x04;
} else if (!strcmp(name, "net_data_sent")) {
- net_sent = (counter_t) (value * 1024);
+ net_sent = (derive_t) (value * 1024);
counter_flags |= 0x08;
} else if (!strcmp(name, "cpu_busy")) {
- cpu_busy = (counter_t) value;
+ cpu_busy = (derive_t) value;
counter_flags |= 0x10;
} else if (!strcmp(name, "cpu_elapsed_time")) {
- cpu_total = (counter_t) value;
+ cpu_total = (derive_t) value;
counter_flags |= 0x20;
} else if ((cfg_system->flags & CFG_SYSTEM_OPS)
&& (value > 0) && (strlen(name) > 4)
&& (!strcmp(name + strlen(name) - 4, "_ops"))) {
- submit_counter (hostname, instance, "disk_ops_complex", name,
- (counter_t) value, timestamp, interval);
+ submit_derive (hostname, instance, "disk_ops_complex", name,
+ (derive_t) value, timestamp, interval);
}
} /* for (counter) */
if ((cfg_system->flags & CFG_SYSTEM_DISK)
&& (HAS_ALL_FLAGS (counter_flags, 0x01 | 0x02)))
- submit_two_counters (hostname, instance, "disk_octets", NULL,
+ 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_counters (hostname, instance, "if_octets", NULL,
+ submit_two_derive (hostname, instance, "if_octets", NULL,
net_recv, net_sent, timestamp, interval);
if ((cfg_system->flags & CFG_SYSTEM_CPU)
&& (HAS_ALL_FLAGS (counter_flags, 0x10 | 0x20)))
{
- submit_counter (hostname, instance, "cpu", "system",
+ submit_derive (hostname, instance, "cpu", "system",
cpu_busy, timestamp, interval);
- submit_counter (hostname, instance, "cpu", "idle",
+ submit_derive (hostname, instance, "cpu", "idle",
cpu_total - cpu_busy, timestamp, interval);
}
diff --git a/src/network.c b/src/network.c
index 7a1fcf7fd2bc9c3a6734a1e5ada0f2a68b5cef90..cc3d6b3a3a3aa24af444be96e01bca5cb056260a 100644 (file)
--- a/src/network.c
+++ b/src/network.c
/**
* collectd - src/network.c
- * Copyright (C) 2005-2009 Florian octo Forster
+ * Copyright (C) 2005-2010 Florian octo Forster
* Copyright (C) 2009 Aman Gupta
*
* This program is free software; you can redistribute it and/or modify it
* example). Only if neither is true, the stats_lock is acquired. The counters
* are always read without holding a lock in the hope that writing 8 bytes to
* memory is an atomic operation. */
-static uint64_t stats_octets_rx = 0;
-static uint64_t stats_octets_tx = 0;
-static uint64_t stats_packets_rx = 0;
-static uint64_t stats_packets_tx = 0;
-static uint64_t stats_values_dispatched = 0;
-static uint64_t stats_values_not_dispatched = 0;
-static uint64_t stats_values_sent = 0;
-static uint64_t stats_values_not_sent = 0;
+static derive_t stats_octets_rx = 0;
+static derive_t stats_octets_tx = 0;
+static derive_t stats_packets_rx = 0;
+static derive_t stats_packets_tx = 0;
+static derive_t stats_values_dispatched = 0;
+static derive_t stats_values_not_dispatched = 0;
+static derive_t stats_values_sent = 0;
+static derive_t stats_values_not_sent = 0;
static pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER;
/*
static int network_stats_read (void) /* {{{ */
{
- uint64_t copy_octets_rx;
- uint64_t copy_octets_tx;
- uint64_t copy_packets_rx;
- uint64_t copy_packets_tx;
- uint64_t copy_values_dispatched;
- uint64_t copy_values_not_dispatched;
- uint64_t copy_values_sent;
- uint64_t copy_values_not_sent;
- uint64_t copy_receive_list_length;
+ derive_t copy_octets_rx;
+ derive_t copy_octets_tx;
+ derive_t copy_packets_rx;
+ derive_t copy_packets_tx;
+ derive_t copy_values_dispatched;
+ derive_t copy_values_not_dispatched;
+ derive_t copy_values_sent;
+ derive_t copy_values_not_sent;
+ derive_t copy_receive_list_length;
value_list_t vl = VALUE_LIST_INIT;
value_t values[2];
sstrncpy (vl.plugin, "network", sizeof (vl.plugin));
/* Octets received / sent */
- vl.values[0].counter = (counter_t) copy_octets_rx;
- vl.values[1].counter = (counter_t) copy_octets_tx;
+ vl.values[0].derive = (derive_t) copy_octets_rx;
+ vl.values[1].derive = (derive_t) copy_octets_tx;
sstrncpy (vl.type, "if_octets", sizeof (vl.type));
plugin_dispatch_values (&vl);
/* Packets received / send */
- vl.values[0].counter = (counter_t) copy_packets_rx;
- vl.values[1].counter = (counter_t) copy_packets_tx;
+ vl.values[0].derive = (derive_t) copy_packets_rx;
+ vl.values[1].derive = (derive_t) copy_packets_tx;
sstrncpy (vl.type, "if_packets", sizeof (vl.type));
plugin_dispatch_values (&vl);
diff --git a/src/processes.c b/src/processes.c
index 30798d42a6b76274608a6270c7481dddd3a17350..655cddb7d085a15a7e9e13e6dacabd20cb22d9a1 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
/**
* collectd - src/processes.c
* Copyright (C) 2005 Lyonel Vincent
- * Copyright (C) 2006-2008 Florian octo Forster
+ * Copyright (C) 2006-2010 Florian octo Forster
* Copyright (C) 2008 Oleg King
* Copyright (C) 2009 Sebastian Harl
* Copyright (C) 2009 Andrés J. Díaz
unsigned long vmem_minflt;
unsigned long vmem_majflt;
- unsigned long vmem_minflt_counter;
- unsigned long vmem_majflt_counter;
+ derive_t vmem_minflt_counter;
+ derive_t vmem_majflt_counter;
unsigned long cpu_user;
unsigned long cpu_system;
- unsigned long cpu_user_counter;
- unsigned long cpu_system_counter;
+ derive_t cpu_user_counter;
+ derive_t cpu_system_counter;
/* io data */
derive_t io_rchar;
unsigned long vmem_code;
unsigned long stack_size;
- unsigned long vmem_minflt_counter;
- unsigned long vmem_majflt_counter;
+ derive_t vmem_minflt_counter;
+ derive_t vmem_majflt_counter;
- unsigned long cpu_user_counter;
- unsigned long cpu_system_counter;
+ derive_t cpu_user_counter;
+ derive_t cpu_system_counter;
/* io data */
derive_t io_rchar;
plugin_dispatch_values (&vl);
sstrncpy (vl.type, "ps_cputime", sizeof (vl.type));
- vl.values[0].counter = ps->cpu_user_counter;
- vl.values[1].counter = ps->cpu_system_counter;
+ vl.values[0].derive = ps->cpu_user_counter;
+ vl.values[1].derive = ps->cpu_system_counter;
vl.values_len = 2;
plugin_dispatch_values (&vl);
plugin_dispatch_values (&vl);
sstrncpy (vl.type, "ps_pagefaults", sizeof (vl.type));
- vl.values[0].counter = ps->vmem_minflt_counter;
- vl.values[1].counter = ps->vmem_majflt_counter;
+ vl.values[0].derive = ps->vmem_minflt_counter;
+ vl.values[1].derive = ps->vmem_majflt_counter;
vl.values_len = 2;
plugin_dispatch_values (&vl);
DEBUG ("name = %s; num_proc = %lu; num_lwp = %lu; "
"vmem_size = %lu; vmem_rss = %lu; vmem_data = %lu; "
"vmem_code = %lu; "
- "vmem_minflt_counter = %lu; vmem_majflt_counter = %lu; "
- "cpu_user_counter = %lu; cpu_system_counter = %lu; "
+ "vmem_minflt_counter = %"PRIi64"; vmem_majflt_counter = %"PRIi64"; "
+ "cpu_user_counter = %"PRIi64"; cpu_system_counter = %"PRIi64"; "
"io_rchar = %"PRIi64"; io_wchar = %"PRIi64"; "
"io_syscr = %"PRIi64"; io_syscw = %"PRIi64";",
ps->name, ps->num_proc, ps->num_lwp,
int ppid;
int name_len;
- long long unsigned cpu_user_counter;
- long long unsigned cpu_system_counter;
+ derive_t cpu_user_counter;
+ derive_t cpu_system_counter;
long long unsigned vmem_size;
long long unsigned vmem_rss;
long long unsigned stack_size;
cpu_system_counter = atoll (fields[14]);
vmem_size = atoll (fields[22]);
vmem_rss = atoll (fields[23]);
- ps->vmem_minflt_counter = atol (fields[9]);
- ps->vmem_majflt_counter = atol (fields[11]);
+ ps->vmem_minflt_counter = atoll (fields[9]);
+ ps->vmem_majflt_counter = atoll (fields[11]);
{
unsigned long long stack_start = atoll (fields[27]);
DEBUG("ps_read_process: did not get vmem data for pid %i",pid);
}
- ps->cpu_user_counter = (unsigned long) cpu_user_counter;
- ps->cpu_system_counter = (unsigned long) cpu_system_counter;
+ ps->cpu_user_counter = cpu_user_counter;
+ ps->cpu_system_counter = cpu_system_counter;
ps->vmem_size = (unsigned long) vmem_size;
ps->vmem_rss = (unsigned long) vmem_rss;
ps->stack_size = (unsigned long) stack_size;
diff --git a/src/serial.c b/src/serial.c
index cfa26bbd120b268cefea5d90669bd58917d3bb82..9bd885dbbf0bec28aeacbe8ae06624a06bf0a98e 100644 (file)
--- a/src/serial.c
+++ b/src/serial.c
#endif
static void serial_submit (const char *type_instance,
- counter_t rx, counter_t tx)
+ derive_t rx, derive_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
vl.values = values;
vl.values_len = 2;
FILE *fh;
char buffer[1024];
- counter_t rx = 0;
- counter_t tx = 0;
+ derive_t rx = 0;
+ derive_t tx = 0;
char *fields[16];
int i, numfields;
diff --git a/src/vmem.c b/src/vmem.c
index d32f1db8cf42e9b2e155db93f0bf32df89f51e39..56997bf14f54f0a812a3cdb7c5cc17b4b867b517 100644 (file)
--- a/src/vmem.c
+++ b/src/vmem.c
/**
* collectd - src/vmem.c
- * Copyright (C) 2008 Florian octo Forster
+ * Copyright (C) 2008-2010 Florian octo Forster
*
* 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
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
**/
#include "collectd.h"
} /* void vmem_submit */
static void submit_two (const char *plugin_instance, const char *type,
- const char *type_instance, counter_t c0, counter_t c1)
+ const char *type_instance, derive_t c0, derive_t c1)
{
value_t values[2];
- values[0].counter = c0;
- values[1].counter = c1;
+ values[0].derive = c0;
+ values[1].derive = c1;
submit (plugin_instance, type, type_instance, values, 2);
} /* void submit_one */
static int vmem_read (void)
{
#if KERNEL_LINUX
- counter_t pgpgin = 0;
- counter_t pgpgout = 0;
+ derive_t pgpgin = 0;
+ derive_t pgpgout = 0;
int pgpgvalid = 0;
- counter_t pswpin = 0;
- counter_t pswpout = 0;
+ derive_t pswpin = 0;
+ derive_t pswpout = 0;
int pswpvalid = 0;
- counter_t pgfault = 0;
- counter_t pgmajfault = 0;
+ derive_t pgfault = 0;
+ derive_t pgmajfault = 0;
int pgfaultvalid = 0;
FILE *fh;
int fields_num;
char *key;
char *endptr;
- counter_t counter;
+ derive_t counter;
gauge_t gauge;
fields_num = strsplit (buffer, fields, STATIC_ARRAY_SIZE (fields));
else if (strncmp ("pgalloc_", key, strlen ("pgalloc_")) == 0)
{
char *inst = key + strlen ("pgalloc_");
- value_t value = { .counter = counter };
+ value_t value = { .derive = counter };
submit_one (inst, "vmpage_action", "alloc", value);
}
else if (strncmp ("pgrefill_", key, strlen ("pgrefill_")) == 0)
{
char *inst = key + strlen ("pgrefill_");
- value_t value = { .counter = counter };
+ value_t value = { .derive = counter };
submit_one (inst, "vmpage_action", "refill", value);
}
else if (strncmp ("pgsteal_", key, strlen ("pgsteal_")) == 0)
{
char *inst = key + strlen ("pgsteal_");
- value_t value = { .counter = counter };
+ value_t value = { .derive = counter };
submit_one (inst, "vmpage_action", "steal", value);
}
else if (strncmp ("pgscan_kswapd_", key, strlen ("pgscan_kswapd_")) == 0)
{
char *inst = key + strlen ("pgscan_kswapd_");
- value_t value = { .counter = counter };
+ value_t value = { .derive = counter };
submit_one (inst, "vmpage_action", "scan_kswapd", value);
}
else if (strncmp ("pgscan_direct_", key, strlen ("pgscan_direct_")) == 0)
{
char *inst = key + strlen ("pgscan_direct_");
- value_t value = { .counter = counter };
+ value_t value = { .derive = counter };
submit_one (inst, "vmpage_action", "scan_direct", value);
}
*/
else if (strcmp ("pgfree", key) == 0)
{
- value_t value = { .counter = counter };
+ value_t value = { .derive = counter };
submit_one (NULL, "vmpage_action", "free", value);
}
else if (strcmp ("pgactivate", key) == 0)
{
- value_t value = { .counter = counter };
+ value_t value = { .derive = counter };
submit_one (NULL, "vmpage_action", "activate", value);
}
else if (strcmp ("pgdeactivate", key) == 0)
{
- value_t value = { .counter = counter };
+ value_t value = { .derive = counter };
submit_one (NULL, "vmpage_action", "deactivate", value);
}
} /* while (fgets) */
diff --git a/src/vserver.c b/src/vserver.c
index 1615ca04a1fc1bdbb2c22650e4397f49f80ee552..d80717cd3349e6a684e977375604209e7d05b775 100644 (file)
--- a/src/vserver.c
+++ b/src/vserver.c
/**
* collectd - src/vserver.c
* Copyright (C) 2006,2007 Sebastian Harl
- * Copyright (C) 2007,2008 Florian octo Forster
+ * Copyright (C) 2007-2010 Florian octo Forster
*
* 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
} /* static void vserver_init(void) */
static void traffic_submit (const char *plugin_instance,
- const char *type_instance, counter_t rx, counter_t tx)
+ const char *type_instance, derive_t rx, derive_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
plugin_dispatch_values (&vl);
} /* void submit_gauge */
-static inline long long __get_sock_bytes(const char *s)
+static derive_t vserver_get_sock_bytes(const char *s)
{
+ value_t v;
+ int status;
+
while (s[0] != '/')
++s;
/* Remove '/' */
++s;
- return atoll(s);
+
+ status = parse_value (s, &v, DS_TYPE_DERIVE);
+ if (status != 0)
+ return (-1);
+ return (v.derive);
}
static int vserver_read (void)
while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh)))
{
- counter_t rx;
- counter_t tx;
+ derive_t rx;
+ derive_t tx;
char *type_instance;
if (strsplit (buffer, cols, 4) < 4)
else
continue;
- rx = __get_sock_bytes (cols[1]);
- tx = __get_sock_bytes (cols[2]);
+ rx = vserver_get_sock_bytes (cols[1]);
+ tx = vserver_get_sock_bytes (cols[2]);
/* cols[3] == errors */
traffic_submit (dent->d_name, type_instance, rx, tx);