[SIGAR-117] fix Cpu.Percent ptql

This commit is contained in:
Doug MacEachern 2008-08-07 20:23:01 +00:00
parent 1a0db053ed
commit 8316f5e619
2 changed files with 19 additions and 1 deletions

View File

@ -196,5 +196,15 @@ public class TestPTQL extends SigarTestCase {
}
this.qf.clear();
}
public void testSelf() throws Exception {
Sigar sigar = getSigar();
//should have eaten some cpu during this test
ProcessQuery status =
this.qf.getQuery("Cpu.Percent.ge=0.01");
long pid = sigar.getPid();
assertTrue(status.match(sigar, pid));
}
}

View File

@ -624,6 +624,10 @@ static int ptql_branch_match(ptql_branch_t *branch)
return branch->match.ui32(branch,
*(sigar_uint32_t *)DATA_PTR(branch),
branch->value.ui32);
case PTQL_VALUE_TYPE_DBL:
return branch->match.dbl(branch,
*(double *)DATA_PTR(branch),
branch->value.dbl);
case PTQL_VALUE_TYPE_CHR:
return branch->match.chr(branch,
*(char *)DATA_PTR(branch),
@ -652,6 +656,10 @@ static int ptql_branch_match_ref(ptql_branch_t *branch, ptql_branch_t *ref)
return branch->match.ui32(branch,
*(sigar_uint32_t *)DATA_PTR(branch),
*(sigar_uint32_t *)DATA_PTR(ref));
case PTQL_VALUE_TYPE_DBL:
return branch->match.dbl(branch,
*(double *)DATA_PTR(branch),
*(double *)DATA_PTR(ref));
case PTQL_VALUE_TYPE_CHR:
return branch->match.chr(branch,
*(char *)DATA_PTR(branch),
@ -1253,7 +1261,7 @@ static ptql_lookup_t PTQL_Cpu[] = {
{ "User", PTQL_LOOKUP_ENTRY(proc_cpu, user, UI64) },
{ "Sys", PTQL_LOOKUP_ENTRY(proc_cpu, sys, UI64) },
{ "Total", PTQL_LOOKUP_ENTRY(proc_cpu, total, UI64) },
{ "Percent", PTQL_LOOKUP_ENTRY(proc_cpu, total, DBL) },
{ "Percent", PTQL_LOOKUP_ENTRY(proc_cpu, percent, DBL) },
{ NULL }
};