Merge branch 'collectd-4.4'
authorFlorian Forster <octo@huhu.verplant.org>
Tue, 12 Aug 2008 09:31:40 +0000 (11:31 +0200)
committerFlorian Forster <octo@huhu.verplant.org>
Tue, 12 Aug 2008 09:31:40 +0000 (11:31 +0200)
15 files changed:
configure.in
contrib/collection3/bin/graph.cgi
contrib/collection3/bin/index.cgi
contrib/collection3/bin/json.cgi
contrib/collection3/etc/collection.conf [new file with mode: 0644]
contrib/collection3/etc/collection3.conf [deleted file]
contrib/collection3/lib/Collectd/Config.pm [new file with mode: 0644]
contrib/collection3/lib/Collectd/Graph/Type.pm
contrib/collection3/lib/Collectd/Graph/Type/GenericStacked.pm
contrib/collection3/lib/Collectd/Graph/TypeLoader.pm
contrib/collection3/share/navigate.js [new file with mode: 0644]
contrib/collection3/share/style.css
src/Makefile.am
src/memory.c
src/utils_threshold.c

index a67f2a1..2b85a2b 100644 (file)
@@ -50,6 +50,18 @@ case $host_os in
 esac
 AC_MSG_RESULT([$ac_system])
 
+if test "x$ac_system" = "xLinux"
+then
+       AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
+       if test -z "$KERNEL_DIR"
+       then
+               KERNEL_DIR="/lib/modules/`uname -r`/source"
+       fi
+
+       KERNEL_CFLAGS="-I$KERNEL_DIR/include"
+       AC_SUBST(KERNEL_CFLAGS)
+fi
+
 #
 # Checks for header files.
 #
@@ -278,8 +290,13 @@ have_net_ip_vs_h="no"
 have_ip_vs_h="no"
 if test "x$ac_system" = "xLinux"
 then
+       SAVE_CFLAGS=$CFLAGS
+       CFLAGS="$CFLAGS $KERNEL_CFLAGS"
+
        AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
        AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
+
+       CFLAGS=$SAVE_CFLAGS
 fi
 
 # For quota module
@@ -1683,15 +1700,6 @@ then
        LDFLAGS=$SAVE_LDFLAGS
 fi
 
