add more logging

This commit is contained in:
Doug MacEachern 2005-12-09 20:02:44 +00:00
parent fb475be338
commit 85c55bc8ba
2 changed files with 25 additions and 5 deletions

View File

@ -41,6 +41,7 @@ int sigar_get_kstats(sigar_t *sigar)
kstat_ctl_t *kc = sigar->kc; kstat_ctl_t *kc = sigar->kc;
kstat_t *ksp; kstat_t *ksp;
unsigned int i, ncpu = sysconf(_SC_NPROCESSORS_CONF); unsigned int i, ncpu = sysconf(_SC_NPROCESSORS_CONF);
int is_debug = SIGAR_LOG_IS_DEBUG(sigar);
ksp = kstat_lookup(kc, "unix", -1, "vminfo"); ksp = kstat_lookup(kc, "unix", -1, "vminfo");
sigar->ks.vminfo = ksp; sigar->ks.vminfo = ksp;
@ -61,6 +62,9 @@ int sigar_get_kstats(sigar_t *sigar)
sigar->ks.cpuid = malloc(sizeof(*(sigar->ks.cpuid)) * ncpu); sigar->ks.cpuid = malloc(sizeof(*(sigar->ks.cpuid)) * ncpu);
} }
else { else {
sigar_log_printf(sigar, SIGAR_LOG_INFO,
"ncpu changed from %d to %d",
sigar->ncpu, ncpu);
if (ncpu > sigar->ks.lcpu) { if (ncpu > sigar->ks.lcpu) {
/* one or more cpus have been added */ /* one or more cpus have been added */
sigar->ks.cpu = realloc(sigar->ks.cpu, 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.cpu[i] = ksp;
sigar->ks.cpuid[i] = atoi(id); 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++; i++;
} }
} }

View File

@ -329,12 +329,25 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
char *buf; char *buf;
if (!CPU_ONLINE(sigar->ks.cpuid[i])) { 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; continue;
} }
if (!((ksp = sigar->ks.cpu[i]) &&
(kstat_read(kc, ksp, NULL) >= 0))) if (!(ksp = sigar->ks.cpu[i])) {
{ sigar_log_printf(sigar, SIGAR_LOG_ERROR,
continue; /* XXX: shouldnot happen */ "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 */
} }
/* /*