Merge branch 'ms/aix'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 8 Dec 2009 14:43:47 +0000 (15:43 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 8 Dec 2009 14:43:47 +0000 (15:43 +0100)
1  2 
AUTHORS
configure.in
src/Makefile.am
src/disk.c
src/interface.c
src/load.c
src/memory.c
src/processes.c
src/swap.c

diff --combined AUTHORS
+++ b/AUTHORS
@@@ -82,10 -82,20 +82,21 @@@ Luke Herberling <collectd at c-ware.com
  Lyonel Vincent <lyonel at ezix.org>
   - processes plugin.
  
+ Manuel Sanmartin
+  - AIX port of the following plugins:
+    + cpu
+    + disk
+    + interface
+    + load
+    + memory
+    + processes
+    + swap
+  - Various AIX-related fixes and hacks.
  Marco Chiappero <marco at absence.it>
   - uptime plugin.
   - ip6tables support in the iptables plugin.
 + - openvpn plugin (support for more status file formats)
  
  Michael Stapelberg <michael+git at stapelberg.de>
   - OpenBSD port of the tcpconns plugin.
@@@ -155,7 -165,6 +166,7 @@@ Stefan Hacker <stefan.hacker at web.de
  
  Sven Trenkel <collectd at semidefinite.de>
   - netapp plugin.
 + - python plugin.
  
  Tomasz Pala <gotar at pld-linux.org>
   - conntrack plugin.
diff --combined configure.in
@@@ -9,7 -9,6 +9,7 @@@ m4_ifdef([LT_PACKAGE_VERSION]
         LT_CONFIG_LTDL_DIR([libltdl])
         LT_INIT([dlopen])
         LTDL_INIT([convenience])
 +       AC_DEFINE(LIBTOOL_VERSION, 2, [Define to used libtool version.])
        ]
  ,
        # libtool <= 1.5
@@@ -19,7 -18,6 +19,7 @@@
         AC_SUBST(LIBLTDL)
         AC_LIBTOOL_DLOPEN
         AC_CONFIG_SUBDIRS(libltdl)
 +       AC_DEFINE(LIBTOOL_VERSION, 1, [Define to used libtool version.])
        ]
  )
  
@@@ -63,6 -61,10 +63,10 @@@ case $host_os i
        *openbsd*)
        ac_system="OpenBSD"
        ;;
+       *aix*)
+       AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
+       ac_system="AIX"
+       ;;
        *)
        ac_system="unknown"
  esac
@@@ -629,6 -631,8 +633,8 @@@ static float foo = NAN
    fi
  fi
  if test "x$nan_type" = "xnone"; then
+   SAVE_LDFLAGS=$LDFLAGS
+   LDFLAGS="$LDFLAGS -lm"
    AC_CACHE_CHECK([whether NAN can be defined by 0/0],
      [c_cv_have_nan_zero],
      AC_RUN_IFELSE(
@@@ -655,6 -659,7 +661,7 @@@ static float foo = NAN
        [c_cv_have_nan_zero="no"]
      )
    )
+   LDFLAGS=$SAVE_LDFLAGS
    if test "x$c_cv_have_nan_zero" = "xyes"
    then
      nan_type="zero"
  m4_divert_once([HELP_WITH], [
  collectd additional packages:])
  
+ AM_CONDITIONAL([BUILD_AIX],[test "x$x$ac_system" = "xAIX"]) 
+ if test "x$ac_system" = "xAIX"
+ then
+       with_perfstat="yes"
+       with_procinfo="yes"
+ else
+       with_perfstat="no (AIX only)"
+       with_procinfo="no (AIX only)"
+ fi
+ if test "x$with_perfstat" = "xyes"
+ then
+       AC_CHECK_LIB(perfstat, perfstat_reset, [with_perfstat="yes"], [with_perfstat="no (perfstat not found)"], [])
+ #     AC_CHECK_HEADERS(sys/protosw.h libperfstat.h,, [with_perfstat="no (perfstat not found)"])
+ fi
+ if test "x$with_perfstat" = "xyes"
+ then
+        AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)])
+ fi
+ AM_CONDITIONAL(BUILD_WITH_PERFSTAT, test "x$with_perfstat" = "xyes")
+ # Processes plugin under AIX.
+ if test "x$with_procinfo" = "xyes"
+ then
+       AC_CHECK_HEADERS(procinfo.h,, [with_procinfo="no (procinfo.h not found)"])
+ fi
+ if test "x$with_procinfo" = "xyes"
+ then
+        AC_DEFINE(HAVE_PROCINFO_H, 1, [Define to 1 if you have the procinfo.h])
+ fi
  if test "x$ac_system" = "xSolaris"
  then
        with_kstat="yes"
