add Service.Exe ptql support
This commit is contained in:
parent
5df4850bf3
commit
b83b819b00
|
@ -72,6 +72,7 @@ public class TestPTQL extends SigarTestCase {
|
||||||
"Service.Name.ct=Oracle",
|
"Service.Name.ct=Oracle",
|
||||||
"Service.DisplayName.re=DHCP|DNS",
|
"Service.DisplayName.re=DHCP|DNS",
|
||||||
"Service.Path.ct=svchost",
|
"Service.Path.ct=svchost",
|
||||||
|
"Service.Exe.Ieq=inetinfo.exe",
|
||||||
OTHER_JAVA_PROCESS, //all java procs cept this one
|
OTHER_JAVA_PROCESS, //all java procs cept this one
|
||||||
"Cpu.Percent.ge=0.2",
|
"Cpu.Percent.ge=0.2",
|
||||||
"State.Name.sw=java,Args.*.eq=org.jboss.Main", //jboss
|
"State.Name.sw=java,Args.*.eq=org.jboss.Main", //jboss
|
||||||
|
|
|
@ -666,7 +666,8 @@ enum {
|
||||||
PTQL_PID_FILE,
|
PTQL_PID_FILE,
|
||||||
PTQL_PID_SERVICE_NAME,
|
PTQL_PID_SERVICE_NAME,
|
||||||
PTQL_PID_SERVICE_DISPLAY,
|
PTQL_PID_SERVICE_DISPLAY,
|
||||||
PTQL_PID_SERVICE_PATH
|
PTQL_PID_SERVICE_PATH,
|
||||||
|
PTQL_PID_SERVICE_EXE
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SIGAR_64BIT
|
#ifdef SIGAR_64BIT
|
||||||
|
@ -700,6 +701,10 @@ static int ptql_branch_init_service(ptql_parse_branch_t *parsed,
|
||||||
else if (strEQ(parsed->attr, "Path")) {
|
else if (strEQ(parsed->attr, "Path")) {
|
||||||
branch->flags = PTQL_PID_SERVICE_PATH;
|
branch->flags = PTQL_PID_SERVICE_PATH;
|
||||||
}
|
}
|
||||||
|
else if (strEQ(parsed->attr, "Exe")) {
|
||||||
|
/* basename of Path */
|
||||||
|
branch->flags = PTQL_PID_SERVICE_EXE;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return ptql_error(error, "Unsupported %s attribute: %s",
|
return ptql_error(error, "Unsupported %s attribute: %s",
|
||||||
parsed->name, parsed->attr);
|
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++) {
|
for (i=0; i<ss.count; i++) {
|
||||||
int status;
|
int status;
|
||||||
char *value;
|
char *value = NULL;
|
||||||
char *name = ss.services[i].lpServiceName;
|
char *name = ss.services[i].lpServiceName;
|
||||||
|
|
||||||
if (branch == NULL) {
|
if (branch == NULL) {
|
||||||
|
@ -801,10 +806,17 @@ static int sigar_services_walk(sigar_services_walker_t *walker,
|
||||||
value = ss.services[i].lpDisplayName;
|
value = ss.services[i].lpDisplayName;
|
||||||
break;
|
break;
|
||||||
case PTQL_PID_SERVICE_PATH:
|
case PTQL_PID_SERVICE_PATH:
|
||||||
|
case PTQL_PID_SERVICE_EXE:
|
||||||
status = ptql_service_query_config(ss.handle, name, config);
|
status = ptql_service_query_config(ss.handle, name, config);
|
||||||
if (status == SIGAR_OK) {
|
if (status == SIGAR_OK) {
|
||||||
|
if (branch->flags == PTQL_PID_SERVICE_EXE) {
|
||||||
|
value = strrchr(config->lpBinaryPathName, '\\');
|
||||||
|
if (value) ++value;
|
||||||
|
}
|
||||||
|
if (value == NULL) {
|
||||||
value = config->lpBinaryPathName;
|
value = config->lpBinaryPathName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue