diff options
Diffstat (limited to 'util/isensor.c')
-rw-r--r-- | util/isensor.c | 169 |
1 files changed, 144 insertions, 25 deletions
diff --git a/util/isensor.c b/util/isensor.c index a59e18b..9456613 100644 --- a/util/isensor.c +++ b/util/isensor.c @@ -164,10 +164,12 @@ extern int decode_sensor_supermicro(uchar *sdr,uchar *reading,char *pstring, int slen); /*see oem_supermicro.c*/ extern int decode_sensor_quanta(uchar *sdr,uchar *reading,char *pstring, int slen); /*see oem_quanta.c*/ -extern int decode_sensor_hp(uchar *sdr,uchar *reading,char *pstring, - int slen); /*see oem_hp.c*/ extern int decode_sensor_dell(uchar *sdr,uchar *reading,char *pstring, int slen); /*see oem_dell.c*/ +extern int decode_sensor_lenovo(uchar *sdr,uchar *reading,char *pstring, + int slen); /*see oem_lenovo.c*/ +extern int decode_sensor_hp(uchar *sdr,uchar *reading,char *pstring, + int slen); /*see oem_hp.c*/ extern void show_oemsdr_hp(uchar *sdr); #else int is_romley(int vend, int prod) { @@ -252,7 +254,7 @@ char *decode_entity_id(int id) { * Global Data ************************/ static char *progname = "isensor"; -static char *progver = "3.00"; +static char *progver = "3.01"; #ifdef WIN32 static char savefile[] = "%ipmiutildir%\\thresholds.cmd"; #else @@ -314,7 +316,7 @@ static int prod_id; * This is used to decode the sensor reading types and meanings. * Use IPMI Table 36-1 and 36-2 for this. */ -#define N_DSTATUS 82 +#define N_DSTATUS 101 #define STR_CUSTOM 58 #define STR_OEM 71 #define STR_AC_LOST 76 @@ -351,10 +353,10 @@ static char *sensor_dstatus[N_DSTATUS] = { /*19 Avl */ "RedunLost", /*20 Avl */ "RedunDegr", /* ACPI Device Power States */ -/*21 ACPI*/ "Off ", -/*22 ACPI*/ "Working", +/*21 ACPI*/ "Off ", /*D3*/ +/*22 ACPI*/ "Working", /*D1*/ /*23 ACPI*/ "Sleeping", /*D2/S2*/ -/*24 ACPI*/ "On", +/*24 ACPI*/ "On", /*D0*/ /* Critical Interrupt event states */ /*25 CrI */ "FP_NMI ", /*26 CrI */ "Bus_TimOut", @@ -424,7 +426,26 @@ static char *sensor_dstatus[N_DSTATUS] = { /*78 PS */ "Config_Err", /*79 HSC */ "Offline", /*80 HSC */ "Rebuilding", -/*81 other*/ " _ " +/*81 other*/ " _ ", +/*82 Avl */ "NonRedund_Sufficient", +/*83 Avl */ "NonRedund_Insufficient", +/*84 Usage */ "Idle", +/*85 Usage */ "Active", +/*86 Usage */ "Busy", +/*87 Trans */ "Non-Critical", +/*88 Trans */ "Critical", +/*89 Trans */ "Non-Recoverable", +/*90 Trans */ "Monitor", +/*91 Trans */ "Informational", +/*92 State */ "Running", +/*93 State */ "In_Test", +/*94 State */ "Power_Off", +/*95 State */ "Online", +/*96 State */ "Offline", +/*97 State */ "Off_Duty", +/*98 State */ "Degraded", +/*99 State */ "PowerSave", +/*100 State */ "InstallError" }; static char *raid_states[9] = { /*for sensor type 0x0d drive status */ @@ -1941,6 +1962,10 @@ int decode_oem_sensor(uchar *sdr,uchar *reading,char *pstring,int slen) case VENDOR_DELL: rv = decode_sensor_dell(sdr, reading, pstring, slen); break; + case VENDOR_LENOVO: + case VENDOR_LENOVO2: + rv = decode_sensor_lenovo(sdr, reading, pstring, slen); + break; default: break; } /*end-switch vend_id*/ @@ -2109,6 +2134,97 @@ ShowThresh(int flg, uchar bits, uchar *vals, uchar *sdr) } /*endif full sdr*/ } +int decode_comp_generic(uchar type, uchar evtype, uchar num, ushort reading) +{ + int istr = 0; + uchar b; + /* decode via evtype */ + switch(evtype) + { + case 0x02: + if (reading & 0x01) istr = 85; /* Active */ + if (reading & 0x02) istr = 86; /* Busy */ + else istr = 84; /* Idle (OK)) */ + case 0x03: + if (reading & 0x01) istr = 13; /* Asserted */ + else istr = 0; /* "OK" Deasserted */ + break; + case 0x04: + if (reading & 0x01) istr = 15; /* Predictive Failure */ + else istr = 0; /* "OK" Deasserted */ + break; + case 0x05: + if (reading & 0x01) istr = 65; /* Limit Exceeded*/ + else istr = 0; /* "OK" LimitNotExceeded*/ + break; + case 0x07: /* transition */ + b = bitnum(reading); + switch(b) { + case 0: istr = 0; break; /*no bits set, OK*/ + case 1: istr = 87; break; /*transition up to Non-Critical*/ + case 2: istr = 88; break; /*transition up to Critical */ + case 3: istr = 89; break; /*transition up to Non-recoverable */ + case 4: istr = 87; break; /*transition down to Non-Critical */ + case 5: istr = 88; break; /*transition down to Critical */ + case 6: istr = 89; break; /*transition to Non-recoverable */ + case 7: istr = 90; break; /*Monitor*/ + case 8: istr = 91; break; /*Informational*/ + default: istr = 8; break; /*'OK*'*/ + } + break; + case 0x08: + if (reading & 0x01) istr = 9; /* Present */ + else istr = 10; /*Absent*/ + break; + case 0x09: /* Availability event states */ + if (reading & 0x01) istr = 17; /* Enabled */ + else istr = 16; /*Disabled*/ + break; + case 0x0A: /* */ + b = (reading & 0x7f); + switch(b) { + case 0x00: istr = 8; break; /* 00 'OK*'*/ + case 0x01: istr = 92; break; /* transition to Running */ + case 0x02: istr = 93; break; /* transition to In Test */ + case 0x04: istr = 94; break; /* transition to Power Off */ + case 0x08: istr = 95; break; /* transition to On Line */ + case 0x10: istr = 96; break; /* transition to Off Line */ + case 0x20: istr = 97; break; /* transition to Off Duty */ + case 0x40: istr = 98; break; /* transition to Degraded */ + case 0x80: istr = 99; break; /* transition to Power Save */ + default: istr = 100; break; /* Install Error */ + } + break; + case 0x0B: /* Redundancy */ + b = (reading & 0x7f); + switch(b) { + case 0x00: istr = 8; break; /* 00 'OK*'*/ + case 0x01: istr = 18; break; /* 01 Fully Redundant */ + case 0x02: istr = 19; break; /* 02 Redundancy Lost */ + case 0x04: istr = 20; break; /* 04 Redundancy Degraded */ + case 0x08: istr = 82; break; /* 08 Non-Redundant/Sufficient down */ + case 0x10: istr = 82; break; /* 10 Non-Redundant/Sufficient up*/ + case 0x20: istr = 83; break; /* 20 Non-Redundant/Insufficient */ + case 0x40: istr = 20; break; /* 40 Redundancy Degraded down */ + default: istr = 20; break; /* Redundancy Degraded up */ + } + break; + case 0x0C: /* ACPI Power States */ + if (reading & 0x04) istr = 21; /* D3, Off */ + else if (reading & 0x02) istr = 23; /* D2, Sleeping */ + else if (reading & 0x01) istr = 22; /* D1, Working */ + else istr = 24; /*D0, On*/ + break; + default: + if (fdebug) + printf("sensor[%x] et %02x type %02x not decoded, reading = %04x\n", + num,evtype,type,reading); + istr = STR_OTHER; /* other " - " */ + break; + } + return(istr); +} + /* * decode_comp_reading * @@ -2147,10 +2263,10 @@ decode_comp_reading(uchar type, uchar evtype, uchar num, } else if (evtype == 0x05) { /* see CPU1 VRD Temp on S5000, snum 0xc0 thru 0xcf */ if (reading & 0x01) istr = 65; /* Limit Exceeded*/ - else istr = 0; /* "OK" LimitNotExceeded*/ + else istr = 0; /* "OK" LimitNotExceeded*/ } else if (evtype == 0x03) { if (reading & 0x01) istr = 13; /* Asserted */ - else istr = 0; /* "OK" Deasserted */ + else istr = 0; /* "OK" Deasserted */ } else { /* evtype == other 0x05 */ if (reading & 0x01) istr = 0; /* 8="OK*", 0="OK" */ else istr = 5; /*state asserted, Crit-hi */ @@ -2351,8 +2467,8 @@ decode_comp_reading(uchar type, uchar evtype, uchar num, case 7: case 8: case 11: - case 13: istr = 21; break; /*Off*/ case 12: istr = 24; break; /*On*/ + case 13: istr = 21; break; /*Off*/ default: istr = 41; /*unknown*/ } break; @@ -2378,8 +2494,12 @@ decode_comp_reading(uchar type, uchar evtype, uchar num, else istr = 42; /* NotAvailable */ break; case 0x28: /* BMC FW Health */ - if (reading == 0) istr = 0; /*OK*/ - else istr = 12; /*Faulty*/ + if (evtype == 0x6F) { /*Sensor-specific*/ + if (reading == 0) istr = 0; /*OK*/ + else istr = 12; /*Faulty*/ + } else { /*use event/reading type*/ + istr = decode_comp_generic(type, evtype, num, reading); + } break; case 0x29: /* Battery */ switch(reading & 0x7f) { @@ -2395,8 +2515,8 @@ decode_comp_reading(uchar type, uchar evtype, uchar num, else istr = 46; /*Deactivated*/ break; case 0x2B: /* Version Change */ - b = bitnum(reading1); - switch(b) { + b = bitnum(reading1); + switch(b) { case 0: istr = 0; break; /*OK, no bits set*/ case 1: istr = 72; break; /*HW Changed, bit 0 set*/ case 2: istr = 73; break; /*SW Changed, bit 1 set*/ @@ -2404,9 +2524,7 @@ decode_comp_reading(uchar type, uchar evtype, uchar num, default: istr = 75; break; /*Change error*/ } break; - case 0x60: /* SCSI 1 Term Flt */ - case 0x61: /* SCSI 2 Term Flt */ - break; + /* sensor types 0xC0 - 0xFF are OEM RESERVED */ case 0xF1: /* ATCA IPMB-0 Sensor */ if ((reading & 0x7fff) == 0x0008) istr = 0; /*OK*/ @@ -2418,13 +2536,14 @@ decode_comp_reading(uchar type, uchar evtype, uchar num, case 0xF2: /* ATCA Module HotSwap, TODO: refine this */ case 0xF3: /* SMI Timeout, etc. */ if (reading & 0x01) istr = 13; /* Asserted */ - else istr = 0; /* "OK", Deasserted */ + else istr = 0; /* "OK", Deasserted */ break; + + case 0x60: /* SCSI 1 Term Flt */ + case 0x61: /* SCSI 2 Term Flt */ default: - if (fdebug) - printf("sensor[%x] type %02x not decoded, reading = %04x\n", - num,type,reading); - istr = STR_OTHER; /* other " - " */ + istr = decode_comp_generic(type, evtype, num, reading); + break; } return(istr); } /* end decode_comp_reading */ @@ -2553,7 +2672,7 @@ ShowSDR(char *tag, uchar *sdr) sens[0], sensor_dstatus[i],val,typestr); } sep[0] = 0; /*null string*/ - printf("%s", tag); + printf("%s", tag); if (fsimple) { sprintf(sep,"%c ",bdelim); printf("%04x %c Full %c %s %c %02x %c %s %c %s%c", @@ -3350,7 +3469,7 @@ int i_sensor(int argc, char **argv) fmBMC = 0; if (is_romley(vend_id,prod_id)) fRomley = 1; if (is_grantley(vend_id,prod_id)) fGrantley = 1; - if (prod_id == 0x003E || fRomley) /*Urbanna NSN2U,CG2100*/ + if (prod_id == 0x003E || fRomley || fGrantley) /*Urbanna,CG2100*/ set_max_kcs_loops(URNLOOPS); /*longer KCS timeout*/ } else if ((vend_id == VENDOR_SUPERMICRO) || (vend_id == VENDOR_SUPERMICROX)) { |