add proc_state.threads metric
This commit is contained in:
parent
5ae081f7a9
commit
fb61a2ebb0
|
@ -348,6 +348,11 @@ my %classes = (
|
||||||
desc => 'Kernel scheduling priority of process',
|
desc => 'Kernel scheduling priority of process',
|
||||||
plat => 'DFHLSW'
|
plat => 'DFHLSW'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name => 'threads', type => 'Long',
|
||||||
|
desc => 'Number of active threads',
|
||||||
|
plat => ''
|
||||||
|
},
|
||||||
],
|
],
|
||||||
ProcFd => [
|
ProcFd => [
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,8 @@ public class TestProcState extends SigarTestCase {
|
||||||
ProcState procState = sigar.getProcState(sigar.getPid());
|
ProcState procState = sigar.getProcState(sigar.getPid());
|
||||||
char state = procState.getState();
|
char state = procState.getState();
|
||||||
traceln(procState.getName() + "=" + state);
|
traceln(procState.getName() + "=" + state);
|
||||||
|
traceln("threads=" + procState.getThreads());
|
||||||
|
|
||||||
assertTrue((state == 'R') || (state == 'S'));
|
assertTrue((state == 'R') || (state == 'S'));
|
||||||
|
|
||||||
assertTrue(procState.getName().indexOf("java") != -1);
|
assertTrue(procState.getName().indexOf("java") != -1);
|
||||||
|
|
|
@ -255,6 +255,7 @@ typedef struct {
|
||||||
int tty;
|
int tty;
|
||||||
int priority;
|
int priority;
|
||||||
int nice;
|
int nice;
|
||||||
|
int threads;
|
||||||
} sigar_proc_state_t;
|
} sigar_proc_state_t;
|
||||||
|
|
||||||
SIGAR_DECLARE(int) sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
SIGAR_DECLARE(int) sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
||||||
|
|
|
@ -696,6 +696,29 @@ int sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int proc_status_get(sigar_t *sigar, sigar_pid_t pid,
|
||||||
|
sigar_proc_state_t *procstate)
|
||||||
|
{
|
||||||
|
char buffer[BUFSIZ], *ptr;
|
||||||
|
int status = SIGAR_PROC_FILE2STR(buffer, pid, PROC_PSTATUS);
|
||||||
|
|
||||||
|
if (status != SIGAR_OK) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = strstr(buffer, "\nThreads:");
|
||||||
|
if (ptr) {
|
||||||
|
/* 2.6+ kernel only */
|
||||||
|
ptr = sigar_skip_token(ptr);
|
||||||
|
procstate->threads = sigar_strtoul(ptr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
procstate->threads = SIGAR_FIELD_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SIGAR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
||||||
sigar_proc_state_t *procstate)
|
sigar_proc_state_t *procstate)
|
||||||
{
|
{
|
||||||
|
@ -714,6 +737,8 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
||||||
procstate->priority = pstat->priority;
|
procstate->priority = pstat->priority;
|
||||||
procstate->nice = pstat->nice;
|
procstate->nice = pstat->nice;
|
||||||
|
|
||||||
|
proc_status_get(sigar, pid, procstate);
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -660,6 +660,7 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
||||||
procstate->tty = pinfo->pr_ttydev;
|
procstate->tty = pinfo->pr_ttydev;
|
||||||
procstate->priority = pinfo->pr_lwp.pr_pri;
|
procstate->priority = pinfo->pr_lwp.pr_pri;
|
||||||
procstate->nice = pinfo->pr_lwp.pr_nice - NZERO;
|
procstate->nice = pinfo->pr_lwp.pr_nice - NZERO;
|
||||||
|
procstate->threads = pinfo->pr_nlwp;
|
||||||
|
|
||||||
switch (pinfo->pr_lwp.pr_state) {
|
switch (pinfo->pr_lwp.pr_state) {
|
||||||
case SONPROC:
|
case SONPROC:
|
||||||
|
|
Loading…
Reference in New Issue