Merge branch 'collectd-4.4'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 10 Jun 2008 15:10:05 +0000 (17:10 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 10 Jun 2008 15:10:05 +0000 (17:10 +0200)
configure.in
src/collectd.h
src/disk.c
src/network.c
src/plugin.h
src/wireless.c

index 13228c1..b1b259b 100644 (file)
@@ -57,7 +57,7 @@ AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
 AC_HEADER_DIRENT
 
-AC_CHECK_HEADERS(stdint.h stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h)
+AC_CHECK_HEADERS(stdint.h stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h)
 
 # For ping library
 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
index 55aac16..0ccf533 100644 (file)
 # endif /* !defined(isnan) */
 #endif /* NAN_ZERO_ZERO */
 
+/* Try really, really hard to determine endianess. Under NexentaStor 1.0.2 this
+ * information is in <sys/isa_defs.h>, possibly some other Solaris versions do
+ * this too.. */
 #if HAVE_ENDIAN_H
 # include <endian.h>
+#elif HAVE_SYS_ISA_DEFS_H
+# include <sys/isa_defs.h>
 #endif
 
 #ifndef BYTE_ORDER
 #  define BIG_ENDIAN __BIG_ENDIAN
 # endif
 #endif
+#ifndef LITTLE_ENDIAN
+# if defined(_LITTLE_ENDIAN)
+#  define LITTLE_ENDIAN _LITTLE_ENDIAN
+# elif defined(__LITTLE_ENDIAN)
+#  define LITTLE_ENDIAN __LITTLE_ENDIAN
+# endif
+#endif
+#ifndef BYTE_ORDER
+# if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
+#  undef BIG_ENDIAN
+#  define BIG_ENDIAN 4321
+#  define LITTLE_ENDIAN 1234
+#  define BYTE_ORDER BIG_ENDIAN
+# elif !defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
+#  undef LITTLE_ENDIAN
+#  define BIG_ENDIAN 4321
+#  define LITTLE_ENDIAN 1234
+#  define BYTE_ORDER LITTLE_ENDIAN
+# endif
+#endif
 #if !defined(BYTE_ORDER) || !defined(BIG_ENDIAN)
 # error "Cannot determine byte order"
 #endif
 
 #define STATIC_ARRAY_LEN(array) (sizeof (array) / sizeof ((array)[0]))
 
+/* Remove GNU specific __attribute__ settings when using another compiler */
+#if !__GNUC__
+# define __attribute__(x) /**/
+#endif
+
 extern char hostname_g[];
 extern int  interval_g;
 
index c5a0cc8..a6f850a 100644 (file)
@@ -454,7 +454,7 @@ static int disk_read (void)
                major = atoll (fields[0]);
                minor = atoll (fields[1]);
 
-               disk_name = fields[2];
+               disk_name = fields[2 + fieldshift];
 
                for (ds = disklist, pre_ds = disklist; ds != NULL; pre_ds = ds, ds = ds->next)
                        if (strcmp (disk_name, ds->name) == 0)
index 6be7a09..b6778fa 100644 (file)
@@ -183,7 +183,7 @@ static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static c_avl_tree_t      *cache_tree = NULL;
 static pthread_mutex_t  cache_lock = PTHREAD_MUTEX_INITIALIZER;
-static time_t           cache_flush_last;
+static time_t           cache_flush_last = 0;
 static int              cache_flush_interval = 1800;
 
 /*
@@ -1704,11 +1704,19 @@ static int network_shutdown (void)
        plugin_unregister_write ("network");
        plugin_unregister_shutdown ("network");
 
+       /* Let the init function do it's move again ;) */
+       cache_flush_last = 0;
+
        return (0);
 } /* int network_shutdown */
 
 static int network_init (void)
 {
+       /* Check if we were already initialized. If so, just return - there's
+        * nothing more to do (for now, that is). */
+       if (cache_flush_last != 0)
+               return (0);
+
        plugin_register_shutdown ("network", network_shutdown);
 
        send_buffer_ptr  = send_buffer;
index ac389c6..e2de6ff 100644 (file)
@@ -213,7 +213,9 @@ int plugin_dispatch_values (value_list_t *vl);
 
 int plugin_dispatch_notification (const notification_t *notif);
 
-void plugin_log (int level, const char *format, ...);
+void plugin_log (int level, const char *format, ...)
+       __attribute__ ((format(printf,2,3)));
+
 #define ERROR(...)   plugin_log (LOG_ERR,     __VA_ARGS__)
 #define WARNING(...) plugin_log (LOG_WARNING, __VA_ARGS__)
 #define NOTICE(...)  plugin_log (LOG_NOTICE,  __VA_ARGS__)
index 1282b48..a0644fe 100644 (file)
@@ -129,7 +129,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 */
@@ -138,7 +140,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);