From: Florian Forster Date: Mon, 10 Jul 2006 12:34:45 +0000 (+0200) Subject: processes plugin: Implement collecting the number of pagefaults for a selected process. X-Git-Tag: collectd-3.11.0~76^2~4 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a0a59f6222f774778707423f3f04300315fcec35;p=collectd.git processes plugin: Implement collecting the number of pagefaults for a selected process. --- diff --git a/src/processes.c b/src/processes.c index 0b52b989..b02e869d 100644 --- a/src/processes.c +++ b/src/processes.c @@ -131,6 +131,16 @@ static char *ps_count_ds_def[] = }; static int ps_count_ds_num = 2; +static char *ps_pagefaults_file = "processes/ps_pagefaults-%s.rrd"; +static char *ps_pagefaults_ds_def[] = +{ + /* max = 2^63 - 1 */ + "DS:minflt:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:majflt:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807", + NULL +}; +static int ps_pagefaults_ds_num = 2; + static char *config_keys[] = { "CollectName", @@ -330,6 +340,21 @@ static void ps_count_write (char *host, char *inst, char *val) ps_count_ds_def, ps_count_ds_num); } +static void ps_pagefaults_write (char *host, char *inst, char *val) +{ + char filename[256]; + int status; + + status = snprintf (filename, 256, ps_pagefaults_file, inst); + if ((status < 1) || (status >= 256)) + return; + + DBG ("host = %s; filename = %s; val = %s;", + host, filename, val); + rrd_update_file (host, filename, val, + ps_pagefaults_ds_def, ps_pagefaults_ds_num); +} + #if PROCESSES_HAVE_READ static void ps_submit (int running, int sleeping, @@ -379,6 +404,12 @@ static void ps_submit_proc (procstat_t *ps) buffer[63] = '\0'; plugin_submit ("ps_count", ps->name, buffer); + snprintf (buffer, 64, "%u:%lu:%lu", + (unsigned int) curtime, + ps->vmem_minflt, ps->vmem_majflt); + buffer[63] = '\0'; + plugin_submit ("ps_pagefaults", ps->name, buffer); + DBG ("name = %s; num_proc = %i; num_lwp = %i; vmem_rss = %i; " "vmem_minflt = %i; vmem_majflt = %i; " "cpu_user = %i; cpu_system = %i;", @@ -791,6 +822,7 @@ void module_register (void) plugin_register ("ps_rss", NULL, NULL, ps_rss_write); plugin_register ("ps_cputime", NULL, NULL, ps_cputime_write); plugin_register ("ps_count", NULL, NULL, ps_count_write); + plugin_register ("ps_pagefaults", NULL, NULL, ps_pagefaults_write); cf_register (MODULE_NAME, ps_config, config_keys, config_keys_num); }