add proc_stat.threads

This commit is contained in:
Doug MacEachern 2007-10-20 12:49:37 +00:00
parent e82820a8c5
commit 8ff408bb44
4 changed files with 12 additions and 1 deletions

View File

@ -620,6 +620,11 @@ our %classes = (
desc => 'Total number of processes in zombie state', desc => 'Total number of processes in zombie state',
plat => '*' plat => '*'
}, },
{
name => 'threads', type => 'Long',
desc => 'Total number of threads',
plat => '*'
},
], ],
ProcExe => [ ProcExe => [
{ {

View File

@ -50,7 +50,7 @@ public class Top {
stat.getSleeping() + " sleeping, " + stat.getSleeping() + " sleeping, " +
stat.getRunning() + " running, " + stat.getRunning() + " running, " +
stat.getZombie() + " zombie, " + stat.getZombie() + " zombie, " +
stat.getStopped() + " stopped"; stat.getStopped() + " stopped... " + stat.getThreads() + " threads";
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -244,6 +244,7 @@ typedef struct {
sigar_uint64_t zombie; sigar_uint64_t zombie;
sigar_uint64_t stopped; sigar_uint64_t stopped;
sigar_uint64_t idle; sigar_uint64_t idle;
sigar_uint64_t threads;
} sigar_proc_stat_t; } sigar_proc_stat_t;
SIGAR_DECLARE(int) sigar_proc_stat_get(sigar_t *sigar, SIGAR_DECLARE(int) sigar_proc_stat_get(sigar_t *sigar,

View File

@ -155,6 +155,7 @@ SIGAR_DECLARE(int) sigar_proc_stat_get(sigar_t *sigar,
sigar_proc_list_t proclist; sigar_proc_list_t proclist;
SIGAR_ZERO(procstat); SIGAR_ZERO(procstat);
procstat->threads = SIGAR_FIELD_NOTIMPL;
if ((status = sigar_proc_list_get(sigar, &proclist)) != SIGAR_OK) { if ((status = sigar_proc_list_get(sigar, &proclist)) != SIGAR_OK) {
return status; return status;
@ -170,6 +171,10 @@ SIGAR_DECLARE(int) sigar_proc_stat_get(sigar_t *sigar,
continue; continue;
} }
if (state.threads != SIGAR_FIELD_NOTIMPL) {
procstat->threads += state.threads;
}
switch (state.state) { switch (state.state) {
case SIGAR_PROC_STATE_IDLE: case SIGAR_PROC_STATE_IDLE:
procstat->idle++; procstat->idle++;