-if test "x$ac_system" = "xLinux"
-then
-       AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
-       if test -z "$KERNEL_DIR"
-       then
-               KERNEL_DIR="/lib/modules/`uname -r`/source"
-       fi
-fi
-
 with_own_libiptc="no"
 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
 [
@@ -1737,7 +1745,7 @@ fi
 if test "x$with_libiptc" = "xyes"
 then
        SAVE_CFLAGS=$CFLAGS
-       CFLAGS="$CFLAGS -I$KERNEL_DIR/include"
+       CFLAGS="$CFLAGS $KERNEL_CFLAGS"
 
        AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
        [
index c84199d..7c29bb0 100755 (executable)
@@ -9,7 +9,8 @@ use Carp (qw(confess cluck));
 use CGI (':cgi');
 use RRDs ();
 
-use Collectd::Graph::TypeLoader (qw(tl_read_config tl_load_type));
+use Collectd::Graph::Config (qw(gc_read_config gc_get_scalar));
+use Collectd::Graph::TypeLoader (qw(tl_load_type));
 
 use Collectd::Graph::Common (qw(sanitize_type get_selected_files
       epoch_to_rfc1123));
@@ -18,6 +19,7 @@ use Collectd::Graph::Type ();
 our $Debug = param ('debug');
 our $Begin = param ('begin');
 our $End = param ('end');
+our $GraphWidth = param ('width');
 
 if ($Debug)
 {
@@ -27,7 +29,17 @@ Content-Type: text/plain
 HTTP
 }
 
-tl_read_config ("$RealBin/../etc/collection3.conf");
+gc_read_config ("$RealBin/../etc/collection.conf");
+
+if ($GraphWidth)
+{
+  $GraphWidth =~ s/\D//g;
+}
+
+if (!$GraphWidth)
+{
+  $GraphWidth = gc_get_scalar ('GraphWidth', 400);
+}
 
 { # Sanitize begin and end times
   $End ||= 0;
@@ -93,15 +105,29 @@ for (@$files)
 }
 
 my $expires = time ();
+# IF (End is `now')
+#    OR (Begin is before `now' AND End is after `now')
 if (($End == 0) || (($Begin <= $expires) && ($End >= $expires)))
 {
   # 400 == width in pixels
-  my $timespan = $expires - $Begin;
-  $expires += int ($timespan / 400);
+  my $timespan;
+
+  if ($End == 0)
+  {
+    $timespan = $expires - $Begin;
+  }
+  else
+  {
+    $timespan = $End - $Begin;
+  }
+  $expires += int ($timespan / 400.0);
 }
+# IF (End is not `now')
+#    AND (End is before `now')
+# ==> Graph will never change again!
 elsif (($End > 0) && ($End < $expires))
 {
-  $expires += 366 * 86400;
+  $expires += (366 * 86400);
 }
 elsif ($Begin > $expires)
 {
@@ -112,6 +138,11 @@ print STDOUT header (-Content_type => 'image/png',
   -Last_Modified => epoch_to_rfc1123 ($obj->getLastModified ()),
   -Expires => epoch_to_rfc1123 ($expires));
 
+if ($Debug)
+{
+  print "\$expires = $expires;\n";
+}
+
 my $args = $obj->getRRDArgs (0);
 
 if ($Debug)
@@ -135,7 +166,7 @@ else
   }
 
   $| = 1;
-  RRDs::graph ('-', '-a', 'PNG', @timesel, @$args);
+  RRDs::graph ('-', '-a', 'PNG', '--width', $GraphWidth, @timesel, @$args);
   if (my $err = RRDs::error ())
   {
     print STDERR "RRDs::graph failed: $err\n";
index b0001d2..d581bfb 100755 (executable)
@@ -27,7 +27,8 @@ use HTML::Entities ('encode_entities');
 
 use Data::Dumper;
 
-use Collectd::Graph::TypeLoader (qw(tl_read_config tl_load_type));
+use Collectd::Graph::Config (qw(gc_read_config));
+use Collectd::Graph::TypeLoader (qw(tl_load_type));
 use Collectd::Graph::Common (qw(get_files_from_directory get_all_hosts
       get_timespan_selection get_selected_files get_host_selection
       get_plugin_selection));
@@ -57,7 +58,7 @@ if (!exists ($Actions{$action}))
   exit 1;
 }
 
-tl_read_config ("$RealBin/../etc/collection3.conf");
+gc_read_config ("$RealBin/../etc/collection.conf");
 
 $Actions{$action}->();
 exit (0);
@@ -107,6 +108,14 @@ sub start_html
 {
   return if ($html_started);
 
+  my $end;
+  my $begin;
+  my $timespan;
+
+  $end = time ();
+  $timespan = get_timespan_selection ();
+  $begin = $end - $timespan;
+
   if (can_handle_xhtml ())
   {
     print <<HTML;
@@ -136,8 +145,9 @@ HTML
     <title>collection.cgi, Version 3</title>
     <link rel="icon" href="../share/shortcut-icon.png" type="image/png" />
     <link rel="stylesheet" href="../share/style.css" type="text/css" />
+    <script type="text/javascript" src="../share/navigate.js" />
   </head>
-  <body>
+  <body onload="nav_init ($begin, $end);">
 HTML
   $html_started = 1;
 }}
@@ -266,6 +276,8 @@ sub action_show_selection
   my $all_files;
   my $types = {};
 
+  my $id_counter = 0;
+
   $all_files = get_selected_files ();
 
   if ($Debug)
@@ -307,11 +319,46 @@ sub action_show_selection
     {
       my $args = $types->{$type}->getGraphArgs ($i);
       my $url = encode_entities ("graph.cgi?$args;begin=-$timespan");
+      my $id = sprintf ("graph%04i", $id_counter++);
 
       print "      <tr>\n";
       print "        <td rowspan=\"$graphs_num\">$type</td>\n" if ($i == 0);
-
-      print qq#        <td><img src="$url" /></td>\n#;
+      print <<EOF;
+        <td>
+          <div class="graph_canvas">
+            <div class="graph_float">
+              <img id="${id}" class="graph_image"
+                alt="A graph"
+                src="$url" />
+              <div class="controls zoom">
+                <div title="Earlier"
+                  onclick="nav_move_earlier ('${id}');">&#x2190;</div>
+                <div title="Zoom out"
+                  onclick="nav_zoom_out ('${id}');">-</div>
+                <div title="Zoom in"
+                  onclick="nav_zoom_in ('${id}');">+</div>
+                <div title="Later"
+                  onclick="nav_move_later ('${id}');">&#x2192;</div>
+              </div>
+              <div class="controls preset">
+                <div title="Show current hour"
+                  onclick="nav_time_reset ('${id}', 3600);">H</div>
+                <div title="Show current day"
+                  onclick="nav_time_reset ('${id}', 86400);">D</div>
+                <div title="Show current week"
+                  onclick="nav_time_reset ('${id}', 7 * 86400);">W</div>
+                <div title="Show current month"
+                  onclick="nav_time_reset ('${id}', 31 * 86400);">M</div>
+                <div title="Show current year"
+                  onclick="nav_time_reset ('${id}', 366 * 86400);">Y</div>
+                <div title="Set all images to this timespan"
+                  onclick="nav_set_reference ('${id}');">!</div>
+              </div>
+            </div>
+          </div>
+       </td>
+EOF
+      # print qq#        <td><img src="$url" /></td>\n#;
       print "      </tr>\n";
     }
   }
index 0dceb62..c2af61c 100755 (executable)
@@ -27,13 +27,14 @@ use URI::Escape ('uri_escape');
 
 use Data::Dumper;
 
-use Collectd::Graph::TypeLoader (qw(tl_read_config tl_load_type));
+use Collectd::Graph::Config (qw(gc_read_config));
+use Collectd::Graph::TypeLoader (qw(tl_load_type));
 use Collectd::Graph::Common (qw(get_all_hosts get_files_for_host type_to_module_name));
 use Collectd::Graph::Type ();
 
 our $Debug = param ('debug') ? 1 : 0;
 
-tl_read_config ("$RealBin/../etc/collection3.conf");
+gc_read_config ("$RealBin/../etc/collection.conf");
 
 if ($Debug)
 {
diff --git a/contrib/collection3/etc/collection.conf b/contrib/collection3/etc/collection.conf
new file mode 100644 (file)
index 0000000..e60316f
--- /dev/null
@@ -0,0 +1,286 @@
+GraphWidth 400
+<Type apache_scoreboard>
+  Module GenericStacked
+  DataSources count
+  RRDTitle "Apache scoreboard on {hostname}"
+  RRDVerticalLabel "Slots"
+  RRDFormat "%6.2lf"
+  DSName closing Closing
+  DSName dnslookup DNS lookup
+  DSName finishing Finishing
+  DSName idle_cleanup Idle cleanup
+  DSName keepalive Keep alive
+  DSName logging Logging
+  DSName open Open (empty)
+  DSName reading Reading
+  DSName sending Sending
+  DSName starting Starting
+  DSName waiting Waiting
+  Order open closing dnslookup finishing idle_cleanup keepalive logging open reading sending starting waiting
+  Color closing      000080
+  Color dnslookup    ff0000
+  Color finishing    008080
+  Color idle_cleanup ffff00
+  Color keepalive    0080ff
+  Color logging      a000a0
+  Color open         e0e0e0
+  Color reading      0000ff
+  Color sending      00e000
+  Color starting     ff00ff
+  Color waiting      ffb000
+</Type>
+<Type cpu>
+  Module GenericStacked
+  DataSources value
+  RRDTitle "CPU {plugin_instance} usage"
+  RRDVerticalLabel "Jiffies"
+  RRDFormat "%5.2lf"
+  DSName idle Idle
+  DSName nice Nice
+  DSName user User
+  DSName wait Wait-IO
+  DSName system System
+  DSName softirq SoftIRQ
+  DSName interrupt IRQ
+  DSName steal Steal
+  Order idle nice user wait system softirq interrupt steal
+  Color idle      e8e8e8
+  Color nice      00e000
+  Color user      0000ff
+  Color wait      ffb000
+  Color system    ff0000
+  Color softirq   ff00ff
+  Color interrupt a000a0
+  Color steal     000000
+</Type>
+<Type df>
+  Module Df
+  DataSources free used
+</Type>
+<Type disk_octets>
+  Module GenericIO
+  DataSources read write
+  DSName "read Read   "
+  DSName write Written
+  RRDTitle "Disk Traffic ({plugin_instance})"
+  RRDVerticalLabel "Bytes per second"
+# RRDOptions ...
+  RRDFormat "%5.1lf%s"
+</Type>
+<Type disk_ops>
+  Module GenericIO
+  DataSources read write
+  DSName "read Read   "
+  DSName write Written
+  RRDTitle "Disk Operations ({plugin_instance})"
+  RRDVerticalLabel "Operations per second"
+# RRDOptions ...
+  RRDFormat "%5.1lf"
+</Type>
+<Type disk_merged>
+  Module GenericIO
+  DataSources read write
+  DSName "read Read   "
+  DSName write Written
+  RRDTitle "Disk Merged Operations ({plugin_instance})"
+  RRDVerticalLabel "Merged operations/s"
+# RRDOptions ...
+  RRDFormat "%5.1lf"
+</Type>
+<Type disk_time>
+  Module GenericIO
+  DataSources read write
+  DSName "read Read   "
+  DSName write Written
+  RRDTitle "Disk time per operation ({plugin_instance})"
+  RRDVerticalLabel "Avg. Time/Op"
+# RRDOptions ...
+  RRDFormat "%5.1lf%ss"
+  Scale 0.001
+</Type>
+<Type entropy>
+  DataSources entropy
+  DSName entropy Entropy bits
+  RRDTitle "Available entropy on {hostname}"
+  RRDVerticalLabel "Bits"
+  RRDFormat "%4.0lf"
+</Type>
+<Type fanspeed>
+  DataSources value
+  DSName value RPM
+  RRDTitle "Fanspeed ({instance})"
+  RRDVerticalLabel "RPM"
+  RRDFormat "%6.1lf"
+  Color value 00b000
+</Type>
+<Type if_errors>
+  Module GenericIO
+  DataSources rx tx
+  DSName rx RX
+  DSName tx TX
+  RRDTitle "Interface Errors ({type_instance})"
+  RRDVerticalLabel "Errors per second"
+# RRDOptions ...
+  RRDFormat "%.3lf"
+</Type>
+<Type if_rx_errors>
+  Module GenericStacked
+  DataSources value
+  RRDTitle "Interface receive errors ({plugin_instance})"
+  RRDVerticalLabel "Erorrs/s"
+  RRDFormat "%.1lf"
+  Color length  f00000
+  Color over    00e0ff
+  Color crc     00e000
+  Color frame   ffb000
+  Color fifo    f000c0
+  Color missed  0000f0
+</Type>
+<Type if_tx_errors>
+  Module GenericStacked
+  DataSources value
+  RRDTitle "Interface transmit errors ({plugin_instance})"
+  RRDVerticalLabel "Erorrs/s"
+  RRDFormat "%.1lf"
+  Color aborted   f00000
+  Color carrier   00e0ff
+  Color fifo      00e000
+  Color heartbeat ffb000
+  Color window    f000c0
+</Type>
+<Type if_octets>
+  Module GenericIO
+  DataSources rx tx
+  DSName rx RX
+  DSName tx TX
+  RRDTitle "Interface Traffic ({type_instance})"
+  RRDVerticalLabel "Bits per second"
+# RRDOptions ...
+  RRDFormat "%5.1lf%s"
+  Scale 8
+</Type>
+<Type if_packets>
+  Module GenericIO
+  DataSources rx tx
+  DSName rx RX
+  DSName tx TX
+  RRDTitle "Interface Packets ({type_instance})"
+  RRDVerticalLabel "Packets per second"
+# RRDOptions ...
+  RRDFormat "%5.1lf%s"
+</Type>
+<Type ipt_bytes>
+  DataSources value
+  DSName value Bytes/s
+  RRDTitle "Traffic ({type_instance})"
+  RRDVerticalLabel "Bytes per second"
+# RRDOptions ...
+  RRDFormat "%5.1lf%s"
+</Type>
+<Type ipt_packets>
+  DataSources value
+  DSName value Packets/s
+  RRDTitle "Packets ({type_instance})"
+  RRDVerticalLabel "Packets per second"
+# RRDOptions ...
+  RRDFormat "%5.1lf"
+</Type>
+<Type irq>
+  Module GenericStacked
+  DataSources value
+  RRDTitle "Interrupts on {hostname}"
+  RRDVerticalLabel "IRQs/s"
+  RRDFormat "%5.1lf"
+</Type>
+<Type load>
+  Module Load
+</Type>
+<Type memory>
+  Module GenericStacked
+  DataSources value
+  RRDTitle "Physical memory utilization on {hostname}"
+  RRDVerticalLabel "Bytes"
+  RRDFormat "%5.1lf%s"
+  RRDOptions -b 1024 -l 0
+  DSName     "free Free    "
+  DSName   "cached Cached  "
+  DSName "buffered Buffered"
+  DSName     "used Used    "
+  #Order used buffered cached free
+  Order free cached buffered used
+  Color free      00e000
+  Color cached    0000ff
+  Color buffered  ffb000
+  Color used      ff0000
+</Type>
+<Type ping>
+  DataSources ping
+  DSName "ping Latency"
+  RRDTitle "Network latency ({type_instance})"
+  RRDVerticalLabel "Milliseconds"
+  RRDFormat "%5.2lfms"
+</Type>
+<Type ps_state>
+  Module GenericStacked
+  DataSources value
+  RRDTitle "Processes on {hostname}"
+  RRDVerticalLabel "Processes"
+  RRDFormat "%5.1lf%s"
+  DSName running  Running
+  DSName sleeping Sleeping
+  DSName paging   Paging
+  DSName zombies  Zombies
+  DSName blocked  Blocked
+  DSName stopped  Stopped
+  Order paging blocked zombies stopped running sleeping
+  Color running  00e000
+  Color sleeping 0000ff
+  Color paging   ffb000
+  Color zombies  ff0000
+  Color blocked  ff00ff
+  Color stopped  a000a0
+</Type>
+<Type tcp_connections>
+  Module GenericStacked
+  DataSources value
+  RRDTitle "TCP connections ({plugin_instance})"
+  RRDVerticalLabel "Connections"
+  RRDFormat "%5.1lf"
+  Order LISTEN CLOSING LAST_ACK CLOSE_WAIT CLOSE TIME_WAIT FIN_WAIT2 FIN_WAIT1 SYN_RECV SYN_SENT ESTABLISHED CLOSED
+  Color ESTABLISHED 00e000
+  Color SYN_SENT   00e0ff
+  Color SYN_RECV   00e0a0
+  Color FIN_WAIT1  f000f0
+  Color FIN_WAIT2  f000a0
+  Color TIME_WAIT  ffb000
+  Color CLOSE      0000f0
+  Color CLOSE_WAIT 0000a0
+  Color LAST_ACK   000080
+  Color LISTEN     ff0000
+  Color CLOSING    000000
+  Color CLOSED     0000f0
+</Type>
+<Type temperature>
+  DataSources value
+  DSName value Temp
+  RRDTitle "Temperature ({instance})"
+  RRDVerticalLabel "°Celsius"
+  RRDFormat "%4.1lf°C"
+</Type>
+<Type users>
+  DataSources users
+  DSName users Users
+  RRDTitle "Users ({type_instance}) on {hostname}"
+  RRDVerticalLabel "Users"
+  RRDFormat "%.1lf"
+  Color users 0000f0
+</Type>
+<Type voltage>
+  DataSources value
+  DSName value Volts
+  RRDTitle "Voltage ({type_instance})"
+  RRDVerticalLabel "Volts"
+  RRDFormat "%4.1lfV"
+  Color value f00000
+</Type>
+# vim: set sw=2 sts=2 et syntax=apache fileencoding=latin-1 :
diff --git a/contrib/collection3/etc/collection3.conf b/contrib/collection3/etc/collection3.conf
deleted file mode 100644 (file)
index 583eeac..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-<Type cpu>
-  Module GenericStacked
-  DataSources value
-  RRDTitle "CPU {plugin_instance} usage"
-  RRDVerticalLabel "Jiffies"
-  RRDFormat "%5.2lf"
-  DSName idle Idle
-  DSName nice Nice
-  DSName user User
-  DSName wait Wait-IO
-  DSName system System
-  DSName softirq SoftIRQ
-  DSName interrupt IRQ
-  DSName steal Steal
-  Order idle nice user wait system softirq interrupt steal
-  Color idle      e8e8e8
-  Color nice      00e000
-  Color user      0000ff
-  Color wait      ffb000
-  Color system    ff0000
-  Color softirq   ff00ff
-  Color interrupt a000a0
-  Color steal     000000
-</Type>
-<Type df>
-  Module Df
-  DataSources free used
-</Type>
-<Type disk_octets>
-  Module GenericIO
-  DataSources read write
-  DSName "read Read   "
-  DSName write Written
-  RRDTitle "Disk Traffic ({plugin_instance})"
-  RRDVerticalLabel "Bytes per second"
-# RRDOptions ...
-  RRDFormat "%5.1lf%s"
-</Type>
-<Type disk_ops>
-  Module GenericIO
-  DataSources read write
-  DSName "read Read   "
-  DSName write Written
-  RRDTitle "Disk Operations ({plugin_instance})"
-  RRDVerticalLabel "Operations per second"
-# RRDOptions ...
-  RRDFormat "%5.1lf"
-</Type>
-<Type disk_merged>
-  Module GenericIO
-  DataSources read write
-  DSName "read Read   "
-  DSName write Written
-  RRDTitle "Disk Merged Operations ({plugin_instance})"
-  RRDVerticalLabel "Merged operations/s"
-# RRDOptions ...
-  RRDFormat "%5.1lf"
-</Type>
-<Type disk_time>
-  Module GenericIO
-  DataSources read write
-  DSName "read Read   "
-  DSName write Written
-  RRDTitle "Disk time per operation ({plugin_instance})"
-  RRDVerticalLabel "Avg. Time/Op"
-# RRDOptions ...
-  RRDFormat "%5.1lf%ss"
-  Scale 0.001
-</Type>
-<Type entropy>
-  DataSources entropy
-  DSName entropy Entropy bits
-  RRDTitle "Available entropy on {hostname}"
-  RRDVerticalLabel "Bits"
-  RRDFormat "%4.0lf"
-</Type>
-<Type fanspeed>
-  DataSources value
-  DSName value RPM
-  RRDTitle "Fanspeed ({type_instance})"
-  RRDVerticalLabel "RPM"
-  RRDFormat "%6.1lf"
-  Color value 00b000
-</Type>
-<Type if_errors>
-  Module GenericIO
-  DataSources rx tx
-  DSName rx RX
-  DSName tx TX
-  RRDTitle "Interface Errors ({type_instance})"
-  RRDVerticalLabel "Errors per second"
-# RRDOptions ...
-  RRDFormat "%.3lf"
-</Type>
-<Type if_rx_errors>
-  Module GenericStacked
-  DataSources value
-  RRDTitle "Interface receive errors ({plugin_instance})"
-  RRDVerticalLabel "Erorrs/s"
-  RRDFormat "%.1lf"
-  Color length  f00000
-  Color over    00e0ff
-  Color crc     00e000
-  Color frame   ffb000
-  Color fifo    f000c0
-  Color missed  0000f0
-</Type>
-<Type if_tx_errors>
-  Module GenericStacked
-  DataSources value
-  RRDTitle "Interface transmit errors ({plugin_instance})"
-  RRDVerticalLabel "Erorrs/s"
-  RRDFormat "%.1lf"
-  Color aborted   f00000
-  Color carrier   00e0ff
-  Color fifo      00e000
-  Color heartbeat ffb000
-  Color window    f000c0
-</Type>
-<Type if_octets>
-  Module GenericIO
-  DataSources rx tx
-  DSName rx RX
-  DSName tx TX
-  RRDTitle "Interface Traffic ({type_instance})"
-  RRDVerticalLabel "Bits per second"
-# RRDOptions ...
-  RRDFormat "%5.1lf%s"
-  Scale 8
-</Type>
-<Type if_packets>
-  Module GenericIO
-  DataSources rx tx
-  DSName rx RX
-  DSName tx TX
-  RRDTitle "Interface Packets ({type_instance})"
-  RRDVerticalLabel "Packets per second"
-# RRDOptions ...
-  RRDFormat "%5.1lf%s"
-</Type>
-<Type ipt_bytes>
-  DataSources value
-  DSName value Bytes/s
-  RRDTitle "Traffic ({type_instance})"
-  RRDVerticalLabel "Bytes per second"
-# RRDOptions ...
-  RRDFormat "%5.1lf%s"
-</Type>
-<Type ipt_packets>
-  DataSources value
-  DSName value Packets/s
-  RRDTitle "Packets ({type_instance})"
-  RRDVerticalLabel "Packets per second"
-# RRDOptions ...
-  RRDFormat "%5.1lf"
-</Type>
-<Type irq>
-  Module GenericStacked
-  DataSources value
-  RRDTitle "Interrupts on {hostname}"
-  RRDVerticalLabel "IRQs/s"
-  RRDFormat "%5.1lf"
-</Type>
-<Type load>
-  Module Load
-</Type>
-<Type memory>
-  Module GenericStacked
-  DataSources value
-  RRDTitle "Physical memory utilization on {hostname}"
-  RRDVerticalLabel "Bytes"
-  RRDFormat "%5.1lf%s"
-  RRDOptions -b 1024 -l 0
-  DSName     "free Free    "
-  DSName   "cached Cached  "
-  DSName "buffered Buffered"
-  DSName     "used Used    "
-  #Order used buffered cached free
-  Order free cached buffered used
-  Color free      00e000
-  Color cached    0000ff
-  Color buffered  ffb000
-  Color used      ff0000
-</Type>
-<Type ping>
-  DataSources ping
-  DSName "ping Latency"
-  RRDTitle "Network latency ({type_instance})"
-  RRDVerticalLabel "Milliseconds"
-  RRDFormat "%5.2lfms"
-</Type>
-<Type ps_state>
-  Module GenericStacked
-  DataSources value
-  RRDTitle "Processes on {hostname}"
-  RRDVerticalLabel "Processes"
-  RRDFormat "%5.1lf%s"
-  DSName running  Running
-  DSName sleeping Sleeping
-  DSName paging   Paging
-  DSName zombies  Zombies
-  DSName blocked  Blocked
-  DSName stopped  Stopped
-  Order paging blocked zombies stopped running sleeping
-  Color running  00e000
-  Color sleeping 0000ff
-  Color paging   ffb000
-  Color zombies  ff0000
-  Color blocked  ff00ff
-  Color stopped  a000a0
-</Type>
-<Type tcp_connections>
-  Module GenericStacked
-  DataSources value
-  RRDTitle "TCP connections ({plugin_instance})"
-  RRDVerticalLabel "Connections"
-  RRDFormat "%5.1lf"
-  Order LISTEN CLOSING LAST_ACK CLOSE_WAIT CLOSE TIME_WAIT FIN_WAIT2 FIN_WAIT1 SYN_RECV SYN_SENT ESTABLISHED CLOSED
-  Color ESTABLISHED 00e000
-  Color SYN_SENT   00e0ff
-  Color SYN_RECV   00e0a0
-  Color FIN_WAIT1  f000f0
-  Color FIN_WAIT2  f000a0
-  Color TIME_WAIT  ffb000
-  Color CLOSE      0000f0
-  Color CLOSE_WAIT 0000a0
-  Color LAST_ACK   000080
-  Color LISTEN     ff0000
-  Color CLOSING    000000
-  Color CLOSED     0000f0
-</Type>
-<Type temperature>
-  DataSources value
-  DSName value Temp
-  RRDTitle "Temperature ({type_instance})"
-  RRDVerticalLabel "°Celsius"
-  RRDFormat "%4.1lf°C"
-</Type>
-<Type users>
-  DataSources users
-  DSName users Users
-  RRDTitle "Users ({type_instance}) on {hostname}"
-  RRDVerticalLabel "Users"
-  RRDFormat "%.1lf"
-  Color users 0000f0
-</Type>
-<Type voltage>
-  DataSources value
-  DSName value Volts
-  RRDTitle "Voltage ({type_instance})"
-  RRDVerticalLabel "Volts"
-  RRDFormat "%4.1lfV"
-  Color value f00000
-</Type>
-# vim: set sw=2 sts=2 et syntax=apache :
diff --git a/contrib/collection3/lib/Collectd/Config.pm b/contrib/collection3/lib/Collectd/Config.pm
new file mode 100644 (file)
index 0000000..d20be35
--- /dev/null
@@ -0,0 +1,144 @@
+package Collectd::Graph::Config;
+
+=head1 NAME
+
+Collectd::Graph::Config - Parse the collection3 config file.
+
+=cut
+
+# Copyright (C) 2008  Florian octo Forster <octo at verplant.org>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; only version 2 of the License is applicable.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+use strict;
+use warnings;
+
+use Carp (qw(cluck confess));
+use Exporter ();
+use Config::General ('ParseConfig');
+use Collectd::Graph::Type ();
+
+@Collectd::Graph::Config::ISA = ('Exporter');
+@Collectd::Graph::Config::EXPORT_OK = (qw(gc_read_config gc_get_config
+  gc_get_scalar));
+
+our $Configuration = undef;
+
+return (1);
+
+=head1 EXPORTED FUNCTIONS
+
+=over 4
+
+=item B<gc_read_config> (I<$file>)
+
+Reads the configuration from the file located at I<$file>. Returns B<true> when
+successfull and B<false> otherwise.
+
+=cut
+
+sub gc_read_config
+{
+  my $file = shift;
+  my %conf;
+
+  if ($Configuration)
+  {
+    return (1);
+  }
+
+  $file ||= "etc/collection.conf";
+
+  %conf = ParseConfig (-ConfigFile => $file,
+    -LowerCaseNames => 1,
+    -UseApacheInclude => 1,
+    -IncludeDirectories => 1,
+    ($Config::General::VERSION >= 2.38) ? (-IncludeAgain => 0) : (),
+    -MergeDuplicateBlocks => 1,
+    -CComments => 0);
+  if (!%conf)
+  {
+    return;
+  }
+
+  $Configuration = \%conf;
+  return (1);
+} # gc_read_config
+
+=item B<gc_get_config> ()
+
+Returns the hash as provided by L<Config::General>. The hash is returned as a
+hash reference. Don't change it!
+
+=cut
+
+sub gc_get_config
+{
+  return ($Configuration);
+} # gc_get_config
+
+=item B<gc_get_config> (I<$key>, [I<$default>])
+
+Returns the scalar value I<$key> from the config file. If the key does not
+exist, I<$default> will be returned. If no default is given, B<undef> will be
+used in this case.
+
+=cut
+
+sub gc_get_scalar
+{
+  my $key = shift;
+  my $default = (@_ != 0) ? shift : undef;
+  my $value;
+
+  if (!$Configuration)
+  {
+    return ($default);
+  }
+
+  $value = $Configuration->{lc ($key)};
+  if (!defined ($value))
+  {
+    return ($default);
+  }
+
+  if (ref ($value) ne '')
+  {
+    cluck ("Value for `$key' should be scalar, but actually is "
+      . ref ($value));
+    return ($default);
+  }
+
+  return ($value);
+} # gc_get_config
+
+=back
+
+=head1 DEPENDS ON
+
+L<Config::General>
+
+=head1 SEE ALSO
+
+L<Collectd::Graph::Type>
+
+=head1 AUTHOR AND LICENSE
+
+Copyright (c) 2008 by Florian Forster
+E<lt>octoE<nbsp>atE<nbsp>verplant.orgE<gt>. Licensed under the terms of the GNU
+General Public License, VersionE<nbsp>2 (GPLv2).
+
+=cut
+
+# vim: set shiftwidth=2 softtabstop=2 tabstop=8 et fdm=marker :
index 60097e5..1fb60af 100644 (file)
@@ -248,6 +248,20 @@ sub getTitle
   my $plugin_instance = $ident->{'plugin_instance'};
   my $type = $ident->{'type'};
   my $type_instance = $ident->{'type_instance'};
+  my $instance;
+
+  if (defined $type_instance)
+  {
+    $instance = $type_instance;
+  }
+  elsif (defined $plugin_instance)
+  {
+    $instance = $plugin_instance;
+  }
+  else
+  {
+    $instance = 'no instance';
+  }
 
   if (!defined $plugin_instance)
   {
@@ -264,6 +278,7 @@ sub getTitle
   $title =~ s#{plugin_instance}#$plugin_instance#g;
   $title =~ s#{type}#$type#g;
   $title =~ s#{type_instance}#$type_instance#g;
+  $title =~ s#{instance}#$instance#g;
 
   return ($title);
 }
index 273d89e..a1a3e1c 100644 (file)
@@ -32,6 +32,18 @@ sub getRRDArgs
   my $idents = $group->{$group[$index]};
   my $ds_name_len = 0;
 
+  my $ds = $obj->getDataSources ();
+  if (!$ds)
+  {
+    confess ("obj->getDataSources failed.");
+  }
+  if (@$ds != 1)
+  {
+    confess ("I can only work with RRD files that have "
+      . "exactly one data source!");
+  }
+  my $data_source = $ds->[0];
+
   my $rrd_title = $obj->getTitle ($idents->[0]);
 
   my $colors = $obj->{'rrd_colors'} || {};
@@ -64,9 +76,9 @@ sub getRRDArgs
     $names[$i] =~ s/:/\\:/g;
 
     push (@ret,
-      "DEF:min${i}=${filename}:value:MIN",
-      "DEF:avg${i}=${filename}:value:AVERAGE",
-      "DEF:max${i}=${filename}:value:MAX");
+      "DEF:min${i}=${filename}:${data_source}:MIN",
+      "DEF:avg${i}=${filename}:${data_source}:AVERAGE",
+      "DEF:max${i}=${filename}:${data_source}:MAX");
   }
 
   for (my $i = @$idents - 1; $i >= 0; $i--)
