Merged trunk... huh...
authorniki <niki>
Sun, 11 Dec 2005 15:16:52 +0000 (15:16 +0000)
committerniki <niki>
Sun, 11 Dec 2005 15:16:52 +0000 (15:16 +0000)
26 files changed:
AUTHORS
ChangeLog [new file with mode: 0644]
INSTALL
Makefile.am
README
collectd.spec [new file with mode: 0644]
configure.in
contrib/museum/collection.cgi [new file with mode: 0755]
contrib/users [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/collectd-users.files [new file with mode: 0644]
debian/collectd.examples [new file with mode: 0644]
debian/control
debian/rules
src/Makefile.am
src/collectd.c
src/collectd.pod
src/common.h
src/config.h.in [deleted file]
src/cpu.c [new file with mode: 0644]
src/cpu.h [new file with mode: 0644]
src/load.c [new file with mode: 0644]
src/load.h [new file with mode: 0644]
src/plugin.c
src/users.c [new file with mode: 0644]
src/users.h [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
index c363772..cac8245 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -22,6 +22,9 @@ serial module by:
 tape module by:
   Scott Garrett <sgarrett@technomancer.com>
 
+users module by:
+  Sebastian Harl <sh@tokkee.org>
+
 don't-fork-patch by:
   Alvaro Barcellos <alvaro.barcellos@gmail.com>
 
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..5b4af8d
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,120 @@
+2005-12-07, Version 3.5.0
+       * A bug in the `load' module under Solaris has been fixed.
+       * The `users' module has been contributed by Sebastian Harl. It counts
+         currently logged in users.
+
+2005-11-15, Version 3.4.0 (Revision 236)
+       * A PID-file is written to /var/run upon startup. Thanks to `Tommie'
+         from gentoo's bugzilla for writing the patch.
+       * The build dependency for librrd has been removed. Binaries built
+         without librrd are client-only and will multicast their value as
+         with the `-c' argument.
+       * A patch by Peter Holik adds a module for monitoring CPU frequencies.
+       * The newly introduced `-f' switch prevents daemon initialization
+         (forking, closing standard filehandles, etc.) Thanks to Alvaro
+         Barcellos for this patch.
+
+2005-11-04, Version 3.3.0 (Revision 216)
+       * New modules have been added:
+         - `serial', for monitoring traffic on the serial interfaces
+         - `nfs', for graphing NFS procedure calls
+         - `tape', traffic from/to tape devices
+       * The the memory.rrd now accepts more than 4Gig of memory.
+
+2005-10-26, Version 3.2.0 (Revision 200)
+       * Support for graphing the processes has been added (thanks to Lyonel
+         Vincent)
+       * If reading from hddtemp failes collectd will increase the time
+         between polls up to one day.
+       * The init.d files have been improved.
+       * Problems with the spec file have been fixed.
+
+2005-10-16, Version 3.1.0 (Revision 194)
+       * Added the `setsid' syscall to the startup code.
+       * Support for hddtemp has been added (thanks to Vincent StehlĂ©)
+
+2005-09-30, Version 3.0.0 (Revision 184)
+       * The ability to send/receive data to/from the network (think
+         multicast) has been added.
+       * Modules have been split up into shared libraries can be loaded at
+         runtime. The biggest advantage is that the core program doesn't need
+         to be linked against an external library.
+       * A patch by George Kargiotakis has been applied: It fixes the sensors
+         behaviour then more than one sensor is being queried.
+
+2005-09-16, Version 2.1.0 (Revision 172)
+       * A module for swap statistics has been added.
+
+2005-09-09, Version 2.0.0 (Revision 135)
+       * Filenames can no longer be configured at program startup. The only
+         options as of this version are the directory and ping hosts.
+       * CPU statistics now include Wait-IO. If privided under Linux IRQ and
+         Soft-IRQ statistics are added to `System'. 
+       * Diskstats now collect read and write bytes, not sectors.
+       * Ping statistics can now be collected for more than one host. There
+         is no default any more: If no host is given no host will be pinged.
+       * A self-written patch for libping has been applied so it builds
+         cleanly.
+
+2005-09-01, Version 1.8.1 (Revision 123)
+       * Much improved configure-script: libraries and features may now be
+         disabled.
+       * More detailed warnings/error messages when RRD update failes.
+
+2005-08-29, Version 1.8.0:
+       * Support for collecting disk statistics under Solaris.
+
+2005-08-25, Version 1.7.0:
+       * Support for libstatgrab[1] for load, memory usage and network
+         traffic. CPU- and disk-usage are not (yet) supported, since
+         libstatgrab returns insufficient information. I will contact the
+         authors.
+       * Improved the CPU-initialization code for Solaris. Apparently CPUs
+         aren't neccessarily counted linear which is now handled correctly.
+       [1]: http://www.i-scream.org/libstatgrab/
+
+2005-08-21, Version 1.6.0:
+       * Basic support for Solaris: System load and cpu-usage can be
+         collected unter Solaris, too. Other stats will follow later.
+       * Many fixes in the autoconf-script
+       * Collection/Museum scripts have been added unter contrib/museum
+       * collectd may now be started in unprivileged mode, though ping
+         statistics will not work.
+
+2005-07-17, Version 1.5.1:
+       * Diskstats-RRDs now use major/minor for naming. Some systems have
+         weird strings as disk-names..
+
+2005-07-17, Version 1.5:
+       * A new module, diskstats, has been added. It collects information
+         about the disks and partitions.
+
+2005-07-11, Version 1.4.2:
+       * The meminfo mofule has been changed to work with more platforms
+         and/or kernel versions.
+
+2005-07-10, Version 1.4.1: Correct traffic stats
+       * The traffic rrd-file is now created with DS-type `COUNTER' which I
+         forgot to correct when I changed that module.
+
+2005-07-09, Version 1.4: More traffic stats
+       * Traffic is now collected for all interfaces that can be found
+       * Temperature-statistics are read from lm-sensors if available
+
+2005-07-08, Version 1.3: CPU stats
+       * Collecting CPU statistics now
+
+2004-07-12, Version 1.2: Using syslog
+       * collectd is now using the syslog facility to report errors, warnings
+         and the like..
+       * The default directory is now /var/db/collectd
+
+2004-07-10, Version 1.1: Minor changes
+       * Nothing really usefull to say ;)
+
+2004-07-09, Version 1.0: Initial Version
+       * The following modules are provided:
+         * Load average
+         * Ping time
+         * Traffic
+         * Memory info
diff --git a/INSTALL b/INSTALL
index 23e5f25..da55609 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,43 +1,27 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
-Software Foundation, Inc.
-
-This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
-
 Basic Installation
 ==================
 
-These are generic installation instructions.
+   These are generic installation instructions.
 
    The `configure' shell script attempts to guess correct values for
 various system-dependent variables used during compilation.  It uses
 those values to create a `Makefile' in each directory of the package.
 It may also create one or more `.h' files containing system-dependent
 definitions.  Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
-   It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  (Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.)
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
 
    If you need to do unusual things to compile the package, please try
 to figure out how `configure' could check whether to do them, and mail
 diffs or instructions to the address given in the `README' so they can
-be considered for the next release.  If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
+be considered for the next release.  If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
 
-   The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You only need
-`configure.ac' if you want to change it or regenerate `configure' using
-a newer version of `autoconf'.
+   The file `configure.in' is used to create `configure' by a program
+called `autoconf'.  You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
 
 The simplest way to compile this package is:
 
@@ -70,22 +54,20 @@ The simplest way to compile this package is:
 Compilers and Options
 =====================
 
-Some systems require unusual options for compilation or linking that the
-`configure' script does not know about.  Run `./configure --help' for
-details on some of the pertinent environment variables.
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  You can give `configure'
+initial values for variables by setting them in the environment.  Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+     CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
 
-   You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment.  Here
-is an example:
-
-     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
-
-   *Note Defining Variables::, for more details.
+Or on systems that have the `env' program, you can do it like this:
+     env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
 
 Compiling For Multiple Architectures
 ====================================
 
-You can compile the package for more than one kind of computer at the
+   You can compile the package for more than one kind of computer at the
 same time, by placing the object files for each architecture in their
 own directory.  To do this, you must use a version of `make' that
 supports the `VPATH' variable, such as GNU `make'.  `cd' to the
@@ -93,28 +75,27 @@ directory where you want the object files and executables to go and run
 the `configure' script.  `configure' automatically checks for the
 source code in the directory that `configure' is in and in `..'.
 
-   If you have to use a `make' that does not support the `VPATH'
-variable, you have to compile the package for one architecture at a
-time in the source code directory.  After you have installed the
-package for one architecture, use `make distclean' before reconfiguring
-for another architecture.
+   If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory.  After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
 
 Installation Names
 ==================
 
-By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc.  You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX'.
+   By default, `make install' will install the package's files in
+`/opt/collectd'.  You can specify an installation prefix other than
+`/opt/collectd' by giving `configure' the option `--prefix=PATH'.
 
    You can specify separate installation prefixes for
 architecture-specific files and architecture-independent files.  If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
 
    In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
+options like `--bindir=PATH' to specify different values for particular
 kinds of files.  Run `configure --help' for a list of the directories
 you can set and what kinds of files go in them.
 
@@ -125,7 +106,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
 Optional Features
 =================
 
-Some packages pay attention to `--enable-FEATURE' options to
+   Some packages pay attention to `--enable-FEATURE' options to
 `configure', where FEATURE indicates an optional part of the package.
 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
 is something like `gnu-as' or `x' (for the X Window System).  The
@@ -140,86 +121,48 @@ you can use the `configure' options `--x-includes=DIR' and
 Specifying the System Type
 ==========================
 
-There may be some features `configure' cannot figure out automatically,
-but needs to determine by the type of machine the package will run on.
-Usually, assuming the package is built to be run on the _same_
-architectures, `configure' can figure that out, but if it prints a
-message saying it cannot guess the machine type, give it the
-`--build=TYPE' option.  TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
+   There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on.  Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
      CPU-COMPANY-SYSTEM
 
-where SYSTEM can have one of these forms:
-
-     OS KERNEL-OS
-
-   See the file `config.sub' for the possible values of each field.  If
+See the file `config.sub' for the possible values of each field.  If
 `config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
-   If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
-produce code for.
+need to know the host type.
 
-   If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
+   If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
 
 Sharing Defaults
 ================
 
-If you want to set default values for `configure' scripts to share, you
-can create a site shell script called `config.site' that gives default
-values for variables like `CC', `cache_file', and `prefix'.
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
 `configure' looks for `PREFIX/share/config.site' if it exists, then
 `PREFIX/etc/config.site' if it exists.  Or, you can set the
 `CONFIG_SITE' environment variable to the location of the site script.
 A warning: not all `configure' scripts look for a site script.
 
-Defining Variables
+Operation Controls
 ==================
 
-Variables not defined in a site shell script can be set in the
-environment passed to `configure'.  However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost.  In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'.  For example:
-
-     ./configure CC=/usr/local2/bin/gcc
-
-causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).  Here is a another example:
-
-     /bin/bash ./configure CONFIG_SHELL=/bin/bash
+   `configure' recognizes the following options to control how it
+operates.
 
-Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
-configuration-related scripts to be executed by `/bin/bash'.
-
-`configure' Invocation
-======================
-
-`configure' recognizes the following options to control how it operates.
+`--cache-file=FILE'
+     Use and save the results of the tests in FILE instead of
+     `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
+     debugging `configure'.
 
 `--help'
-`-h'
      Print a summary of the options to `configure', and exit.
 
-`--version'
-`-V'
-     Print the version of Autoconf used to generate the `configure'
-     script, and exit.
-
-`--cache-file=FILE'
-     Enable the cache: use and save the results of the tests in FILE,
-     traditionally `config.cache'.  FILE defaults to `/dev/null' to
-     disable caching.
-
-`--config-cache'
-`-C'
-     Alias for `--cache-file=config.cache'.
-
 `--quiet'
 `--silent'
 `-q'
@@ -231,6 +174,8 @@ configuration-related scripts to be executed by `/bin/bash'.
      Look for the package's source code in directory DIR.  Usually
      `configure' can determine that directory automatically.
 
-`configure' also accepts some other, not widely useful, options.  Run
-`configure --help' for more details.
+`--version'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
 
+`configure' also accepts some other, not widely useful, options.
index 35e96ea..c60110c 100644 (file)
@@ -5,3 +5,6 @@ EXTRA_DIST = collectd.spec contrib debian
 
 dist-hook:
        find $(distdir) -type d -name '.svn' | xargs rm -rf
+
+install-exec-hook:
+       $(mkinstalldirs) $(DESTDIR)$(localstatedir)/run
diff --git a/README b/README
index af8b92d..794904d 100644 (file)
--- a/README
+++ b/README
@@ -56,6 +56,9 @@ Features
     - Traffic
       (In/Outbound traffic on the interfaces)
 
+    - Users
+      (Currently logged in users)
+
   * Performance: Running as a daemon collectd doesn't spend much time in
     startup. Since collectd links against libping, librrd and libsensors it
     doesn't need to start any other processes.
diff --git a/collectd.spec b/collectd.spec
new file mode 100644 (file)
index 0000000..746f670
--- /dev/null
@@ -0,0 +1,135 @@
+Summary:       Statistics collection daemon for filling RRD files.
+Name:           collectd
+Version:       3.5.0
+Release:       1
+Source:                http://verplant.org/collectd/%{name}-%{version}.tar.gz
+License:       GPL
+Group:         System Environment/Daemons
+BuildRoot:     %{_tmppath}/%{name}-%{version}-root
+BuildPrereq:   lm_sensors-devel, rrdtool-devel
+Requires:      rrdtool
+Packager:      Florian octo Forster <octo@verplant.org>
+Vendor:                Florian octo Forster <octo@verplant.org>
+
+%description
+collectd is a small daemon written in C for performance.  It reads various
+system  statistics  and updates  RRD files,  creating  them if neccessary.
+Since the daemon doesn't need to startup every time it wants to update the
+files it's very fast and easy on the system. Also, the statistics are very
+fine grained since the files are updated every 10 seconds.
+
+%package sensors
+Summary:       libsensors-module for collectd.
+Group:         System Environment/Daemons
+Requires:      collectd = %{version}, lm_sensors
+%description sensors
+This  plugin  for  collectd  provides  querying  of sensors  supported  by
+lm_sensors.
+
+%package hddtemp
+Summary:       hddtemp-module for collectd.
+Group:         System Environment/Daemons
+Requires:      collectd = %{version}, hddtemp >= 0.3
+%description hddtemp
+This plugin for  collectd provides querying  the hddtemp-daemon.  For more
+information see hddtemp's homepage:  http://www.guzu.net/linux/hddtemp.php
+
+%prep
+rm -rf $RPM_BUILD_ROOT
+%setup
+
+%build
+./configure --prefix=%{_prefix} --sbindir=%{_sbindir} --mandir=%{_mandir} --libdir=%{_libdir}
+make
+
+%install
+make install DESTDIR=$RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/etc/default
+cp debian/collectd.default $RPM_BUILD_ROOT/etc/default/collectd
+mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
+cp contrib/init.d-rh7 $RPM_BUILD_ROOT/etc/rc.d/init.d/collectd
+mkdir -p $RPM_BUILD_ROOT/var/lib/collectd
+rm -f $RPM_BUILD_ROOT%{_libdir}/%{name}/*.a
+rm -f $RPM_BUILD_ROOT%{_libdir}/%{name}/*.la
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc AUTHORS COPYING ChangeLog INSTALL NEWS README
+%doc contrib
+%config /etc/default/collectd
+%attr(0755,root,root) /etc/rc.d/init.d/collectd
+%attr(0755,root,root) %{_sbindir}/collectd
+%attr(0444,root,root) %{_mandir}/man1/*
+%attr(0444,root,root) %{_libdir}/%{name}/cpu.so*
+%attr(0444,root,root) %{_libdir}/%{name}/cpufreq.so*
+%attr(0444,root,root) %{_libdir}/%{name}/disk.so*
+%attr(0444,root,root) %{_libdir}/%{name}/load.so*
+%attr(0444,root,root) %{_libdir}/%{name}/memory.so*
+%attr(0444,root,root) %{_libdir}/%{name}/nfs.so*
+%attr(0444,root,root) %{_libdir}/%{name}/ping.so*
+%attr(0444,root,root) %{_libdir}/%{name}/processes.so*
+%attr(0444,root,root) %{_libdir}/%{name}/serial.so*
+%attr(0444,root,root) %{_libdir}/%{name}/swap.so*
+%attr(0444,root,root) %{_libdir}/%{name}/traffic.so*
+%attr(0444,root,root) %{_libdir}/%{name}/users.so*
+%dir /var/lib/collectd
+
+%files sensors
+%attr(0444,root,root) %{_libdir}/%{name}/sensors.so*
+
+%files hddtemp
+%attr(0444,root,root) %{_libdir}/%{name}/hddtemp.so*
+
+%changelog
+* Wed Dec 07 2005 Florian octo Forster <octo@verplant.org> 3.5.0-1
+- New upstream version
+
+* Sat Nov 26 2005 Florian octo Forster <octo@verplant.org> 3.4.0-1
+- New upstream version
+
+* Sat Nov 05 2005 Florian octo Forster <octo@verplant.org> 3.3.0-1
+- New upstream version
+
+* Tue Oct 26 2005 Florian octo Forster <octo@verplant.org> 3.2.0-1
+- New upstream version
+- Added statement to remove the `*.la' files. This fixes a problem when
+  `Unpackaged files terminate build' is in effect.
+- Added `processes.so*' to the main package
+
+* Fri Oct 14 2005 Florian octo Forster <octo@verplant.org> 3.1.0-1
+- New upstream version
+- Added package `collectd-hddtemp'
+
+* Fri Sep 30 2005 Florian octo Forster <octo@verplant.org> 3.0.0-1
+- New upstream version
+- Split the package into `collectd' and `collectd-sensors'
+
+* Fri Sep 16 2005 Florian octo Forster <octo@verplant.org> 2.1.0-1
+- New upstream version
+
+* Mon Sep 10 2005 Florian octo Forster <octo@verplant.org> 2.0.0-1
+- New upstream version
+
+* Mon Aug 29 2005 Florian octo Forster <octo@verplant.org> 1.8.0-1
+- New upstream version
+
+* Sun Aug 25 2005 Florian octo Forster <octo@verplant.org> 1.7.0-1
+- New upstream version
+
+* Sun Aug 21 2005 Florian octo Forster <octo@verplant.org> 1.6.0-1
+- New upstream version
+
+* Sun Jul 17 2005 Florian octo Forster <octo@verplant.org> 1.5.1-1
+- New upstream version
+
+* Sun Jul 17 2005 Florian octo Forster <octo@verplant.org> 1.5-1
+- New upstream version
+
+* Mon Jul 11 2005 Florian octo Forster <octo@verplant.org> 1.4.2-1
+- New upstream version
+
+* Sat Jul 09 2005 Florian octo Forster <octo@verplant.org> 1.4-1
+- Built on RedHat 7.3
index 7556ac3..33d0383 100644 (file)
@@ -1,12 +1,15 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(src/collectd.c)
-AM_INIT_AUTOMAKE(collectd, 3.4.0-quota)
-AM_CONFIG_HEADER(src/config.h src/libping/config.h)
+AC_INIT(collectd, 3.5.alpha1-quota)
+AC_CONFIG_SRCDIR(src/collectd.c)
+AC_CONFIG_HEADERS(src/config.h src/libping/config.h)
+AM_INIT_AUTOMAKE(dist-bzip2)
 AC_LANG(C)
 
 AC_PREFIX_DEFAULT("/opt/collectd")
 
-dnl Checks for programs.
+#
+# Checks for programs.
+#
 AC_PROG_CC
 AC_PROG_CPP
 AC_PROG_INSTALL
@@ -14,63 +17,100 @@ AC_PROG_LN_S
 AC_PROG_MAKE_SET
 
 dnl configure libtool
-#AC_PROG_RANLIB
 AC_DISABLE_STATIC
 AC_LIBLTDL_CONVENIENCE
 AC_SUBST(LTDLINCL)
 AC_SUBST(LIBLTDL)
 AC_LIBTOOL_DLOPEN
 AC_PROG_LIBTOOL
+#AC_PROG_RANLIB
 AC_CONFIG_SUBDIRS(libltdl)
 
-dnl Checks for header files.
+#
+# Checks for header files.
+#
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(stdarg.h)
 AC_CHECK_HEADERS(fcntl.h)
 AC_CHECK_HEADERS(signal.h)
-AC_CHECK_HEADERS(limits.h)
 AC_CHECK_HEADERS(sys/socket.h)
 AC_CHECK_HEADERS(sys/select.h)
-AC_HEADER_TIME
+AC_CHECK_HEADERS(netdb.h)
 AC_CHECK_HEADERS(sys/resource.h)
 AC_CHECK_HEADERS(errno.h)
+AC_CHECK_HEADERS(syslog.h)
+
+# For cpu modules
+AC_CHECK_HEADERS(sys/sysctl.h sys/dkstat.h)
+
+# For load module
+AC_CHECK_HEADERS(sys/loadavg.h)
+
+# For ping module
 AC_CHECK_HEADERS(arpa/inet.h)
 AC_CHECK_HEADERS(netinet/in.h)
-AC_CHECK_HEADERS(netdb.h)
-AC_CHECK_HEADERS(syslog.h)
+
+# For users module
+AC_CHECK_HEADERS(utmp.h)
+AC_CHECK_HEADERS(utmpx.h)
+
+# For quota module
 AC_CHECK_HEADERS(grp.h pwd.h)
 AC_CHECK_HEADERS(ctype.h)
+AC_CHECK_HEADERS(limits.h)
+AC_CHECK_HEADERS(sys/quota.h)
+AC_CHECK_HEADERS(xfs/xqm.h)
+
+# For mount interface
 AC_CHECK_HEADERS(paths.h)
 AC_CHECK_HEADERS(mntent.h)
 AC_CHECK_HEADERS(sys/fs_types.h)
 AC_CHECK_HEADERS(sys/mntent.h)
 AC_CHECK_HEADERS(sys/mnttab.h)
 AC_CHECK_HEADERS(sys/mount.h)
-AC_CHECK_HEADERS(sys/quota.h)
 AC_CHECK_HEADERS(sys/vfs.h)
 AC_CHECK_HEADERS(sys/vfstab.h)
-AC_CHECK_HEADERS(xfs/xqm.h)
+
+# For debugging interface (variable number of arguments)
+AC_CHECK_HEADERS(stdarg.h)
 
 dnl Checking for libraries
 AC_CHECK_LIB(m, ext)
 
-dnl Checks for typedefs, structures, and compiler characteristics.
+#
+# Checks for typedefs, structures, and compiler characteristics.
+#
 AC_C_CONST
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
+AC_HEADER_TIME
 
-dnl Checks for library functions.
+#
+# Checks for library functions.
+#
 AC_PROG_GCC_TRADITIONAL
 AC_CHECK_FUNCS(gettimeofday select strdup strtol)
 AC_CHECK_FUNCS(socket, , AC_CHECK_LIB(socket, socket))
 AC_CHECK_FUNCS(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
 AC_CHECK_FUNCS(strchr memcpy strstr strcmp strncmp strncpy strlen)
 AC_CHECK_FUNCS(strncasecmp strcasecmp)
+
+# For cpu module
+AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
+
+# For load module
+AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
+
+# For users module
+have_getutent="no"
+AC_CHECK_FUNCS(getutent getutxent, [have_getutent="yes"])
+
+# For quota module
 AC_CHECK_FUNCS(quotactl)
 AC_CHECK_FUNCS(getgrgid getpwuid)
+
+# For mount interface
 AC_CHECK_FUNCS(getfsent getvfsent listmntent)
 AC_FUNC_GETMNTENT
-
 if test "x$ac_cv_func_getmntent" = 'xyes'; then
        saveCFLAGS="$CFLAGS"
        CFLAGS="-Wall -Werror $CFLAGS"
@@ -217,6 +257,8 @@ AC_ARG_WITH(libstatgrab, AC_HELP_STRING([--with-libstatgrab@<:@=PFX@:>@], [Path
 ])
 if test "x$with_libstatgrab" = "xyes"
 then
+       AC_CHECK_LIB(devstat, getdevs)
+       AC_CHECK_LIB(kvm, kvm_getargv)
        AC_CHECK_LIB(statgrab, sg_init,, [with_libstatgrab="no (not found)"])
        AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (not found)"])
 fi
@@ -307,7 +349,7 @@ AM_CONDITIONAL(BUILD_DAEMON, test "x$enable_daemon" = "xyes")
 AC_ARG_ENABLE(cpu, AC_HELP_STRING([--disable-cpu], [Disable CPU usage statistics]),, [enable_cpu="yes"])
 if test "x$enable_cpu" != "xno"
 then
-       if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes"
+       if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$have_sysctlbyname" = "xyes"
        then
                enable_cpu="yes"
        else
@@ -382,7 +424,7 @@ AM_CONDITIONAL(BUILD_MODULE_HDDTEMP, test "x$enable_hddtemp" = "xyes")
 AC_ARG_ENABLE(load, AC_HELP_STRING([--disable-load], [Disable system load statistics]),, [enable_load="yes"])
 if test "x$enable_load" != "xno"
 then
-       if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes"
+       if test "x$have_getloadavg" = "xyes" -o "x$ac_system" = "xLinux" -o "x$with_libstatgrab" = "xyes"
        then
                enable_load="yes"
        else
@@ -534,6 +576,22 @@ then
 fi
 AM_CONDITIONAL(BUILD_MODULE_TRAFFIC, test "x$enable_traffic" = "xyes")
 
+AC_ARG_ENABLE(users, AC_HELP_STRING([--disable-users], [Disable user count statistics]),, [enable_users="yes"])
+if test "x$enable_users" != "xno"
+then
+       if test "x$have_getutent" = "xyes"
+       then
+               enable_users="yes"
+       else
+               enable_users="no"
+       fi
+fi
+if test "x$enable_users" = "xno"
+then
+       AC_DEFINE(COLLECT_USERS, 0, [Wether or not to collect user count statistics])
+fi
+AM_CONDITIONAL(BUILD_MODULE_USERS, test "x$enable_users" = "xyes")
+
 AC_OUTPUT(Makefile src/libping/Makefile src/Makefile)
 
 cat <<EOF;
@@ -566,5 +624,6 @@ Configuration:
     swap  . . . . . . . $enable_swap
     tape  . . . . . . . $enable_tape
     traffic . . . . . . $enable_traffic
+    users . . . . . . . $enable_users
 
 EOF
diff --git a/contrib/museum/collection.cgi b/contrib/museum/collection.cgi
new file mode 100755 (executable)
index 0000000..b048d52
--- /dev/null
@@ -0,0 +1,1211 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+no warnings ('qw');
+
+use CGI;
+use RRDs;
+use Fcntl (qw(:flock));
+use Carp (qw(carp cluck confess croak));
+
+our $Config = read_config ();
+
+our $AbsDir;
+our $RelDir;
+our $Type;
+our $Inst;
+our $TimeSpan;
+
+for (qw(Red Green Blue Yellow Cyan Magenta))
+{
+       $Config->{'Colors'}{"Half$_"} = color_calculate_transparent ($Config->{'Colors'}{'Alpha'},
+               $Config->{'Colors'}{'Canvas'}, $Config->{'Colors'}{"Full$_"});
+}
+
+$Config->{'Colors'}{'HalfBlueGreen'} = color_calculate_transparent ($Config->{'Colors'}{'Alpha'},
+       $Config->{'Colors'}{'Canvas'}, $Config->{'Colors'}{'FullGreen'}, $Config->{'Colors'}{'FullBlue'});
+$Config->{'Colors'}{'HalfRedBlue'} = color_calculate_transparent ($Config->{'Colors'}{'Alpha'},
+       $Config->{'Colors'}{'Canvas'}, $Config->{'Colors'}{'FullBlue'}, $Config->{'Colors'}{'FullRed'});
+
+our $GraphDefs;
+{
+       my $Alpha  = $Config->{'Colors'}{'Alpha'};
+       my $Canvas = $Config->{'Colors'}{'Canvas'};
+
+       my $FullRed    = $Config->{'Colors'}{'FullRed'};
+       my $FullGreen  = $Config->{'Colors'}{'FullGreen'};
+       my $FullBlue   = $Config->{'Colors'}{'FullBlue'};
+       my $FullYellow = $Config->{'Colors'}{'FullYellow'};
+       my $FullCyan   = $Config->{'Colors'}{'FullCyan'};
+       my $FullMagenta= $Config->{'Colors'}{'FullMagenta'};
+
+       my $HalfRed    = $Config->{'Colors'}{'HalfRed'};
+       my $HalfGreen  = $Config->{'Colors'}{'HalfGreen'};
+       my $HalfBlue   = $Config->{'Colors'}{'HalfBlue'};
+       my $HalfYellow = $Config->{'Colors'}{'HalfYellow'};
+       my $HalfCyan   = $Config->{'Colors'}{'HalfCyan'};
+       my $HalfMagenta= $Config->{'Colors'}{'HalfMagenta'};
+
+       my $HalfBlueGreen = $Config->{'Colors'}{'HalfBlueGreen'};
+       my $HalfRedBlue   = $Config->{'Colors'}{'HalfRedBlue'};
+       
+       $GraphDefs =
+       {
+               cpu => ['DEF:user_avg={file}:user:AVERAGE',
+                       'DEF:user_min={file}:user:MIN',
+                       'DEF:user_max={file}:user:MAX',
+                       'DEF:nice_avg={file}:nice:AVERAGE',
+                       'DEF:nice_min={file}:nice:MIN',
+                       'DEF:nice_max={file}:nice:MAX',
+                       'DEF:syst_avg={file}:syst:AVERAGE',
+                       'DEF:syst_min={file}:syst:MIN',
+                       'DEF:syst_max={file}:syst:MAX',
+                       'DEF:wait_avg={file}:wait:AVERAGE',
+                       'DEF:wait_min={file}:wait:MIN',
+                       'DEF:wait_max={file}:wait:MAX',
+                       'CDEF:user_avg_notnull=user_avg,UN,0,user_avg,IF',
+                       'CDEF:nice_avg_notnull=nice_avg,UN,0,nice_avg,IF',
+                       'CDEF:syst_avg_notnull=syst_avg,UN,0,syst_avg,IF',
+                       'CDEF:wait_avg_notnull=wait_avg,UN,0,wait_avg,IF',
+                       'CDEF:nice_acc=syst_avg,wait_avg_notnull,user_avg,nice_avg_notnull,+,+,+',
+                       'CDEF:user_acc=syst_avg,wait_avg_notnull,user_avg,+,+',
+                       'CDEF:wait_acc=syst_avg,wait_avg_notnull,+',
+                       'CDEF:syst_acc=syst_avg',
+                       "AREA:nice_acc#$HalfGreen",
+                       "AREA:user_acc#$HalfBlue",
+                       "AREA:wait_acc#$HalfYellow",
+                       "AREA:syst_acc#$HalfRed",
+                       "LINE1:nice_acc#$FullGreen:Nice   ",
+                       'GPRINT:nice_min:MIN:%5.1lf%% Min,',
+                       'GPRINT:nice_avg:AVERAGE:%5.1lf%% Avg,',
+                       'GPRINT:nice_max:MAX:%5.1lf%% Max,',
+                       'GPRINT:nice_avg:LAST:%5.1lf%% Last\l',
+                       "LINE1:user_acc#$FullBlue:User   ",
+                       'GPRINT:user_min:MIN:%5.1lf%% Min,',
+                       'GPRINT:user_avg:AVERAGE:%5.1lf%% Avg,',
+                       'GPRINT:user_max:MAX:%5.1lf%% Max,',
+                       'GPRINT:user_avg:LAST:%5.1lf%% Last\l',
+                       "LINE1:wait_acc#$FullYellow:Wait-IO",
+                       'GPRINT:wait_min:MIN:%5.1lf%% Min,',
+                       'GPRINT:wait_avg:AVERAGE:%5.1lf%% Avg,',
+                       'GPRINT:wait_max:MAX:%5.1lf%% Max,',
+                       'GPRINT:wait_avg:LAST:%5.1lf%% Last\l',
+                       "LINE1:syst_acc#$FullRed:System ",
+                       'GPRINT:syst_min:MIN:%5.1lf%% Min,',
+                       'GPRINT:syst_avg:AVERAGE:%5.1lf%% Avg,',
+                       'GPRINT:syst_max:MAX:%5.1lf%% Max,',
+                       'GPRINT:syst_avg:LAST:%5.1lf%% Last\l'
+               ],
+               disk => [
+                       'DEF:rtime_avg={file}:rtime:AVERAGE',
+                       'DEF:rtime_min={file}:rtime:MIN',
+                       'DEF:rtime_max={file}:rtime:MAX',
+                       'DEF:wtime_avg={file}:wtime:AVERAGE',
+                       'DEF:wtime_min={file}:wtime:MIN',
+                       'DEF:wtime_max={file}:wtime:MAX',
+                       'CDEF:rtime_avg_ms=rtime_avg,1000,/',
+                       'CDEF:rtime_min_ms=rtime_min,1000,/',
+                       'CDEF:rtime_max_ms=rtime_max,1000,/',
+                       'CDEF:wtime_avg_ms=wtime_avg,1000,/',
+                       'CDEF:wtime_min_ms=wtime_min,1000,/',
+                       'CDEF:wtime_max_ms=wtime_max,1000,/',
+                       'CDEF:total_avg_ms=rtime_avg_ms,wtime_avg_ms,+',
+                       'CDEF:total_min_ms=rtime_min_ms,wtime_min_ms,+',
+                       'CDEF:total_max_ms=rtime_max_ms,wtime_max_ms,+',
+                       "AREA:total_max_ms#$HalfRed",
+                       "AREA:total_min_ms#$Canvas",
+                       "LINE1:wtime_avg_ms#$FullGreen:Write",
+                       'GPRINT:wtime_min_ms:MIN:%5.1lf%s Min,',
+                       'GPRINT:wtime_avg_ms:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:wtime_max_ms:MAX:%5.1lf%s Max,',
+                       'GPRINT:wtime_avg_ms:LAST:%5.1lf%s Last\n',
+                       "LINE1:rtime_avg_ms#$FullBlue:Read ",
+                       'GPRINT:rtime_min_ms:MIN:%5.1lf%s Min,',
+                       'GPRINT:rtime_avg_ms:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:rtime_max_ms:MAX:%5.1lf%s Max,',
+                       'GPRINT:rtime_avg_ms:LAST:%5.1lf%s Last\n',
+                       "LINE1:total_avg_ms#$FullRed:Total",
+                       'GPRINT:total_min_ms:MIN:%5.1lf%s Min,',
+                       'GPRINT:total_avg_ms:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:total_max_ms:MAX:%5.1lf%s Max,',
+                       'GPRINT:total_avg_ms:LAST:%5.1lf%s Last'
+               ],
+               hddtemp => [
+                       'DEF:temp_avg={file}:value:AVERAGE',
+                       'DEF:temp_min={file}:value:MIN',
+                       'DEF:temp_max={file}:value:MAX',
+                       "AREA:temp_max#$HalfBlue",
+                       "AREA:temp_min#$Canvas",
+                       "LINE1:temp_avg#$FullBlue:Temperature",
+                       'GPRINT:temp_min:MIN:%4.1lf Min,',
+                       'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
+                       'GPRINT:temp_max:MAX:%4.1lf Max,',
+                       'GPRINT:temp_avg:LAST:%4.1lf Last\l'
+               ],
+               load => ['DEF:s_avg={file}:shortterm:AVERAGE',
+                       'DEF:s_min={file}:shortterm:MIN',
+                       'DEF:s_max={file}:shortterm:MAX',
+                       'DEF:m_avg={file}:midterm:AVERAGE',
+                       'DEF:m_min={file}:midterm:MIN',
+                       'DEF:m_max={file}:midterm:MAX',
+                       'DEF:l_avg={file}:longterm:AVERAGE',
+                       'DEF:l_min={file}:longterm:MIN',
+                       'DEF:l_max={file}:longterm:MAX',
+                       "AREA:s_max#$HalfGreen",
+                       "AREA:s_min#$Canvas",
+                       "LINE1:s_avg#$FullGreen: 1m average",
+                       'GPRINT:s_min:MIN:%4.2lf Min,',
+                       'GPRINT:s_avg:AVERAGE:%4.2lf Avg,',
+                       'GPRINT:s_max:MAX:%4.2lf Max,',
+                       'GPRINT:s_avg:LAST:%4.2lf Last\n',
+                       "LINE1:m_avg#$FullBlue: 5m average",
+                       'GPRINT:m_min:MIN:%4.2lf Min,',
+                       'GPRINT:m_avg:AVERAGE:%4.2lf Avg,',
+                       'GPRINT:m_max:MAX:%4.2lf Max,',
+                       'GPRINT:m_avg:LAST:%4.2lf Last\n',
+                       "LINE1:l_avg#$FullRed:15m average",
+                       'GPRINT:l_min:MIN:%4.2lf Min,',
+                       'GPRINT:l_avg:AVERAGE:%4.2lf Avg,',
+                       'GPRINT:l_max:MAX:%4.2lf Max,',
+                       'GPRINT:l_avg:LAST:%4.2lf Last'
+               ],
+               mails => ['DEF:rawgood={file}:good:AVERAGE',
+                       'DEF:rawspam={file}:spam:AVERAGE',
+                       'CDEF:good=rawgood,UN,0,rawgood,IF',
+                       'CDEF:spam=rawspam,UN,0,rawspam,IF',
+                       'CDEF:negspam=spam,-1,*',
+                       "AREA:good#$HalfGreen",
+                       "LINE1:good#$FullGreen:Good mails",
+                       'GPRINT:good:AVERAGE:%4.1lf Avg,',
+                       'GPRINT:good:MAX:%4.1lf Max,',
+                       'GPRINT:good:LAST:%4.1lf Last\n',
+                       "AREA:negspam#$HalfRed",
+                       "LINE1:negspam#$FullRed:Spam mails",
+                       'GPRINT:spam:AVERAGE:%4.1lf Avg,',
+                       'GPRINT:spam:MAX:%4.1lf Max,',
+                       'GPRINT:spam:LAST:%4.1lf Last',
+                       'HRULE:0#000000'],
+               memory => [
+                       'DEF:used_avg={file}:used:AVERAGE',
+                       'DEF:free_avg={file}:free:AVERAGE',
+                       'DEF:buffers_avg={file}:buffers:AVERAGE',
+                       'DEF:cached_avg={file}:cached:AVERAGE',
+                       'DEF:used_min={file}:used:MIN',
+                       'DEF:free_min={file}:free:MIN',
+                       'DEF:buffers_min={file}:buffers:MIN',
+                       'DEF:cached_min={file}:cached:MIN',
+                       'DEF:used_max={file}:used:MAX',
+                       'DEF:free_max={file}:free:MAX',
+                       'DEF:buffers_max={file}:buffers:MAX',
+                       'DEF:cached_max={file}:cached:MAX',
+                       'CDEF:free_cached_buffers_used=free_avg,cached_avg,+,buffers_avg,+,used_avg,+',
+                       'CDEF:cached_buffers_used=cached_avg,buffers_avg,+,used_avg,+',
+                       'CDEF:buffers_used=buffers_avg,used_avg,+',
+                       "AREA:free_cached_buffers_used#$HalfGreen",
+                       "AREA:cached_buffers_used#$HalfBlue",
+                       "AREA:buffers_used#$HalfYellow",
+                       "AREA:used_avg#$HalfRed",
+                       "LINE1:free_cached_buffers_used#$FullGreen:Free        ",
+                       'GPRINT:free_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:free_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
+                       "LINE1:cached_buffers_used#$FullBlue:Page cache  ",
+                       'GPRINT:cached_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:cached_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:cached_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:cached_avg:LAST:%5.1lf%s Last\n',
+                       "LINE1:buffers_used#$FullYellow:Buffer cache",
+                       'GPRINT:buffers_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:buffers_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:buffers_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:buffers_avg:LAST:%5.1lf%s Last\n',
+                       "LINE1:used_avg#$FullRed:Used        ",
+                       'GPRINT:used_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:used_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:used_avg:LAST:%5.1lf%s Last'
+               ],
+               nfs3_procedures => [
+                       "DEF:null_avg={file}:null:AVERAGE",
+                       "DEF:getattr_avg={file}:getattr:AVERAGE",
+                       "DEF:setattr_avg={file}:setattr:AVERAGE",
+                       "DEF:lookup_avg={file}:lookup:AVERAGE",
+                       "DEF:access_avg={file}:access:AVERAGE",
+                       "DEF:readlink_avg={file}:readlink:AVERAGE",
+                       "DEF:read_avg={file}:read:AVERAGE",
+                       "DEF:write_avg={file}:write:AVERAGE",
+                       "DEF:create_avg={file}:create:AVERAGE",
+                       "DEF:mkdir_avg={file}:mkdir:AVERAGE",
+                       "DEF:symlink_avg={file}:symlink:AVERAGE",
+                       "DEF:mknod_avg={file}:mknod:AVERAGE",
+                       "DEF:remove_avg={file}:remove:AVERAGE",
+                       "DEF:rmdir_avg={file}:rmdir:AVERAGE",
+                       "DEF:rename_avg={file}:rename:AVERAGE",
+                       "DEF:link_avg={file}:link:AVERAGE",
+                       "DEF:readdir_avg={file}:readdir:AVERAGE",
+                       "DEF:readdirplus_avg={file}:readdirplus:AVERAGE",
+                       "DEF:fsstat_avg={file}:fsstat:AVERAGE",
+                       "DEF:fsinfo_avg={file}:fsinfo:AVERAGE",
+                       "DEF:pathconf_avg={file}:pathconf:AVERAGE",
+                       "DEF:commit_avg={file}:commit:AVERAGE",
+                       "DEF:null_max={file}:null:MAX",
+                       "DEF:getattr_max={file}:getattr:MAX",
+                       "DEF:setattr_max={file}:setattr:MAX",
+                       "DEF:lookup_max={file}:lookup:MAX",
+                       "DEF:access_max={file}:access:MAX",
+                       "DEF:readlink_max={file}:readlink:MAX",
+                       "DEF:read_max={file}:read:MAX",
+                       "DEF:write_max={file}:write:MAX",
+                       "DEF:create_max={file}:create:MAX",
+                       "DEF:mkdir_max={file}:mkdir:MAX",
+                       "DEF:symlink_max={file}:symlink:MAX",
+                       "DEF:mknod_max={file}:mknod:MAX",
+                       "DEF:remove_max={file}:remove:MAX",
+                       "DEF:rmdir_max={file}:rmdir:MAX",
+                       "DEF:rename_max={file}:rename:MAX",
+                       "DEF:link_max={file}:link:MAX",
+                       "DEF:readdir_max={file}:readdir:MAX",
+                       "DEF:readdirplus_max={file}:readdirplus:MAX",
+                       "DEF:fsstat_max={file}:fsstat:MAX",
+                       "DEF:fsinfo_max={file}:fsinfo:MAX",
+                       "DEF:pathconf_max={file}:pathconf:MAX",
+                       "DEF:commit_max={file}:commit:MAX",
+                       "CDEF:other_avg=null_avg,readlink_avg,create_avg,mkdir_avg,symlink_avg,mknod_avg,remove_avg,rmdir_avg,rename_avg,link_avg,readdir_avg,readdirplus_avg,fsstat_avg,fsinfo_avg,pathconf_avg,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
+                       "CDEF:other_max=null_max,readlink_max,create_max,mkdir_max,symlink_max,mknod_max,remove_max,rmdir_max,rename_max,link_max,readdir_max,readdirplus_max,fsstat_max,fsinfo_max,pathconf_max,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
+                       "CDEF:stack_read=read_avg",
+                       "CDEF:stack_getattr=stack_read,getattr_avg,+",
+                       "CDEF:stack_access=stack_getattr,access_avg,+",
+                       "CDEF:stack_lookup=stack_access,lookup_avg,+",
+                       "CDEF:stack_write=stack_lookup,write_avg,+",
+                       "CDEF:stack_commit=stack_write,commit_avg,+",
+                       "CDEF:stack_setattr=stack_commit,setattr_avg,+",
+                       "CDEF:stack_other=stack_setattr,other_avg,+",
+                       "AREA:stack_other#$HalfRed",
+                       "AREA:stack_setattr#$HalfGreen",
+                       "AREA:stack_commit#$HalfYellow",
+                       "AREA:stack_write#$HalfGreen",
+                       "AREA:stack_lookup#$HalfBlue",
+                       "AREA:stack_access#$HalfMagenta",
+                       "AREA:stack_getattr#$HalfCyan",
+                       "AREA:stack_read#$HalfBlue",
+                       "LINE1:stack_other#$FullRed:Other  ",
+                       'GPRINT:other_max:MAX:%5.1lf Max,',
+                       'GPRINT:other_avg:AVERAGE:%5.1lf Avg,',
+                       'GPRINT:other_avg:LAST:%5.1lf Last\l',
+                       "LINE1:stack_setattr#$FullGreen:setattr",
+                       'GPRINT:setattr_max:MAX:%5.1lf Max,',
+                       'GPRINT:setattr_avg:AVERAGE:%5.1lf Avg,',
+                       'GPRINT:setattr_avg:LAST:%5.1lf Last\l',
+                       "LINE1:stack_commit#$FullYellow:commit ",
+                       'GPRINT:commit_max:MAX:%5.1lf Max,',
+                       'GPRINT:commit_avg:AVERAGE:%5.1lf Avg,',
+                       'GPRINT:commit_avg:LAST:%5.1lf Last\l',
+                       "LINE1:stack_write#$FullGreen:write  ",
+                       'GPRINT:write_max:MAX:%5.1lf Max,',
+                       'GPRINT:write_avg:AVERAGE:%5.1lf Avg,',
+                       'GPRINT:write_avg:LAST:%5.1lf Last\l',
+                       "LINE1:stack_lookup#$FullBlue:lookup ",
+                       'GPRINT:lookup_max:MAX:%5.1lf Max,',
+                       'GPRINT:lookup_avg:AVERAGE:%5.1lf Avg,',
+                       'GPRINT:lookup_avg:LAST:%5.1lf Last\l',
+                       "LINE1:stack_access#$FullMagenta:access ",
+                       'GPRINT:access_max:MAX:%5.1lf Max,',
+                       'GPRINT:access_avg:AVERAGE:%5.1lf Avg,',
+                       'GPRINT:access_avg:LAST:%5.1lf Last\l',
+                       "LINE1:stack_getattr#$FullCyan:getattr",
+                       'GPRINT:getattr_max:MAX:%5.1lf Max,',
+                       'GPRINT:getattr_avg:AVERAGE:%5.1lf Avg,',
+                       'GPRINT:getattr_avg:LAST:%5.1lf Last\l',
+                       "LINE1:stack_read#$FullBlue:read   ",
+                       'GPRINT:read_max:MAX:%5.1lf Max,',
+                       'GPRINT:read_avg:AVERAGE:%5.1lf Avg,',
+                       'GPRINT:read_avg:LAST:%5.1lf Last\l'
+               ],
+               partition => [
+                       "DEF:rbyte_avg={file}:rbytes:AVERAGE",
+                       "DEF:rbyte_min={file}:rbytes:MIN",
+                       "DEF:rbyte_max={file}:rbytes:MAX",
+                       "DEF:wbyte_avg={file}:wbytes:AVERAGE",
+                       "DEF:wbyte_min={file}:wbytes:MIN",
+                       "DEF:wbyte_max={file}:wbytes:MAX",
+                       'CDEF:overlap=wbyte_avg,rbyte_avg,GT,rbyte_avg,wbyte_avg,IF',
+                       "AREA:wbyte_avg#$HalfGreen",
+                       "AREA:rbyte_avg#$HalfBlue",
+                       "AREA:overlap#$HalfBlueGreen",
+                       "LINE1:wbyte_avg#$FullGreen:Write",
+                       'GPRINT:wbyte_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:wbyte_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:wbyte_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:wbyte_avg:LAST:%5.1lf%s Last\l',
+                       "LINE1:rbyte_avg#$FullBlue:Read ",
+                       'GPRINT:rbyte_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:rbyte_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:rbyte_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:rbyte_avg:LAST:%5.1lf%s Last\l'
+               ],
+               ping => ['DEF:ping_avg={file}:ping:AVERAGE',
+                       'DEF:ping_min={file}:ping:MIN',
+                       'DEF:ping_max={file}:ping:MAX',
+                       "AREA:ping_max#$HalfBlue",
+                       "AREA:ping_min#$Canvas",
+                       "LINE1:ping_avg#$FullBlue:Ping",
+                       'GPRINT:ping_min:MIN:%4.1lf ms Min,',
+                       'GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,',
+                       'GPRINT:ping_max:MAX:%4.1lf ms Max,',
+                       'GPRINT:ping_avg:LAST:%4.1lf ms Last'],
+               processes => [
+                       "DEF:running_avg={file}:running:AVERAGE",
+                       "DEF:running_min={file}:running:MIN",
+                       "DEF:running_max={file}:running:MAX",
+                       "DEF:sleeping_avg={file}:sleeping:AVERAGE",
+                       "DEF:sleeping_min={file}:sleeping:MIN",
+                       "DEF:sleeping_max={file}:sleeping:MAX",
+                       "DEF:zombies_avg={file}:zombies:AVERAGE",
+                       "DEF:zombies_min={file}:zombies:MIN",
+                       "DEF:zombies_max={file}:zombies:MAX",
+                       "DEF:stopped_avg={file}:stopped:AVERAGE",
+                       "DEF:stopped_min={file}:stopped:MIN",
+                       "DEF:stopped_max={file}:stopped:MAX",
+                       "DEF:paging_avg={file}:paging:AVERAGE",
+                       "DEF:paging_min={file}:paging:MIN",
+                       "DEF:paging_max={file}:paging:MAX",
+                       "DEF:blocked_avg={file}:blocked:AVERAGE",
+                       "DEF:blocked_min={file}:blocked:MIN",
+                       "DEF:blocked_max={file}:blocked:MAX",
+                       'CDEF:paging_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,paging_avg,+,+,+,+,+',
+                       'CDEF:blocked_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,+,+,+,+',
+                       'CDEF:zombies_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,+,+,+',
+                       'CDEF:stopped_acc=sleeping_avg,running_avg,stopped_avg,+,+',
+                       'CDEF:running_acc=sleeping_avg,running_avg,+',
+                       'CDEF:sleeping_acc=sleeping_avg',
+                       "AREA:paging_acc#$HalfYellow",
+                       "AREA:blocked_acc#$HalfCyan",
+                       "AREA:zombies_acc#$HalfRed",
+                       "AREA:stopped_acc#$HalfMagenta",
+                       "AREA:running_acc#$HalfGreen",
+                       "AREA:sleeping_acc#$HalfBlue",
+                       "LINE1:paging_acc#$FullYellow:Paging  ",
+                       'GPRINT:paging_min:MIN:%5.1lf Min,',
+                       'GPRINT:paging_avg:AVERAGE:%5.1lf Average,',
+                       'GPRINT:paging_max:MAX:%5.1lf Max,',
+                       'GPRINT:paging_avg:LAST:%5.1lf Last\l',
+                       "LINE1:blocked_acc#$FullCyan:Blocked ",
+                       'GPRINT:blocked_min:MIN:%5.1lf Min,',
+                       'GPRINT:blocked_avg:AVERAGE:%5.1lf Average,',
+                       'GPRINT:blocked_max:MAX:%5.1lf Max,',
+                       'GPRINT:blocked_avg:LAST:%5.1lf Last\l',
+                       "LINE1:zombies_acc#$FullRed:Zombies ",
+                       'GPRINT:zombies_min:MIN:%5.1lf Min,',
+                       'GPRINT:zombies_avg:AVERAGE:%5.1lf Average,',
+                       'GPRINT:zombies_max:MAX:%5.1lf Max,',
+                       'GPRINT:zombies_avg:LAST:%5.1lf Last\l',
+                       "LINE1:stopped_acc#$FullMagenta:Stopped ",
+                       'GPRINT:stopped_min:MIN:%5.1lf Min,',
+                       'GPRINT:stopped_avg:AVERAGE:%5.1lf Average,',
+                       'GPRINT:stopped_max:MAX:%5.1lf Max,',
+                       'GPRINT:stopped_avg:LAST:%5.1lf Last\l',
+                       "LINE1:running_acc#$FullGreen:Running ",
+                       'GPRINT:running_min:MIN:%5.1lf Min,',
+                       'GPRINT:running_avg:AVERAGE:%5.1lf Average,',
+                       'GPRINT:running_max:MAX:%5.1lf Max,',
+                       'GPRINT:running_avg:LAST:%5.1lf Last\l',
+                       "LINE1:sleeping_acc#$FullBlue:Sleeping",
+                       'GPRINT:sleeping_min:MIN:%5.1lf Min,',
+                       'GPRINT:sleeping_avg:AVERAGE:%5.1lf Average,',
+                       'GPRINT:sleeping_max:MAX:%5.1lf Max,',
+                       'GPRINT:sleeping_avg:LAST:%5.1lf Last\l'
+               ],
+               sensors => [
+                       'DEF:temp_avg={file}:value:AVERAGE',
+                       'DEF:temp_min={file}:value:MIN',
+                       'DEF:temp_max={file}:value:MAX',
+                       "AREA:temp_max#$HalfBlue",
+                       "AREA:temp_min#$Canvas",
+                       "LINE1:temp_avg#$FullBlue:Value",
+                       'GPRINT:temp_min:MIN:%4.1lf Min,',
+                       'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
+                       'GPRINT:temp_max:MAX:%4.1lf Max,',
+                       'GPRINT:temp_avg:LAST:%4.1lf Last\l'
+               ],
+               swap => [
+                       'DEF:used_avg={file}:used:AVERAGE',
+                       'DEF:used_min={file}:used:MIN',
+                       'DEF:used_max={file}:used:MAX',
+                       'DEF:free_avg={file}:free:AVERAGE',
+                       'DEF:free_min={file}:free:MIN',
+                       'DEF:free_max={file}:free:MAX',
+                       'DEF:cach_avg={file}:cached:AVERAGE',
+                       'DEF:cach_min={file}:cached:MIN',
+                       'DEF:cach_max={file}:cached:MAX',
+                       'DEF:resv_avg={file}:resv:AVERAGE',
+                       'DEF:resv_min={file}:resv:MIN',
+                       'DEF:resv_max={file}:resv:MAX',
+                       'CDEF:cach_avg_notnull=cach_avg,UN,0,cach_avg,IF',
+                       'CDEF:resv_avg_notnull=resv_avg,UN,0,resv_avg,IF',
+                       'CDEF:used_acc=used_avg',
+                       'CDEF:resv_acc=used_acc,resv_avg_notnull,+',
+                       'CDEF:cach_acc=resv_acc,cach_avg_notnull,+',
+                       'CDEF:free_acc=cach_acc,free_avg,+',
+                       "AREA:free_acc#$HalfGreen",
+                       "AREA:cach_acc#$HalfBlue",
+                       "AREA:resv_acc#$HalfYellow",
+                       "AREA:used_acc#$HalfRed",
+                       "LINE1:free_acc#$FullGreen:Free    ",
+                       'GPRINT:free_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:free_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
+                       "LINE1:cach_acc#$FullBlue:Cached  ",
+                       'GPRINT:cach_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:cach_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:cach_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:cach_avg:LAST:%5.1lf%s Last\l',
+                       "LINE1:resv_acc#$FullYellow:Reserved",
+                       'GPRINT:resv_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:resv_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:resv_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:resv_avg:LAST:%5.1lf%s Last\n',
+                       "LINE1:used_acc#$FullRed:Used    ",
+                       'GPRINT:used_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:used_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:used_avg:LAST:%5.1lf%s Last\l'
+               ],
+               traffic => ['DEF:out_min_raw={file}:outgoing:MIN',
+                       'DEF:out_avg_raw={file}:outgoing:AVERAGE',
+                       'DEF:out_max_raw={file}:outgoing:MAX',
+                       'DEF:inc_min_raw={file}:incoming:MIN',
+                       'DEF:inc_avg_raw={file}:incoming:AVERAGE',
+                       'DEF:inc_max_raw={file}:incoming:MAX',
+                       'CDEF:out_min=out_min_raw,8,*',
+                       'CDEF:out_avg=out_avg_raw,8,*',
+                       'CDEF:out_max=out_max_raw,8,*',
+                       'CDEF:inc_min=inc_min_raw,8,*',
+                       'CDEF:inc_avg=inc_avg_raw,8,*',
+                       'CDEF:inc_max=inc_max_raw,8,*',
+                       'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
+                       'CDEF:mytime=out_avg_raw,TIME,TIME,IF',
+                       'CDEF:sample_len_raw=mytime,PREV(mytime),-',
+                       'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
+                       'CDEF:out_avg_sample=out_avg_raw,UN,0,out_avg_raw,IF,sample_len,*',
+                       'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
+                       'CDEF:inc_avg_sample=inc_avg_raw,UN,0,inc_avg_raw,IF,sample_len,*',
+                       'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
+                       "AREA:out_avg#$HalfGreen",
+                       "AREA:inc_avg#$HalfBlue",
+                       "AREA:overlap#$HalfBlueGreen",
+                       "LINE1:out_avg#$FullGreen:Outgoing",
+                       'GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:out_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:out_avg:LAST:%5.1lf%s Last',
+                       'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
+                       "LINE1:inc_avg#$FullBlue:Incoming",
+                       #'GPRINT:inc_min:MIN:%5.1lf %s Min,',
+                       'GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:inc_max:MAX:%5.1lf%s Max,',
+                       'GPRINT:inc_avg:LAST:%5.1lf%s Last',
+                       'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
+               ],
+                cpufreq => [
+                        'DEF:cpufreq_avg={file}:value:AVERAGE',
+                        'DEF:cpufreq_min={file}:value:MIN',
+                        'DEF:cpufreq_max={file}:value:MAX',
+                        "AREA:cpufreq_max#$HalfBlue",
+                        "AREA:cpufreq_min#$Canvas",
+                        "LINE1:cpufreq_avg#$FullBlue:Frequency",
+                        'GPRINT:cpufreq_min:MIN:%5.1lf%s Min,',
+                        'GPRINT:cpufreq_avg:AVERAGE:%5.1lf%s Avg,',
+                        'GPRINT:cpufreq_max:MAX:%5.1lf%s Max,',
+                        'GPRINT:cpufreq_avg:LAST:%5.1lf%s Last\l'
+                ],
+        users => [
+            'DEF:users_avg={file}:users:AVERAGE',
+            'DEF:users_min={file}:users:MIN',
+            'DEF:users_max={file}:users:MAX',
+            "AREA:users_max#$HalfBlue",
+            "AREA:users_min#$Canvas",
+            "LINE1:users_avg#$FullBlue:Users",
+            'GPRINT:users_min:MIN:%4.1lf Min,',
+            'GPRINT:users_avg:AVERAGE:%4.1lf Average,',
+            'GPRINT:users_max:MAX:%4.1lf Max,',
+            'GPRINT:users_avg:LAST:%4.1lf Last\l'
+        ],
+       };
+       $GraphDefs->{'disk'} = $GraphDefs->{'partition'};
+       $GraphDefs->{'meminfo'} = $GraphDefs->{'memory'};
+}
+
+our $GraphArgs =
+{
+       cpu => ['-t', '{host} cpu{inst} usage', '-v', 'Percent', '-l', '0'],
+       cpufreq => ['-t', '{host} cpu{inst} usage', '-v', 'Mhz'],
+       #disk => ['-t', '{host} disk {inst} IO wait', '-v', 'Seconds'],
+       disk => ['-t', '{host} disk {inst} usage', '-v', 'Byte/s'],
+       hddtemp => ['-t', '{host} hdd temperature {inst}', '-v', '°Celsius'],
+       load => ['-t', '{host} load average', '-v', 'System load', '-X', '0'],
+       mails   => ['-t', '{host} mail count', '-v', 'Amount', '-X', '0'],
+       memory => ['-t', '{host} memory usage', '-v', 'Bytes', '-b', '1024', '-l', '0'],
+       nfs3_procedures => ['-t', '{host} NFSv3 {inst} procedures', '-v', 'Procedures/s' ],
+       partition => ['-t', '{host} partition {inst} usage', '-v', 'Byte/s'],
+       ping => ['-t', '{host} ping to {inst}', '-v', 'ms'],
+       processes => ['-t', '{host} processes', '-v', 'Processes'],
+       sensors => ['-t', '{host} sensor {inst}', '-v', '°Celsius'],
+       swap => ['-t', '{host} swap usage', '-v', 'Bytes', '-b', '1024', '-l', '0'],
+       traffic => ['-t', '{host} {inst} traffic', '-v', 'Bit/s'],
+    users => ['-t', '{host} users', '-v', 'Users'],
+};
+
+our $GraphMulti =
+{
+       cpu     => \&output_graph_cpu,
+       cpufreq => 1,
+       disk    => 1,
+       load    => 0,
+       mails   => 0,
+       memory  => 0,
+       partition => 1,
+       ping    => \&output_graph_ping,
+       sensors => 1,
+       traffic => 1,
+    users => 1
+};
+
+our @Info;
+if (defined ($ENV{'GATEWAY_INTERFACE'}))
+{
+       @Info = ($ENV{'PATH_INFO'} || '') =~ m#([\w\-\.]+)#g;
+}
+else
+{
+       @Info = @ARGV;
+}
+
+parse_pathinfo (@Info);
+
+if ($TimeSpan)
+{
+       output_graph ();
+}
+else
+{
+       output_page ();
+}
+
+exit (0);
+
+sub output_graph_cpu
+{
+       my @inst = @_;
+       my @ret = ();
+
+       die if (@inst < 2);
+
+       for (@inst)
+       {
+               push (@ret,
+                       "DEF:user_avg_$_=$AbsDir/cpu-$_.rrd:user:AVERAGE",
+                       "DEF:user_min_$_=$AbsDir/cpu-$_.rrd:user:MIN",
+                       "DEF:user_max_$_=$AbsDir/cpu-$_.rrd:user:MAX",
+                       "DEF:nice_avg_$_=$AbsDir/cpu-$_.rrd:nice:AVERAGE",
+                       "DEF:nice_min_$_=$AbsDir/cpu-$_.rrd:nice:MIN",
+                       "DEF:nice_max_$_=$AbsDir/cpu-$_.rrd:nice:MAX",
+                       "DEF:syst_avg_$_=$AbsDir/cpu-$_.rrd:syst:AVERAGE",
+                       "DEF:syst_min_$_=$AbsDir/cpu-$_.rrd:syst:MIN",
+                       "DEF:syst_max_$_=$AbsDir/cpu-$_.rrd:syst:MAX",
+                       "DEF:wait_avg_$_=$AbsDir/cpu-$_.rrd:wait:AVERAGE",
+                       "DEF:wait_min_$_=$AbsDir/cpu-$_.rrd:wait:MIN",
+                       "DEF:wait_max_$_=$AbsDir/cpu-$_.rrd:wait:MAX");
+       }
+
+       for (qw(user nice syst wait))
+       {
+               my $def = $_;
+               my $cdef;
+
+               my $default_value = ($def eq 'user' or $def eq 'syst') ? 'UNKN' : '0';
+
+               for (qw(avg min max))
+               {
+                       my $cf = $_;
+
+                       for (@inst)
+                       {
+                               push (@ret, "CDEF:${def}_${cf}_notnull_${_}=${def}_${cf}_${_},UN,0,${def}_${cf}_${_},IF");
+                               push (@ret, "CDEF:${def}_${cf}_defined_${_}=${def}_${cf}_${_},UN,0,1,IF");
+                       }
+
+                       $cdef = "CDEF:${def}_${cf}_num=" . join (',', map { "${def}_${cf}_defined_${_}" } (@inst));
+                       $cdef .= ',+' x (scalar (@inst) - 1);
+                       push (@ret, $cdef);
+
+                       $cdef = "CDEF:${def}_${cf}=${def}_${cf}_num," . join (',', map { "${def}_${cf}_notnull_${_}" } (@inst));
+                       $cdef .= ',+' x (scalar (@inst) - 1);
+                       $cdef .= ",${def}_${cf}_num,${def}_${cf}_num,1,IF,/,$default_value,IF";
+                       push (@ret, $cdef);
+                       push (@ret, "CDEF:${def}_${cf}_notnull=${def}_${cf},UN,0,${def}_${cf},IF");
+               }
+       }
+
+       push (@ret,
+               "CDEF:nice_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,nice_avg_notnull,+,+,+",
+               "CDEF:user_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,+,+",
+               "CDEF:wait_acc=syst_avg_notnull,wait_avg_notnull,+",
+               "CDEF:syst_acc=syst_avg_notnull");
+
+       push (@ret, grep { $_ !~ m/^C?DEF/ } (@{$GraphDefs->{'cpu'}}));
+
+       return (@ret);
+}
+
+sub output_graph_ping
+{
+       my @inst = @_;
+       my @ret = ();
+
+       die if (@inst < 2);
+
+       my @colors = get_n_colors (scalar (@inst));
+
+       for (my $i = 0; $i < scalar (@inst); $i++)
+       {
+               my $inst = $inst[$i];
+               push (@ret,
+                       "DEF:avg_$i=$AbsDir/ping-$inst.rrd:ping:AVERAGE",
+                       "DEF:min_$i=$AbsDir/ping-$inst.rrd:ping:MIN",
+                       "DEF:max_$i=$AbsDir/ping-$inst.rrd:ping:MAX");
+       }
+
+       for (my $i = 0; $i < scalar (@inst); $i++)
+       {
+               my $inst = $inst[$i];
+               my $color = $colors[$i];
+
+               if (length ($inst) > 15)
+               {
+                       $inst = substr ($inst, 0, 12) . '...';
+               }
+               else
+               {
+                       $inst = sprintf ('%-15s', $inst);
+               }
+
+               push (@ret,
+                       "LINE1:avg_$i#$color:$inst",
+                       "GPRINT:min_$i:MIN:%4.1lf ms Min,",
+                       "GPRINT:avg_$i:AVERAGE:%4.1lf ms Avg,",
+                       "GPRINT:max_$i:MAX:%4.1lf ms Max,",
+                       "GPRINT:avg_$i:LAST:%4.1lf ms Last\\l");
+       }
+
+       return (@ret);
+}
+
+sub output_graph
+{
+       die unless (defined ($GraphDefs->{$Type}));
+
+       my $host;
+       my @cmd = ();
+       my $file = $AbsDir . '/';
+       my $files = get_all_files ($AbsDir);
+
+       #
+       # get hostname
+       #
+       if ($RelDir =~ m#([^/]+)$#)
+       {
+               $host = $1;
+       }
+       else
+       {
+               $host = $Config->{'HostName'};
+       }
+
+       #
+       # get timespan
+       #
+       if ($TimeSpan =~ m/(\d+)/)
+       {
+               $TimeSpan = -1 * int ($1);
+       }
+       else
+       {
+               my %t = (hour => -3600, day => -86400, week => -604800, month => -2678400, year => -31622400);
+               die unless (defined ($t{$TimeSpan}));
+               $TimeSpan = $t{$TimeSpan};
+       }
+
+       if (scalar (@{$files->{$Type}}) == 1)
+       {
+               $Inst = $files->{$Type}[0];
+       }
+
+       push (@cmd, '-', '-a', 'PNG', '-s', $TimeSpan);
+       push (@cmd, @{$GraphArgs->{$Type}}) if (defined ($GraphArgs->{$Type}));
+
+       for (qw(Back ShadeA ShadeB Font Canvas Grid MGrid Frame Arrow))
+       {
+               push (@cmd, '-c', uc ($_) . '#' . $Config->{'Colors'}{$_});
+       }
+
+       if ((length ($Inst) == 0) and (ref ($GraphMulti->{$Type}) eq 'CODE'))
+       {
+               push (@cmd, $GraphMulti->{$Type}->(@{$files->{$Type}}));
+       }
+       else
+       {
+               if (length ("$Inst"))
+               {
+                       $file .= "$Type-$Inst.rrd";
+               }
+               else
+               {
+                       $file .= "$Type.rrd";
+               }
+
+               die ("File not found: $file") unless (-e $file);
+
+               push (@cmd, @{$GraphDefs->{$Type}});
+       }
+
+       for (@cmd)
+       {
+               $_ =~ s/{file}/$file/g;
+               $_ =~ s/{host}/$host/g;
+               $_ =~ s/{inst}/$Inst/g;
+               $_ =~ s/{type}/$Type/g;
+       }
+
+       $| = 1;
+
+       print STDOUT <<HEADER if (defined ($ENV{'GATEWAY_INTERFACE'}));
+Content-Type: image/png
+Cache-Control: no-cache
+
+HEADER
+
+       if (1)
+       {
+               my $fh;
+               open ($fh, ">/tmp/collection.log") or die ("open: $!");
+               flock ($fh, LOCK_EX) or die ("flock: $!");
+
+               print $fh join ("\n\t", @cmd) . "\n";
+
+               close ($fh);
+       }
+
+       RRDs::graph (@cmd);
+
+       die ('RRDs::error: ' . RRDs::error ()) if (RRDs::error ());
+}
+
+sub output_page
+{
+       my $files = get_all_files ($AbsDir);
+       my $dirs  = get_all_dirs  ($AbsDir);
+
+       print STDOUT <<HEADER if (defined ($ENV{'GATEWAY_INTERFACE'}));
+Content-Type: text/html
+Cache-Control: no-cache
+
+<html>
+       <head>
+               <title>Collection: $RelDir</title>
+               <style type="text/css">
+                       img { border: none; display: block; }
+               </style>
+       </head>
+
+       <body>
+HEADER
+
+       my $MySelf = defined ($ENV{'GATEWAY_INTERFACE'}) ? $ENV{'SCRIPT_NAME'} : $0;
+
+       if ((length ($Type) != 0) and (length ($Inst) == 0) and (ref ($GraphMulti->{$Type}) eq 'CODE') and (scalar (@{$files->{$Type}}) > 1))
+       {
+               print qq(\t\t<div><a href="$MySelf$RelDir">Go up</a></div>\n);
+
+               print "\t\t<ul>\n";
+               for (@{$files->{$Type}})
+               {
+                       print qq(\t\t\t<li><a href="$MySelf$RelDir/$Type/$_">$_</a></li>\n);
+               }
+               print <<HTML;
+               </ul>
+
+               <h3>Daily</h3>
+               <div><img src="$MySelf$RelDir/$Type/day" /></div>
+               <h3>Weekly</h3>
+               <div><img src="$MySelf$RelDir/$Type/week" /></div>
+               <h3>Monthly</h3>
+               <div><img src="$MySelf$RelDir/$Type/month" /></div>
+               <h3>Yearly</h3>
+               <div><img src="$MySelf$RelDir/$Type/year" /></div>
+HTML
+       }
+       elsif (length ($Type) != 0)
+       {
+               my $ext = length ($Inst) ? "$Type/$Inst" : $Type;
+
+               if ((ref ($GraphMulti->{$Type}) eq 'CODE') and (scalar (@{$files->{$Type}}) > 1))
+               {
+                       print qq(<div><a href="$MySelf$RelDir/$Type">Go up</a></div>\n);
+               }
+               else
+               {
+                       print qq(<div><a href="$MySelf$RelDir">Go up</a></div>\n);
+               }
+
+               print <<HTML;
+               <h3>Daily</h3>
+               <div><img src="$MySelf$RelDir/$ext/day" /></div>
+               <h3>Weekly</h3>
+               <div><img src="$MySelf$RelDir/$ext/week" /></div>
+               <h3>Monthly</h3>
+               <div><img src="$MySelf$RelDir/$ext/month" /></div>
+               <h3>Yearly</h3>
+               <div><img src="$MySelf$RelDir/$ext/year" /></div>
+HTML
+       }
+       else
+       {
+               if ($RelDir)
+               {
+                       my ($up) = $RelDir =~ m#(.*)/[^/]+$#;
+                       print qq(\t\t<div><a href="$MySelf$up">Go up</a></div>\n);
+               }
+
+               if (@$dirs)
+               {
+                       print "<ul>\n";
+                       for (@$dirs)
+                       {
+                               print qq(<li>$AbsDir/<a href="$MySelf$RelDir/$_">$_</a></li>\n);
+                       }
+                       print "</ul>\n";
+               }
+
+               for (sort (keys %$files))
+               {
+                       my $type = $_;
+
+                       if (ref ($GraphMulti->{$type}) eq 'CODE')
+                       {
+                               print qq(\t\t<a href="$MySelf$RelDir/$type" />),
+                               qq(<img src="$MySelf$RelDir/$type/day" /></a>\n);
+                               next;
+                       }
+
+                       for (@{$files->{$type}})
+                       {
+                               my $inst = "$_";
+
+                               if (length ($inst))
+                               {
+                                       print qq(\t\t<a href="$MySelf$RelDir/$type/$inst" />),
+                                       qq(<img src="$MySelf$RelDir/$type/$inst/day" /></a>\n);
+                               }
+                               else
+                               {
+                                       print qq(\t\t<a href="$MySelf$RelDir/$type" />),
+                                       qq(<img src="$MySelf$RelDir/$type/day" /></a>\n);
+                               }
+                       }
+               }
+       }
+
+       print STDOUT <<FOOTER if (defined ($ENV{'GATEWAY_INTERFACE'}));
+       </body>
+</html>
+FOOTER
+}
+
+sub output_xml
+{
+       my $files = get_all_files ();
+
+       print STDOUT <<HEADER if (defined ($ENV{'GATEWAY_INTERFACE'}));
+Content-Type: text/xml
+Cache-Control: no-cache
+
+HEADER
+       print STDOUT pl2xml ($files);
+}
+
+sub read_config
+{
+       my $file = @_ ? shift : '/etc/collection.conf';
+       my $conf;
+       my $fh;
+
+#      if (open ($fh, "< $file"))
+#      {
+#              my $xml;
+#              local $/ = undef;
+#              $xml = <$fh>;
+#
+#              eval
+#              {
+#                      $conf = xml2pl ($xml);
+#              };
+#              close ($fh);
+#      }
+
+       if (!$conf)
+       {
+               return ({
+                               Colors =>
+                               {
+                                       Back    => 'FFFFFF',
+                                       ShadeA  => 'FFFFFF',
+                                       ShadeB  => 'FFFFFF',
+                                       Font    => '000000',
+                                       Canvas  => 'F5F5F5',
+                                       Grid    => 'D0D0D0',
+                                       MGrid   => 'A0A0A0',
+                                       Frame   => '646464',
+                                       Arrow   => 'FF0000',
+
+                                       FullRed         => 'FF0000',
+                                       FullBlue        => '0000FF',
+                                       FullGreen       => '00E000',
+                                       FullYellow      => 'F0A000',
+                                       FullCyan        => '00A0FF',
+                                       FullMagenta     => 'A000FF',
+                                       Alpha           => 0.25,
+                                       HalfRed         => 'F8B8B8',
+                                       HalfBlue        => 'B8B8F8',
+                                       HalfGreen       => 'B8F0B8',
+                                       HalfYellow      => 'F4F4B8'
+                               },
+                               Directory => '/var/lib/collectd',
+                               HostName  => (defined ($ENV{'SERVER_NAME'}) ? $ENV{'SERVER_NAME'} : 'localhost')
+                       });
+       }
+       else
+       {
+               return ($conf);
+       }
+}
+
+sub parse_pathinfo
+{
+       my @info = @_;
+
+       $AbsDir = $Config->{'Directory'};
+       $RelDir = '';
+
+       while (@info and -d $AbsDir . '/' . $Info[0])
+       {
+               my $new = shift (@info);
+               next if ($new =~ m/^\./);
+
+               $AbsDir .= '/' . $new;
+               $RelDir .= '/' . $new;
+       }
+
+       $Type = '';
+       $Inst = '';
+       $TimeSpan = '';
+
+       confess ("parse_pathinfo: too many elements in pathinfo") if (scalar (@info) > 3);
+       return unless (@info);
+
+       $Type = shift (@info);
+       return unless (@info);
+
+       if ($info[-1] =~ m/^(hour|day|week|month|year)$/i)
+       {
+               $TimeSpan = pop (@info);
+       }
+
+       $Inst = shift (@info) if (@info);
+
+       confess ("unrecognized elements in pathinfo") if (@info);
+}
+
+sub get_all_files
+{
+       my $dir = @_ ? shift : $Config->{'Directory'};
+       my $hash = {};
+       my $dh;
+
+       if (opendir ($dh, $dir))
+       {
+               while (my $thing = readdir ($dh))
+               {
+                       next if ($thing =~ m/^\./);
+
+                       my $type;
+                       my $inst;
+
+                       if ($thing =~ m/^(\w+)-([\w\-\.]+)\.rrd$/)
+                       {
+                               $type = $1;
+                               $inst = $2;
+                       }
+                       elsif ($thing =~ m/^(\w+)\.rrd$/)
+                       {
+                               $type = $1;
+                               $inst = '';
+                       }
+                       else
+                       {
+                               next;
+                       }
+
+                       $hash->{$type} = [] unless (defined ($hash->{$type}));
+                       push (@{$hash->{$type}}, $inst);
+               }
+
+               closedir ($dh);
+       }
+
+       return ($hash);
+}
+
+sub get_all_dirs
+{
+       my $dir = @_ ? shift : $Config->{'Directory'};
+       my @ret = ();
+       my $dh;
+
+       if (opendir ($dh, $dir))
+       {
+               while (my $thing = readdir ($dh))
+               {
+                       next if ($thing =~ m/^\./);
+
+                       next if (!-d "$dir/$thing");
+
+                       push (@ret, $thing);
+               }
+
+               closedir ($dh);
+       }
+
+       return (@ret) if (wantarray ());
+       return (\@ret);
+}
+
+sub color_hex2rgb
+{
+       my $color = shift;
+
+       my ($red, $green, $blue) = map { ord (pack ("H2", $_)) } ($color =~ m/([A-Fa-f0-9]{2})/g);
+       #print STDERR "$color -> rgb($red,$green,$blue)\n";
+
+       return ($red, $green, $blue);
+}
+
+sub color_rgb2hex
+{
+       croak unless (scalar (@_) == 3);
+       
+       my ($red, $green, $blue) = @_;
+
+       my $ret = sprintf ("%02X%02X%02X", $red, $green, $blue);
+       #print STDERR "rgb($red,$green,$blue) -> $ret\n";
+
+       return ($ret);
+}
+
+sub color_calculate_transparent
+{
+       my $alpha = shift;
+       my $canvas = [color_hex2rgb (shift)];
+       my @colors = map { [color_hex2rgb ($_)] } (@_);
+
+       if (($alpha < 0.0) or ($alpha > 1.0))
+       {
+               $alpha = 1.0;
+       }
+
+       if ($alpha == 0.0)
+       {
+               return (color_rgb2hex (@$canvas));
+       }
+       if ($alpha == 1.0)
+       {
+               return (color_rgb2hex (@{$colors[-1]}));
+       }
+
+       my $ret = _color_calculate_transparent ($alpha, $canvas, @colors);
+
+       return (color_rgb2hex (@$ret));
+}
+
+sub _color_calculate_transparent
+{
+       my $alpha = shift;
+       my $canvas = shift;
+       my $color = shift;
+       my @colors = @_ ? shift : ();
+       my $ret = [0, 0, 0];
+
+       for (my $i = 0; $i < 3; $i++)
+       {
+               $ret->[$i] = ($alpha * $color->[$i]) + ((1 - $alpha) * $canvas->[$i]);
+       }
+
+       return (_color_calculate_transparent ($alpha, $ret, @colors)) if (@colors);
+       return ($ret);
+}
+
+sub get_n_colors
+{
+       my $num = shift;
+       my @ret = ();
+
+       for (my $i = 0; $i < $num; $i++)
+       {
+               my $pos = 6 * $i / $num;
+               my $n = int ($pos);
+               my $p = $pos - $n;
+               my $q = 1 - $p;
+
+               my $red   = 0;
+               my $green = 0;
+               my $blue  = 0;
+
+               if ($n == 0)
+               {
+                       $red  = 255;
+                       $blue = 255 * $p;
+               }
+               elsif ($n == 1)
+               {
+                       $red  = 255 * $q;
+                       $blue = 255;
+               }
+               elsif ($n == 2)
+               {
+                       $green = 255 * $p;
+                       $blue  = 255;
+               }
+               elsif ($n == 3)
+               {
+                       $green = 255;
+                       $blue  = 255 * $q;
+               }
+               elsif ($n == 4)
+               {
+                       $red   = 255 * $p;
+                       $green = 255;
+               }
+               elsif ($n == 5)
+               {
+                       $red   = 255;
+                       $green = 255 * $q;
+               }
+               else { die; }
+
+               push (@ret, sprintf ("%02x%02x%02x", $red, $green, $blue));
+       }
+
+       return (@ret);
+}
diff --git a/contrib/users b/contrib/users
new file mode 100644 (file)
index 0000000..0514f93
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+FILE="/var/lib/collectd/users.rrd"
+HOST=""
+
+if [ -n "$SERVER_NAME" ]; then
+    HOST=$SERVER_NAME
+    echo "Content-Type: image/png";
+    echo "";
+else
+    HOST=`hostname -f`
+fi
+
+rrdtool graph - -a PNG -t "$HOST users" -v "Users" \
+    -c "BACK#000000" \
+    -c "SHADEA#000000" \
+    -c "SHADEB#000000" \
+    -c "FONT#dddddd" \
+    -c "CANVAS#202020" \
+    -c "GRID#666666" \
+    -c "MGRID#aaaaaa" \
+    -c "FRAME#202020" \
+    -c "ARROW#ffffff" \
+    "DEF:users_avg=$FILE:users:AVERAGE" \
+    "DEF:users_min=$FILE:users:MIN" \
+    "DEF:users_max=$FILE:users:MAX" \
+    "AREA:users_max#804040" \
+    "AREA:users_min#202020" \
+    "LINE1:users_avg#ff0000:Users" \
+    "GPRINT:users_min:MIN:%4.1lf Min," \
+    "GPRINT:users_avg:AVERAGE:%4.1lf Average," \
+    "GPRINT:users_max:MAX:%4.1lf Max," \
+    "GPRINT:users_avg:LAST:%4.1lf Last\l"
+
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..7199fb7
--- /dev/null
@@ -0,0 +1,117 @@
+collectd (3.5.0-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Wed, 07 Dec 2005 11:50:17 +0200
+
+collectd (3.4.0-1) unstable; urgency=low
+
+  * New upstream version
+  * The package has been split up into one binary package and many many plugin
+    packages
+
+ -- Florian Forster <octo@verplant.org>  Sat, 26 Nov 2005 13:14:22 +0200
+
+collectd (3.3.0-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Sat, 05 Nov 2005 12:02:50 +0200
+
+collectd (3.2.0-1) unstable; urgency=low
+
+  * New upstream version
+  * Problems with the debian init.d file have been fixed.
+  * Added `processes.so*' to the main package
+
+ -- Florian Forster <octo@verplant.org>  Tue, 25 Oct 2005 09:34:29 +0200
+
+collectd (3.1.0-1) unstable; urgency=low
+
+  * New upstream version
+  * Added package `collectd-hddtemp'
+
+ -- Florian Forster <octo@verplant.org>  Fri, 14 Oct 2005 19:32:59 +0200
+
+collectd (3.0.0-1) unstable; urgency=low
+
+  * New upstream version
+  * Split the package into `collectd' and `collectd-sensors'
+
+ -- Florian Forster <octo@verplant.org>  Fri, 30 Sep 2005 14:15:15 +0200
+
+collectd (2.1.0-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Fri, 16 Sep 2005 21:24:10 +0200
+
+collectd (2.0.0-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Sat, 10 Sep 2005 16:11:37 +0200
+
+collectd (1.8.1-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Mon, 01 Sep 2005 21:27:16 +0200
+
+collectd (1.8.0-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Mon, 29 Aug 2005 12:09:20 +0200
+
+collectd (1.7.0-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Sun, 25 Aug 2005 10:50:08 +0200
+
+collectd (1.6.0-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Sun, 21 Aug 2005 19:03:02 +0200
+
+collectd (1.5.1-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Sun, 17 Jul 2005 11:56:50 +0200
+
+collectd (1.5-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Sun, 17 Jul 2005 11:56:50 +0200
+
+collectd (1.4.2-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Mon, 11 Jul 2005 10:40:20 +0200
+
+collectd (1.4.1-1) unstable; urgency=low
+
+  * New upstream version
+
+ -- Florian Forster <octo@verplant.org>  Fri, 10 Jul 2005 11:34:45 +0200
+
+collectd (1.4-1) unstable; urgency=low
+
+  * New upstream version
+  * Added examples from the contrib/ directory
+  * Added /etc/default/collectd for easy configuration
+  * Added libsensors3 to the dependencies
+
+ -- Florian Forster <octo@verplant.org>  Fri,  9 Jul 2005 01:01:32 +0200
+
+collectd (1.3-1) unstable; urgency=low
+
+  * Initial release.
+
+ -- Florian Forster <octo@verplant.org>  Fri,  8 Jul 2005 19:05:16 +0200
+
diff --git a/debian/collectd-users.files b/debian/collectd-users.files
new file mode 100644 (file)
index 0000000..8fd44ff
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/collectd/users.so*
diff --git a/debian/collectd.examples b/debian/collectd.examples
new file mode 100644 (file)
index 0000000..37d7dde
--- /dev/null
@@ -0,0 +1,12 @@
+contrib/cpu
+contrib/load
+contrib/iobytes
+contrib/iowait
+contrib/load
+contrib/memory
+contrib/ping
+contrib/swap
+contrib/temperature
+contrib/traffic
+contrib/users
+contrib/museum
index 35b6f1f..941de0e 100644 (file)
@@ -94,3 +94,9 @@ Architecture: any
 Depends: collectd (= ${Source-Version})
 Description: collectd module for network traffic.
  collectd module to collect network traffic counters.
+
+Package: collectd-users
+Architecture: any
+Depends: collectd (= ${Source-Version})
+Description: collectd module for user count.
+ collectd module to collect the number of users logged into the system.
index 3198d15..25a9e29 100755 (executable)
@@ -18,7 +18,7 @@ DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
 
 CFLAGS = -Wall -g
 
-PLUGINS = cpu cpufreq disk hddtemp load memory nfs ping processes sensors serial swap traffic
+PLUGINS = cpu cpufreq disk hddtemp load memory nfs ping processes sensors serial swap traffic users
 
 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
        CFLAGS += -O0
index dc189d4..cab7265 100644 (file)
@@ -148,6 +148,14 @@ collectd_LDADD += "-dlopen" traffic.la
 collectd_DEPENDENCIES += traffic.la
 endif
 
+if BUILD_MODULE_USERS
+pkglib_LTLIBRARIES += users.la
+users_la_SOURCES = users.c users.h
+users_la_LDFLAGS = -module -avoid-version
+collectd_LDADD += "-dlopen" users.la
+collectd_DEPENDENCIES += users.la
+endif
+
 man_MANS = collectd.1
 #collectd_1_SOURCES = collectd.pod
 
index 31f473e..ddfb9f2 100644 (file)
@@ -211,7 +211,7 @@ int pidfile_remove (void)
 int main (int argc, char **argv)
 {
        struct sigaction sigIntAction, sigChldAction;
-#if COLLECTD_DAEMON
+#if COLLECT_DAEMON
        pid_t pid;
 #endif
 
@@ -316,7 +316,7 @@ int main (int argc, char **argv)
        /*
         * fork off child
         */
-#if COLLECTD_DAEMON
+#if COLLECT_DAEMON
        if (daemonize)
        {
                if ((pid = fork ()) == -1)
@@ -360,7 +360,7 @@ int main (int argc, char **argv)
                        return (1);
                }
        } /* if (daemonize) */
