From 85c55bc8baf36771f69ec41e6107baef847771be Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 9 Dec 2005 20:02:44 +0000 Subject: [PATCH] add more logging --- src/os/solaris/kstats.c | 9 ++++++++- src/os/solaris/solaris_sigar.c | 21 +++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/os/solaris/kstats.c b/src/os/solaris/kstats.c index 8dab8591..d354ad99 100644 --- a/src/os/solaris/kstats.c +++ b/src/os/solaris/kstats.c @@ -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++; } } diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 6325846f..277fcfda 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -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 */ } /*