summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f51548e)
raw | patch | inline | side by side (parent: f51548e)
author | Florian Forster <octo@huhu.verplant.org> | |
Sat, 28 Nov 2009 20:33:28 +0000 (21:33 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Sat, 28 Nov 2009 20:33:28 +0000 (21:33 +0100) |
src/routeros.c | patch | blob | history | |
src/types.db | patch | blob | history |
diff --git a/src/routeros.c b/src/routeros.c
index 3e5e6680e6031df93d22d90aa7c0e97b90f1a971..93c281272570b14435bea7ce42d2b3b4a1ad6c87 100644 (file)
--- a/src/routeros.c
+++ b/src/routeros.c
return (0);
} /* }}} int handle_interface */
+static void cr_submit_gauge (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 = STATIC_ARRAY_SIZE (values);
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "routeros", sizeof (vl.plugin));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+
+ plugin_dispatch_values (&vl);
+} /* }}} void cr_submit_gauge */
+
+static void submit_regtable (const ros_registration_table_t *r) /* {{{ */
+{
+ char type_instance[DATA_MAX_NAME_LEN];
+
+ if (r == NULL)
+ return;
+
+ /*** RX ***/
+ ssnprintf (type_instance, sizeof (type_instance), "%s-%s-rx",
+ r->interface, r->radio_name);
+ cr_submit_gauge ("bitrate", type_instance,
+ (gauge_t) (1000000.0 * r->rx_rate));
+ cr_submit_gauge ("signal_power", type_instance,
+ (gauge_t) r->rx_signal_strength);
+ cr_submit_gauge ("signal_quality", type_instance,
+ (gauge_t) r->rx_ccq);
+
+ /*** TX ***/
+ ssnprintf (type_instance, sizeof (type_instance), "%s-%s-tx",
+ r->interface, r->radio_name);
+ cr_submit_gauge ("bitrate", type_instance,
+ (gauge_t) (1000000.0 * r->tx_rate));
+ cr_submit_gauge ("signal_power", type_instance,
+ (gauge_t) r->tx_signal_strength);
+ cr_submit_gauge ("signal_quality", type_instance,
+ (gauge_t) r->tx_ccq);
+
+ /*** RX / TX ***/
+ ssnprintf (type_instance, sizeof (type_instance), "%s-%s",
+ r->interface, r->radio_name);
+ cr_submit_io ("if_octets", type_instance,
+ (counter_t) r->rx_bytes, (counter_t) r->tx_bytes);
+ cr_submit_gauge ("snr", type_instance, (gauge_t) r->signal_to_noise);
+
+ submit_regtable (r->next);
+} /* }}} void submit_regtable */
+
+static int handle_regtable (__attribute__((unused)) ros_connection_t *c, /* {{{ */
+ const ros_registration_table_t *r,
+ __attribute__((unused)) void *user_data)
+{
+ submit_regtable (r);
+ return (0);
+} /* }}} int handle_regtable */
+
static int cr_read (void) /* {{{ */
{
int status;
}
assert (connection != NULL);
- status = ros_interface (connection, handle_interface, /* user data = */ NULL);
+ status = ros_interface (connection, handle_interface,
+ /* user data = */ NULL);
if (status != 0)
{
char errbuf[128];
return (-1);
}
+ status = ros_registration_table (connection, handle_regtable,
+ /* user data = */ NULL);
+ if (status != 0)
+ {
+ char errbuf[128];
+ ERROR ("routeros plugin: ros_registration_table failed: %s",
+ sstrerror (status, errbuf, sizeof (errbuf)));
+ ros_disconnect (connection);
+ connection = NULL;
+ return (-1);
+ }
+
return (0);
} /* }}} int cr_read */
diff --git a/src/types.db b/src/types.db
index c8c6b98aa7a73337a68252e73c0c33feb4727498..d8a39d64a53ee2ccd9ad2b7926cae887bdc6c32b 100644 (file)
--- a/src/types.db
+++ b/src/types.db
signal_noise value:GAUGE:U:0
signal_power value:GAUGE:U:0
signal_quality value:GAUGE:0:U
+snr value:GAUGE:0:U
spam_check value:GAUGE:0:U
spam_score value:GAUGE:U:U
swap_io value:DERIVE:0:1099511627776