-#endif /* COLLECTD_DAEMON */
+#endif /* COLLECT_DAEMON */
 
        /*
         * run the actual loops
index ba7b6be..55a99ed 100644 (file)
@@ -66,6 +66,10 @@ Tape drive usage (I<tape>, Solaris only)
 
 Network traffic (I<traffic>)
 
+=item
+
+Number of users logged into the system (I<users>)
+
 =back
 
 =head1 OPTIONS
@@ -82,6 +86,11 @@ See L<"MODES">.
 Sets the directory collectd should work in. All F<.rrd>-files are created in
 this directory. Per default this is F</var/lib/collectd/>.
 
+=item B<-P> I<E<lt>directoryE<gt>>
+
+Sets the directory collectd should look for plugins in. Per default this is
+F</usr/lib/collectd>.
+
 =item B<-f>
 
 Don't fork to the background. I<collectd> will also B<not> close standard file
@@ -148,7 +157,7 @@ The DS'es depend on the module creating the RRD files:
 
 =item Diskstats (F<disk-I<E<lt>majorE<gt>>-I<E<lt>minorE<gt>>.rrd>)
 
-  DS:rcount:COUNTER:25:0:
+  DS:rcount:COUNTER:25:0:U
   DS:rmerged:COUNTER:25:0:U
   DS:rbytes:COUNTER:25:0:U
   DS:rtime:COUNTER:25:0:U
@@ -272,6 +281,10 @@ The DS'es depend on the module creating the RRD files:
   DS:incoming:COUNTER:25:0:U
   DS:outgoing:COUNTER:25:0:U
 
+=item Users (F<users.rrd>)
+
+  DS:users:GAUGE:25:0:65535
+
 =back
 
 =head1 MODES
@@ -307,6 +320,10 @@ it's totally up to you to secure your net.
 
 The UDP port used has been checked to not be assigned by the IANA.
 
+On multi-homed machines you may need to add a route to the multicast net
+(B<224.0.0.0/4>) if multicast packages take the wrong interface. The listener
+on the other hand listens on B<all> interfaces.
+
 =head1 SPECIAL MODULES
 
 =head2 cpufreq
index 89cae6a..a3fe5fd 100644 (file)
@@ -1,3 +1,27 @@
+/**
+ * collectd - src/common.h
+ * Copyright (C) 2005  Florian octo Forster
+ *
+ * This program is free software; you can redistribute it and/
+ * or modify it under the terms of the GNU General Public Li-
+ * cence as published by the Free Software Foundation; either
+ * version 2 of the Licence, or any later version.
+ *
+ * This program is distributed in the hope that it will be use-
+ * ful, but WITHOUT ANY WARRANTY; without even the implied war-
+ * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public Licence for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * Licence along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+ * USA.
+ *
+ * Authors:
+ *   Florian octo Forster <octo at verplant.org>
+ *   Niki W. Waibel <niki.waibel@gmx.net>
+**/
+
 #ifndef COMMON_H
 #define COMMON_H
 
