projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
contrib/php-collection: Add a PHP frontend for graph generation.
[collectd.git]
/
src
/
wireless.c
diff --git
a/src/wireless.c
b/src/wireless.c
index
1067549
..
0edaf45
100644
(file)
--- a/
src/wireless.c
+++ b/
src/wireless.c
@@
-23,15
+23,12
@@
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
-#if defined(KERNEL_LINUX)
-# define WIRELESS_HAVE_READ 1
-#else
-# define WIRELESS_HAVE_READ 0
+#if !KERNEL_LINUX
+# error "No applicable input method."
#endif
#define WIRELESS_PROC_FILE "/proc/net/wireless"
#endif
#define WIRELESS_PROC_FILE "/proc/net/wireless"
-#if WIRELESS_HAVE_READ
#if 0
static double wireless_dbm_to_watt (double dbm)
{
#if 0
static double wireless_dbm_to_watt (double dbm)
{
@@
-59,8
+56,8
@@
static void wireless_submit (const char *plugin_instance, const char *type,
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- s
trcpy (vl.host, hostname_g
);
- s
trcpy (vl.plugin, "wireless"
);
+ s
strncpy (vl.host, hostname_g, sizeof (vl.host)
);
+ s
strncpy (vl.plugin, "wireless", sizeof (vl.plugin)
);
strncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
strncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
@@
-131,16
+128,20
@@
static int wireless_read (void)
power = 1.0; /* invalid */
else if ((power >= 0.0) && (power <= 100.0))
power = wireless_percent_to_power (power);
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 */
power = 1.0; /* invalid */
/* noise [dBm] < 0.0 */
- noise = strtod (fields[
3
], &endptr);
- if (fields[
3
] == endptr)
+ noise = strtod (fields[
4
], &endptr);
+ if (fields[
4
] == endptr)
noise = 1.0; /* invalid */
else if ((noise >= 0.0) && (noise <= 100.0))
noise = wireless_percent_to_power (noise);
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);
noise = 1.0; /* invalid */
wireless_submit (device, "signal_quality", quality);
@@
-160,11
+161,8
@@
static int wireless_read (void)
return (0);
} /* int wireless_read */
return (0);
} /* int wireless_read */
-#endif /* WIRELESS_HAVE_READ */
void module_register (void)
{
void module_register (void)
{
-#if WIRELESS_HAVE_READ
plugin_register_read ("wireless", wireless_read);
plugin_register_read ("wireless", wireless_read);
-#endif /* WIRELESS_HAVE_READ */
} /* void module_register */
} /* void module_register */