Merge branch 'master' into ff/modbus
authorFlorian Forster <octo@noris.net>
Wed, 17 Mar 2010 12:45:36 +0000 (13:45 +0100)
committerFlorian Forster <octo@noris.net>
Wed, 17 Mar 2010 12:45:36 +0000 (13:45 +0100)
15 files changed:
.mailmap
configure.in
src/collectd.conf.pod
src/common.c
src/common.h
src/configfile.c
src/exec.c
src/logfile.c
src/memcached.c
src/oracle.c
src/owniptc/libip4tc.c
src/owniptc/libip6tc.c
src/owniptc/libiptc.c
src/processes.c
src/types.db

index 9bb4399..a39a1d2 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -5,4 +5,5 @@ Luboš Staněk <kolektor@atlas.cz>
 Luboš Staněk <lubek@users.sourceforge.net>
 Niki W. Waibel <niki>
 Sebastian Harl <tokkee>
+Rodolphe Quiedeville <rquiedeville@bearstech.com>
 
index a3b2ab6..1193583 100644 (file)
@@ -931,6 +931,27 @@ if test "x$have_getmntent" = "xgen"; then
                  [Define if the function getmntent exists. It's the version from libgen.])
 fi
 
+# Check for htonll
+AC_MSG_CHECKING([if have htonll defined])
+
+    have_htonll="no"
+    AC_RUN_IFELSE([
+       AC_LANG_PROGRAM([
+#include <sys/types.h>
+#include <netinet/in.h>
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h> 
+#endif
+       ], [
+          return htonll(0);
+       ])
+    ], [
+      have_htonll="yes"
+      AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
+    ])
+AC_MSG_RESULT([$have_htonll])
+
 # Check for structures
 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
        [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
index 09508f7..26cad5f 100644 (file)
@@ -1583,6 +1583,11 @@ running in foreground- or non-daemon-mode.
 
 Prefix all lines printed by the current time. Defaults to B<true>.
 
+=item B<PrintSeverity> B<true>|B<false>
+
+When enabled, all lines are prefixed by the severity of the log message, for
+example "warning". Defaults to B<false>.
+
 =back
 
 B<Note>: There is no need to notify the daemon after moving or removing the
index 8c2aeae..2598036 100644 (file)
@@ -668,6 +668,7 @@ long long get_kstat_value (kstat_t *ksp, char *name)
 }
 #endif /* HAVE_LIBKSTAT */
 
+#ifndef HAVE_HTONLL
 unsigned long long ntohll (unsigned long long n)
 {
 #if BYTE_ORDER == BIG_ENDIAN
@@ -685,6 +686,7 @@ unsigned long long htonll (unsigned long long n)
        return (((unsigned long long) htonl (n)) << 32) + htonl (n >> 32);
 #endif
 } /* unsigned long long htonll */
+#endif /* HAVE_HTONLL */
 
 #if FP_LAYOUT_NEED_NOTHING
 /* Well, we need nothing.. */
index fc809f2..c0bea36 100644 (file)
@@ -236,8 +236,10 @@ int get_kstat (kstat_t **ksp_ptr, char *module, int instance, char *name);
 long long get_kstat_value (kstat_t *ksp, char *name);
 #endif
 
+#ifndef HAVE_HTONLL
 unsigned long long ntohll (unsigned long long n);
 unsigned long long htonll (unsigned long long n);
+#endif
 
 #if FP_LAYOUT_NEED_NOTHING
 # define ntohd(d) (d)
index aade476..fe2bce3 100644 (file)
@@ -575,14 +575,14 @@ static oconfig_item_t *cf_read_dir (const char *dir, int depth)
                ERROR ("configfile: malloc failed.");
                return (NULL);
        }
