svn merge -r523:547 branches/config-step trunk
authorocto <octo>
Tue, 21 Mar 2006 13:26:41 +0000 (13:26 +0000)
committerocto <octo>
Tue, 21 Mar 2006 13:26:41 +0000 (13:26 +0000)
1  2 
configure.in
src/ping.c
src/vserver.c
src/wireless.c

diff --combined configure.in
@@@ -35,6 -35,7 +35,7 @@@ AC_HEADER_SYS_WAI
  AC_HEADER_DIRENT
  AC_CHECK_HEADERS(stdint.h)
  AC_CHECK_HEADERS(errno.h)
+ AC_CHECK_HEADERS(math.h)
  AC_CHECK_HEADERS(syslog.h)
  AC_CHECK_HEADERS(fcntl.h)
  AC_CHECK_HEADERS(signal.h)
@@@ -142,9 -143,6 +143,9 @@@ AC_CHECK_HEADERS(sys/loadavg.h
  AC_CHECK_HEADERS(utmp.h)
  AC_CHECK_HEADERS(utmpx.h)
  
 +# For apache plugin
 +AC_CHECK_HEADERS(curl/curl.h)
 +
  # For quota module
  AC_CHECK_HEADERS(grp.h pwd.h sys/ucred.h)
  AC_CHECK_HEADERS(ctype.h)
@@@ -311,24 -309,6 +312,24 @@@ AC_CHECK_LIB(resolv, res_search
  [with_libresolv="no"])
  AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
  
 +with_libcurl="yes"
 +AC_CHECK_LIB(curl, curl_easy_init,
 +[
 +      AC_DEFINE(HAVE_LIBCURL, 1, [Define to 1 if you have the 'curl' library (-lcurl).])
 +],
 +[with_libcurl="no"])
 +AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
 +
 +if test "x$with_libcurl" = "xyes"
 +then
 +      with_libcurl_libs=`curl-config --libs`
 +      if test "x$with_libcurl_libs" != "x"
 +      then
 +              BUILD_WITH_LIBCURL_LIBS="$with_libcurl_libs";
 +              AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
 +      fi
 +fi
 +
  m4_divert_once([HELP_WITH], [
  collectd additional packages:])
  
@@@ -530,6 -510,42 +531,42 @@@ AC_DEFINE_UNQUOTED(COLLECT_LIBMYSQL, [$
        [Wether or not to use mysql library])
  AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
  
+ # Define `step' and `hearbeat' values..
+ declare -i collectd_step=10
+ declare -i collectd_heartbeat=25
+ AC_ARG_WITH(step, [AS_HELP_STRING([--with-step=SECONDS], [Interval in which plugins are queried.])],
+ [
+       if test "x$withval" != "xno" -a "x$withval" != "xyes"
+       then
+               declare -i tmp_collectd_step="$withval"
+               if test $tmp_collectd_step -gt 0
+               then
+                       collectd_step=$tmp_collectd_step
+                       let "collectd_heartbeat=$collectd_step*2"
+               fi
+       fi
+ ], [])
+ AC_ARG_WITH(heartbeat, [AS_HELP_STRING([--with-heartbeat=SECONDS], [Heartbeat of the DS in generated RRD files.])],
+ [
+       if test "x$withval" != "xno" -a "x$withval" != "xyes"
+       then
+               declare -i tmp_collectd_heartbeat="$withval"
+               if test $tmp_collectd_heartbeat -gt 0
+               then
+                       collectd_heartbeat=$tmp_collectd_heartbeat
+               fi
+       fi
+ ], [])
+ if test $collectd_step -ne 10
+ then
+       AC_DEFINE_UNQUOTED(COLLECTD_STEP, "$collectd_step", [Interval in which plugins are queried.])
+ fi
+ if test $collectd_heartbeat -ne 25
+ then
+       AC_DEFINE_UNQUOTED(COLLECTD_HEARTBEAT, "$collectd_heartbeat", [Interval in which plugins are queried.])
+ fi
  #
  # Check for enabled/disabled features
  #
@@@ -601,7 -617,6 +638,7 @@@ AC_COLLECTD([daemon],    [disable], [fe
  
  m4_divert_once([HELP_ENABLE], [
  collectd modules:])
 +AC_COLLECTD([apache],    [disable], [module], [Apache httpd statistics])
  AC_COLLECTD([battery],   [disable], [module], [battery statistics])
  AC_COLLECTD([cpu],       [disable], [module], [cpu usage statistics])
  AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
@@@ -846,7 -861,6 +883,7 @@@ cat <<EOF
  
  Configuration:
    Libraries:
 +    libcurl . . . . . . $with_libcurl
      librrd  . . . . . . $with_rrdtool
      lm_sensors  . . . . $with_lm_sensors
      libstatgrab . . . . $with_libstatgrab
    Features:
      debug . . . . . . . $enable_debug
      daemon mode . . . . $enable_daemon
+     step  . . . . . . . $collectd_step seconds
+     heartbeat . . . . . $collectd_heartbeat seconds
  
    Modules:
      battery . . . . . . $enable_battery
diff --combined src/ping.c
@@@ -37,7 -37,7 +37,7 @@@ static char *file_template = "ping-%s.r
  
  static char *ds_def[] = 
  {
-       "DS:ping:GAUGE:25:0:65535",
+       "DS:ping:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
        NULL
  };
  static int ds_num = 1;
@@@ -72,7 -72,8 +72,7 @@@ static int ping_config (char *key, cha
  
        if (ping_host_add (pingobj, value) < 0)
        {
 -              syslog (LOG_ERR, "ping: `ping_host_add' failed.\n");
 -              return (-1);
 +              syslog (LOG_WARNING, "ping: `ping_host_add' failed.\n");
        }
  
        return (0);
diff --combined src/vserver.c
@@@ -49,7 -49,7 +49,7 @@@ static char *rrd_inet6        = "vserver-%s/tr
  static char *rrd_other        = "vserver-%s/traffic-other.rrd";
  static char *rrd_unspec       = "vserver-%s/traffic-unspec.rrd";
  
 -static char *rrd_thread       = "vserver-%s/threads.rrd";
 +static char *rrd_thread       = "vserver-%s/vs_threads.rrd";
  
  static char *rrd_load = "vserver-%s/load.rrd";
  
@@@ -60,71 -60,71 +60,71 @@@ static char *rrd_memory    = "vserver-%s/v
  /* bytes transferred */
  static char *ds_def_unix[] =
  {
-       "DS:incoming:COUNTER:25:0:9223372036854775807",
-       "DS:outgoing:COUNTER:25:0:9223372036854775807",
-       "DS:failed:COUNTER:25:0:9223372036854775807",
+       "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
        NULL
  };
  static int ds_num_unix = 3;
  
  static char *ds_def_inet[] =
  {
-       "DS:incoming:COUNTER:25:0:9223372036854775807",
-       "DS:outgoing:COUNTER:25:0:9223372036854775807",
-       "DS:failed:COUNTER:25:0:9223372036854775807",
+       "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
        NULL
  };
  static int ds_num_inet = 3;
  
  static char *ds_def_inet6[] =
  {
-       "DS:incoming:COUNTER:25:0:9223372036854775807",
-       "DS:outgoing:COUNTER:25:0:9223372036854775807",
-       "DS:failed:COUNTER:25:0:9223372036854775807",
+       "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
        NULL
  };
  static int ds_num_inet6 = 3;
  
  static char *ds_def_other[] =
  {
-       "DS:incoming:COUNTER:25:0:9223372036854775807",
-       "DS:outgoing:COUNTER:25:0:9223372036854775807",
-       "DS:failed:COUNTER:25:0:9223372036854775807",
+       "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
        NULL
  };
  static int ds_num_other = 3;
  
  static char *ds_def_unspec[] =
  {
-       "DS:incoming:COUNTER:25:0:9223372036854775807",
-       "DS:outgoing:COUNTER:25:0:9223372036854775807",
-       "DS:failed:COUNTER:25:0:9223372036854775807",
+       "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807",
        NULL
  };
  static int ds_num_unspec = 3;
  
  static char *ds_def_threads[] =
  {
-       "DS:total:GAUGE:25:0:65535",
-       "DS:running:GAUGE:25:0:65535",
-       "DS:uninterruptible:GAUGE:25:0:65535",
-       "DS:onhold:GAUGE:25:0:65535",
+       "DS:total:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
+       "DS:running:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
+       "DS:uninterruptible:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
+       "DS:onhold:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
        NULL
  };
  static int ds_num_threads = 4;
  
  static char *ds_def_load[] =
  {
-       "DS:shortterm:GAUGE:25:0:100",
-       "DS:midterm:GAUGE:25:0:100",
-       "DS:longterm:GAUGE:25:0:100",
+       "DS:shortterm:GAUGE:"COLLECTD_HEARTBEAT":0:100",
+       "DS:midterm:GAUGE:"COLLECTD_HEARTBEAT":0:100",
+       "DS:longterm:GAUGE:"COLLECTD_HEARTBEAT":0:100",
        NULL
  };
  static int ds_num_load = 3;
  
  static char *ds_def_procs[] =
  {
-       "DS:total:GAUGE:25:0:65535",
+       "DS:total:GAUGE:"COLLECTD_HEARTBEAT":0:65535",
        NULL
  };
  static int ds_num_procs = 1;
  /* bytes */
  static char *ds_def_memory[] =
  {
-       "DS:vm:GAUGE:25:0:9223372036854775807",
-       "DS:vml:GAUGE:25:0:9223372036854775807",
-       "DS:rss:GAUGE:25:0:9223372036854775807",
-       "DS:anon:GAUGE:25:0:9223372036854775807",
+       "DS:vm:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:vml:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:rss:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807",
+       "DS:anon:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807",
        NULL
  };
  static int ds_num_memory = 4;
diff --combined src/wireless.c
@@@ -24,6 -24,8 +24,6 @@@
  #include "common.h"
  #include "plugin.h"
  
 -#include <math.h>
 -
  #define MODULE_NAME "wireless"
  #define BUFSIZE 1024
  
@@@ -39,9 -41,9 +39,9 @@@ static char *filename_template = "wirel
  
  static char *ds_def[] =
  {
-       "DS:quality:GAUGE:25:0:U",
-       "DS:power:GAUGE:25:U:0",
-       "DS:noise:GAUGE:25:U:0",
+       "DS:quality:GAUGE:"COLLECTD_HEARTBEAT":0:U",
 -      "DS:power:GAUGE:"COLLECTD_HEARTBEAT":0:U",
 -      "DS:noise:GAUGE:"COLLECTD_HEARTBEAT":0:U",
++      "DS:power:GAUGE:"COLLECTD_HEARTBEAT":U:0",
++      "DS:noise:GAUGE:"COLLECTD_HEARTBEAT":U:0",
        NULL
  };
  static int ds_num = 3;
@@@ -77,7 -79,6 +77,7 @@@ static void wireless_write (char *host
  }
  
  #if WIRELESS_HAVE_READ
 +#if 0
  static double wireless_dbm_to_watt (double dbm)
  {
        double watt;
@@@ -91,7 -92,6 +91,7 @@@
  
        return (watt);
  }
 +#endif
  
  static void wireless_submit (char *device,
                double quality, double power, double noise)
@@@ -154,15 -154,18 +154,15 @@@ static void wireless_read (void
                power   = atof (fields[3]);
                noise   = atof (fields[4]);
  
 +              /* Fill in invalid values when conversion failed.. */
                if (quality == 0.0)
 -                      quality = -1.0;
 +                      quality = -1.0; /* quality >= 0 */
  
 -              if (power >= 0.0)
 -                      power = -1.0;
 -              else
 -                      power = wireless_dbm_to_watt (power);
 +              if (power == 0.0)
 +                      power = 1.0; /* power <= 0 */
  
 -              if (noise >= 0.0)
 -                      noise = -1.0;
 -              else
 -                      noise = wireless_dbm_to_watt (noise);
 +              if (noise == 0.0)
 +                      noise = 1.0; /* noise <= 0 */
  
                wireless_submit (device, quality, power, noise);
        }
  
  void module_register (void)
  {
 -   plugin_register (MODULE_NAME, wireless_init, wireless_read, wireless_write);
 +      plugin_register (MODULE_NAME, wireless_init, wireless_read, wireless_write);
  }
  
  #undef BUFSIZE