From e8c6efb8bf77e835c28ff2c14f13aecbb73e3e28 Mon Sep 17 00:00:00 2001 From: JoW Date: Mon, 9 Jun 2008 13:27:16 +0200 Subject: [PATCH] wireless plugins: Interpret noise/power values >100 as (dBm + 256). Hi list, I currently develop an embedded statistics application and web interface for OpenWrt Kamikaze based on Collectd and RRDTool. While working with the wireless plugin I noticed some incompatibilities with different drivers, namely the Broadcom proprietary driver and madwifi. /proc/net/wireless on Broadcom: Inter-| sta-| Quality | Discarded packets | Missed | WE face | tus | link level noise | nwid crypt frag retry misc | beacon | 18 wl0: 0000 2. 179. 163. 0 0 8040 723 0 0 With the Broadcom proprietary driver you get the actual signal and noise dbm units by substracting 255 from the values in /proc: level: 179 - 255 = -76 dBm noise: 163 - 255 = -92 dBm /proc/net/wireless on Atheros SoC: Inter-| sta-| Quality | Discarded packets | Missed | WE face | tus | link level noise | nwid crypt frag retry misc | beacon | 22 ath0: 0004 21. -73. -94. 21841 0 0 0 0 0 Madwifi writes the actual dBm values into /proc. So we have (at least for now) three possible types of values: ( x > 0.0 && x <= 100.0 ) current implementation: x is in percent (?) ( x > 100.0 && x <= 255.0 ) broadcom: range intersects with percents but values below 100.0 (100.0 - 255.0 = -155.0 dBm) are somewhat unlikely to occur ( x < 0.0 ) atheros: value is already in dBm A patch which implements the two additional possibilities in collectd's wireless plugin can be found in the OpenWrt Trac: https://dev.openwrt.org/browser/packages/utils/collectd/patches/200-wireless-compat.patch The patch was made against v4.4.0 of collectd but should work with v4.4.1 too. It would be nice to have this in the next release or so :) Greetings, JoW --- src/wireless.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wireless.c b/src/wireless.c index 285fb744..fdea9d3b 100644 --- a/src/wireless.c +++ b/src/wireless.c @@ -128,7 +128,9 @@ static int wireless_read (void) power = 1.0; /* invalid */ else if ((power >= 0.0) && (power <= 100.0)) power = wireless_percent_to_power (power); - else if (power > 100.0) + else if ((power > 100.0) && (power <= 256.0)) + power = power - 256.0; + else if (power > 0.0) power = 1.0; /* invalid */ /* noise [dBm] < 0.0 */ @@ -137,7 +139,9 @@ static int wireless_read (void) noise = 1.0; /* invalid */ else if ((noise >= 0.0) && (noise <= 100.0)) noise = wireless_percent_to_power (noise); - else if (noise > 100.0) + else if ((noise > 100.0) && (noise <= 256.0)) + noise = noise - 256.0; + else if (noise > 0.0) noise = 1.0; /* invalid */ wireless_submit (device, "signal_quality", quality); -- 2.11.0