add Service.Exe ptql support

This commit is contained in:
Doug MacEachern 2008-03-26 21:42:35 +00:00
parent 5df4850bf3
commit b83b819b00
2 changed files with 16 additions and 3 deletions

View File

@ -72,6 +72,7 @@ public class TestPTQL extends SigarTestCase {
"Service.Name.ct=Oracle",
"Service.DisplayName.re=DHCP|DNS",
"Service.Path.ct=svchost",
"Service.Exe.Ieq=inetinfo.exe",
OTHER_JAVA_PROCESS, //all java procs cept this one
"Cpu.Percent.ge=0.2",
"State.Name.sw=java,Args.*.eq=org.jboss.Main", //jboss

View File

@ -666,7 +666,8 @@ enum {
PTQL_PID_FILE,
PTQL_PID_SERVICE_NAME,
PTQL_PID_SERVICE_DISPLAY,
PTQL_PID_SERVICE_PATH
PTQL_PID_SERVICE_PATH,
PTQL_PID_SERVICE_EXE
};
#ifdef SIGAR_64BIT
@ -700,6 +701,10 @@ static int ptql_branch_init_service(ptql_parse_branch_t *parsed,
else if (strEQ(parsed->attr, "Path")) {
branch->flags = PTQL_PID_SERVICE_PATH;
}
else if (strEQ(parsed->attr, "Exe")) {
/* basename of Path */
branch->flags = PTQL_PID_SERVICE_EXE;
}
else {
return ptql_error(error, "Unsupported %s attribute: %s",
parsed->name, parsed->attr);
@ -785,7 +790,7 @@ static int sigar_services_walk(sigar_services_walker_t *walker,
}
for (i=0; i<ss.count; i++) {
int status;
char *value;
char *value = NULL;
char *name = ss.services[i].lpServiceName;
if (branch == NULL) {
@ -801,10 +806,17 @@ static int sigar_services_walk(sigar_services_walker_t *walker,
value = ss.services[i].lpDisplayName;
break;
case PTQL_PID_SERVICE_PATH:
case PTQL_PID_SERVICE_EXE:
status = ptql_service_query_config(ss.handle, name, config);
if (status == SIGAR_OK) {
if (branch->flags == PTQL_PID_SERVICE_EXE) {
value = strrchr(config->lpBinaryPathName, '\\');
if (value) ++value;
}
if (value == NULL) {
value = config->lpBinaryPathName;
}
}
else {
continue;
}