@@@ -2655,184 -2692,6 +2694,184 @@@ AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$c
  AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
  # }}}
  
 +# --with-python {{{
 +with_python_prog=""
 +with_python_path="$PATH"
 +AC_ARG_WITH(python, [AS_HELP_STRING([--with-python@<:@=PREFIX@:>@], [Path to the python interpreter.])],
 +[
 + if test "x$withval" = "xyes" || test "x$withval" = "xno"
 + then
 +       with_python="$withval"
 + else if test -x "$withval"
 + then
 +       with_python_prog="$withval"
 +       with_python_path="`dirname \"$withval\"`$PATH_SEPARATOR$with_python_path"
 +       with_python="yes"
 + else if test -d "$withval"
 + then
 +       with_python_path="$withval$PATH_SEPARATOR$with_python_path"
 +       with_python="yes"
 + else
 +       AC_MSG_WARN([Argument not recognized: $withval])
 + fi; fi; fi
 +], [with_python="yes"])
 +
 +SAVE_PATH="$PATH"
 +SAVE_CPPFLAGS="$CPPFLAGS"
 +SAVE_LDFLAGS="$LDFLAGS"
 +SAVE_LIBS="$LIBS"
 +
 +PATH="$with_python_path"
 +
 +if test "x$with_python" = "xyes" && test "x$with_python_prog" = "x"
 +then
 +      AC_MSG_CHECKING([for python])
 +      with_python_prog="`which python 2>/dev/null`"
 +      if test "x$with_python_prog" = "x"
 +      then
 +              AC_MSG_RESULT([not found])
 +              with_python="no (interpreter not found)"
 +      else
 +              AC_MSG_RESULT([$with_python_prog])
 +      fi
 +fi
 +
 +if test "x$with_python" = "xyes"
 +then
 +      AC_MSG_CHECKING([for Python CPPFLAGS])
 +      python_include_path=`echo "import distutils.sysconfig;print distutils.sysconfig.get_python_inc()" | "$with_python_prog" 2>&1`
 +      python_config_status=$?
 +
 +      if test "$python_config_status" -ne 0 || test "x$python_include_path" = "x"
 +      then
 +              AC_MSG_RESULT([failed with status $python_config_status (output: $python_include_path)])
 +              with_python="no"
 +      else
 +              AC_MSG_RESULT([$python_include_path])
 +      fi
 +fi
 +
 +if test "x$with_python" = "xyes"
 +then
 +      CPPFLAGS="-I$python_include_path $CPPFLAGS"
 +      AC_CHECK_HEADERS(Python.h,
 +                       [with_python="yes"],
 +                       [with_python="no ('Python.h' not found)"])
 +fi
 +
 +if test "x$with_python" = "xyes"
 +then
 +      AC_MSG_CHECKING([for Python LDFLAGS])
 +      python_library_path=`echo "import distutils.sysconfig;print distutils.sysconfig.get_config_vars(\"LIBDIR\").__getitem__(0)" | "$with_python_prog" 2>&1`
 +      python_config_status=$?
 +
 +      if test "$python_config_status" -ne 0 || test "x$python_library_path" = "x"
 +      then
 +              AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_path)])
 +              with_python="no"
 +      else
 +              AC_MSG_RESULT([$python_library_path])
 +      fi
 +fi
 +
 +if test "x$with_python" = "xyes"
 +then
 +      AC_MSG_CHECKING([for Python LIBS])
 +      python_library_flags=`echo "import distutils.sysconfig;print distutils.sysconfig.get_config_vars(\"BLDLIBRARY\").__getitem__(0)" | "$with_python_prog" 2>&1`
 +      python_config_status=$?
 +
 +      if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x"
 +      then
 +              AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_flags)])
 +              with_python="no"
 +      else
 +              AC_MSG_RESULT([$python_library_flags])
 +      fi
 +fi
 +
 +if test "x$with_python" = "xyes"
 +then
 +      LDFLAGS="-L$python_library_path $LDFLAGS"
 +      LIBS="$python_library_flags $LIBS"
 +
 +      AC_CHECK_FUNC(PyObject_CallFunction,
 +                    [with_python="yes"],
 +                    [with_python="no (Symbol 'PyObject_CallFunction' not found)"])
 +fi
 +
 +PATH="$SAVE_PATH"
 +CPPFLAGS="$SAVE_CPPFLAGS"
 +LDFLAGS="$SAVE_LDFLAGS"
 +LIBS="$SAVE_LIBS"
 +
 +if test "x$with_python" = "xyes"
 +then
 +      BUILD_WITH_PYTHON_CPPFLAGS="-I$python_include_path"
 +      BUILD_WITH_PYTHON_LDFLAGS="-L$python_library_path"
 +      BUILD_WITH_PYTHON_LIBS="$python_library_flags"
 +      AC_SUBST(BUILD_WITH_PYTHON_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_PYTHON_LDFLAGS)
 +      AC_SUBST(BUILD_WITH_PYTHON_LIBS)
 +fi
 +# }}} --with-python
 +
 +# --with-librouteros {{{
 +AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
 +[
 + if test "x$withval" = "xyes"
 + then
 +       with_librouteros="yes"
 + else if test "x$withval" = "xno"
 + then
 +       with_librouteros="no"
 + else
 +       with_librouteros="yes"
 +       LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS -I$withval/include"
 +       LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS -L$withval/lib"
 + fi; fi
 +],
 +[with_librouteros="yes"])
 +
 +SAVE_CPPFLAGS="$CPPFLAGS"
 +SAVE_LDFLAGS="$LDFLAGS"
 +
 +CPPFLAGS="$CPPFLAGS $LIBROUTEROS_CPPFLAGS"
 +LDFLAGS="$LDFLAGS $LIBROUTEROS_LDFLAGS"
 +
 +if test "x$with_librouteros" = "xyes"
 +then
 +      if test "x$LIBROUTEROS_CPPFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([librouteros CPPFLAGS: $LIBROUTEROS_CPPFLAGS])
 +      fi
 +      AC_CHECK_HEADERS(routeros_api.h,
 +      [with_librouteros="yes"],
 +      [with_librouteros="no ('routeros_api.h' not found)"])
 +fi
 +if test "x$with_librouteros" = "xyes"
 +then
 +      if test "x$LIBROUTEROS_LDFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([librouteros LDFLAGS: $LIBROUTEROS_LDFLAGS])
 +      fi
 +      AC_CHECK_LIB(routeros, ros_interface,
 +      [with_librouteros="yes"],
 +      [with_librouteros="no (symbol 'ros_interface' not found)"])
 +fi
 +
 +CPPFLAGS="$SAVE_CPPFLAGS"
 +LDFLAGS="$SAVE_LDFLAGS"
 +
 +if test "x$with_librouteros" = "xyes"
 +then
 +      BUILD_WITH_LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS"
 +      BUILD_WITH_LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS"
 +      AC_SUBST(BUILD_WITH_LIBROUTEROS_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBROUTEROS_LDFLAGS)
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBROUTEROS, test "x$with_librouteros" = "xyes")
 +# }}}
 +
  # --with-librrd {{{
  # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
  librrd_cflags=""
        plugin_disk="yes"
  fi
  
