add more logging
This commit is contained in:
parent
fb475be338
commit
85c55bc8ba
|
@ -41,6 +41,7 @@ int sigar_get_kstats(sigar_t *sigar)
|
|||
kstat_ctl_t *kc = sigar->kc;
|
||||
kstat_t *ksp;
|
||||
unsigned int i, ncpu = sysconf(_SC_NPROCESSORS_CONF);
|
||||
int is_debug = SIGAR_LOG_IS_DEBUG(sigar);
|
||||
|
||||
ksp = kstat_lookup(kc, "unix", -1, "vminfo");
|
||||
sigar->ks.vminfo = ksp;
|
||||
|
@ -61,6 +62,9 @@ int sigar_get_kstats(sigar_t *sigar)
|
|||
sigar->ks.cpuid = malloc(sizeof(*(sigar->ks.cpuid)) * ncpu);
|
||||
}
|
||||
else {
|
||||
sigar_log_printf(sigar, SIGAR_LOG_INFO,
|
||||
"ncpu changed from %d to %d",
|
||||
sigar->ncpu, ncpu);
|
||||
if (ncpu > sigar->ks.lcpu) {
|
||||
/* one or more cpus have been added */
|
||||
sigar->ks.cpu = realloc(sigar->ks.cpu,
|
||||
|
@ -99,7 +103,10 @@ int sigar_get_kstats(sigar_t *sigar)
|
|||
|
||||
sigar->ks.cpu[i] = ksp;
|
||||
sigar->ks.cpuid[i] = atoi(id);
|
||||
|
||||
if (is_debug) {
|
||||
sigar_log_printf(sigar, SIGAR_LOG_DEBUG,
|
||||
"cpu %d id=%d", i, sigar->ks.cpuid[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -329,12 +329,25 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
|
|||
char *buf;
|
||||
|
||||
if (!CPU_ONLINE(sigar->ks.cpuid[i])) {
|
||||
sigar_log_printf(sigar, SIGAR_LOG_INFO,
|
||||
"cpu %d (id=%d) is offline",
|
||||
i, sigar->ks.cpuid[i]);
|
||||
continue;
|
||||
}
|
||||
if (!((ksp = sigar->ks.cpu[i]) &&
|
||||
(kstat_read(kc, ksp, NULL) >= 0)))
|
||||
{
|
||||
continue; /* XXX: shouldnot happen */
|
||||
|
||||
if (!(ksp = sigar->ks.cpu[i])) {
|
||||
sigar_log_printf(sigar, SIGAR_LOG_ERROR,
|
||||
"NULL ksp for cpu %d (id=%d)",
|
||||
i, sigar->ks.cpuid[i]);
|
||||
continue; /* shouldnot happen */
|
||||
}
|
||||
|
||||
if (kstat_read(kc, ksp, NULL) < 0) {
|
||||
sigar_log_printf(sigar, SIGAR_LOG_ERROR,
|
||||
"kstat_read failed for cpu %d (id=%d): %s",
|
||||
i, sigar->ks.cpuid[i],
|
||||
sigar_strerror(sigar, errno));
|
||||
continue; /* shouldnot happen */
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue