Check for duplicate sensor names in the IPMI table. If a duplicate name
is found, try to make it unique by appending a count (1-99) to the sensor description (truncating, if necessary). This takes my Dell PowerEdge 1800 from: Temp: 40.000 degC VRD 1 Temp: 35.000 degC VRD 0 Temp: 39.000 degC Planar Temp: 35.000 degC Ambient Temp: 20.000 degC Fan 2: 1500 RPM Fan 1: 1425 RPM CMOS Battery: 3.057 V Intrusion: ON Status : ON to: Temp3: 40.000 degC Temp2: 40.000 degC VRD 1 Temp: 35.000 degC VRD 0 Temp: 39.000 degC Planar Temp: 35.000 degC Ambient Temp: 20.000 degC Temp1: 41.000 degC Temp: 43.000 degC Fan 2: 1500 RPM Fan 1: 1425 RPM CMOS Battery: 3.057 V Intrusion: ON Status 1: ON Status : ON
This commit is contained in:
parent
0322f263f2
commit
b53262281a
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ipmi.c,v 1.11 2007/07/09 20:52:38 ad Exp $ */
|
||||
/* $NetBSD: ipmi.c,v 1.12 2007/08/13 18:32:22 briggs Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
*
|
||||
@ -56,7 +56,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.11 2007/07/09 20:52:38 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.12 2007/08/13 18:32:22 briggs Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -1488,12 +1488,26 @@ add_sdr_sensor(struct ipmi_softc *sc, u_int8_t *psdr)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
ipmi_is_dupname(char *name)
|
||||
{
|
||||
struct ipmi_sensor *ipmi_s;
|
||||
|
||||
SLIST_FOREACH(ipmi_s, &ipmi_sensor_list, i_list) {
|
||||
if (strcmp(ipmi_s->i_envdesc, name) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
add_child_sensors(struct ipmi_softc *sc, u_int8_t *psdr, int count,
|
||||
int sensor_num, int sensor_type, int ext_type, int sensor_base,
|
||||
int entity, const char *name)
|
||||
{
|
||||
int typ, idx;
|
||||
int typ, idx, dupcnt, c;
|
||||
char *e;
|
||||
struct ipmi_sensor *psensor;
|
||||
struct sdrtype1 *s1 = (struct sdrtype1 *)psdr;
|
||||
|
||||
@ -1503,6 +1517,7 @@ add_child_sensors(struct ipmi_softc *sc, u_int8_t *psdr, int count,
|
||||
"name:%s\n", sensor_type, ext_type, sensor_num, name);
|
||||
return 0;
|
||||
}
|
||||
dupcnt = 0;
|
||||
sc->sc_nsensors += count;
|
||||
sc->sc_nsensors_typ[typ] += count;
|
||||
for (idx = 0; idx < count; idx++) {
|
||||
@ -1527,6 +1542,32 @@ add_child_sensors(struct ipmi_softc *sc, u_int8_t *psdr, int count,
|
||||
strlcpy(psensor->i_envdesc, name,
|
||||
sizeof(psensor->i_envdesc));
|
||||
|
||||
/*
|
||||
* Check for duplicates. If there are duplicates,
|
||||
* make sure there is space in the name (if not,
|
||||
* truncate to make space) for a count (1-99) to
|
||||
* add to make the name unique. If we run the
|
||||
* counter out, just accept the duplicate (@name99)
|
||||
* for now.
|
||||
*/
|
||||
if (ipmi_is_dupname(psensor->i_envdesc)) {
|
||||
if (strlen(psensor->i_envdesc) >=
|
||||
sizeof(psensor->i_envdesc) - 3) {
|
||||
e = psensor->i_envdesc +
|
||||
sizeof(psensor->i_envdesc) - 3;
|
||||
} else {
|
||||
e = psensor->i_envdesc +
|
||||
strlen(psensor->i_envdesc);
|
||||
}
|
||||
c = psensor->i_envdesc +
|
||||
sizeof(psensor->i_envdesc) - e;
|
||||
do {
|
||||
dupcnt++;
|
||||
snprintf(e, c, "%d", dupcnt);
|
||||
} while (dupcnt < 100 &&
|
||||
ipmi_is_dupname(psensor->i_envdesc));
|
||||
}
|
||||
|
||||
dbg_printf(5, "add sensor:%.4x %.2x:%d ent:%.2x:%.2x %s\n",
|
||||
s1->sdrhdr.record_id, s1->sensor_type,
|
||||
typ, s1->entity_id, s1->entity_instance,
|
||||
|
Loading…
x
Reference in New Issue
Block a user