-       memset (root, '\0', sizeof (oconfig_item_t));
+       memset (root, 0, sizeof (oconfig_item_t));
 
        while ((de = readdir (dh)) != NULL)
        {
                char   name[1024];
                char **tmp;
 
-               if ((de->d_name[0] == '.') || (de->d_name[0] == '\0'))
+               if ((de->d_name[0] == '.') || (de->d_name[0] == 0))
                        continue;
 
                status = ssnprintf (name, sizeof (name), "%s/%s",
@@ -624,13 +624,11 @@ static oconfig_item_t *cf_read_dir (const char *dir, int depth)
                char *name = filenames[i];
 
                temp = cf_read_generic (name, depth);
-               if (temp == NULL) {
-                       int j;
-                       for (j = i; j < filenames_num; ++j)
-                               free (filenames[j]);
-                       free (filenames);
-                       oconfig_free (root);
-                       return (NULL);
+               if (temp == NULL)
+               {
+                       /* An error should already have been reported. */
+                       sfree (name);
+                       continue;
                }
 
                cf_ci_append_children (root, temp);
index 3bd6309..681b94d 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/exec.c
- * Copyright (C) 2007-2009  Florian octo Forster
+ * Copyright (C) 2007-2010  Florian octo Forster
  * Copyright (C) 2007-2009  Sebastian Harl
  * Copyright (C) 2008       Peter Holik
  *
@@ -276,6 +276,7 @@ static void set_environment (void) /* {{{ */
   setenv ("COLLECTD_HOSTNAME", buffer, /* overwrite = */ 1);
 } /* }}} void set_environment */
 
+__attribute__((noreturn))
 static void exec_child (program_list_t *pl) /* {{{ */
 {
   int status;
@@ -550,7 +551,13 @@ static void *exec_read_one (void *arg) /* {{{ */
 
   status = fork_child (pl, NULL, &fd, &fd_err);
   if (status < 0)
+  {
+    /* Reset the "running" flag */
+    pthread_mutex_lock (&pl_lock);
+    pl->flags &= ~PL_RUNNING;
+    pthread_mutex_unlock (&pl_lock);
     pthread_exit ((void *) 1);
+  }
   pl->pid = status;
 
   assert (pl->pid != 0);
@@ -806,7 +813,7 @@ static int exec_read (void) /* {{{ */
   return (0);
 } /* int exec_read }}} */
 
-static int exec_notification (const notification_t *n,
+static int exec_notification (const notification_t *n, /* {{{ */
     user_data_t __attribute__((unused)) *user_data)
 {
   program_list_t *pl;
index 7b96ac5..6d0f6e0 100644 (file)
@@ -39,12 +39,14 @@ static pthread_mutex_t file_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static char *log_file = NULL;
 static int print_timestamp = 1;
+static int print_severity = 0;
 
 static const char *config_keys[] =
 {
        "LogLevel",
        "File",
-       "Timestamp"
+       "Timestamp",
+       "PrintSeverity"
 };
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
 
@@ -78,6 +80,11 @@ static int logfile_config (const char *key, const char *value)
                        print_timestamp = 0;
                else
                        print_timestamp = 1;
+       } else if (0 == strcasecmp(key, "PrintSeverity")) {
+               if (IS_FALSE (value))
+                       print_severity = 0;
+               else
+                       print_severity = 1;
        }
        else {
                return -1;
@@ -85,12 +92,37 @@ static int logfile_config (const char *key, const char *value)
        return 0;
 } /* int logfile_config (const char *, const char *) */
 
-static void logfile_print (const char *msg, time_t timestamp_time)
+static void logfile_print (const char *msg, int severity, time_t timestamp_time)
 {
        FILE *fh;
        int do_close = 0;
        struct tm timestamp_tm;
        char timestamp_str[64];
+       char level_str[16] = "";
+
+       if (print_severity)
+       {
+               switch (severity)
+               {
+               case LOG_ERR:
+                       snprintf(level_str, sizeof (level_str), "[error] ");
+                       break;  
+               case LOG_WARNING:
+                       snprintf(level_str, sizeof (level_str), "[warning] ");
+                       break;
+               case LOG_NOTICE:
+                       snprintf(level_str, sizeof (level_str), "[notice] ");
+                       break;  
+               case LOG_INFO:
+                       snprintf(level_str, sizeof (level_str), "[info] ");
+                       break;  
+               case LOG_DEBUG:
+                       snprintf(level_str, sizeof (level_str), "[debug] ");
+                       break;  
+               default:
+                       break;
+               }
+       }
 
        if (print_timestamp)
        {
@@ -128,9 +160,9 @@ static void logfile_print (const char *msg, time_t timestamp_time)
        else
        {
                if (print_timestamp)
-                       fprintf (fh, "[%s] %s\n", timestamp_str, msg);
+                       fprintf (fh, "[%s] %s%s\n", timestamp_str, level_str, msg);
                else
-                       fprintf (fh, "%s\n", msg);
+                       fprintf (fh, "%s%s\n", level_str, msg);
 
                if (do_close != 0)
                        fclose (fh);
@@ -147,7 +179,7 @@ static void logfile_log (int severity, const char *msg,
        if (severity > log_level)
                return;
 
-       logfile_print (msg, time (NULL));
+       logfile_print (msg, severity, time (NULL));
 } /* void logfile_log (int, const char *) */
 
 static int logfile_notification (const notification_t *n,
@@ -185,7 +217,7 @@ static int logfile_notification (const notification_t *n,
 
        buf[sizeof (buf) - 1] = '\0';
 
-       logfile_print (buf,
+       logfile_print (buf, LOG_INFO,
                        (n->time > 0) ? n->time : time (NULL));
 
        return (0);
index b332157..348591f 100644 (file)
 # include <netinet/in.h>
 # include <netinet/tcp.h>
 
+/* Hack to work around the missing define in AIX */
+#ifndef MSG_DONTWAIT
+# define MSG_DONTWAIT MSG_NONBLOCK
+#endif
+
 #define MEMCACHED_DEF_HOST "127.0.0.1"
 #define MEMCACHED_DEF_PORT "11211"
 
index 49cf657..7a8ccc6 100644 (file)
@@ -612,16 +612,22 @@ static int o_read_database (o_database_t *db) /* {{{ */
       o_report_error ("o_read_database", "OCIAttrGet", oci_error);
       return (-1);
     }
-    assert (server_handle != NULL);
 
-    connection_status = 0;
-    status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER,
-        (void *) &connection_status, /* size pointer = */ NULL,
-        OCI_ATTR_SERVER_STATUS, oci_error);
-    if (status != OCI_SUCCESS)
+    if (server_handle == NULL)
     {
-      o_report_error ("o_read_database", "OCIAttrGet", oci_error);
-      return (-1);
+      connection_status = OCI_SERVER_NOT_CONNECTED;
+    }
+    else /* if (server_handle != NULL) */
+    {
+      connection_status = 0;
+      status = OCIAttrGet ((void *) server_handle, OCI_HTYPE_SERVER,
+          (void *) &connection_status, /* size pointer = */ NULL,
+          OCI_ATTR_SERVER_STATUS, oci_error);
+      if (status != OCI_SUCCESS)
+      {
+        o_report_error ("o_read_database", "OCIAttrGet", oci_error);
+        return (-1);
+      }
     }
 
     if (connection_status != OCI_SERVER_NORMAL)
index 66abb44..bf7327c 100644 (file)
@@ -173,7 +173,8 @@ dump_entry(STRUCT_ENTRY *e, const TC_HANDLE_T handle)
        t = GET_TARGET(e);
        printf("Target name: `%s' [%u]\n", t->u.user.name, t->u.target_size);
        if (strcmp(t->u.user.name, STANDARD_TARGET) == 0) {
-               int pos = *(int *)t->data;
+               const unsigned char *data = t->data;
+               int pos = *(const int *)data;
                if (pos < 0)
                        printf("verdict=%s\n",
                               pos == -NF_ACCEPT-1 ? "NF_ACCEPT"
index 276b7af..672dae1 100644 (file)
@@ -204,7 +204,8 @@ dump_entry(struct ip6t_entry *e, const ip6tc_handle_t handle)
        t = ip6t_get_target(e);
        printf("Target name: `%s' [%u]\n", t->u.user.name, t->u.target_size);
        if (strcmp(t->u.user.name, IP6T_STANDARD_TARGET) == 0) {
-               int pos = *(int *)t->data;
+               const unsigned char *data = t->data;
+               int pos = *(const int *)data;
                if (pos < 0)
                        printf("verdict=%s\n",
                               pos == -NF_ACCEPT-1 ? "NF_ACCEPT"
index 5e5fde0..8f0b0f0 100644 (file)
@@ -744,14 +744,16 @@ static void iptcc_delete_rule(struct rule_head *r)
  * to be called from specific places within the parser */
 static int __iptcc_p_del_policy(TC_HANDLE_T h, unsigned int num)
 {
+       const unsigned char *data;
+
        if (h->chain_iterator_cur) {
                /* policy rule is last rule */
                struct rule_head *pr = (struct rule_head *)
                        h->chain_iterator_cur->rules.prev;
 
                /* save verdict */
-               h->chain_iterator_cur->verdict = 
-                       *(int *)GET_TARGET(pr->entry)->data;
+               data = GET_TARGET(pr->entry)->data;
+               h->chain_iterator_cur->verdict = *(const int *)data;
 
                /* save counter and counter_map information */
                h->chain_iterator_cur->counter_map.maptype = 
@@ -1563,6 +1565,7 @@ const char *TC_GET_TARGET(const STRUCT_ENTRY *ce,
 {
        STRUCT_ENTRY *e = (STRUCT_ENTRY *)ce;
        struct rule_head *r = container_of(e, struct rule_head, entry[0]);
+       const unsigned char *data;
 
        iptc_fn = TC_GET_TARGET;
 
@@ -1576,7 +1579,8 @@ const char *TC_GET_TARGET(const STRUCT_ENTRY *ce,
                        return r->jump->name;
                        break;
                case IPTCC_R_STANDARD:
-                       spos = *(int *)GET_TARGET(e)->data;
+                       data = GET_TARGET(e)->data;
+                       spos = *(const int *)data;
                        DEBUGP("r=%p, spos=%d'\n", r, spos);
                        return standard_target_map(spos);
                        break;
index 5e176c8..c642e58 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (C) 2009       Sebastian Harl
  * Copyright (C) 2009       Andrés J. Díaz
  * Copyright (C) 2009       Manuel Sanmartin
+ * Copyright (C) 2010       Clément Stenac
  *
  * 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
@@ -28,6 +29,7 @@
  *   Sebastian Harl <sh at tokkee.org>
  *   Andrés J. Díaz <ajdiaz at connectical.com>
  *   Manuel Sanmartin
+ *   Clément Stenac <clement.stenac at diwi.org>
  **/
 
 #include "collectd.h"
 #  define ARG_MAX 4096
 #endif
 
-#define BUFSIZE 256
-
 static const char *config_keys[] =
 {
        "Process",
@@ -137,6 +137,8 @@ typedef struct procstat_entry_s
        unsigned long num_lwp;
        unsigned long vmem_size;
        unsigned long vmem_rss;
+       unsigned long vmem_data;
+       unsigned long vmem_code;
        unsigned long stack_size;
 
        unsigned long vmem_minflt;
@@ -170,6 +172,8 @@ typedef struct procstat
        unsigned long num_lwp;
        unsigned long vmem_size;
        unsigned long vmem_rss;
+       unsigned long vmem_data;
+       unsigned long vmem_code;
        unsigned long stack_size;
 
        unsigned long vmem_minflt_counter;
@@ -262,7 +266,7 @@ static void ps_list_register (const char *name, const char *regexp)
                ERROR ("processes plugin: ps_list_register: "
                                "Regular expression \"%s\" found in config "
                                "file, but support for regular expressions "
-                               "has been dispabled at compile time.",
+                               "has been disabled at compile time.",
                                regexp);
                sfree (new);
                return;
@@ -364,6 +368,8 @@ static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t
                pse->num_lwp    = entry->num_lwp;
                pse->vmem_size  = entry->vmem_size;
                pse->vmem_rss   = entry->vmem_rss;
+               pse->vmem_data  = entry->vmem_data;
+               pse->vmem_code  = entry->vmem_code;
                pse->stack_size = entry->stack_size;
                pse->io_rchar   = entry->io_rchar;
                pse->io_wchar   = entry->io_wchar;
@@ -374,6 +380,8 @@ static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t
                ps->num_lwp    += pse->num_lwp;
                ps->vmem_size  += pse->vmem_size;
                ps->vmem_rss   += pse->vmem_rss;
+               ps->vmem_data  += pse->vmem_data;
+               ps->vmem_code  += pse->vmem_code;
                ps->stack_size += pse->stack_size;
 
                ps->io_rchar   += ((pse->io_rchar == -1)?0:pse->io_rchar);
@@ -470,6 +478,8 @@ static void ps_list_reset (void)
                ps->num_lwp     = 0;
                ps->vmem_size   = 0;
                ps->vmem_rss    = 0;
+               ps->vmem_data   = 0;
+               ps->vmem_code   = 0;
                ps->stack_size  = 0;
                ps->io_rchar = -1;
                ps->io_wchar = -1;
@@ -638,6 +648,16 @@ static void ps_submit_proc_list (procstat_t *ps)
        vl.values_len = 1;
        plugin_dispatch_values (&vl);
 
+       sstrncpy (vl.type, "ps_data", sizeof (vl.type));
+       vl.values[0].gauge = ps->vmem_data;
+       vl.values_len = 1;
+       plugin_dispatch_values (&vl);
+
+       sstrncpy (vl.type, "ps_code", sizeof (vl.type));
+       vl.values[0].gauge = ps->vmem_code;
+       vl.values_len = 1;
+       plugin_dispatch_values (&vl);
+
        sstrncpy (vl.type, "ps_stacksize", sizeof (vl.type));
        vl.values[0].gauge = ps->stack_size;
        vl.values_len = 1;
@@ -679,12 +699,16 @@ static void ps_submit_proc_list (procstat_t *ps)
                plugin_dispatch_values (&vl);
        }
 
-       DEBUG ("name = %s; num_proc = %lu; num_lwp = %lu; vmem_rss = %lu; "
+       DEBUG ("name = %s; num_proc = %lu; num_lwp = %lu; "
+                        "vmem_size = %lu; vmem_rss = %lu; vmem_data = %lu; "
+                       "vmem_code = %lu; "
                        "vmem_minflt_counter = %lu; vmem_majflt_counter = %lu; "
                        "cpu_user_counter = %lu; cpu_system_counter = %lu; "
                        "io_rchar = %"PRIi64"; io_wchar = %"PRIi64"; "
                        "io_syscr = %"PRIi64"; io_syscw = %"PRIi64";",
-                       ps->name, ps->num_proc, ps->num_lwp, ps->vmem_rss,
+                       ps->name, ps->num_proc, ps->num_lwp,
+                       ps->vmem_size, ps->vmem_rss,
+                       ps->vmem_data, ps->vmem_code,
                        ps->vmem_minflt_counter, ps->vmem_majflt_counter,
                        ps->cpu_user_counter, ps->cpu_system_counter,
                        ps->io_rchar, ps->io_wchar, ps->io_syscr, ps->io_syscw);
@@ -719,6 +743,69 @@ static int ps_read_tasks (int pid)
        return ((count >= 1) ? count : 1);
 } /* int *ps_read_tasks */
 
+/* Read advanced virtual memory data from /proc/pid/status */
+static procstat_t *ps_read_vmem (int pid, procstat_t *ps)
+{
+       FILE *fh;
+       char buffer[1024];
+       char filename[64];
+       unsigned long long lib = 0;
+       unsigned long long exe = 0;
+       unsigned long long data = 0;
+       char *fields[8];
+       int numfields;
+
+       ssnprintf (filename, sizeof (filename), "/proc/%i/status", pid);
+       if ((fh = fopen (filename, "r")) == NULL)
+               return (NULL);
+
+       while (fgets (buffer, sizeof(buffer), fh) != NULL)
+       {
+               long long tmp;
+               char *endptr;
+
+               if (strncmp (buffer, "Vm", 2) != 0)
+                       continue;
+
+               numfields = strsplit (buffer, fields,
+                                      STATIC_ARRAY_SIZE (fields));
+
+               if (numfields < 2)
+                       continue;
+
+               errno = 0;
+               endptr = NULL;
+               tmp = strtoll (fields[1], &endptr, /* base = */ 10);
+               if ((errno == 0) && (endptr != fields[1]))
+               {
+                       if (strncmp (buffer, "VmData", 6) == 0) 
+                       {
+                               data = tmp;
+                       }
+                       else if (strncmp (buffer, "VmLib", 5) == 0)
+                       {
+                               lib = tmp;
+                       }
+                       else if  (strncmp(buffer, "VmExe", 5) == 0)
+                       {
+                               exe = tmp;
+                       }
+               }
+       } /* while (fgets) */
+
+       if (fclose (fh))
+       {
+               char errbuf[1024];
+               WARNING ("processes: fclose: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+       }
+
+       ps->vmem_data = data * 1024;
+       ps->vmem_code = (exe + lib) * 1024;
+
+       return (ps);
+} /* procstat_t *ps_read_vmem */
+
 static procstat_t *ps_read_io (int pid, procstat_t *ps)
 {
        FILE *fh;
@@ -732,7 +819,7 @@ static procstat_t *ps_read_io (int pid, procstat_t *ps)
        if ((fh = fopen (filename, "r")) == NULL)
                return (NULL);
 
-       while (fgets (buffer, 1024, fh) != NULL)
+       while (fgets (buffer, sizeof (buffer), fh) != NULL)
        {
                derive_t *val = NULL;
                long long tmp;
@@ -749,7 +836,8 @@ static procstat_t *ps_read_io (int pid, procstat_t *ps)
                else
                        continue;
 
-               numfields = strsplit (buffer, fields, 8);
+               numfields = strsplit (buffer, fields,
+                               STATIC_ARRAY_SIZE (fields));
 
                if (numfields < 2)
                        continue;
@@ -801,7 +889,7 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
                return (-1);
        buffer[i] = 0;
 
-       fields_len = strsplit (buffer, fields, 64);
+       fields_len = strsplit (buffer, fields, STATIC_ARRAY_SIZE (fields));
        if (fields_len < 24)
        {
                DEBUG ("processes plugin: ps_read_process (pid = %i):"
@@ -869,6 +957,14 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
        cpu_system_counter = cpu_system_counter * 1000000 / CONFIG_HZ;
        vmem_rss = vmem_rss * pagesize_g;
 
+       if ( (ps_read_vmem(pid, ps)) == NULL)
+       {
+               /* No VMem data */
+               ps->vmem_data = -1;
+               ps->vmem_code = -1;
+               DEBUG("ps_read_process: did not get vmem data for pid %i",pid);
+       }
+
        ps->cpu_user_counter = (unsigned long) cpu_user_counter;
        ps->cpu_system_counter = (unsigned long) cpu_system_counter;
        ps->vmem_size = (unsigned long) vmem_size;
@@ -1009,7 +1105,7 @@ static unsigned long read_fork_rate ()
 
                errno = 0;
                endptr = NULL;
-               result = strtoul(fields[1], &endptr, 10);
+               result = strtoul(fields[1], &endptr, /* base = */ 10);
                if ((endptr == fields[1]) || (errno != 0)) {
                        ERROR ("processes plugin: Cannot parse fork rate: %s",
                                        fields[1]);
@@ -1208,7 +1304,11 @@ static int ps_read (void)
                                }
 
                                pse.num_proc++;
+                               pse.vmem_size = task_basic_info.virtual_size;
                                pse.vmem_rss = task_basic_info.resident_size;
+                               /* Does not seem to be easily exposed */
+                               pse.vmem_data = 0;
+                               pse.vmem_code = 0;
 
                                pse.vmem_minflt_counter = task_events_info.cow_faults;
                                pse.vmem_majflt_counter = task_events_info.faults;
@@ -1402,6 +1502,8 @@ static int ps_read (void)
                pse.num_lwp    = ps.num_lwp;
                pse.vmem_size  = ps.vmem_size;
                pse.vmem_rss   = ps.vmem_rss;
+               pse.vmem_data  = ps.vmem_data;
+               pse.vmem_code  = ps.vmem_code;
                pse.stack_size = ps.stack_size;
 
                pse.vmem_minflt = 0;
@@ -1532,6 +1634,8 @@ static int ps_read (void)
 
                pse.vmem_size = procs[i].ki_size;
                pse.vmem_rss = procs[i].ki_rssize * getpagesize();
+               pse.vmem_data = procs[i].ki_dsize * getpagesize();
+               pse.vmem_code = procs[i].ki_tsize * getpagesize();
                pse.stack_size = procs[i].ki_ssize * getpagesize();
                pse.vmem_minflt = 0;
                pse.vmem_minflt_counter = procs[i].ki_rusage.ru_minflt;
@@ -1688,6 +1792,9 @@ static int ps_read (void)
 
                        pse.vmem_size = procentry[i].pi_tsize + procentry[i].pi_dvm * pagesize;
                        pse.vmem_rss = (procentry[i].pi_drss + procentry[i].pi_trss) * pagesize;
+                       /* Not supported */
+                       pse.vmem_data = 0;
+                       pse.vmem_code = 0;
                        pse.stack_size =  0;
 
                        ps_list_add (cmdline, cargs, &pse);
index dffb10a..fc53fbf 100644 (file)
@@ -128,6 +128,8 @@ ps_pagefaults               minflt:COUNTER:0:9223372036854775807, majflt:COUNTER:0:9223372036
 ps_disk_octets         read:DERIVE:0:U, write:DERIVE:0:U
 ps_disk_ops            read:DERIVE:0:U, write:DERIVE:0:U
 ps_rss                 value:GAUGE:0:9223372036854775807
+ps_code                        value:GAUGE:0:9223372036854775807
+ps_data                        value:GAUGE:0:9223372036854775807
 ps_stacksize           value:GAUGE:0:9223372036854775807
 ps_state               value:GAUGE:0:65535
 ps_vm                  value:GAUGE:0:9223372036854775807