+ # AIX
+ if test "x$with_perfstat" = "xyes"
+ then
+       plugin_cpu="yes"
+       plugin_disk="yes"
+       plugin_memory="yes"
+       plugin_swap="yes"
+       plugin_interface="yes"
+       plugin_load="yes"
+ fi
+ if test "x$with_procinfo" = "xyes"
+ then
+       plugin_processes="yes"
+ fi
  # Solaris
  if test "x$with_kstat" = "xyes"
  then
@@@ -4078,8 -3953,6 +4133,8 @@@ AC_PLUGIN([postgresql],  [$with_libpq]
  AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
  AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
  AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
 +AC_PLUGIN([python],      [$with_python],       [Embed a Python interpreter])
 +AC_PLUGIN([routeros],    [$with_librouteros],  [RouterOS plugin])
  AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
  AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
  AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
@@@ -4299,10 -4172,10 +4354,11 @@@ Configuration
      libopenipmi . . . . . $with_libopenipmipthread
      liboping  . . . . . . $with_liboping
      libpcap . . . . . . . $with_libpcap
+     libperfstat . . . . . $with_perfstat
      libperl . . . . . . . $with_libperl
      libpq . . . . . . . . $with_libpq
      libpthread  . . . . . $with_libpthread
 +    librouteros . . . . . $with_librouteros
      librrd  . . . . . . . $with_librrd
      libsensors  . . . . . $with_libsensors
      libstatgrab . . . . . $with_libstatgrab
      libxmms . . . . . . . $with_libxmms
      libyajl . . . . . . . $with_libyajl
      oracle  . . . . . . . $with_oracle
 +    python  . . . . . . . $with_python
  
    Features:
      daemon mode . . . . . $enable_daemon
      powerdns  . . . . . . $enable_powerdns
      processes . . . . . . $enable_processes
      protocols . . . . . . $enable_protocols
 +    python  . . . . . . . $enable_python
 +    routeros  . . . . . . $enable_routeros
      rrdcached . . . . . . $enable_rrdcached
      rrdtool . . . . . . . $enable_rrdtool
      sensors . . . . . . . $enable_sensors
diff --combined src/Makefile.am
@@@ -68,6 -68,10 +68,10 @@@ endi
  if BUILD_WITH_LIBDEVINFO
  collectd_LDADD += -ldevinfo
  endif
+ if BUILD_AIX
+ collectd_LDFLAGS += -Wl,-bexpall,-brtllib
+ collectd_LDADD += -lm
+ endif
  
  # The daemon needs to call sg_init, so we need to link it against libstatgrab,
  # too. -octo
@@@ -91,6 -95,10 +95,10 @@@ collectd_nagios_LDADD 
  if BUILD_WITH_LIBSOCKET
  collectd_nagios_LDADD += -lsocket
  endif
+ if BUILD_AIX
+ collectd_nagios_LDADD += -lm
+ endif
  collectd_nagios_LDADD += libcollectdclient/libcollectdclient.la
  collectd_nagios_DEPENDENCIES = libcollectdclient/libcollectdclient.la
  
@@@ -197,6 -205,9 +205,9 @@@ if BUILD_WITH_LIBSTATGRA
  cpu_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
  cpu_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
  endif
+ if BUILD_WITH_PERFSTAT
+ cpu_la_LIBADD += -lperfstat
+ endif
  collectd_LDADD += "-dlopen" cpu.la
  collectd_DEPENDENCIES += cpu.la
  endif
@@@ -284,6 -295,9 +295,9 @@@ if BUILD_WITH_LIBSTATGRA
  disk_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)  
  disk_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
  endif
+ if BUILD_WITH_PERFSTAT
+ disk_la_LIBADD += -lperfstat
+ endif
  collectd_LDADD += "-dlopen" disk.la
  collectd_DEPENDENCIES += disk.la
  endif
@@@ -374,6 -388,9 +388,9 @@@ if BUILD_WITH_LIBDEVINF
  interface_la_LIBADD += -ldevinfo
  endif # BUILD_WITH_LIBDEVINFO
  endif # !BUILD_WITH_LIBSTATGRAB
+ if BUILD_WITH_PERFSTAT
+ interface_la_LIBADD += -lperfstat
+ endif
  endif # BUILD_PLUGIN_INTERFACE
  
  if BUILD_PLUGIN_IPTABLES
@@@ -452,6 -469,9 +469,9 @@@ if BUILD_WITH_LIBSTATGRA
  load_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
  load_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
  endif # BUILD_WITH_LIBSTATGRAB
+ if BUILD_WITH_PERFSTAT
+ load_la_LIBADD += -lperfstat
+ endif
  endif # BUILD_PLUGIN_LOAD
  
  if BUILD_PLUGIN_LOGFILE
@@@ -562,6 -582,9 +582,9 @@@ if BUILD_WITH_LIBSTATGRA
  memory_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
  memory_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
  endif