diff --git a/src/config.h.in b/src/config.h.in
deleted file mode 100644 (file)
index 746d711..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-/* src/config.h.in.  Generated from configure.in by autoheader.  */
-
-/* Wether or not to collect CPU usage statistics */
-#undef COLLECT_CPU
-
-/* Wether or not to collect cpu frequency statistics */
-#undef COLLECT_CPUFREQ
-
-/* Wether or not to enable daemon mode */
-#undef COLLECT_DAEMON
-
-/* Wether or not to enable debugging */
-#undef COLLECT_DEBUG
-
-/* Wether or not to collect diskstats */
-#undef COLLECT_DISK
-
-/* Wether or not to collect hdd temperature statistics */
-#undef COLLECT_HDDTEMP
-
-/* Wether or not to collect system load statistics */
-#undef COLLECT_LOAD
-
-/* Wether or not to collect memory statistics */
-#undef COLLECT_MEMORY
-
-/* Wether or not to collect nfs statistics */
-#undef COLLECT_NFS
-
-/* Wether or not to collect ping statistics */
-#undef COLLECT_PING
-
-/* Wether or not to collect processes statistics */
-#undef COLLECT_PROCESSES
-
-/* Wether or not to use pth (portable threads) library */
-#undef COLLECT_PTH
-
-/* Wether or not to collect quota statistics */
-#undef COLLECT_QUOTA
-
-/* Wether or not to collect lm_sensors statistics */
-#undef COLLECT_SENSORS
-
-/* Wether or not to collect serial statistics */
-#undef COLLECT_SERIAL
-
-/* Wether or not to collect swap statistics */
-#undef COLLECT_SWAP
-
-/* Wether or not to collect tape statistics */
-#undef COLLECT_TAPE
-
-/* Wether or not to collect network traffic statistics */
-#undef COLLECT_TRAFFIC
-
-/* Define to 1 if you have the <arpa/inet.h> header file. */
-#undef HAVE_ARPA_INET_H
-
-/* Define to 1 if you have the <ctype.h> header file. */
-#undef HAVE_CTYPE_H
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <errno.h> header file. */
-#undef HAVE_ERRNO_H
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
-
-/* Define to 1 if you have the `getfsent' function. */
-#undef HAVE_GETFSENT
-
-/* Define to 1 if you have the `getgrgid' function. */
-#undef HAVE_GETGRGID
-
-/* Define to 1 if you have the `gethostbyname' function. */
-#undef HAVE_GETHOSTBYNAME
-
-/* Define to 1 if you have the `getmntent' function. */
-#undef HAVE_GETMNTENT
-
-/* Define if there is a function named getmntent for reading the list of
-   mounted filesystems, and that function takes a single argument. (4.3BSD,
-   SunOS, HP-UX, Dynix, Irix, Linux) */
-#undef HAVE_GETMNTENT1
-
-/* Define if there is a function named getmntent for reading the list of
-   mounted filesystems, and that function takes two arguments. (SVR4) */
-#undef HAVE_GETMNTENT2
-
-/* Define to 1 if you have the `getpwuid' function. */
-#undef HAVE_GETPWUID
-
-/* Define to 1 if you have the `gettimeofday' function. */
-#undef HAVE_GETTIMEOFDAY
-
-/* Define to 1 if you have the `getvfsent' function. */
-#undef HAVE_GETVFSENT
-
-/* Define to 1 if you have the <grp.h> header file. */
-#undef HAVE_GRP_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <kstat.h> header file. */
-#undef HAVE_KSTAT_H
-
-/* Define to 1 if you have the `devinfo' library (-ldevinfo). */
-#undef HAVE_LIBDEVINFO
-
-/* Define to 1 if you have the `kstat' library (-lkstat). */
-#undef HAVE_LIBKSTAT
-
-/* Define to 1 if you have the `m' library (-lm). */
-#undef HAVE_LIBM
-
-/* Define to 1 if you have the `nsl' library (-lnsl). */
-#undef HAVE_LIBNSL
-
-/* Define to 1 if you have the `pth' library (-lpth). */
-#undef HAVE_LIBPTH
-
-/* Define to 1 if you have the `resolv' library (-lresolv). */
-#undef HAVE_LIBRESOLV
-
-/* Define to 1 if you have the `rrd' library (-lrrd). */
-#undef HAVE_LIBRRD
-
-/* Define to 1 if you have the sensors library (-lsensors). */
-#undef HAVE_LIBSENSORS
-
-/* Define to 1 if you have the `socket' library (-lsocket). */
-#undef HAVE_LIBSOCKET
-
-/* Define to 1 if you have the `statgrab' library (-lstatgrab). */
-#undef HAVE_LIBSTATGRAB
-
-/* Define to 1 if you have the <limits.h> header file. */
-#undef HAVE_LIMITS_H
-
-/* Define to 1 if you have the `listmntent' function. */
-#undef HAVE_LISTMNTENT
-
-/* Define to 1 if you have the `memcpy' function. */
-#undef HAVE_MEMCPY
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <mntent.h> header file. */
-#undef HAVE_MNTENT_H
-
-/* Define to 1 if you have the <netdb.h> header file. */
-#undef HAVE_NETDB_H
-
-/* Define to 1 if you have the <netinet/in.h> header file. */
-#undef HAVE_NETINET_IN_H
-
-/* Define to 1 if you have the <paths.h> header file. */
-#undef HAVE_PATHS_H
-
-/* Define to 1 if you have the <pth.h> header file. */
-#undef HAVE_PTH_H
-
-/* Define to 1 if you have the <pwd.h> header file. */
-#undef HAVE_PWD_H
-
-/* Define to 1 if you have the `quotactl' function. */
-#undef HAVE_QUOTACTL
-
-/* Define to 1 if you have the <rrd.h> header file. */
-#undef HAVE_RRD_H
-
-/* Define to 1 if you have the `select' function. */
-#undef HAVE_SELECT
-
-/* Define to 1 if you have the <sensors/sensors.h> header file. */
-#undef HAVE_SENSORS_SENSORS_H
-
-/* Define to 1 if you have the <signal.h> header file. */
-#undef HAVE_SIGNAL_H
-
-/* Define to 1 if you have the `socket' function. */
-#undef HAVE_SOCKET
-
-/* Define to 1 if you have the <statgrab.h> header file. */
-#undef HAVE_STATGRAB_H
-
-/* Define to 1 if you have the <stdarg.h> header file. */
-#undef HAVE_STDARG_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the `strcasecmp' function. */
-#undef HAVE_STRCASECMP
-
-/* Define to 1 if you have the `strchr' function. */
-#undef HAVE_STRCHR
-
-/* Define to 1 if you have the `strcmp' function. */
-#undef HAVE_STRCMP
-
-/* Define to 1 if you have the `strdup' function. */
-#undef HAVE_STRDUP
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the `strlen' function. */
-#undef HAVE_STRLEN
-
-/* Define to 1 if you have the `strncasecmp' function. */
-#undef HAVE_STRNCASECMP
-
-/* Define to 1 if you have the `strncmp' function. */
-#undef HAVE_STRNCMP
-
-/* Define to 1 if you have the `strncpy' function. */
-#undef HAVE_STRNCPY
-
-/* Define to 1 if you have the `strstr' function. */
-#undef HAVE_STRSTR
-
-/* Define to 1 if you have the `strtol' function. */
-#undef HAVE_STRTOL
-
-/* Define to 1 if you have the <syslog.h> header file. */
-#undef HAVE_SYSLOG_H
-
-/* Define to 1 if you have the <sys/fs_types.h> header file. */
-#undef HAVE_SYS_FS_TYPES_H
-
-/* Define to 1 if you have the <sys/mntent.h> header file. */
-#undef HAVE_SYS_MNTENT_H
-
-/* Define to 1 if you have the <sys/mnttab.h> header file. */
-#undef HAVE_SYS_MNTTAB_H
-
-/* Define to 1 if you have the <sys/mount.h> header file. */
-#undef HAVE_SYS_MOUNT_H
-
-/* Define to 1 if you have the <sys/quota.h> header file. */
-#undef HAVE_SYS_QUOTA_H
-
-/* Define to 1 if you have the <sys/resource.h> header file. */
-#undef HAVE_SYS_RESOURCE_H
-
-/* Define to 1 if you have the <sys/select.h> header file. */
-#undef HAVE_SYS_SELECT_H
-
-/* Define to 1 if you have the <sys/socket.h> header file. */
-#undef HAVE_SYS_SOCKET_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <sys/vfstab.h> header file. */
-#undef HAVE_SYS_VFSTAB_H
-
-/* Define to 1 if you have the <sys/vfs.h> header file. */
-#undef HAVE_SYS_VFS_H
-
-/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
-#undef HAVE_SYS_WAIT_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the <xfs/xqm.h> header file. */
-#undef HAVE_XFS_XQM_H
-
-/* True if program is to be compiled for a Linux kernel */
-#undef KERNEL_LINUX
-
-/* True if program is to be compiled for a Solaris kernel */
-#undef KERNEL_SOLARIS
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
-
-/* Define to `int' if <sys/types.h> does not define. */
-#undef pid_t
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-#undef size_t
diff --git a/src/cpu.c b/src/cpu.c
new file mode 100644 (file)
index 0000000..adafbea
--- /dev/null
+++ b/src/cpu.c
@@ -0,0 +1,231 @@
+#include "cpu.h"
+
+#if COLLECT_CPU
+#define MODULE_NAME "cpu"
+
+#ifdef HAVE_LIBKSTAT
+#include <sys/sysinfo.h>
+#endif /* HAVE_LIBKSTAT */
+
+#ifdef HAVE_SYSCTLBYNAME
+#ifdef HAVE_SYS_SYSCTL_H
+#include <sys/sysctl.h>
+#endif
+
+#ifdef HAVE_SYS_DKSTAT_H
+#include <sys/dkstat.h>
+#endif
+
+#if !defined(CP_USER) || !defined(CP_NICE) || !defined(CP_SYS) || !defined(CP_INTR) || !defined(CP_IDLE) || !defined(CPUSTATES)
+#define CP_USER   0
+#define CP_NICE   1
+#define CP_SYS    2
+#define CP_INTR   3
+#define CP_IDLE   4
+#define CPUSTATES 5
+#endif
+#endif /* HAVE_SYSCTLBYNAME */
+
+#include "plugin.h"
+#include "common.h"
+
+#ifdef HAVE_LIBKSTAT
+/* colleague tells me that Sun doesn't sell systems with more than 100 or so CPUs.. */
+#define MAX_NUMCPU 256
+extern kstat_ctl_t *kc;
+static kstat_t *ksp[MAX_NUMCPU];
+static int numcpu;
+#endif /* HAVE_LIBKSTAT */
+
+#ifdef HAVE_SYSCTLBYNAME
+static int numcpu;
+#endif /* HAVE_SYSCTLBYNAME */
+
+static char *cpu_filename = "cpu-%s.rrd";
+
+static char *ds_def[] =
+{
+       "DS:user:COUNTER:25:0:100",
+       "DS:nice:COUNTER:25:0:100",
+       "DS:syst:COUNTER:25:0:100",
+       "DS:idle:COUNTER:25:0:100",
+       "DS:wait:COUNTER:25:0:100",
+       NULL
+};
+static int ds_num = 5;
+
+extern time_t curtime;
+
+void cpu_init (void)
+{
+#ifdef HAVE_LIBKSTAT
+       kstat_t *ksp_chain;
+
+       numcpu = 0;
+
+       if (kc == NULL)
+               return;
+
+       /* Solaris doesn't count linear.. *sigh* */
+       for (numcpu = 0, ksp_chain = kc->kc_chain;
+                       (numcpu < MAX_NUMCPU) && (ksp_chain != NULL);
+                       ksp_chain = ksp_chain->ks_next)
+               if (strncmp (ksp_chain->ks_module, "cpu_stat", 8) == 0)
+                       ksp[numcpu++] = ksp_chain;
+/* #endif HAVE_LIBKSTAT */
+
+#elif defined (HAVE_SYSCTLBYNAME)
+       size_t numcpu_size;
+
+       numcpu_size = sizeof (numcpu);
+
+       if (sysctlbyname ("hw.ncpu", &numcpu, &numcpu_size, NULL, 0) < 0)
+       {
+               syslog (LOG_WARNING, "cpu: sysctlbyname: %s", strerror (errno));
+               return;
+       }
+
+       if (numcpu != 1)
+               syslog (LOG_NOTICE, "cpu: Only one processor supported when using `sysctlbyname' (found %i)", numcpu);
+#endif
+
+       return;
+}
+
+void cpu_write (char *host, char *inst, char *val)
+{
+       char file[512];
+       int status;
+
+       status = snprintf (file, 512, cpu_filename, inst);
+       if (status < 1)
+               return;
+       else if (status >= 512)
+               return;
+
+       rrd_update_file (host, file, val, ds_def, ds_num);
+}
+
+#define BUFSIZE 512
+void cpu_submit (int cpu_num, unsigned long long user, unsigned long long nice, unsigned long long syst,
+               unsigned long long idle, unsigned long long wait)
+{
+       char buf[BUFSIZE];
+       char cpu[16];
+
+       if (snprintf (buf, BUFSIZE, "%u:%llu:%llu:%llu:%llu:%llu", (unsigned int) curtime,
+                               user, nice, syst, idle, wait) >= BUFSIZE)
+               return;
+       snprintf (cpu, 16, "%i", cpu_num);
+
+       plugin_submit (MODULE_NAME, cpu, buf);
+}
+#undef BUFSIZE
+
+void cpu_read (void)
+{
+#ifdef KERNEL_LINUX
+#define BUFSIZE 1024
+       int cpu;
+       unsigned long long user, nice, syst, idle;
+       unsigned long long wait, intr, sitr; /* sitr == soft interrupt */
+       FILE *fh;
+       char buf[BUFSIZE];
+
+       char *fields[9];
+       int numfields;
+
+       if ((fh = fopen ("/proc/stat", "r")) == NULL)
+       {
+               syslog (LOG_WARNING, "cpu: fopen: %s", strerror (errno));
+               return;
+       }
+
+       while (fgets (buf, BUFSIZE, fh) != NULL)
+       {
+               if (strncmp (buf, "cpu", 3))
+                       continue;
+               if ((buf[3] < '0') || (buf[3] > '9'))
+                       continue;
+
+               numfields = strsplit (buf, fields, 9);
+               if (numfields < 5)
+                       continue;
+
+               cpu = atoi (fields[0] + 3);
+               user = atoll (fields[1]);
+               nice = atoll (fields[2]);
+               syst = atoll (fields[3]);
+               idle = atoll (fields[4]);
+
+               if (numfields >= 8)
+               {
+                       wait = atoll (fields[5]);
+                       intr = atoll (fields[6]);
+                       sitr = atoll (fields[7]);
+
+                       /* I doubt anyone cares about the time spent in
+                        * interrupt handlers.. */
+                       syst += intr + sitr;
+               }
+               else
+               {
+                       wait = 0LL;
+               }
+
+               cpu_submit (cpu, user, nice, syst, idle, wait);
+       }
+
+       fclose (fh);
+#undef BUFSIZE
+/* #endif defined(KERNEL_LINUX) */
+
+#elif defined(HAVE_LIBKSTAT)
+       int cpu;
+       unsigned long long user, syst, idle, wait;
+       static cpu_stat_t cs;
+
+       if (kc == NULL)
+               return;
+
+       for (cpu = 0; cpu < numcpu; cpu++)
+       {
+               if (kstat_read (kc, ksp[cpu], &cs) == -1)
+                       continue; /* error message? */
+
+               idle = (unsigned long long) cs.cpu_sysinfo.cpu[CPU_IDLE];
+               user = (unsigned long long) cs.cpu_sysinfo.cpu[CPU_USER];
+               syst = (unsigned long long) cs.cpu_sysinfo.cpu[CPU_KERNEL];
+               wait = (unsigned long long) cs.cpu_sysinfo.cpu[CPU_WAIT];
+
+               cpu_submit (ksp[cpu]->ks_instance,
+                               user, 0LL, syst, idle, wait);
+       }
+/* #endif defined(HAVE_LIBKSTAT) */
+
+#elif defined (HAVE_SYSCTLBYNAME)
+       long cpuinfo[CPUSTATES];
+       size_t cpuinfo_size;
+
+       cpuinfo_size = sizeof (cpuinfo);
+
+       if (sysctlbyname("kern.cp_time", &cpuinfo, &cpuinfo_size, NULL, 0) < 0)
+       {
+               syslog (LOG_WARNING, "cpu: sysctlbyname: %s", strerror (errno));
+               return;
+       }
+
+       cpuinfo[CP_SYS] += cpuinfo[CP_INTR];
+
+       /* FIXME: Instance is always `0' */
+       cpu_submit (0, cpuinfo[CP_USER], cpuinfo[CP_NICE], cpuinfo[CP_SYS], cpuinfo[CP_IDLE], 0LL);
+#endif
+}
+
+void module_register (void)
+{
+       plugin_register (MODULE_NAME, cpu_init, cpu_read, cpu_write);
+}
+
+#undef MODULE_NAME
+#endif /* COLLECT_CPU */
diff --git a/src/cpu.h b/src/cpu.h
new file mode 100644 (file)
index 0000000..340035f
--- /dev/null
+++ b/src/cpu.h
@@ -0,0 +1,20 @@
+#ifndef CPU_H
+#define CPU_H
+
+#include "collectd.h"
+
+#ifndef COLLECT_CPU
+#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) || defined(HAVE_SYSCTLBYNAME)
+#define COLLECT_CPU 1
+#else
+#define COLLECT_CPU 0
+#endif
+#endif /* !defined(COLLECT_CPU) */
+
+#if COLLECT_CPU
+
+void cpu_init (void);
+void cpu_read (void);
+
+#endif /* COLLECT_CPU */
+#endif /* CPU_H */
diff --git a/src/load.c b/src/load.c
new file mode 100644 (file)
index 0000000..2a14edd
--- /dev/null
@@ -0,0 +1,124 @@
+#include "load.h"
+
+#if COLLECT_LOAD
+#define MODULE_NAME "load"
+
+#include "plugin.h"
+#include "common.h"
+
+#ifdef HAVE_SYS_LOADAVG_H
+#include <sys/loadavg.h>
+#endif
+
+#ifdef HAVE_GETLOADAVG
+#if !defined(LOADAVG_1MIN) || !defined(LOADAVG_5MIN) || !defined(LOADAVG_15MIN)
+#define LOADAVG_1MIN  0
+#define LOADAVG_5MIN  1
+#define LOADAVG_15MIN 2
+#endif
+#endif /* defined(HAVE_GETLOADAVG) */
+
+static char *load_file = "load.rrd";
+
+static char *ds_def[] =
+{
+       "DS:shortterm:GAUGE:25:0:100",
+       "DS:midterm:GAUGE:25:0:100",
+       "DS:longterm:GAUGE:25:0:100",
+       NULL
+};
+static int ds_num = 3;
+
+extern time_t curtime;
+
+void load_init (void)
+{
+       return;
+}
+
+void load_write (char *host, char *inst, char *val)
+{
+       rrd_update_file (host, load_file, val, ds_def, ds_num);
+}
+
+#define BUFSIZE 256
+void load_submit (double snum, double mnum, double lnum)
+{
+       char buf[BUFSIZE];
+
+       if (snprintf (buf, BUFSIZE, "%u:%.2f:%.2f:%.2f", (unsigned int) curtime,
+                               snum, mnum, lnum) >= BUFSIZE)
+               return;
+
+       plugin_submit (MODULE_NAME, "-", buf);
+}
+#undef BUFSIZE
+
+void load_read (void)
+{
+#if defined(HAVE_GETLOADAVG)
+       double load[3];
+
+       if (getloadavg (load, 3) == 3)
+               load_submit (load[LOADAVG_1MIN], load[LOADAVG_5MIN], load[LOADAVG_15MIN]);
+       else
+               syslog (LOG_WARNING, "load: getloadavg failed: %s", strerror (errno));
+/* #endif HAVE_GETLOADAVG */
+
+#elif defined(KERNEL_LINUX)
+       double snum, mnum, lnum;
+       FILE *loadavg;
+       char buffer[16];
+
+       char *fields[8];
+       int numfields;
+       
+       if ((loadavg = fopen ("/proc/loadavg", "r")) == NULL)
+       {
+               syslog (LOG_WARNING, "load: fopen: %s", strerror (errno));
+               return;
+       }
+
+       if (fgets (buffer, 16, loadavg) == NULL)
+       {
+               syslog (LOG_WARNING, "load: fgets: %s", strerror (errno));
+               return;
+       }
+
+       if (fclose (loadavg))
+               syslog (LOG_WARNING, "load: fclose: %s", strerror (errno));
+
+       numfields = strsplit (buffer, fields, 8);
+
+       if (numfields < 3)
+               return;
+
+       snum = atof (fields[0]);
+       mnum = atof (fields[1]);
+       lnum = atof (fields[2]);
+
+       load_submit (snum, mnum, lnum);
+/* #endif KERNEL_LINUX */
+
+#elif defined(HAVE_LIBSTATGRAB)
+       double snum, mnum, lnum;
+       sg_load_stats *ls;
+
+       if ((ls = sg_get_load_stats ()) == NULL)
+               return;
+
+       snum = ls->min1;
+       mnum = ls->min5;
+       lnum = ls->min15;
+
+       load_submit (snum, mnum, lnum);
+#endif /* HAVE_LIBSTATGRAB */
+}
+
+void module_register (void)
+{
+       plugin_register (MODULE_NAME, load_init, load_read, load_write);
+}
+
+#undef MODULE_NAME
+#endif /* COLLECT_LOAD */
diff --git a/src/load.h b/src/load.h
new file mode 100644 (file)
index 0000000..ce437eb
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef LOAD_H
+#define LOAD_H
+
+#include "collectd.h"
+#include "common.h"
+
+#ifndef COLLECT_LOAD
+#if defined(HAVE_GETLOADAVG) || defined(KERNEL_LINUX) || defined(HAVE_LIBSTATGRAB)
+#define COLLECT_LOAD 1
+#else
+#define COLLECT_LOAD 0
+#endif
+#endif /* !defined(COLLECT_LOAD) */
+
+#endif /* LOAD_H */
index 5d5a20f..1a3ab34 100644 (file)
@@ -63,7 +63,6 @@ void plugin_load (char *name)
        void (*reg_handle) (void);
 
        lt_dlinit ();
