[SIGAR-17] Fix possible bad cpu list number on Solaris
This commit is contained in:
parent
769634ef4b
commit
39d8d0930b
|
@ -1,3 +1,7 @@
|
||||||
|
2007-02-12 Doug MacEachern <dougm@hyperic.com>
|
||||||
|
|
||||||
|
* [SIGAR-17] Fix possible bad cpu list number on Solaris
|
||||||
|
|
||||||
2007-02-07 Doug MacEachern <dougm@hyperic.com>
|
2007-02-07 Doug MacEachern <dougm@hyperic.com>
|
||||||
|
|
||||||
* Make sure solaris has _POSIX_PTHREAD_SEMANTICS defined
|
* Make sure solaris has _POSIX_PTHREAD_SEMANTICS defined
|
||||||
|
|
|
@ -62,8 +62,7 @@ int sigar_get_multi_kstats(sigar_t *sigar,
|
||||||
int sigar_get_kstats(sigar_t *sigar)
|
int sigar_get_kstats(sigar_t *sigar)
|
||||||
{
|
{
|
||||||
kstat_ctl_t *kc = sigar->kc;
|
kstat_ctl_t *kc = sigar->kc;
|
||||||
kstat_t *ksp;
|
unsigned int i, id, ncpu = sysconf(_SC_NPROCESSORS_CONF);
|
||||||
unsigned int i, ncpu = sysconf(_SC_NPROCESSORS_CONF);
|
|
||||||
int is_debug = SIGAR_LOG_IS_DEBUG(sigar);
|
int is_debug = SIGAR_LOG_IS_DEBUG(sigar);
|
||||||
|
|
||||||
if (ncpu != sigar->ncpu) {
|
if (ncpu != sigar->ncpu) {
|
||||||
|
@ -93,17 +92,6 @@ int sigar_get_kstats(sigar_t *sigar)
|
||||||
|
|
||||||
sigar->ncpu = ncpu;
|
sigar->ncpu = ncpu;
|
||||||
|
|
||||||
for (i=0, ksp=kc->kc_chain; i<ncpu; ksp=ksp->ks_next) {
|
|
||||||
char *id;
|
|
||||||
kstat_t *cpu_info;
|
|
||||||
|
|
||||||
if (!ksp) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (strncmp(ksp->ks_name, "cpu_stat", 8)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* from man p_online:
|
/* from man p_online:
|
||||||
* ``Processor numbers are integers,
|
* ``Processor numbers are integers,
|
||||||
* greater than or equal to 0,
|
* greater than or equal to 0,
|
||||||
|
@ -112,16 +100,21 @@ int sigar_get_kstats(sigar_t *sigar)
|
||||||
* but "not too sparse."``
|
* but "not too sparse."``
|
||||||
* so we maintain our own mapping in ks.cpuid[]
|
* so we maintain our own mapping in ks.cpuid[]
|
||||||
*/
|
*/
|
||||||
id = ksp->ks_name;
|
|
||||||
while (!sigar_isdigit(*id)) {
|
/* lookup in order, which kstat chain may not be in */
|
||||||
id++;
|
for (i=0, id=0; i<ncpu; id++) {
|
||||||
|
kstat_t *cpu_info, *cpu_stat;
|
||||||
|
|
||||||
|
if (!(cpu_stat = kstat_lookup(kc, "cpu_stat", id, NULL))) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sigar->ks.cpu[i] = ksp;
|
sigar->ks.cpu[i] = cpu_stat;
|
||||||
sigar->ks.cpuid[i] = atoi(id);
|
sigar->ks.cpuid[i] = id;
|
||||||
if ((cpu_info = kstat_lookup(kc, "cpu_info", sigar->ks.cpuid[i], NULL))) {
|
if ((cpu_info = kstat_lookup(kc, "cpu_info", id, NULL))) {
|
||||||
sigar->ks.cpu_info[i] = cpu_info;
|
sigar->ks.cpu_info[i] = cpu_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_debug) {
|
if (is_debug) {
|
||||||
sigar_log_printf(sigar, SIGAR_LOG_DEBUG,
|
sigar_log_printf(sigar, SIGAR_LOG_DEBUG,
|
||||||
"cpu %d id=%d", i, sigar->ks.cpuid[i]);
|
"cpu %d id=%d", i, sigar->ks.cpuid[i]);
|
||||||
|
|
Loading…
Reference in New Issue