index 6223eaa..c5fe613 100644 (file)
@@ -27,12 +27,11 @@ use warnings;
 use Carp (qw(cluck confess));
 use Exporter ();
 use Config::General ('ParseConfig');
+use Collectd::Graph::Config ('gc_get_config');
 use Collectd::Graph::Type ();
 
 @Collectd::Graph::TypeLoader::ISA = ('Exporter');
-@Collectd::Graph::TypeLoader::EXPORT_OK = ('tl_read_config', 'tl_load_type');
-
-our $Configuration = undef;
+@Collectd::Graph::TypeLoader::EXPORT_OK = ('tl_load_type');
 
 our @ArrayMembers = (qw(data_sources rrd_opts custom_order));
 our @ScalarMembers = (qw(rrd_title rrd_format rrd_vertical scale));
@@ -53,42 +52,6 @@ our %MemberToConfigMap =
 
 return (1);
 
-=head1 EXPORTED FUNCTIONS
-
-=over 4
-
-=item B<tl_read_config> (I<$file>)
-
-Reads the configuration from the file located at I<$file>.
-
-=cut
-
-sub tl_read_config
-{
-  my $file = shift;
-  my %conf;
-
-  if ($Configuration)
-  {
-    return (1);
-  }
-
-  %conf = ParseConfig (-ConfigFile => $file,
-    -LowerCaseNames => 1,
-    -UseApacheInclude => 1,
-    -IncludeDirectories => 1,
-    ($Config::General::VERSION >= 2.38) ? (-IncludeAgain => 0) : (),
-    -MergeDuplicateBlocks => 1,
-    -CComments => 0);
-  if (!%conf)
-  {
-    return;
-  }
-
-  $Configuration = \%conf;
-  return (1);
-} # tl_read_config
-
 sub _create_object
 {
   my $module = shift;
@@ -123,7 +86,6 @@ sub _load_module_from_config
 
   if ($module)
   {
-    print STDERR "\$module = $module;\n";
     $obj = _create_object ($module);
     if (!$obj)
     {
@@ -232,8 +194,6 @@ sub _load_module_from_config
 
       $obj->{$member} ||= {};
       $obj->{$member}{$ds} = $val;
-
-      print STDERR "\$obj->{$member}{$ds} = $val;\n";
     } # for (@val_list)
   } # }}} for (@DSMappedMembers)
 
@@ -263,6 +223,10 @@ sub _load_module_generic
   return ($obj);
 } # _load_module_generic
 