-
        lt_dlerror (); /* clear errors */
 
        if ((dlh = lt_dlopen (name)) == NULL)
diff --git a/src/users.c b/src/users.c
new file mode 100644 (file)
index 0000000..96cd621
--- /dev/null
@@ -0,0 +1,127 @@
+/* 
+ * users.c
+ *
+ * users plugin for collectd
+ *
+ * This plugin collects the number of users currently logged into the system.
+ *
+ * Written by Sebastian Harl <sh@tokkee.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; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "users.h"
+
+#if COLLECT_USERS
+#define MODULE_NAME "users"
+
+#include "plugin.h"
+#include "common.h"
+
+#ifdef HAVE_UTMPX_H
+#include <utmpx.h>
+#elif defined(HAVE_UTMP_H)
+#include <utmp.h>
+#endif
+
+static char *rrd_file = "users.rrd";
+
+static char *ds_def[] = {
+    "DS:users:GAUGE:25:0:65535",
+    NULL
+};
+static int ds_num = 1;
+
+extern time_t curtime;
+
+void users_init(void)
+{
+    /* we have nothing to do here :-) */
+    return;
+}
+
+void users_read(void)
+{
+#ifdef HAVE_GETUTXENT
+    unsigned int users = 0;
+    struct utmpx *entry = NULL;
+
+    /* according to the *utent(3) man page none of the functions sets errno in
+     * case of an error, so we cannot do any error-checking here */
+    setutxent();
+
+    while (NULL != (entry = getutxent()))
+        if (USER_PROCESS == entry->ut_type)
+            ++users;
+    endutxent();
+
+    users_submit(users);
+/* #endif HAVE_GETUTXENT */
+
+#elif defined(HAVE_GETUTENT)
+    unsigned int users = 0;
+    struct utmp *entry = NULL;
+
+    /* according to the *utent(3) man page none of the functions sets errno in
+     * case of an error, so we cannot do any error-checking here */
+    setutent();
+
+    while (NULL != (entry = getutent()))
+        if (USER_PROCESS == entry->ut_type)
+            ++users;
+    endutent();
+
+    users_submit(users);
+#endif
+
+       return;
+}
+
+/* I don't like this temporary macro definition - well it's used everywhere
+ * else in the collectd-sources, so I will just stick with it...  */
+#define BUFSIZE 256
+void users_submit(users)
+    unsigned int users;
+{
+    char buf[BUFSIZE] = "";
+
+    if (snprintf(buf, BUFSIZE, "%u:%u", 
+                (unsigned int)curtime, 
+                users) >= BUFSIZE)
+        return;
+
+    plugin_submit(MODULE_NAME, NULL, buf);
+    return;
+}
+#undef BUFSIZE
+
+void users_write(host, inst, val)
+    char *host;
+    char *inst;
+    char *val;
+{
+    rrd_update_file(host, rrd_file, val, ds_def, ds_num);
+    return;
+}
+
+void module_register(void)
+{
+    plugin_register(MODULE_NAME, users_init, users_read, users_write);
+    return;
+}
+
+#undef MODULE_NAME
+#endif /* COLLECT_USERS */
+
diff --git a/src/users.h b/src/users.h
new file mode 100644 (file)
index 0000000..03306cf
--- /dev/null
@@ -0,0 +1,54 @@
+/* 
+ * users.h
+ *
+ * users plugin for collectd
+ *
+ * This plugin collects the number of users currently logged into the system.
+ *
+ * Written by Sebastian Harl <sh@tokkee.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; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef USERS_H
+#define USERS_H 1
+
+#include "config.h"
+
+#if !defined(HAVE_UTMPX_H) || !defined(HAVE_GETUTXENT)
+#undef HAVE_UTMPX_H
+#undef HAVE_GETUTXENT
+#endif
+
+#if !defined(HAVE_UTMP_H) || !defined(HAVE_GETUTENT)
+#undef HAVE_UTMPX_H
+#undef HAVE_GETUTXENT
+#endif
+
+#ifndef COLLECT_USERS
+#if defined(HAVE_UTMPX_H) || defined(HAVE_UTMP_H)
+#define COLLECT_USERS 1
+#else
+#define COLLECT_USERS 0
+#endif
+#endif /* ! defined(COLLECT_USERS) */
+
+void users_init(void);
+void users_read(void);
+void users_submit(unsigned int);
+void users_write(char *, char *, char *);
+
+#endif /* ! defined(USERS_H) */
+