diff options
Diffstat (limited to 'util/oem_supermicro.c')
-rw-r--r-- | util/oem_supermicro.c | 91 |
1 files changed, 77 insertions, 14 deletions
diff --git a/util/oem_supermicro.c b/util/oem_supermicro.c index 3937f0d..f3e42dd 100644 --- a/util/oem_supermicro.c +++ b/util/oem_supermicro.c @@ -54,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <time.h> #include "ipmicmd.h" #include "ievents.h" +#include "isensor.h" #include "oem_supermicro.h" #ifdef MOVED /*moved to oem_supermicro.h*/ @@ -67,7 +68,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void set_loglevel(int level); /*prototype */ extern char fsm_debug; /*mem_if.c*/ -static char * progver = "3.00"; +static char * progver = "3.01"; static char * progname = "ismcoem"; static int verbose = 0; static char fdebug = 0; @@ -372,6 +373,35 @@ int oem_supermicro_reset_intrusion(void) return(rv); } +/* decode_threshold_supermicro() assumes Fans, not Temp + * Temp thresholds are different order. */ +int decode_threshold_supermicro(uchar rval, uchar *thresh) +{ + int idx = 0; + uchar bits; + + bits = thresh[0]; + if (bits & 0x20) { /*hi-unrec*/ + if (rval >= thresh[6]) { idx = 6; return(idx); } + } + if (bits & 0x10) { /*hi-crit*/ + if (rval >= thresh[5]) { idx = 5; return(idx); } + } + if (bits & 0x08) { /*hi-noncr*/ + if (rval >= thresh[4]) { idx = 4; return(idx); } + } + if (bits & 0x01) { /*lo-noncr*/ + if (rval <= thresh[1]) { idx = 1; } + } + if (bits & 0x02) { /*lo-crit*/ + if (rval <= thresh[2]) { idx = 2; } + } + if (bits & 0x04) { /*lo-unrec*/ + if (rval <= thresh[3]) { idx = 3; } + } + return(idx); +} + /* * decode_sensor_supermicro * inputs: @@ -386,16 +416,48 @@ int oem_supermicro_reset_intrusion(void) */ int decode_sensor_supermicro(uchar *sdr,uchar *reading,char *pstring, int slen) { - int rv = -1; - uchar stype; + int i, rv = -1; + uchar stype, etype, snum; uchar bval; char *pstr = NULL; + uchar thresh[7]; + SDR01REC *sdr01; + char *typestr = NULL; + double val; if (sdr == NULL || reading == NULL) return(rv); if (pstring == NULL || slen == 0) return(rv); - /* sdr[3] is 0x01 for Full, 0x02 for Compact */ - bval = reading[2]; - stype = sdr[12]; + bval = (reading[2] & 0x3f); + snum = sdr[7]; /*sdr01->sens_num*/ + stype = sdr[12]; /*sensor_type*/ + etype = sdr[13]; /*sdr01->ev_type*/ + /* sdr[3] rec_type is 0x01 for Full, 0x02 for Compact */ + if ((sdr[3] == 0x01) && (etype == 0x01)) { /* full threshold sensor */ + if (bval == 0) return(-1); /* OK, treat it normally */ + /*cannot rely upon the sensor reading[2], so get thresholds and compare*/ + rv = GetSensorThresholds(snum,&thresh[0]); + if (rv != 0) return(rv); + i = decode_threshold_supermicro(reading[0],thresh); + if (fdebug) + printf("decode_sensor_supermicro: snum=%x rdg=%x:%x thresh=%x:%x:%x:%x:%x:%x:%x i=%d rv=%d\n", + snum,reading[0],reading[2], thresh[0], thresh[1], thresh[2], thresh[3], + thresh[4], thresh[5], thresh[6], i,rv); + switch(i) { + case 0: pstr = "OK*"; break; + case 1: pstr = "Warn-lo"; break; + case 2: pstr = "Crit-lo"; break; + case 3: pstr = "BelowCrit"; break; + case 4: pstr = "Warn-hi"; break; + case 5: pstr = "Crit-hi"; break; + case 6: pstr = "AboveCrit"; break; + default: pstr = "OK*"; break; + } + sdr01 = (SDR01REC *)sdr; + val = RawToFloat(reading[0],sdr); + typestr = get_unit_type(sdr01->sens_units,sdr01->sens_base,sdr01->sens_mod, 0); + snprintf(pstring, slen, "%s %.2f %s",pstr,val,typestr); + return(rv); + } switch(stype) { case 0xC0: /* CPU Temp Sensor, EvTyp=0x70 (Full) */ //if (dbg) printf("supermicro %x sensor reading %x\n",stype,reading); @@ -457,14 +519,6 @@ int decode_mem_supermicro(int prod, uchar b2, uchar b3, char *desc, int *psz) cpu = bdata / 10; dimm = bdata % 10; #endif -#ifdef DMIOK - /* Use DMI if we get confirmation about cpu/dimm indices. */ - if (! is_remote()) { - fsm_debug = fdebug; - rv = get_MemDesc(cpu,dimm,desc,psz); - /* if (rv != 0) desc has "DIMM[%d}" */ - } -#endif /* ver 0 previous SuperMicro firmware returned all zeros here. * ver 1 returns data3 with some info (X9) * ver 2 returns data2 with some info (X9,X10) @@ -496,6 +550,14 @@ int decode_mem_supermicro(int prod, uchar b2, uchar b3, char *desc, int *psz) dimm = (bdata & 0x0F) - 9; /*0x0A=dimmX1, 0x0B=dimmX2*/ n = sprintf(desc,"P%d_DIMM%c%d",cpu,rgpair[pair],dimm); } +#ifdef DMIOK + /* Use DMI if we get confirmation about cpu/dimm indices. */ + if (! is_remote()) { + fsm_debug = fdebug; + rv = get_MemDesc(cpu,dimm,desc,psz); + /* if (rv != 0) desc has "DIMM[%d}" */ + } +#endif if (fdebug) printf("decode_mem_supermicro: v%d bdata=%02x(%d) cpu=%d dimm=%d pair=%d\n",ver,bdata,bdata,cpu,dimm,pair); @@ -514,6 +576,7 @@ int decode_mem_supermicro(int prod, uchar b2, uchar b3, char *desc, int *psz) * rv = 0 if this event was successfully interpreted here, * non-zero otherwise, to use default interpretations. * outbuf = will contain the interpreted event text string (if rv==0) + * See also decode_mem_supermicro above */ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc, char fdbg) |