+=head1 EXPORTED FUNCTIONS
+
+=over 4
+
 =item B<tl_load_type> (I<$type>)
 
 Does whatever is necessary to get an object with which to graph RRD files of
@@ -273,10 +237,11 @@ type I<$type>.
 sub tl_load_type
 {
   my $type = shift;
+  my $conf = gc_get_config ();
 
-  if (defined $Configuration->{'type'}{$type})
+  if (defined ($conf) && defined ($conf->{'type'}{$type}))
   {
-    return (_load_module_from_config ($Configuration->{'type'}{$type}));
+    return (_load_module_from_config ($conf->{'type'}{$type}));
   }
   else
   {
diff --git a/contrib/collection3/share/navigate.js b/contrib/collection3/share/navigate.js
new file mode 100644 (file)
index 0000000..3bfe56e
--- /dev/null
@@ -0,0 +1,300 @@
+function nav_init (time_begin, time_end)
+{
+  var all_images;
+  var i;
+
+  all_images = document.getElementsByTagName ("img");
+  for (i = 0; i < all_images.length; i++)
+  {
+    if (all_images[i].className != "graph_image")
+      continue;
+
+    all_images[i].navTimeBegin = new Number (time_begin);
+    all_images[i].navTimeEnd   = new Number (time_end);
+
+    all_images[i].navBaseURL = all_images[i].src.replace (/;(begin|end)=[^;]*/g, '');
+
+    if (all_images[i].addEventListener) /* Mozilla */
+    {
+      all_images[i].addEventListener ('dblclick', nav_handle_dblclick,
+          false /* == bubbling */);
+      all_images[i].addEventListener ('DOMMouseScroll', nav_handle_wheel,
+          false /* == bubbling */);
+    }
+    else
+    {
+      all_images[i].ondblclick = nav_handle_dblclick;
+      all_images[i].onmousewheel = nav_handle_wheel;
+    }
+  }
+
+  return (true);
+} /* nav_init */
+
+function nav_image_repaint (img)
+{
+  if (!img || !img.navBaseURL
+      || !img.navTimeBegin || !img.navTimeEnd)
+    return;
+
+  img.src = img.navBaseURL + ";"
+    + "begin=" + img.navTimeBegin.toFixed (0) + ";"
+    + "end=" + img.navTimeEnd.toFixed (0);
+} /* nav_image_repaint */
+
+function nav_time_reset (img_id ,diff)
+{
+  var img;
+
+  img = document.getElementById (img_id);
+  if (!img)
+    return (false);
+
+  img.navTimeEnd = new Number ((new Date ()).getTime () / 1000);
+  img.navTimeBegin = new Number (img.navTimeEnd - diff);
+
+  nav_image_repaint (img);
+
+  return (true);
+}
+
+function nav_time_change_obj (img, factor_begin, factor_end)
+{
+  var diff;
+
+  if (!img || !img.navBaseURL
+      || !img.navTimeBegin || !img.navTimeEnd)
+    return (false);
+
+  diff = img.navTimeEnd - img.navTimeBegin;
+
+  /* Prevent zooming in if diff is less than five minutes */
+  if ((diff <= 300) && (factor_begin > 0.0) && (factor_end < 0.0))
+    return (true);
+
+  img.navTimeBegin += (diff * factor_begin);
+  img.navTimeEnd   += (diff * factor_end);
+
+  nav_image_repaint (img);
+
+  return (true);
+} /* nav_time_change */
+
+function nav_time_change (img_id, factor_begin, factor_end)
+{
+  var diff;
+
+  if (img_id == '*')
+  {
+    var all_images;
+    var i;
+
+    all_images = document.getElementsByTagName ("img");
+    for (i = 0; i < all_images.length; i++)
+    {
+      if (all_images[i].className != "graph_image")
+        continue;
+    
+      nav_time_change_obj (all_images[i], factor_begin, factor_end);
+    }
+  }
+  else
+  {
+    var img;
+
+    img = document.getElementById (img_id);
+    if (!img)
+      return (false);
+
+    nav_time_change_obj (img, factor_begin, factor_end);
+  }
+
+  return (true);
+} /* nav_time_change */
+
+function nav_move_earlier (img_id)
+{
+  return (nav_time_change (img_id, -0.2, -0.2));
+} /* nav_move_earlier */
+
+function nav_move_later (img_id)
+{
+  return (nav_time_change (img_id, +0.2, +0.2));
+} /* nav_move_later */
+
+function nav_zoom_in (img_id)
+{
+  return (nav_time_change (img_id, +0.2, -0.2));
+} /* nav_zoom_in */
+
+function nav_zoom_out (img_id)
+{
+  return (nav_time_change (img_id, (-1.0 / 3.0), (1.0 / 3.0)));
+} /* nav_zoom_in */
+
+function nav_set_reference (img_id)
+{
+  var img;
+  var all_images;
+  var tmp;
+  var i;
+
+  img = document.getElementById (img_id);
+  if (!img || (img.className != "graph_image")
+      || !img.navTimeBegin || !img.navTimeEnd)
+    return;
+
+  all_images = document.getElementsByTagName ("img");
+  for (i = 0; i < all_images.length; i++)
+  {
+    tmp = all_images[i];
+    if (!tmp || (tmp.className != "graph_image")
+        || !tmp.navTimeBegin || !tmp.navTimeEnd)
+      continue;
+
+    if (tmp.id == img_id)
+      continue;
+
+    tmp.navTimeBegin = img.navTimeBegin;
+    tmp.navTimeEnd = img.navTimeEnd;
+
+    nav_image_repaint (tmp);
+  }
+} /* nav_set_reference */
+
+/* 
+ * TODO: calculate the mouse position relative to the image in a cross-browser
+ * manner.
+ */
+function nav_calculate_offset_x (obj)
+{
+  var offset = 0;
+
+  if (!obj)
+    return (offset);
+
+  offset = obj.offsetLeft;
+  if (obj.offsetParent)
+    offset += nav_calculate_offset_x (obj.offsetParent);
+
+  return (offset);
+} /* nav_calculate_offset_x */
+
+function nav_calculate_event_x (e)
+{
+  var pos = 0;
+  var off = 0;
+
+  if (!e || !e.target)
+    return;
+  
+  off = nav_calculate_offset_x (e.target);
+
+  if (e.pageX || e.pageY)
+  {
+    pos = e.pageX;
+  }
+  else if (e.clientX || e.clientY)
+  {
+    pos = e.clientX + document.body.scrollLeft
+      + document.documentElement.scrollLeft;
+  }
+
+  return (pos);
+} /* nav_calculate_event_x */
+
+function nav_recenter (e)
+{
+  var x;
+  var y;
+  var img;
+  var diff;
+  var time_old_center;
+  var time_new_center;
+  var width;
+
+  img = e.target;
+  if (!img || (img.className != "graph_image")
+      || !img.navTimeBegin || !img.navTimeEnd)
+    return;
+
+  width = img.width - 97;
+
+  x = e.layerX - 70;
+  if (!x || (x < 0) || (x > width))
+    return;
+
+  y = e.layerY;
+  if (!y || (y < 35) || (y > 135))
+    return;
+
+  diff = img.navTimeEnd - img.navTimeBegin;
+
+  time_old_center = img.navTimeBegin + (diff / 2.0);
+  time_new_center = img.navTimeBegin + (x * diff / width);
+
+  img.navTimeBegin += (time_new_center - time_old_center);
+  img.navTimeEnd   += (time_new_center - time_old_center);
+} /* nav_recenter */
+
+function nav_handle_dblclick (e)
+{
+  var img;
+
+  /* M$IE */
+  if (!e)
+    e = window.event;
+
+  img = e.target;
+  if (!img || (img.className != "graph_image")
+      || !img.navTimeBegin || !img.navTimeEnd)
+    return;
+
+  nav_recenter (e);
+  nav_image_repaint (img);
+
+  // e.returnValue = false;
+} /* nav_handle_dblclick */
+
+/* Taken from <http://adomas.org/javascript-mouse-wheel/> */
+function nav_handle_wheel (e)
+{
+  var delta = 0;
+  var img;
+  
+  /* M$IE */
+  if (!e)
+    e = window.event;
+
+  img = e.target;
+  if (!img || (img.className != "graph_image")
+      || !img.navTimeBegin || !img.navTimeEnd)
+    return;
+
+  /* Opera and M$IE */
+  if (e.wheelDelta)
+  {
+    delta = e.wheelDelta; 
+    if (window.opera)
+      delta = delta * (-1);
+  }
+  else if (e.detail)
+  {
+    delta = e.detail * (-1);
+  }
+
+  if (!delta)
+    return;
+
+  nav_recenter (e);
+  if (delta > 0)
+    nav_zoom_in (img.id);
+  else
+    nav_zoom_out (img.id);
+
+  if (e.preventDefault)
+    e.preventDefault ();
+  e.returnValue = false;
+} /* function nav_handle_wheel */
+
+/* vim: set sw=2 sts=2 et : */
index a6648aa..8c12951 100644 (file)
@@ -1,3 +1,73 @@
+div.graph
+{
+}
+
+div.graph_canvas div.graph_float
+{
+  float: left;
+  position: relative;
+}
+
+div.graph_float div.controls
+{
+  display: none;
+  position: absolute;
+}
+
+div.graph_float:hover div.controls
+{
+  display: block;
+}
+
+div.graph_float div.controls.zoom
+{
+  right: 5px;
+  bottom: 10px;
+}
+
+div.graph_float div.controls.preset
+{
+  right: 5px;
+  top: 5px;
+}
+
+div.graph_float div.controls div
+{
+  display: block;
+
+  color: gray;
+  background: white;
+
+  text-decoration: none;
+  text-align: center;
+  font-size: small;
+
+  cursor: pointer;
+
+  border: 1px solid gray;
+  width: 1em;
+  height: 1em;
+  padding: 1px;
+  margin: 0px;
+}
+
+div.graph_float div.controls div:hover
+{
+  color: black;
+  border-color: black;
+}
+
+div.graph_float div.controls.preset div
+{
+  margin: 1px 0px 1px 0px;
+}
+
+div.graph_float div.controls.zoom div
+{
+  float: left;
+  margin: 0px 1px 0px 1px;
+}
+
 table
 {
   border-collapse: collapse;
index 4926157..3c5c87b 100644 (file)
@@ -314,6 +314,7 @@ endif
 if BUILD_PLUGIN_IPVS
 pkglib_LTLIBRARIES += ipvs.la
 ipvs_la_SOURCES = ipvs.c
+ipvs_la_CFLAGS = $(KERNEL_CFLAGS)
 ipvs_la_LDFLAGS = -module -avoid-version
 collectd_LDADD += "-dlopen" ipvs.la
 collectd_DEPENDENCIES += ipvs.la
index c1564c8..c31b30e 100644 (file)
@@ -319,7 +319,7 @@ static int memory_read (void)
        if ((ios = sg_get_mem_stats ()) != NULL)
        {
                memory_submit ("used",   ios->used);
-               memory_submit ("cached", ios->cached);
+               memory_submit ("cached", ios->cache);
                memory_submit ("free",   ios->free);
        }
 #endif /* HAVE_LIBSTATGRAB */
index bea5bfb..68b85a3 100644 (file)
@@ -862,6 +862,7 @@ int ut_check_interesting (const char *name)
   if (status != 0)
   {
     ERROR ("ut_check_interesting: parse_identifier failed.");
+    sfree (name_copy);
     return (-1);
   }