workaround issue seen on occasion w/ 2003 server in vmware.

for reasons unknown, the process perf object sometimes comes back with
the counter titles but no instances.  this would crash the agent.
This commit is contained in:
Doug MacEachern 2004-08-10 21:51:13 +00:00
parent 28b71f3651
commit b85eea0ff9
1 changed files with 19 additions and 5 deletions

View File

@ -443,8 +443,6 @@ SIGAR_DECLARE(int) sigar_proc_list_get(sigar_t *sigar,
return err;
}
sigar_proc_list_create(proclist);
/*
* note we assume here:
* block->NumObjectTypes == 1
@ -466,6 +464,15 @@ SIGAR_DECLARE(int) sigar_proc_list_get(sigar_t *sigar,
}
}
/* XXX dont know why this happens, have only
* seen it using 2003 server within vmware.
*/
if (object->NumInstances < 1) {
return ENOENT;
}
sigar_proc_list_create(proclist);
for (i=0, inst = PdhFirstInstance(object);
i<object->NumInstances;
i++, inst = PdhNextInstance(inst))
@ -675,9 +682,6 @@ static int get_proc_info(sigar_t *sigar, sigar_pid_t pid)
}
}
pinfo->pid = pid;
pinfo->mtime = timenow;
memset(&perf_offsets, 0, sizeof(perf_offsets));
object = get_process_object(sigar, &err);
@ -686,6 +690,16 @@ static int get_proc_info(sigar_t *sigar, sigar_pid_t pid)
return err;
}
/* XXX dont know why this happens, have only
* seen it using 2003 server within vmware.
*/
if (object->NumInstances < 1) {
return ENOENT;
}
pinfo->pid = pid;
pinfo->mtime = timenow;
/*
* note we assume here:
* block->NumObjectTypes == 1