+ if BUILD_WITH_PERFSTAT
+ memory_la_LIBADD += -lperfstat
+ endif
  endif
  
  if BUILD_PLUGIN_MULTIMETER
@@@ -790,16 -813,6 +813,16 @@@ collectd_LDADD += "-dlopen" powerdns.l
  collectd_DEPENDENCIES += powerdns.la
  endif
  
 +if BUILD_PLUGIN_PYTHON
 +pkglib_LTLIBRARIES += python.la
 +python_la_SOURCES = python.c pyconfig.c pyvalues.c cpython.h
 +python_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_PYTHON_CPPFLAGS)
 +python_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_PYTHON_LDFLAGS)
 +python_la_LIBADD = $(BUILD_WITH_PYTHON_LIBS)
 +collectd_LDADD += "-dlopen" python.la
 +collectd_DEPENDENCIES += python.la
 +endif
 +
  if BUILD_PLUGIN_PROCESSES
  pkglib_LTLIBRARIES += processes.la
  processes_la_SOURCES = processes.c
@@@ -820,16 -833,6 +843,16 @@@ collectd_LDADD += "-dlopen" protocols.l
  collectd_DEPENDENCIES += protocols.la
  endif
  
 +if BUILD_PLUGIN_ROUTEROS
 +pkglib_LTLIBRARIES += routeros.la
 +routeros_la_SOURCES = routeros.c
 +routeros_la_CPPFLAGS = $(BUILD_WITH_LIBROUTEROS_CPPFLAGS)
 +routeros_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBROUTEROS_LDFLAGS)
 +routeros_la_LIBADD = -lrouteros
 +collectd_LDADD += "-dlopen" routeros.la
 +collectd_DEPENDENCIES += routeros.la
 +endif
 +
  if BUILD_PLUGIN_RRDCACHED
  pkglib_LTLIBRARIES += rrdcached.la
  rrdcached_la_SOURCES = rrdcached.c utils_rrdcreate.c utils_rrdcreate.h
@@@ -906,6 -909,10 +929,10 @@@ if BUILD_WITH_LIBSTATGRA
  swap_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
  swap_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
  endif
+ if BUILD_WITH_PERFSTAT
+ swap_la_LIBADD += -lperfstat
+ endif
  endif
  
  if BUILD_PLUGIN_SYSLOG
@@@ -1142,7 -1149,6 +1169,7 @@@ dist_man_MANS = collectd.1 
                collectdmon.1 \
                collectd-nagios.1 \
                collectd-perl.5 \
 +              collectd-python.5 \
                collectd-snmp.5 \
                collectd-unixsock.5 \
                types.db.5
@@@ -1158,7 -1164,6 +1185,7 @@@ EXTRA_DIST +=   collectd.conf.pod 
                collectdmon.pod \
                collectd-nagios.pod \
                collectd-perl.pod \
 +              collectd-python.pod \
                collectd.pod \
                collectd-snmp.pod \
                collectd-unixsock.pod \
diff --combined src/disk.c
@@@ -1,6 -1,7 +1,7 @@@
  /**
   * collectd - src/disk.c
   * Copyright (C) 2005-2008  Florian octo Forster
+  * Copyright (C) 2009       Manuel Sanmartin
   *
   * 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
@@@ -17,6 -18,7 +18,7 @@@
   *
   * Authors:
   *   Florian octo Forster <octo at verplant.org>
+  *   Manuel Sanmartin
   **/
  
  #include "collectd.h"
  # include <statgrab.h>
  #endif
  
+ #if HAVE_PERFSTAT
+ # ifndef _AIXVERSION_610
+ # include <sys/systemcfg.h>
+ # endif
+ # include <sys/protosw.h>
+ # include <libperfstat.h>
+ #endif
  #if HAVE_IOKIT_IOKITLIB_H
  static mach_port_t io_master_port = MACH_PORT_NULL;
  /* #endif HAVE_IOKIT_IOKITLIB_H */
@@@ -105,6 -115,12 +115,12 @@@ static int numdisk = 0
  #elif defined(HAVE_LIBSTATGRAB)
  /* #endif HAVE_LIBKSTATGRAB */
  
+ #elif HAVE_PERFSTAT
+ static perfstat_disk_t * stat_disk;
+ static int numdisk;
+ static int pnumdisk;
+ /* #endif HAVE_PERFSTAT */
  #else
  # error "No applicable input method."
  #endif
@@@ -148,7 -164,7 +164,7 @@@ static int disk_init (void
  {
  #if HAVE_IOKIT_IOKITLIB_H
        kern_return_t status;
 -      
 +
        if (io_master_port != MACH_PORT_NULL)
        {
                mach_port_deallocate (mach_task_self (),
@@@ -681,7 -697,60 +697,60 @@@ static int disk_read (void
                disk_submit (name, "disk_octets", ds->read_bytes, ds->write_bytes);
                ds++;
        }
- #endif /* defined(HAVE_LIBSTATGRAB) */
+ /* #endif defined(HAVE_LIBSTATGRAB) */
+ #elif defined(HAVE_PERFSTAT)
+       counter_t read_sectors;
+       counter_t write_sectors;
+       counter_t read_time;
+       counter_t write_time;
+       counter_t read_ops;
+       counter_t write_ops;
+       perfstat_id_t firstpath;
+       int rnumdisk;
+       int i;
+       if ((numdisk = perfstat_disk(NULL, NULL, sizeof(perfstat_disk_t), 0)) < 0) 
+       {
+               char errbuf[1024];
+               WARNING ("disk plugin: perfstat_disk: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+               return (-1);
+       }
+       if (numdisk != pnumdisk || stat_disk==NULL) {
+               if (stat_disk!=NULL) 
+                       free(stat_disk);
+               stat_disk = (perfstat_disk_t *)calloc(numdisk, sizeof(perfstat_disk_t));
+       } 
+       pnumdisk = numdisk;
+       firstpath.name[0]='\0';
+       if ((rnumdisk = perfstat_disk(&firstpath, stat_disk, sizeof(perfstat_disk_t), numdisk)) < 0) 
+       {
+               char errbuf[1024];
+               WARNING ("disk plugin: perfstat_disk : %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+               return (-1);
+       }
+       for (i = 0; i < rnumdisk; i++) 
+       {
+               read_sectors = stat_disk[i].rblks*stat_disk[i].bsize;
+               write_sectors = stat_disk[i].wblks*stat_disk[i].bsize;
+               disk_submit (stat_disk[i].name, "disk_octets", read_sectors, write_sectors);
+               read_ops = stat_disk[i].xrate;
+               write_ops = stat_disk[i].xfers - stat_disk[i].xrate;
+               disk_submit (stat_disk[i].name, "disk_ops", read_ops, write_ops);
+               read_time = stat_disk[i].rserv;
+               read_time *= ((double)(_system_configuration.Xint)/(double)(_system_configuration.Xfrac)) / 1000000.0;
+               write_time = stat_disk[i].wserv;
+               write_time *= ((double)(_system_configuration.Xint)/(double)(_system_configuration.Xfrac)) / 1000000.0;
+               disk_submit (stat_disk[i].name, "disk_time", read_time, write_time);
+       }
+ #endif /* defined(HAVE_PERFSTAT) */
  
        return (0);
  } /* int disk_read */
diff --combined src/interface.c
@@@ -1,6 -1,7 +1,7 @@@
  /**
   * collectd - src/interface.c
   * Copyright (C) 2005-2008  Florian octo Forster
+  * Copyright (C) 2009       Manuel Sanmartin
   *
   * 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
@@@ -18,6 -19,7 +19,7 @@@
   * Authors:
   *   Florian octo Forster <octo at verplant.org>
   *   Sune Marcher <sm at flork.dk>
+  *   Manuel Sanmartin
   **/
  
  #include "collectd.h"
  # include <statgrab.h>
  #endif
  
+ #if HAVE_PERFSTAT
+ # include <sys/protosw.h>
+ # include <libperfstat.h>
+ #endif
  /*
   * Various people have reported problems with `getifaddrs' and varying versions
   * of `glibc'. That's why it's disabled by default. Since more statistics are
  # endif /* !COLLECT_GETIFADDRS */
  #endif /* KERNEL_LINUX */
  
- #if !HAVE_GETIFADDRS && !KERNEL_LINUX && !HAVE_LIBKSTAT && !HAVE_LIBSTATGRAB
+ #if HAVE_PERFSTAT
+ static perfstat_netinterface_t *ifstat;
+ static int nif;
+ static int pnif;
+ #endif /* HAVE_PERFSTAT */
+ #if !HAVE_GETIFADDRS && !KERNEL_LINUX && !HAVE_LIBKSTAT && !HAVE_LIBSTATGRAB && !HAVE_PERFSTAT
  # error "No applicable input method."
  #endif
  
@@@ -222,7 -235,7 +235,7 @@@ static int interface_read (void
        char buffer[1024];
        unsigned long long incoming, outgoing;
        char *device;
 -      
 +
        char *dummy;
        char *fields[16];
        int numfields;
  
                if (device[0] == '\0')
                        continue;
 -              
 +
                numfields = strsplit (dummy, fields, 16);
  
                if (numfields < 11)
  
        for (i = 0; i < num; i++)
                if_submit (ios[i].interface_name, "if_octets", ios[i].rx, ios[i].tx);
- #endif /* HAVE_LIBSTATGRAB */
+ /* #endif HAVE_LIBSTATGRAB */
+ #elif defined(HAVE_PERFSTAT)
+       perfstat_id_t id;
+       int i, ifs;
+       if ((nif =  perfstat_netinterface(NULL, NULL, sizeof(perfstat_netinterface_t), 0)) < 0)
+       {
+               char errbuf[1024];
+               WARNING ("interface plugin: perfstat_netinterface: %s",
+                       sstrerror (errno, errbuf, sizeof (errbuf)));
+               return (-1);
+       }
+       if (pnif != nif || ifstat == NULL)
+       {
+               if (ifstat != NULL)
+                       free(ifstat);
+               ifstat = malloc(nif * sizeof(perfstat_netinterface_t));
+       }
+       pnif = nif;
+       id.name[0]='\0';
+       if ((ifs = perfstat_netinterface(&id, ifstat, sizeof(perfstat_netinterface_t), nif)) < 0)
+       {
+               char errbuf[1024];
+               WARNING ("interface plugin: perfstat_netinterface (interfaces=%d): %s",
+                       nif, sstrerror (errno, errbuf, sizeof (errbuf)));
+               return (-1);
+       }
+       for (i = 0; i < ifs; i++)
+       {
+               if_submit (ifstat[i].name, "if_octets", ifstat[i].ibytes, ifstat[i].obytes);
+               if_submit (ifstat[i].name, "if_packets", ifstat[i].ipackets ,ifstat[i].opackets);
+               if_submit (ifstat[i].name, "if_errors", ifstat[i].ierrors, ifstat[i].oerrors );
+       }
+ #endif /* HAVE_PERFSTAT */
  
        return (0);
  } /* int interface_read */
diff --combined src/load.c
@@@ -1,6 -1,7 +1,7 @@@
  /**
   * collectd - src/load.c
   * Copyright (C) 2005-2008  Florian octo Forster
+  * Copyright (C) 2009       Manuel Sanmartin
   *
   * 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
@@@ -17,6 -18,7 +18,7 @@@
   *
   * Authors:
   *   Florian octo Forster <octo at verplant.org>
+  *   Manuel Sanmartin
   **/
  
  #define _BSD_SOURCE
  #endif
  #endif /* defined(HAVE_GETLOADAVG) */
  
+ #ifdef HAVE_PERFSTAT
+ # include <sys/proc.h> /* AIX 5 */
+ # include <sys/protosw.h>
+ # include <libperfstat.h>
+ #endif /* HAVE_PERFSTAT */
  static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum)
  {
        value_t values[3];
@@@ -81,7 -89,7 +89,7 @@@ static int load_read (void
  
        char *fields[8];
        int numfields;
 -      
 +
        if ((loadavg = fopen ("/proc/loadavg", "r")) == NULL)
        {
                char errbuf[1024];
        load_submit (snum, mnum, lnum);
  /* #endif HAVE_LIBSTATGRAB */
  
+ #elif HAVE_PERFSTAT
+       gauge_t snum, mnum, lnum;
+       perfstat_cpu_total_t cputotal;
+       if (perfstat_cpu_total(NULL,  &cputotal, sizeof(perfstat_cpu_total_t), 1) < 0)
+       {
+               char errbuf[1024];
+               WARNING ("load: perfstat_cpu : %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+               return (-1);
+       }
+       snum = (float)cputotal.loadavg[0]/(float)(1<<SBITS);
+       mnum = (float)cputotal.loadavg[1]/(float)(1<<SBITS);
+       lnum = (float)cputotal.loadavg[2]/(float)(1<<SBITS);
+       load_submit (snum, mnum, lnum);
+ /* #endif HAVE_PERFSTAT */
  #else
  # error "No applicable input method."
  #endif
diff --combined src/memory.c
@@@ -2,6 -2,7 +2,7 @@@
   * collectd - src/memory.c
   * Copyright (C) 2005-2008  Florian octo Forster
   * Copyright (C) 2009       Simon Kuhnle
+  * Copyright (C) 2009       Manuel Sanmartin
   *
   * 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
@@@ -19,6 -20,7 +20,7 @@@
   * Authors:
   *   Florian octo Forster <octo at verplant.org>
   *   Simon Kuhnle <simon at blarzwurst.de>
+  *   Manuel Sanmartin
   **/
  
  #include "collectd.h"
  # include <statgrab.h>
  #endif
  
+ #if HAVE_PERFSTAT
+ # include <sys/protosw.h>
+ # include <libperfstat.h>
+ #endif /* HAVE_PERFSTAT */
  /* vm_statistics_data_t */
  #if HAVE_HOST_STATISTICS
  static mach_port_t port_host;
@@@ -75,7 -82,10 +82,10 @@@ static int pagesize
  #elif HAVE_LIBSTATGRAB
  /* no global variables */
  /* endif HAVE_LIBSTATGRAB */
+ #elif HAVE_PERFSTAT
+ static int pagesize;
+ static perfstat_memory_total_t pmemory;
+ /* endif HAVE_PERFSTAT */
  #else
  # error "No applicable input method."
  #endif
@@@ -116,8 -126,11 +126,11 @@@ static int memory_init (void
  
  #elif HAVE_LIBSTATGRAB
  /* no init stuff */
#endif /* HAVE_LIBSTATGRAB */
/* #endif HAVE_LIBSTATGRAB */
  
+ #elif HAVE_PERFSTAT
+       pagesize = getpagesize ();
+ #endif /* HAVE_PERFSTAT */
        return (0);
  } /* int memory_init */
  
@@@ -250,7 -263,7 +263,7 @@@ static int memory_read (void
  #elif KERNEL_LINUX
        FILE *fh;
        char buffer[1024];
 -      
 +
        char *fields[8];
        int numfields;
  
                memory_submit ("cached", ios->cache);
                memory_submit ("free",   ios->free);
        }
- #endif /* HAVE_LIBSTATGRAB */
+ /* #endif HAVE_LIBSTATGRAB */
+ #elif HAVE_PERFSTAT
+       if (perfstat_memory_total(NULL, &pmemory, sizeof(perfstat_memory_total_t), 1) < 0)
+       {
+               char errbuf[1024];
+               WARNING ("memory plugin: perfstat_memory_total failed: %s",
+                       sstrerror (errno, errbuf, sizeof (errbuf)));
+               return (-1);
+       }
+       memory_submit ("used",   pmemory.real_inuse * pagesize);
+       memory_submit ("free",   pmemory.real_free * pagesize);
+       memory_submit ("cached", pmemory.numperm * pagesize);
+       memory_submit ("system", pmemory.real_system * pagesize);
+       memory_submit ("user",   pmemory.real_process * pagesize);
+ #endif /* HAVE_PERFSTAT */
  
        return (0);
  }
diff --combined src/processes.c
@@@ -4,6 -4,7 +4,7 @@@
   * Copyright (C) 2006-2008  Florian octo Forster
   * Copyright (C) 2008       Oleg King
   * Copyright (C) 2009       Sebastian Harl
+  * Copyright (C) 2009       Manuel Sanmartin
   *
   * 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
@@@ -24,6 -25,7 +25,7 @@@
   *   Florian octo Forster <octo at verplant.org>
   *   Oleg King <king2 at kaluga.ru>
   *   Sebastian Harl <sh at tokkee.org>
+  *   Manuel Sanmartin
   **/
  
  #include "collectd.h"
  #  include <sys/proc.h>
  /* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
  
+ #elif HAVE_PROCINFO_H
+ #  include <procinfo.h>
+ #  include <sys/types.h>
+ #define MAXPROCENTRY 32
+ #define MAXTHRDENTRY 16
+ #define MAXARGLN 1024
+ /* #endif HAVE_PROCINFO_H */
  #else
  # error "No applicable input method."
  #endif
@@@ -191,7 -202,19 +202,19 @@@ static long pagesize_g
  
  #elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD
  /* no global variables */
- #endif /* HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
+ /* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
+ #elif HAVE_PROCINFO_H
+ static  struct procentry64 procentry[MAXPROCENTRY];
+ static  struct thrdentry64 thrdentry[MAXTHRDENTRY];
+ static int pagesize;
+ #ifndef _AIXVERSION_610
+ int     getprocs64 (void *procsinfo, int sizproc, void *fdsinfo, int sizfd, pid_t *index, int count);
+ int     getthrds64( pid_t, void *, int, tid64_t *, int );
+ #endif
+ int getargs (struct procentry64 *processBuffer, int bufferLen, char *argsBuffer, int argsLen);
+ #endif /* HAVE_PROCINFO_H */
  
  /* put name of process from config to list_head_g tree
     list_head_g is a list of 'procstat_t' structs with
@@@ -243,7 -266,7 +266,7 @@@ static void ps_list_register (const cha
                return;
        }
  #endif
 -      
 +
        for (ptr = list_head_g; ptr != NULL; ptr = ptr->next)
        {
                if (strcmp (ptr->name, name) == 0)
@@@ -319,13 -342,13 +342,13 @@@ static void ps_list_add (const char *na
                if ((pse == NULL) || (pse->id != entry->id))
                {
                        procstat_entry_t *new;
 -                      
 +
                        new = (procstat_entry_t *) malloc (sizeof (procstat_entry_t));
                        if (new == NULL)
                                return;
                        memset (new, 0, sizeof (procstat_entry_t));
                        new->id = entry->id;
 -                      
 +
                        if (pse == NULL)
                                ps->instances = new;
                        else
                                pse->vmem_minflt = entry->vmem_minflt_counter - pse->vmem_minflt_counter;
                        }
                        pse->vmem_minflt_counter = entry->vmem_minflt_counter;
 -                      
 +
                        if (entry->vmem_majflt_counter < pse->vmem_majflt_counter)
                        {
                                pse->vmem_majflt = entry->vmem_majflt_counter
                                pse->cpu_user = entry->cpu_user_counter - pse->cpu_user_counter;
                        }
                        pse->cpu_user_counter = entry->cpu_user_counter;
 -                      
 +
                        if (entry->cpu_system_counter < pse->cpu_system_counter)
                        {
                                pse->cpu_system = entry->cpu_system_counter
@@@ -563,7 -586,11 +586,11 @@@ static int ps_init (void
  
  #elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD
  /* no initialization */
- #endif /* HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
+ /* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
+ #elif HAVE_PROCINFO_H
+       pagesize = getpagesize();
+ #endif /* HAVE_PROCINFO_H */
  
        return (0);
  } /* int ps_init */
@@@ -1542,7 -1569,133 +1569,133 @@@ static int ps_read (void
  
        for (ps_ptr = list_head_g; ps_ptr != NULL; ps_ptr = ps_ptr->next)
                ps_submit_proc_list (ps_ptr);
- #endif /* HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
+ /* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
+ #elif HAVE_PROCINFO_H
+       /* AIX */
+       int running  = 0;
+       int sleeping = 0;
+       int zombies  = 0;
+       int stopped  = 0;
+       int paging   = 0;
+       int blocked  = 0;
+       pid_t pindex = 0;
+       int nprocs;
+       procstat_t *ps;
+       procstat_entry_t pse;
+       ps_list_reset ();
+       while ((nprocs = getprocs64 (procentry, sizeof(struct procentry64),
+                                       /* fdsinfo = */ NULL, sizeof(struct fdsinfo64),
+                                       &pindex, MAXPROCENTRY)) > 0)
+       {
+               int i;
+               for (i = 0; i < nprocs; i++)
+               {
+                       tid64_t thindex;
+                       int nthreads;
+                       char arglist[MAXARGLN+1];
+                       char *cargs;
+                       char *cmdline;
+                       if (procentry[i].pi_state == SNONE) continue;
+                       /* if (procentry[i].pi_state == SZOMB)  FIXME */
+                       cmdline = procentry[i].pi_comm;
+                       cargs = procentry[i].pi_comm;
+                       if ( procentry[i].pi_flags & SKPROC )
+                       {
+                               if (procentry[i].pi_pid == 0)
+                                       cmdline = "swapper";
+                               cargs = cmdline;
+                       }
+                       else
+                       {
+                               if (getargs(&procentry[i], sizeof(struct procentry64), arglist, MAXARGLN) >= 0)
+                               {
+                                       int n;
+                                       n = -1;
+                                       while (++n < MAXARGLN)
+                                       {
+                                               if (arglist[n] == '\0')
+                                               {
+                                                       if (arglist[n+1] == '\0')
+                                                               break;
+                                                       arglist[n] = ' ';
+                                               }
+                                       }
+                                       cargs = arglist;
+                               }
+                       }
+                       pse.id       = procentry[i].pi_pid;
+                       pse.age      = 0;
+                       pse.num_lwp  = procentry[i].pi_thcount;
+                       pse.num_proc = 1;
+                       thindex=0;
+                       while ((nthreads = getthrds64(procentry[i].pi_pid,
+                                                       thrdentry, sizeof(struct thrdentry64),
+                                                       &thindex, MAXTHRDENTRY)) > 0)
+                       {
+                               int j;
+                               for (j=0; j< nthreads; j++)
+                               {
+                                       switch (thrdentry[j].ti_state)
+                                       {
+                                               /* case TSNONE: break; */
+                                               case TSIDL:     blocked++;      break; /* FIXME is really blocked */
+                                               case TSRUN:     running++;      break;
+                                               case TSSLEEP:   sleeping++;     break;
+                                               case TSSWAP:    paging++;       break;
+                                               case TSSTOP:    stopped++;      break;
+                                               case TSZOMB:    zombies++;      break;
+                                       }
+                               }
+                               if (nthreads < MAXTHRDENTRY)
+                                       break;
+                       }
+                       pse.cpu_user = 0;
+                       /* tv_usec is nanosec ??? */
+                       pse.cpu_user_counter = procentry[i].pi_ru.ru_utime.tv_sec * 1000000 +
+                               procentry[i].pi_ru.ru_utime.tv_usec / 1000;
+                       pse.cpu_system = 0;
+                       /* tv_usec is nanosec ??? */
+                       pse.cpu_system_counter = procentry[i].pi_ru.ru_stime.tv_sec * 1000000 +
+                               procentry[i].pi_ru.ru_stime.tv_usec / 1000;
+                       pse.vmem_minflt = 0;
+                       pse.vmem_minflt_counter = procentry[i].pi_minflt;
+                       pse.vmem_majflt = 0;
+                       pse.vmem_majflt_counter = procentry[i].pi_majflt;
+                       pse.vmem_size = procentry[i].pi_tsize + procentry[i].pi_dvm * pagesize;
+                       pse.vmem_rss = (procentry[i].pi_drss + procentry[i].pi_trss) * pagesize;
+                       pse.stack_size =  0;
+                       ps_list_add (cmdline, cargs, &pse);
+               } /* for (i = 0 .. nprocs) */
+               if (nprocs < MAXPROCENTRY)
+                       break;
+       } /* while (getprocs64() > 0) */
+       ps_submit_state ("running",  running);
+       ps_submit_state ("sleeping", sleeping);
+       ps_submit_state ("zombies",  zombies);
+       ps_submit_state ("stopped",  stopped);
+       ps_submit_state ("paging",   paging);
+       ps_submit_state ("blocked",  blocked);
+       for (ps = list_head_g; ps != NULL; ps = ps->next)
+               ps_submit_proc_list (ps);
+ #endif /* HAVE_PROCINFO_H */
  
        return (0);
  } /* int ps_read */
diff --combined src/swap.c
@@@ -2,6 -2,7 +2,7 @@@
   * collectd - src/swap.c
   * Copyright (C) 2005-2009  Florian octo Forster
   * Copyright (C) 2009       Stefan Völkel
+  * Copyright (C) 2009       Manuel Sanmartin
   *
   * 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
@@@ -18,6 -19,7 +19,7 @@@
   *
   * Authors:
   *   Florian octo Forster <octo at verplant.org>
+  *   Manuel Sanmartin
   **/
  
  #if HAVE_CONFIG_H
  # include <statgrab.h>
  #endif
  
+ #if HAVE_PERFSTAT
+ # include <sys/protosw.h>
+ # include <libperfstat.h>
+ #endif
  #undef  MAX
  #define MAX(x,y) ((x) > (y) ? (x) : (y))
  
@@@ -86,6 -93,11 +93,11 @@@ int kvm_pagesize
  /* No global variables */
  /* #endif HAVE_LIBSTATGRAB */
  
+ #elif HAVE_PERFSTAT
+ static int pagesize;
+ static perfstat_memory_total_t pmemory;
+ /*# endif HAVE_PERFSTAT */ 
  #else
  # error "No applicable input method."
  #endif /* HAVE_LIBSTATGRAB */
@@@ -134,7 -146,11 +146,11 @@@ static int swap_init (void
  
  #elif HAVE_LIBSTATGRAB
        /* No init stuff */
- #endif /* HAVE_LIBSTATGRAB */
+ /* #endif HAVE_LIBSTATGRAB */
+ #elif HAVE_PERFSTAT
+       pagesize = getpagesize();
+ #endif /* HAVE_PERFSTAT */
  
        return (0);
  }
@@@ -173,7 -189,7 +189,7 @@@ static int swap_read (void
  #if KERNEL_LINUX
        FILE *fh;
        char buffer[1024];
 -      
 +
        char *fields[8];
        int numfields;
  
  
        swap_submit ("used", (derive_t) swap->used, DS_TYPE_GAUGE);
        swap_submit ("free", (derive_t) swap->free, DS_TYPE_GAUGE);
- #endif /* HAVE_LIBSTATGRAB */
+ /* #endif  HAVE_LIBSTATGRAB */
+ #elif HAVE_PERFSTAT
+         if(perfstat_memory_total(NULL, &pmemory, sizeof(perfstat_memory_total_t), 1) < 0)
+       {
+                 char errbuf[1024];
+                 WARNING ("memory plugin: perfstat_memory_total failed: %s",
+                         sstrerror (errno, errbuf, sizeof (errbuf)));
+                 return (-1);
+         }
+       swap_submit ("used", (derive_t) (pmemory.pgsp_total - pmemory.pgsp_free) * pagesize, DS_TYPE_GAUGE);
+       swap_submit ("free", (derive_t) pmemory.pgsp_free * pagesize , DS_TYPE_GAUGE);
+ #endif /* HAVE_PERFSTAT */
  
        return (0);
  } /* int swap_read */