X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fprocesses.c;h=09e24d2ae96049e02e60b501ce3c58676cd9c86e;hb=778a6720a300cf549f5bcca9c22a3ef09d97f16f;hp=0649eab285770de13bfa61060ce3ee7eaa155b10;hpb=cedb6f147e94d0e952449f731313412ef4d67904;p=collectd.git diff --git a/src/processes.c b/src/processes.c index 0649eab2..09e24d2a 100644 --- a/src/processes.c +++ b/src/processes.c @@ -280,6 +280,7 @@ static void ps_list_register (const char *name, const char *regexp) { DEBUG ("ProcessMatch: compiling the regular expression \"%s\" failed.", regexp); sfree(new->re); + sfree(new); return; } } @@ -1017,7 +1018,7 @@ int ps_read_process (int pid, procstat_t *ps, char *state) /* Leave the rest at zero if this is only a zombi */ if (ps->num_proc == 0) { - DEBUG ("processes plugin: This is only a zombi: pid = %i; " + DEBUG ("processes plugin: This is only a zombie: pid = %i; " "name = %s;", pid, ps->name); return (0); } @@ -1740,6 +1741,7 @@ static int ps_read (void) continue; } + memset (&pse, 0, sizeof (pse)); pse.id = pid; pse.age = 0; @@ -1912,18 +1914,18 @@ static int ps_read (void) pse.io_syscw = -1; ps_list_add (procs[i].ki_comm, have_cmdline ? cmdline : NULL, &pse); - } /* if ((proc_ptr == NULL) || (proc_ptr->ki_pid != procs[i].ki_pid)) */ - switch (procs[i].ki_stat) - { - case SSTOP: stopped++; break; - case SSLEEP: sleeping++; break; - case SRUN: running++; break; - case SIDL: idle++; break; - case SWAIT: wait++; break; - case SLOCK: blocked++; break; - case SZOMB: zombies++; break; - } + switch (procs[i].ki_stat) + { + case SSTOP: stopped++; break; + case SSLEEP: sleeping++; break; + case SRUN: running++; break; + case SIDL: idle++; break; + case SWAIT: wait++; break; + case SLOCK: blocked++; break; + case SZOMB: zombies++; break; + } + } /* if ((proc_ptr == NULL) || (proc_ptr->ki_pid != procs[i].ki_pid)) */ } kvm_close(kd); @@ -2014,6 +2016,7 @@ static int ps_read (void) } } /* if (process has argument list) */ + memset (&pse, 0, sizeof (pse)); pse.id = procs[i].p_pid; pse.age = 0; @@ -2043,19 +2046,22 @@ static int ps_read (void) pse.io_syscr = -1; pse.io_syscw = -1; + pse.cswitch_vol = -1; + pse.cswitch_invol = -1; + ps_list_add (procs[i].p_comm, have_cmdline ? cmdline : NULL, &pse); - } /* if ((proc_ptr == NULL) || (proc_ptr->p_pid != procs[i].p_pid)) */ - switch (procs[i].p_stat) - { - case SSTOP: stopped++; break; - case SSLEEP: sleeping++; break; - case SRUN: running++; break; - case SIDL: idle++; break; - case SONPROC: onproc++; break; - case SDEAD: dead++; break; - case SZOMB: zombies++; break; - } + switch (procs[i].p_stat) + { + case SSTOP: stopped++; break; + case SSLEEP: sleeping++; break; + case SRUN: running++; break; + case SIDL: idle++; break; + case SONPROC: onproc++; break; + case SDEAD: dead++; break; + case SZOMB: zombies++; break; + } + } /* if ((proc_ptr == NULL) || (proc_ptr->p_pid != procs[i].p_pid)) */ } kvm_close(kd); @@ -2258,6 +2264,7 @@ static int ps_read (void) continue; } + memset (&pse, 0, sizeof (pse)); pse.id = pid; pse.age = 0; @@ -2284,6 +2291,9 @@ static int ps_read (void) pse.io_syscr = ps.io_syscr; pse.io_syscw = ps.io_syscw; + pse.cswitch_vol = -1; + pse.cswitch_invol = -1; + switch (state) { case 'R': running++; break;