mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
added support for built-in sdrs
This commit is contained in:
parent
4d2f9ebdc2
commit
96876bb061
@ -92,6 +92,8 @@ enum {
|
||||
#define SDR_SENSOR_STAT_HI_CR (1<<4)
|
||||
#define SDR_SENSOR_STAT_HI_NR (1<<5)
|
||||
|
||||
#define GET_DEVICE_SDR_INFO 0x20
|
||||
#define GET_DEVICE_SDR 0x21
|
||||
#define GET_SENSOR_FACTORS 0x23
|
||||
#define GET_SENSOR_FACTORS 0x23
|
||||
#define SET_SENSOR_HYSTERESIS 0x24
|
||||
@ -115,6 +117,13 @@ struct sdr_repo_info_rs {
|
||||
uint8_t op_support; /* supported operations */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* builtin (device) sdrs support */
|
||||
struct sdr_device_info_rs {
|
||||
unsigned char count; /* number of records */
|
||||
unsigned char flags; /* flags */
|
||||
unsigned char popChangeInd[3]; /* free space in SDR */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define GET_SDR_RESERVE_REPO 0x22
|
||||
struct sdr_reserve_repo_rs {
|
||||
uint16_t reserve_id; /* reservation ID */
|
||||
@ -148,7 +157,6 @@ struct sdr_get_rs {
|
||||
uint8_t length; /* remaining record bytes */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
struct sdr_record_mask {
|
||||
union {
|
||||
struct {
|
||||
@ -269,7 +277,6 @@ struct sdr_record_mask {
|
||||
} type;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
struct sdr_record_compact_sensor {
|
||||
struct {
|
||||
uint8_t owner_id;
|
||||
@ -680,7 +687,6 @@ struct sdr_record_oem {
|
||||
int data_len;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* The Get SDR Repository Info response structure
|
||||
* From table 33-3 of the IPMI v2.0 spec
|
||||
@ -711,11 +717,7 @@ struct get_sdr_repository_info_rsp {
|
||||
#endif
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
|
||||
|
||||
struct ipmi_sdr_iterator
|
||||
{
|
||||
struct ipmi_sdr_iterator {
|
||||
uint16_t reservation;
|
||||
int total;
|
||||
int next;
|
||||
@ -747,78 +749,109 @@ static const char * unit_desc[] __attribute__((unused)) = {
|
||||
"lumen", "lux", "Candela",
|
||||
"kPa", "PSI", "Newton",
|
||||
"CFM", "RPM", "Hz",
|
||||
"microsecond", "millisecond", "second", "minute", "hour", "day", "week",
|
||||
"mil", "inches", "feet", "cu in", "cu feet", "mm", "cm", "m", "cu cm", "cu m",
|
||||
"liters", "fluid ounce",
|
||||
"radians", "steradians", "revolutions", "cycles", "gravities",
|
||||
"ounce", "pound", "ft-lb", "oz-in",
|
||||
"gauss", "gilberts", "henry", "millihenry",
|
||||
"farad", "microfarad", "ohms", "siemens", "mole", "becquerel",
|
||||
"PPM", "reserved",
|
||||
"Decibels", "DbA", "DbC",
|
||||
"gray", "sievert", "color temp deg K",
|
||||
"bit", "kilobit", "megabit", "gigabit",
|
||||
"byte", "kilobyte", "megabyte", "gigabyte",
|
||||
"word", "dword", "qword", "line",
|
||||
"hit", "miss", "retry", "reset",
|
||||
"overflow", "underrun",
|
||||
"collision", "packets",
|
||||
"messages", "characters",
|
||||
"error", "correctable error", "uncorrectable error",
|
||||
};
|
||||
"microsecond", "millisecond", "second", "minute", "hour",
|
||||
"day", "week", "mil", "inches", "feet", "cu in", "cu feet",
|
||||
"mm", "cm", "m", "cu cm", "cu m", "liters", "fluid ounce",
|
||||
"radians", "steradians", "revolutions", "cycles",
|
||||
"gravities", "ounce", "pound", "ft-lb", "oz-in", "gauss",
|
||||
"gilberts", "henry", "millihenry", "farad", "microfarad",
|
||||
"ohms", "siemens", "mole", "becquerel", "PPM", "reserved",
|
||||
"Decibels", "DbA", "DbC", "gray", "sievert",
|
||||
"color temp deg K", "bit", "kilobit", "megabit", "gigabit",
|
||||
"byte", "kilobyte", "megabyte", "gigabyte", "word", "dword",
|
||||
"qword", "line", "hit", "miss", "retry", "reset",
|
||||
"overflow", "underrun", "collision", "packets", "messages",
|
||||
"characters", "error", "correctable error", "uncorrectable error",};
|
||||
|
||||
/* sensor type codes (IPMI v1.5 table 36.3) */
|
||||
#define SENSOR_TYPE_MAX 0x29
|
||||
static const char *sensor_type_desc[] __attribute__ ((unused)) = {
|
||||
"reserved",
|
||||
"Temperature", "Voltage", "Current", "Fan", "Physical Security", "Platform Security",
|
||||
"Processor", "Power Supply", "Power Unit", "Cooling Device", "Other", "Memory", "Drive Slot / Bay",
|
||||
"POST Memory Resize", "System Firmwares", "Event Logging Disabled", "Watchdog", "System Event",
|
||||
"Critical Interrupt", "Button", "Module / Board", "Microcontroller", "Add-in Card",
|
||||
"Chassis", "Chip Set", "Other FRU", "Cable / Interconnect", "Terminator", "System Boot Initiated",
|
||||
"Boot Error", "OS Boot", "OS Critical Stop", "Slot / Connector", "System ACPI Power State", "Watchdog",
|
||||
"Platform Alert", "Entity Presence", "Monitor ASIC", "LAN", "Management Subsystem Health", "Battery"
|
||||
};
|
||||
"Temperature", "Voltage", "Current", "Fan",
|
||||
"Physical Security", "Platform Security", "Processor",
|
||||
"Power Supply", "Power Unit", "Cooling Device", "Other",
|
||||
"Memory", "Drive Slot / Bay", "POST Memory Resize",
|
||||
"System Firmwares", "Event Logging Disabled", "Watchdog",
|
||||
"System Event", "Critical Interrupt", "Button",
|
||||
"Module / Board", "Microcontroller", "Add-in Card",
|
||||
"Chassis", "Chip Set", "Other FRU", "Cable / Interconnect",
|
||||
"Terminator", "System Boot Initiated", "Boot Error",
|
||||
"OS Boot", "OS Critical Stop", "Slot / Connector",
|
||||
"System ACPI Power State", "Watchdog", "Platform Alert",
|
||||
"Entity Presence", "Monitor ASIC", "LAN",
|
||||
"Management Subsystem Health", "Battery"};
|
||||
|
||||
struct ipmi_sdr_iterator *ipmi_sdr_start(struct ipmi_intf *intf);
|
||||
struct sdr_get_rs * ipmi_sdr_get_next_header(struct ipmi_intf * intf, struct ipmi_sdr_iterator * i);
|
||||
uint8_t * ipmi_sdr_get_record(struct ipmi_intf * intf, struct sdr_get_rs * header, struct ipmi_sdr_iterator * i);
|
||||
struct sdr_get_rs *ipmi_sdr_get_next_header(struct ipmi_intf *intf,
|
||||
struct ipmi_sdr_iterator *i);
|
||||
uint8_t *ipmi_sdr_get_record(struct ipmi_intf *intf, struct sdr_get_rs *header,
|
||||
struct ipmi_sdr_iterator *i);
|
||||
void ipmi_sdr_end(struct ipmi_intf *intf, struct ipmi_sdr_iterator *i);
|
||||
int ipmi_sdr_print_sdr(struct ipmi_intf *intf, uint8_t type);
|
||||
int ipmi_sdr_print_rawentry(struct ipmi_intf * intf, uint8_t type, uint8_t * raw, int len);
|
||||
int ipmi_sdr_print_listentry(struct ipmi_intf * intf, struct sdr_record_list * entry);
|
||||
int ipmi_sdr_print_rawentry(struct ipmi_intf *intf, uint8_t type, uint8_t * raw,
|
||||
int len);
|
||||
int ipmi_sdr_print_listentry(struct ipmi_intf *intf,
|
||||
struct sdr_record_list *entry);
|
||||
char *ipmi_sdr_get_unit_string(uint8_t type, uint8_t base, uint8_t modifier);
|
||||
const char * ipmi_sdr_get_status(struct sdr_record_full_sensor * sensor, uint8_t stat);
|
||||
double sdr_convert_sensor_reading(struct sdr_record_full_sensor * sensor, uint8_t val);
|
||||
uint8_t sdr_convert_sensor_value_to_raw(struct sdr_record_full_sensor * sensor, double val);
|
||||
struct ipmi_rs * ipmi_sdr_get_sensor_reading(struct ipmi_intf * intf, uint8_t sensor);
|
||||
struct ipmi_rs * ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf * intf, uint8_t sensor, uint8_t target);
|
||||
struct ipmi_rs * ipmi_sdr_get_sensor_thresholds(struct ipmi_intf * intf, uint8_t sensor);
|
||||
struct ipmi_rs * ipmi_sdr_get_sensor_hysteresis(struct ipmi_intf * intf, uint8_t sensor);
|
||||
const char *ipmi_sdr_get_status(struct sdr_record_full_sensor *sensor,
|
||||
uint8_t stat);
|
||||
double sdr_convert_sensor_reading(struct sdr_record_full_sensor *sensor,
|
||||
uint8_t val);
|
||||
uint8_t sdr_convert_sensor_value_to_raw(struct sdr_record_full_sensor *sensor,
|
||||
double val);
|
||||
struct ipmi_rs *ipmi_sdr_get_sensor_reading(struct ipmi_intf *intf,
|
||||
uint8_t sensor);
|
||||
struct ipmi_rs *ipmi_sdr_get_sensor_reading_ipmb(struct ipmi_intf *intf,
|
||||
uint8_t sensor,
|
||||
uint8_t target);
|
||||
struct ipmi_rs *ipmi_sdr_get_sensor_thresholds(struct ipmi_intf *intf,
|
||||
uint8_t sensor);
|
||||
struct ipmi_rs *ipmi_sdr_get_sensor_hysteresis(struct ipmi_intf *intf,
|
||||
uint8_t sensor);
|
||||
const char *ipmi_sdr_get_sensor_type_desc(const uint8_t type);
|
||||
int ipmi_sdr_get_reservation(struct ipmi_intf *intf, uint16_t * reserve_id);
|
||||
|
||||
int ipmi_sdr_print_sensor_full(struct ipmi_intf *intf,
|
||||
struct sdr_record_full_sensor *sensor);
|
||||
int ipmi_sdr_print_sensor_compact(struct ipmi_intf *intf,
|
||||
struct sdr_record_compact_sensor *sensor);
|
||||
int ipmi_sdr_print_sensor_eventonly(struct ipmi_intf *intf,
|
||||
struct sdr_record_eventonly_sensor *sensor);
|
||||
int ipmi_sdr_print_sensor_generic_locator(struct ipmi_intf *intf,
|
||||
struct sdr_record_generic_locator
|
||||
*fru);
|
||||
int ipmi_sdr_print_sensor_fru_locator(struct ipmi_intf *intf,
|
||||
struct sdr_record_fru_locator *fru);
|
||||
int ipmi_sdr_print_sensor_mc_locator(struct ipmi_intf *intf,
|
||||
struct sdr_record_mc_locator *mc);
|
||||
int ipmi_sdr_print_sensor_entity_assoc(struct ipmi_intf *intf,
|
||||
struct sdr_record_entity_assoc *assoc);
|
||||
|
||||
int ipmi_sdr_print_sensor_full(struct ipmi_intf * intf, struct sdr_record_full_sensor * sensor);
|
||||
int ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf, struct sdr_record_compact_sensor * sensor);
|
||||
int ipmi_sdr_print_sensor_eventonly(struct ipmi_intf * intf, struct sdr_record_eventonly_sensor * sensor);
|
||||
int ipmi_sdr_print_sensor_generic_locator(struct ipmi_intf * intf, struct sdr_record_generic_locator * fru);
|
||||
int ipmi_sdr_print_sensor_fru_locator(struct ipmi_intf * intf, struct sdr_record_fru_locator * fru);
|
||||
int ipmi_sdr_print_sensor_mc_locator(struct ipmi_intf * intf, struct sdr_record_mc_locator * mc);
|
||||
int ipmi_sdr_print_sensor_entity_assoc(struct ipmi_intf * intf, struct sdr_record_entity_assoc * assoc);
|
||||
|
||||
struct sdr_record_list * ipmi_sdr_find_sdr_byentity(struct ipmi_intf * intf, struct entity_id * entity);
|
||||
struct sdr_record_list * ipmi_sdr_find_sdr_bynumtype(struct ipmi_intf * intf, uint8_t num, uint8_t type);
|
||||
struct sdr_record_list * ipmi_sdr_find_sdr_bysensortype(struct ipmi_intf * intf, uint8_t type);
|
||||
struct sdr_record_list * ipmi_sdr_find_sdr_byid(struct ipmi_intf * intf, char * id);
|
||||
struct sdr_record_list * ipmi_sdr_find_sdr_bytype(struct ipmi_intf * intf, uint8_t type);
|
||||
struct sdr_record_list *ipmi_sdr_find_sdr_byentity(struct ipmi_intf *intf,
|
||||
struct entity_id *entity);
|
||||
struct sdr_record_list *ipmi_sdr_find_sdr_bynumtype(struct ipmi_intf *intf,
|
||||
uint8_t num, uint8_t type);
|
||||
struct sdr_record_list *ipmi_sdr_find_sdr_bysensortype(struct ipmi_intf *intf,
|
||||
uint8_t type);
|
||||
struct sdr_record_list *ipmi_sdr_find_sdr_byid(struct ipmi_intf *intf,
|
||||
char *id);
|
||||
struct sdr_record_list *ipmi_sdr_find_sdr_bytype(struct ipmi_intf *intf,
|
||||
uint8_t type);
|
||||
int ipmi_sdr_list_cache(struct ipmi_intf *intf);
|
||||
int ipmi_sdr_list_cache_fromfile(struct ipmi_intf *intf, const char *ifile);
|
||||
void ipmi_sdr_list_empty(struct ipmi_intf *intf);
|
||||
int ipmi_sdr_print_info(struct ipmi_intf *intf);
|
||||
void ipmi_sdr_print_discrete_state(const char * desc, uint8_t sensor_type, uint8_t event_type, uint8_t state1, uint8_t state2);
|
||||
void ipmi_sdr_print_discrete_state_mini(const char * separator, uint8_t sensor_type, uint8_t event_type, uint8_t state1, uint8_t state2);
|
||||
int ipmi_sdr_print_sensor_event_status(struct ipmi_intf * intf, uint8_t sensor_num, uint8_t sensor_type, uint8_t event_type, int numeric_fmt);
|
||||
int ipmi_sdr_print_sensor_event_enable(struct ipmi_intf * intf, uint8_t sensor_num, uint8_t sensor_type, uint8_t event_type, int numeric_fmt);
|
||||
void ipmi_sdr_print_discrete_state(const char *desc, uint8_t sensor_type,
|
||||
uint8_t event_type, uint8_t state1,
|
||||
uint8_t state2);
|
||||
void ipmi_sdr_print_discrete_state_mini(const char *separator,
|
||||
uint8_t sensor_type, uint8_t event_type,
|
||||
uint8_t state1, uint8_t state2);
|
||||
int ipmi_sdr_print_sensor_event_status(struct ipmi_intf *intf,
|
||||
uint8_t sensor_num, uint8_t sensor_type,
|
||||
uint8_t event_type, int numeric_fmt);
|
||||
int ipmi_sdr_print_sensor_event_enable(struct ipmi_intf *intf,
|
||||
uint8_t sensor_num, uint8_t sensor_type,
|
||||
uint8_t event_type, int numeric_fmt);
|
||||
|
||||
#endif /* IPMI_SDR_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -53,8 +53,7 @@ static
|
||||
struct ipmi_rs *
|
||||
ipmi_sensor_set_sensor_thresholds(struct ipmi_intf *intf,
|
||||
uint8_t sensor,
|
||||
uint8_t threshold,
|
||||
uint8_t setting)
|
||||
uint8_t threshold, uint8_t setting)
|
||||
{
|
||||
struct ipmi_rq req;
|
||||
static struct sensor_set_thresh_rq set_thresh_rq;
|
||||
@ -119,12 +118,9 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf * intf,
|
||||
val = rsp->data[0];
|
||||
}
|
||||
|
||||
if (csv_output)
|
||||
{
|
||||
if (csv_output) {
|
||||
/* NOT IMPLEMENTED */
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (verbose == 0) {
|
||||
/* output format
|
||||
* id value units status thresholds....
|
||||
@ -133,14 +129,10 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf * intf,
|
||||
if (validread) {
|
||||
printf("| 0x%-8x | %-10s | 0x%02x%02x",
|
||||
val,
|
||||
unitstr,
|
||||
rsp->data[2],
|
||||
rsp->data[3]);
|
||||
unitstr, rsp->data[2], rsp->data[3]);
|
||||
} else {
|
||||
printf("| %-10s | %-10s | %-6s",
|
||||
"na",
|
||||
unitstr,
|
||||
"na");
|
||||
"na", unitstr, "na");
|
||||
}
|
||||
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
|
||||
"na", "na", "na", "na", "na", "na");
|
||||
@ -152,7 +144,8 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf * intf,
|
||||
printf(" Entity ID : %d.%d\n",
|
||||
sensor->entity.id, sensor->entity.instance);
|
||||
printf(" Sensor Type (Discrete): %s\n",
|
||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
|
||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
||||
type));
|
||||
ipmi_sdr_print_discrete_state("States Asserted",
|
||||
sensor->sensor.type,
|
||||
sensor->event_type,
|
||||
@ -211,8 +204,7 @@ ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
|
||||
* Figure out units
|
||||
*/
|
||||
memset(unitstr, 0, sizeof (unitstr));
|
||||
switch (sensor->unit.modifier)
|
||||
{
|
||||
switch (sensor->unit.modifier) {
|
||||
case 2:
|
||||
i += snprintf(unitstr, sizeof (unitstr), "%s * %s",
|
||||
unit_desc[sensor->unit.type.base],
|
||||
@ -237,14 +229,10 @@ ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
|
||||
if (rsp == NULL)
|
||||
thresh_available = 0;
|
||||
|
||||
if (csv_output)
|
||||
{
|
||||
if (csv_output) {
|
||||
/* NOT IPMLEMENTED */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verbose == 0)
|
||||
{
|
||||
} else {
|
||||
if (verbose == 0) {
|
||||
/* output format
|
||||
* id value units status thresholds....
|
||||
*/
|
||||
@ -256,43 +244,51 @@ ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
|
||||
printf("| %-10s | %-10s | %-6s",
|
||||
"na", unitstr, "na");
|
||||
}
|
||||
if (thresh_available)
|
||||
{
|
||||
if (thresh_available) {
|
||||
if (rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)
|
||||
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[3]));
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[3]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & LOWER_CRIT_SPECIFIED)
|
||||
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[2]));
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[2]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)
|
||||
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[1]));
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[1]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)
|
||||
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[4]));
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[4]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & UPPER_CRIT_SPECIFIED)
|
||||
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[5]));
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[5]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)
|
||||
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[6]));
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[6]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
|
||||
} else {
|
||||
printf
|
||||
("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
|
||||
"na", "na", "na", "na", "na", "na");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
printf("Sensor ID : %s (0x%x)\n",
|
||||
id, sensor->keys.sensor_num);
|
||||
|
||||
@ -300,66 +296,89 @@ ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
|
||||
sensor->entity.id, sensor->entity.instance);
|
||||
|
||||
printf(" Sensor Type (Analog) : %s\n",
|
||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
|
||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
||||
type));
|
||||
|
||||
printf(" Sensor Reading : ");
|
||||
if (validread) {
|
||||
uint16_t raw_tol = __TO_TOL(sensor->mtol);
|
||||
double tol = sdr_convert_sensor_reading(sensor, raw_tol * 2);
|
||||
double tol =
|
||||
sdr_convert_sensor_reading(sensor,
|
||||
raw_tol * 2);
|
||||
printf("%.*f (+/- %.*f) %s\n",
|
||||
(val==(int)val) ? 0 : 3,
|
||||
val,
|
||||
(tol==(int)tol) ? 0 : 3,
|
||||
tol,
|
||||
(val == (int) val) ? 0 : 3, val,
|
||||
(tol == (int) tol) ? 0 : 3, tol,
|
||||
unitstr);
|
||||
printf(" Status : %s\n", status ? : "");
|
||||
printf(" Status : %s\n",
|
||||
status ? : "");
|
||||
|
||||
if (thresh_available)
|
||||
{
|
||||
if (rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)
|
||||
printf(" Lower Non-Recoverable : %.3f\n",
|
||||
sdr_convert_sensor_reading(sensor, rsp->data[3]));
|
||||
if (thresh_available) {
|
||||
if (rsp->
|
||||
data[0] & LOWER_NON_RECOV_SPECIFIED)
|
||||
printf
|
||||
(" Lower Non-Recoverable : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[3]));
|
||||
else
|
||||
printf(" Lower Non-Recoverable : na\n");
|
||||
printf
|
||||
(" Lower Non-Recoverable : na\n");
|
||||
if (rsp->data[0] & LOWER_CRIT_SPECIFIED)
|
||||
printf(" Lower Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading(sensor, rsp->data[2]));
|
||||
printf
|
||||
(" Lower Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[2]));
|
||||
else
|
||||
printf(" Lower Critical : na\n");
|
||||
if (rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)
|
||||
printf(" Lower Non-Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading(sensor, rsp->data[1]));
|
||||
printf
|
||||
(" Lower Critical : na\n");
|
||||
if (rsp->
|
||||
data[0] & LOWER_NON_CRIT_SPECIFIED)
|
||||
printf
|
||||
(" Lower Non-Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[1]));
|
||||
else
|
||||
printf(" Lower Non-Critical : na\n");
|
||||
if (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)
|
||||
printf(" Upper Non-Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading(sensor, rsp->data[4]));
|
||||
printf
|
||||
(" Lower Non-Critical : na\n");
|
||||
if (rsp->
|
||||
data[0] & UPPER_NON_CRIT_SPECIFIED)
|
||||
printf
|
||||
(" Upper Non-Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[4]));
|
||||
else
|
||||
printf(" Upper Non-Critical : na\n");
|
||||
printf
|
||||
(" Upper Non-Critical : na\n");
|
||||
if (rsp->data[0] & UPPER_CRIT_SPECIFIED)
|
||||
printf(" Upper Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading(sensor, rsp->data[5]));
|
||||
printf
|
||||
(" Upper Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[5]));
|
||||
else
|
||||
printf(" Upper Critical : na\n");
|
||||
if (rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)
|
||||
printf(" Upper Non-Recoverable : %.3f\n",
|
||||
sdr_convert_sensor_reading(sensor, rsp->data[6]));
|
||||
printf
|
||||
(" Upper Critical : na\n");
|
||||
if (rsp->
|
||||
data[0] & UPPER_NON_RECOV_SPECIFIED)
|
||||
printf
|
||||
(" Upper Non-Recoverable : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[6]));
|
||||
else
|
||||
printf(" Upper Non-Recoverable : na\n");
|
||||
printf
|
||||
(" Upper Non-Recoverable : na\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
printf("Not Present\n");
|
||||
}
|
||||
|
||||
ipmi_sdr_print_sensor_event_status(intf,
|
||||
sensor->keys.sensor_num,
|
||||
sensor->keys.
|
||||
sensor_num,
|
||||
sensor->sensor.type,
|
||||
sensor->event_type,
|
||||
ANALOG_SENSOR);
|
||||
ipmi_sdr_print_sensor_event_enable(intf,
|
||||
sensor->keys.sensor_num,
|
||||
sensor->keys.
|
||||
sensor_num,
|
||||
sensor->sensor.type,
|
||||
sensor->event_type,
|
||||
ANALOG_SENSOR);
|
||||
@ -414,14 +433,10 @@ ipmi_sensor_print_compact(struct ipmi_intf * intf,
|
||||
val = rsp->data[0];
|
||||
}
|
||||
|
||||
if (csv_output)
|
||||
{
|
||||
if (csv_output) {
|
||||
/* NOT IMPLEMENTED */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!verbose)
|
||||
{
|
||||
} else {
|
||||
if (!verbose) {
|
||||
/* output format
|
||||
* id value units status thresholds....
|
||||
*/
|
||||
@ -439,17 +454,19 @@ ipmi_sensor_print_compact(struct ipmi_intf * intf,
|
||||
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
|
||||
"na", "na", "na", "na", "na", "na");
|
||||
printf("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
printf("Sensor ID : %s (0x%x)\n",
|
||||
id, sensor->keys.sensor_num);
|
||||
printf(" Entity ID : %d.%d\n",
|
||||
sensor->entity.id, sensor->entity.instance);
|
||||
printf(" Sensor Type (Discrete): %s\n",
|
||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
|
||||
ipmi_sdr_print_discrete_state("States Asserted", sensor->sensor.type,
|
||||
sensor->event_type, rsp->data[2], rsp->data[3]);
|
||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
||||
type));
|
||||
ipmi_sdr_print_discrete_state("States Asserted",
|
||||
sensor->sensor.type,
|
||||
sensor->event_type,
|
||||
rsp->data[2],
|
||||
rsp->data[3]);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
@ -472,24 +489,28 @@ ipmi_sensor_list(struct ipmi_intf * intf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((header = ipmi_sdr_get_next_header(intf, itr)) != NULL)
|
||||
{
|
||||
while ((header = ipmi_sdr_get_next_header(intf, itr)) != NULL) {
|
||||
int r = 0;
|
||||
uint8_t *rec;
|
||||
|
||||
rec = ipmi_sdr_get_record(intf, header, itr);
|
||||
if (rec == NULL)
|
||||
if (rec == NULL) {
|
||||
lprintf(LOG_DEBUG, "rec == NULL");
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(header->type)
|
||||
{
|
||||
switch (header->type) {
|
||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||
r = ipmi_sensor_print_full(intf,
|
||||
(struct sdr_record_full_sensor *)rec);
|
||||
(struct
|
||||
sdr_record_full_sensor *)
|
||||
rec);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||
r = ipmi_sensor_print_compact(intf,
|
||||
(struct sdr_record_compact_sensor *)rec);
|
||||
(struct
|
||||
sdr_record_compact_sensor
|
||||
*) rec);
|
||||
break;
|
||||
}
|
||||
free(rec);
|
||||
@ -513,7 +534,6 @@ static const struct valstr threshold_vals[] = {
|
||||
{0x00, NULL},
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
__ipmi_sensor_set_threshold(struct ipmi_intf *intf,
|
||||
uint8_t num, uint8_t mask, uint8_t setting)
|
||||
@ -535,7 +555,6 @@ __ipmi_sensor_set_threshold(struct ipmi_intf * intf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
|
||||
{
|
||||
@ -547,24 +566,33 @@ ipmi_sensor_set_threshold(struct ipmi_intf * intf, int argc, char ** argv)
|
||||
|
||||
struct sdr_record_list *sdr;
|
||||
|
||||
if (argc < 3 || strncmp(argv[0], "help", 4) == 0)
|
||||
{
|
||||
if (argc < 3 || strncmp(argv[0], "help", 4) == 0) {
|
||||
lprintf(LOG_NOTICE, "sensor thresh <id> <threshold> <setting>");
|
||||
lprintf(LOG_NOTICE, " id : name of the sensor for which threshold is to be set");
|
||||
lprintf(LOG_NOTICE,
|
||||
" id : name of the sensor for which threshold is to be set");
|
||||
lprintf(LOG_NOTICE, " threshold : which threshold to set");
|
||||
lprintf(LOG_NOTICE, " unr = upper non-recoverable");
|
||||
lprintf(LOG_NOTICE,
|
||||
" unr = upper non-recoverable");
|
||||
lprintf(LOG_NOTICE, " ucr = upper critical");
|
||||
lprintf(LOG_NOTICE, " unc = upper non-critical");
|
||||
lprintf(LOG_NOTICE, " lnc = lower non-critical");
|
||||
lprintf(LOG_NOTICE,
|
||||
" unc = upper non-critical");
|
||||
lprintf(LOG_NOTICE,
|
||||
" lnc = lower non-critical");
|
||||
lprintf(LOG_NOTICE, " lcr = lower critical");
|
||||
lprintf(LOG_NOTICE, " lnr = lower non-recoverable");
|
||||
lprintf(LOG_NOTICE, " setting : the value to set the threshold to");
|
||||
lprintf(LOG_NOTICE,
|
||||
" lnr = lower non-recoverable");
|
||||
lprintf(LOG_NOTICE,
|
||||
" setting : the value to set the threshold to");
|
||||
lprintf(LOG_NOTICE, "");
|
||||
lprintf(LOG_NOTICE, "sensor thresh <id> lower <lnr> <lcr> <lnc>");
|
||||
lprintf(LOG_NOTICE, " Set all lower thresholds at the same time");
|
||||
lprintf(LOG_NOTICE,
|
||||
"sensor thresh <id> lower <lnr> <lcr> <lnc>");
|
||||
lprintf(LOG_NOTICE,
|
||||
" Set all lower thresholds at the same time");
|
||||
lprintf(LOG_NOTICE, "");
|
||||
lprintf(LOG_NOTICE, "sensor thresh <id> upper <unc> <ucr> <unr>");
|
||||
lprintf(LOG_NOTICE, " Set all upper thresholds at the same time");
|
||||
lprintf(LOG_NOTICE,
|
||||
"sensor thresh <id> upper <unc> <ucr> <unr>");
|
||||
lprintf(LOG_NOTICE,
|
||||
" Set all upper thresholds at the same time");
|
||||
lprintf(LOG_NOTICE, "");
|
||||
return 0;
|
||||
}
|
||||
@ -574,25 +602,25 @@ ipmi_sensor_set_threshold(struct ipmi_intf * intf, int argc, char ** argv)
|
||||
|
||||
if (strncmp(thresh, "upper", 5) == 0) {
|
||||
if (argc < 5) {
|
||||
lprintf(LOG_ERR, "usage: sensor thresh <id> upper <unc> <ucr> <unr>");
|
||||
lprintf(LOG_ERR,
|
||||
"usage: sensor thresh <id> upper <unc> <ucr> <unr>");
|
||||
return -1;
|
||||
}
|
||||
allUpper = 1;
|
||||
setting1 = (double) strtod(argv[2], NULL);
|
||||
setting2 = (double) strtod(argv[3], NULL);
|
||||
setting3 = (double) strtod(argv[4], NULL);
|
||||
}
|
||||
else if (strncmp(thresh, "lower", 5) == 0) {
|
||||
} else if (strncmp(thresh, "lower", 5) == 0) {
|
||||
if (argc < 5) {
|
||||
lprintf(LOG_ERR, "usage: sensor thresh <id> lower <unc> <ucr> <unr>");
|
||||
lprintf(LOG_ERR,
|
||||
"usage: sensor thresh <id> lower <unc> <ucr> <unr>");
|
||||
return -1;
|
||||
}
|
||||
allLower = 1;
|
||||
setting1 = (double) strtod(argv[2], NULL);
|
||||
setting2 = (double) strtod(argv[3], NULL);
|
||||
setting3 = (double) strtod(argv[4], NULL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setting1 = (double) atof(argv[2]);
|
||||
if (strncmp(thresh, "unr", 3) == 0)
|
||||
settingMask = UPPER_NON_RECOV_SPECIFIED;
|
||||
@ -607,7 +635,9 @@ ipmi_sensor_set_threshold(struct ipmi_intf * intf, int argc, char ** argv)
|
||||
else if (strncmp(thresh, "lnr", 3) == 0)
|
||||
settingMask = LOWER_NON_RECOV_SPECIFIED;
|
||||
else {
|
||||
lprintf(LOG_ERR, "Valid threshold '%s' for sensor '%s' not specified!", thresh, id);
|
||||
lprintf(LOG_ERR,
|
||||
"Valid threshold '%s' for sensor '%s' not specified!",
|
||||
thresh, id);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -632,58 +662,70 @@ ipmi_sensor_set_threshold(struct ipmi_intf * intf, int argc, char ** argv)
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting1);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw(sdr->record.full, setting1));
|
||||
sdr->record.full->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting1));
|
||||
|
||||
settingMask = UPPER_CRIT_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting2);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw(sdr->record.full, setting2));
|
||||
sdr->record.full->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting2));
|
||||
|
||||
settingMask = UPPER_NON_RECOV_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting3);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw(sdr->record.full, setting3));
|
||||
}
|
||||
else if (allLower) {
|
||||
sdr->record.full->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting3));
|
||||
} else if (allLower) {
|
||||
settingMask = LOWER_NON_RECOV_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting1);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw(sdr->record.full, setting1));
|
||||
sdr->record.full->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting1));
|
||||
|
||||
settingMask = LOWER_CRIT_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting2);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw(sdr->record.full, setting2));
|
||||
sdr->record.full->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting2));
|
||||
|
||||
settingMask = LOWER_NON_CRIT_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting3);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw(sdr->record.full, setting3));
|
||||
}
|
||||
else {
|
||||
sdr->record.full->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting3));
|
||||
} else {
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting1);
|
||||
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw(sdr->record.full, setting1));
|
||||
sdr->record.full->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting1));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -723,16 +765,22 @@ ipmi_sensor_get(struct ipmi_intf * intf, int argc, char ** argv)
|
||||
r = ipmi_sensor_print_full(intf, sdr->record.full);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||
r = ipmi_sensor_print_compact(intf, sdr->record.compact);
|
||||
r = ipmi_sensor_print_compact(intf,
|
||||
sdr->record.compact);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
|
||||
r = ipmi_sdr_print_sensor_eventonly(intf, sdr->record.eventonly);
|
||||
r = ipmi_sdr_print_sensor_eventonly(intf,
|
||||
sdr->record.
|
||||
eventonly);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_FRU_DEVICE_LOCATOR:
|
||||
r = ipmi_sdr_print_sensor_fru_locator(intf, sdr->record.fruloc);
|
||||
r = ipmi_sdr_print_sensor_fru_locator(intf,
|
||||
sdr->record.
|
||||
fruloc);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_MC_DEVICE_LOCATOR:
|
||||
r = ipmi_sdr_print_sensor_mc_locator(intf, sdr->record.mcloc);
|
||||
r = ipmi_sdr_print_sensor_mc_locator(intf,
|
||||
sdr->record.mcloc);
|
||||
break;
|
||||
}
|
||||
verbose = v;
|
||||
@ -751,22 +799,16 @@ ipmi_sensor_main(struct ipmi_intf * intf, int argc, char ** argv)
|
||||
|
||||
if (argc == 0) {
|
||||
rc = ipmi_sensor_list(intf);
|
||||
}
|
||||
else if (strncmp(argv[0], "help", 4) == 0) {
|
||||
} else if (strncmp(argv[0], "help", 4) == 0) {
|
||||
lprintf(LOG_NOTICE, "Sensor Commands: list thresh get");
|
||||
}
|
||||
else if (strncmp(argv[0], "list", 4) == 0) {
|
||||
} else if (strncmp(argv[0], "list", 4) == 0) {
|
||||
rc = ipmi_sensor_list(intf);
|
||||
}
|
||||
else if (strncmp(argv[0], "thresh", 5) == 0) {
|
||||
} else if (strncmp(argv[0], "thresh", 5) == 0) {
|
||||
rc = ipmi_sensor_set_threshold(intf, argc - 1, &argv[1]);
|
||||
}
|
||||
else if (strncmp(argv[0], "get", 3) == 0) {
|
||||
} else if (strncmp(argv[0], "get", 3) == 0) {
|
||||
rc = ipmi_sensor_get(intf, argc - 1, &argv[1]);
|
||||
}
|
||||
else {
|
||||
lprintf(LOG_ERR, "Invalid sensor command: %s",
|
||||
argv[0]);
|
||||
} else {
|
||||
lprintf(LOG_ERR, "Invalid sensor command: %s", argv[0]);
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user