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;
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;
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;
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);
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;
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;
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);
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, 1024, fh) != NULL)
+ {
+ long long tmp;
+ char *endptr;
+
+ if (strncasecmp (buffer, "Vm", 2) != 0)
+ continue;
+
+ numfields = strsplit (buffer, fields, 8);
+
+ 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;
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;
pse.num_proc++;
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;
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;
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;
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);