summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7a12fd2)
raw | patch | inline | side by side (parent: 7a12fd2)
author | Florian Forster <octo@huhu.verplant.org> | |
Wed, 13 May 2009 16:17:35 +0000 (18:17 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 13 May 2009 16:17:35 +0000 (18:17 +0200) |
src/olsrd.c | patch | blob | history | |
src/types.db | patch | blob | history |
diff --git a/src/olsrd.c b/src/olsrd.c
index 8b73214dfb1c3e767de8c7e995587e9913e9acc1..123520a47b288e85fe14b2ce5f69a6ae0159363d 100644 (file)
--- a/src/olsrd.c
+++ b/src/olsrd.c
return (fh);
} /* }}} FILE *olsrd_connect */
+__attribute__ ((nonnull(2)))
+static void olsrd_submit (const char *plugin_instance, /* {{{ */
+ const char *type, const char *type_instance, gauge_t value)
+{
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ values[0].gauge = value;
+
+ vl.values = values;
+ vl.values_len = 1;
+
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "olsrd", sizeof (vl.plugin));
+ if (plugin_instance != NULL)
+ sstrncpy (vl.plugin_instance, plugin_instance,
+ sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ if (type_instance != NULL)
+ sstrncpy (vl.type_instance, type_instance,
+ sizeof (vl.type_instance));
+
+ plugin_dispatch_values (&vl);
+} /* }}} void olsrd_submit */
+
static int olsrd_cb_ignore (int lineno, /* {{{ */
size_t fields_num, char **fields)
{
static double nlq_sum;
static uint32_t nlq_num;
- char link_name[DATA_MAX_NAME_LEN];
double lq; /* tx */
double nlq; /* rx */
/* Special handling of the last line. */
if (fields_num == 0)
{
- DEBUG ("olsrd plugin: fields_num = %"PRIu32";", links_num);
+ DEBUG ("olsrd plugin: Number of links: %"PRIu32, links_num);
+ olsrd_submit (/* p.-inst = */ "links", /* type = */ "links",
+ /* t.-inst = */ NULL, (gauge_t) links_num);
lq = NAN;
if (lq_num > 0)
lq = lq_sum / ((double) lq_num);
DEBUG ("olsrd plugin: Average LQ: %g", lq);
+ olsrd_submit (/* p.-inst = */ "links", /* type = */ "signal_quality",
+ "average-tx", lq);
nlq = NAN;
if (nlq_num > 0)
nlq = nlq_sum / ((double) nlq_num);
DEBUG ("olsrd plugin: Average NLQ: %g", nlq);
+ olsrd_submit (/* p.-inst = */ "links", /* type = */ "signal_quality",
+ "average-rx", nlq);
return (0);
}
links_num++;
- memset (link_name, 0, sizeof (link_name));
- ssnprintf (link_name, sizeof (link_name), "%s-%s", fields[0], fields[1]);
-
errno = 0;
endptr = NULL;
lq = strtod (fields[3], &endptr);
if (config_want_links == OLSRD_WANT_DETAIL)
{
- DEBUG ("olsrd plugin: %s: LQ = %g.", link_name, lq);
+ char type_instance[DATA_MAX_NAME_LEN];
+
+ ssnprintf (type_instance, sizeof (type_instance), "%s-%s-tx",
+ fields[0], fields[1]);
+
+ DEBUG ("olsrd plugin: links: type_instance = %s; lq = %g;",
+ type_instance, lq);
+ olsrd_submit (/* p.-inst = */ "links", /* type = */ "signal_quality",
+ type_instance, lq);
}
}
if (config_want_links == OLSRD_WANT_DETAIL)
{
- DEBUG ("olsrd plugin: %s: NLQ = %g.", link_name, lq);
+ char type_instance[DATA_MAX_NAME_LEN];
+
+ ssnprintf (type_instance, sizeof (type_instance), "%s-%s-rx",
+ fields[0], fields[1]);
+
+ DEBUG ("olsrd plugin: links: type_instance = %s; nlq = %g;",
+ type_instance, lq);
+ olsrd_submit (/* p.-inst = */ "links", /* type = */ "signal_quality",
+ type_instance, nlq);
}
}
* 3 = ETX
* 4 = Interface */
+ static uint32_t routes_num;
static uint32_t metric_sum;
static uint32_t metric_num;
-
static double etx_sum;
static uint32_t etx_num;
/* Special handling of the first line */
if (lineno <= 0)
{
+ routes_num = 0;
metric_num = 0;
metric_sum = 0;
+ etx_sum = 0.0;
+ etx_num = 0;
+
return (0);
}
{
double metric_avg;
+ DEBUG ("olsrd plugin: Number of routes: %"PRIu32, routes_num);
+ olsrd_submit (/* p.-inst = */ "routes", /* type = */ "routes",
+ /* t.-inst = */ NULL, (gauge_t) routes_num);
+
metric_avg = NAN;
if (metric_num > 0)
metric_avg = ((double) metric_sum) / ((double) metric_num);
+ DEBUG ("olsrd plugin: Average metric: %g", metric_avg);
+ olsrd_submit (/* p.-inst = */ "routes", /* type = */ "route_metric",
+ "average", metric_avg);
etx = NAN;
if (etx_num > 0)
etx = etx_sum / ((double) etx_sum);
+ DEBUG ("olsrd plugin: Average ETX: %g", etx);
+ olsrd_submit (/* p.-inst = */ "routes", /* type = */ "route_etx",
+ "average", etx);
- DEBUG ("olsrd plugin: Number of routes: %"PRIu32"; Average metric: %g",
- metric_num, metric_avg);
return (0);
}
if (fields_num != 5)
return (-1);
+ routes_num++;
+
errno = 0;
endptr = NULL;
metric = (uint32_t) strtoul (fields[2], &endptr, 0);
if (config_want_routes == OLSRD_WANT_DETAIL)
{
- DEBUG ("olsrd plugin: Route with metric %"PRIu32".", metric);
+ DEBUG ("olsrd plugin: destination = %s; metric = %"PRIu32";",
+ fields[0], metric);
+ olsrd_submit (/* p.-inst = */ "routes", /* type = */ "route_metric",
+ /* t.-inst = */ fields[0], (gauge_t) metric);
}
}
if (config_want_routes == OLSRD_WANT_DETAIL)
{
- DEBUG ("olsrd plugin: Route with ETX %g.", etx);
+ DEBUG ("olsrd plugin: destination = %s; etx = %g;",
+ fields[0], etx);
+ olsrd_submit (/* p.-inst = */ "routes", /* type = */ "route_etx",
+ /* t.-inst = */ fields[0], etx);
}
}
static uint32_t links_num;
- char link_name[DATA_MAX_NAME_LEN];
double lq;
char *endptr;
/* Special handling after the last line */
if (fields_num == 0)
{
+ DEBUG ("olsrd plugin: topology: Number of links: %"PRIu32, links_num);
+ olsrd_submit (/* p.-inst = */ "topology", /* type = */ "links",
+ /* t.-inst = */ NULL, (gauge_t) links_num);
+
lq = NAN;
if (lq_num > 0)
lq = lq_sum / ((double) lq_sum);
-
- DEBUG ("olsrd plugin: Number of links: %"PRIu32, links_num);
- DEBUG ("olsrd plugin: Average link quality: %g", lq);
+ DEBUG ("olsrd plugin: topology: Average link quality: %g", lq);
+ olsrd_submit (/* p.-inst = */ "topology", /* type = */ "signal_quality",
+ /* t.-inst = */ "average", lq);
return (0);
}
if (fields_num != 5)
return (-1);
- memset (link_name, 0, sizeof (link_name));
- ssnprintf (link_name, sizeof (link_name), "%s-%s", fields[0], fields[1]);
links_num++;
errno = 0;
if (config_want_topology == OLSRD_WANT_DETAIL)
{
- DEBUG ("olsrd plugin: link_name = %s; lq = %g;", link_name, lq);
+ char type_instance[DATA_MAX_NAME_LEN];
+
+ memset (type_instance, 0, sizeof (type_instance));
+ ssnprintf (type_instance, sizeof (type_instance), "%s-%s-rx",
+ fields[0], fields[1]);
+ DEBUG ("olsrd plugin: type_instance = %s; lq = %g;", type_instance, lq);
+ olsrd_submit (/* p.-inst = */ "topology", /* type = */ "signal_quality",
+ type_instance, lq);
}
}
}
else
{
- DEBUG ("olsrd plugin: link_name = %s; nlq = %g;", link_name, nlq);
+ char type_instance[DATA_MAX_NAME_LEN];
+
+ memset (type_instance, 0, sizeof (type_instance));
+ ssnprintf (type_instance, sizeof (type_instance), "%s-%s-tx",
+ fields[0], fields[1]);
+ DEBUG ("olsrd plugin: type_instance = %s; nlq = %g;", type_instance, nlq);
+ olsrd_submit (/* p.-inst = */ "topology", /* type = */ "signal_quality",
+ type_instance, nlq);
}
}
diff --git a/src/types.db b/src/types.db
index 6ebc20d0dfc140c4e76db0e61e0fb59a571726c8..ad9de7ed8f9d93d77c042e8abaf6f32ddc80b6d0 100644 (file)
--- a/src/types.db
+++ b/src/types.db
ipt_packets value:COUNTER:0:134217728
irq value:COUNTER:U:65535
latency value:GAUGE:0:65535
+links value:GAUGE:0:U
load shortterm:GAUGE:0:100, midterm:GAUGE:0:100, longterm:GAUGE:0:100
memcached_command value:COUNTER:0:U
memcached_connections value:GAUGE:0:U
ps_state value:GAUGE:0:65535
ps_vm value:GAUGE:0:9223372036854775807
queue_length value:GAUGE:0:U
+route_etx value:GAUGE:0:U
+route_metric value:GAUGE:0:U
+routes value:GAUGE:0:U
serial_octets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
signal_noise value:GAUGE:U:0
signal_power value:GAUGE:U:0