mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-11 02:57:22 +00:00
add 'sdr get' command, add hysteresis to sdr verbose output
This commit is contained in:
parent
f04b6d858f
commit
3af858eecf
@ -93,12 +93,18 @@ enum {
|
|||||||
#define SDR_SENSOR_STAT_HI_NR (1<<5)
|
#define SDR_SENSOR_STAT_HI_NR (1<<5)
|
||||||
|
|
||||||
#define GET_SENSOR_FACTORS 0x23
|
#define GET_SENSOR_FACTORS 0x23
|
||||||
#define GET_SENSOR_THRES 0x27
|
#define GET_SENSOR_FACTORS 0x23
|
||||||
|
#define SET_SENSOR_HYSTERESIS 0x24
|
||||||
|
#define GET_SENSOR_HYSTERESIS 0x25
|
||||||
|
#define SET_SENSOR_THRESHOLDS 0x26
|
||||||
|
#define GET_SENSOR_THRESHOLDS 0x27
|
||||||
#define SET_SENSOR_EVENT_ENABLE 0x28
|
#define SET_SENSOR_EVENT_ENABLE 0x28
|
||||||
#define GET_SENSOR_EVENT_ENABLE 0x29
|
#define GET_SENSOR_EVENT_ENABLE 0x29
|
||||||
#define GET_SENSOR_EVENT_STATUS 0x2b
|
#define GET_SENSOR_EVENT_STATUS 0x2b
|
||||||
#define GET_SENSOR_READING 0x2d
|
#define GET_SENSOR_READING 0x2d
|
||||||
#define GET_SENSOR_TYPE 0x2f
|
#define GET_SENSOR_TYPE 0x2f
|
||||||
|
#define GET_SENSOR_READING 0x2d
|
||||||
|
#define GET_SENSOR_TYPE 0x2f
|
||||||
|
|
||||||
struct sdr_repo_info_rs {
|
struct sdr_repo_info_rs {
|
||||||
uint8_t version; /* SDR version (51h) */
|
uint8_t version; /* SDR version (51h) */
|
||||||
@ -787,6 +793,8 @@ double sdr_convert_sensor_reading(struct sdr_record_full_sensor * sensor, uint8_
|
|||||||
uint8_t sdr_convert_sensor_value_to_raw(struct sdr_record_full_sensor * sensor, double 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(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_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);
|
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_get_reservation(struct ipmi_intf * intf, uint16_t *reserve_id);
|
||||||
|
|
||||||
@ -809,6 +817,7 @@ int ipmi_sdr_list_cache_fromfile(struct ipmi_intf * intf, const char * ifile);
|
|||||||
void ipmi_sdr_list_empty(struct ipmi_intf * intf);
|
void ipmi_sdr_list_empty(struct ipmi_intf * intf);
|
||||||
int ipmi_sdr_print_info(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(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_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);
|
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);
|
||||||
|
|
||||||
|
@ -42,13 +42,6 @@
|
|||||||
#include <ipmitool/ipmi.h>
|
#include <ipmitool/ipmi.h>
|
||||||
#include <ipmitool/ipmi_sdr.h>
|
#include <ipmitool/ipmi_sdr.h>
|
||||||
|
|
||||||
/* ipmi sensor commands */
|
|
||||||
#define GET_SENSOR_READING 0x2d
|
|
||||||
#define GET_SENSOR_FACTORS 0x23
|
|
||||||
#define SET_SENSOR_THRESHOLDS 0x26
|
|
||||||
#define GET_SENSOR_THRESHOLDS 0x27
|
|
||||||
#define GET_SENSOR_TYPE 0x2f
|
|
||||||
|
|
||||||
/* threshold specification bits for analog sensors for get sensor threshold command
|
/* threshold specification bits for analog sensors for get sensor threshold command
|
||||||
* and set sensor threshold command
|
* and set sensor threshold command
|
||||||
*/
|
*/
|
||||||
|
@ -81,6 +81,14 @@ utos(uint32_t val, int bits)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ipmi_sdr_get_unit_string - return units for base/modifier
|
||||||
|
*
|
||||||
|
* @type: unit type
|
||||||
|
* @base: base
|
||||||
|
* @modifier: modifier
|
||||||
|
*
|
||||||
|
* returns pointer to static string
|
||||||
|
*/
|
||||||
char *
|
char *
|
||||||
ipmi_sdr_get_unit_string(uint8_t type, uint8_t base, uint8_t modifier)
|
ipmi_sdr_get_unit_string(uint8_t type, uint8_t base, uint8_t modifier)
|
||||||
{
|
{
|
||||||
@ -222,6 +230,53 @@ sdr_convert_sensor_value_to_raw(struct sdr_record_full_sensor * sensor,
|
|||||||
return (uint8_t)result;
|
return (uint8_t)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ipmi_sdr_get_sensor_thresholds - return thresholds for sensor
|
||||||
|
*
|
||||||
|
* @intf: ipmi interface
|
||||||
|
* @sensor: sensor number
|
||||||
|
*
|
||||||
|
* returns pointer to ipmi response
|
||||||
|
*/
|
||||||
|
struct ipmi_rs *
|
||||||
|
ipmi_sdr_get_sensor_thresholds(struct ipmi_intf * intf, uint8_t sensor)
|
||||||
|
{
|
||||||
|
struct ipmi_rq req;
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
req.msg.netfn = IPMI_NETFN_SE;
|
||||||
|
req.msg.cmd = GET_SENSOR_THRESHOLDS;
|
||||||
|
req.msg.data = &sensor;
|
||||||
|
req.msg.data_len = sizeof(sensor);
|
||||||
|
|
||||||
|
return intf->sendrecv(intf, &req);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ipmi_sdr_get_sensor_hysteresis - return hysteresis for sensor
|
||||||
|
*
|
||||||
|
* @intf: ipmi interface
|
||||||
|
* @sensor: sensor number
|
||||||
|
*
|
||||||
|
* returns pointer to ipmi response
|
||||||
|
*/
|
||||||
|
struct ipmi_rs *
|
||||||
|
ipmi_sdr_get_sensor_hysteresis(struct ipmi_intf * intf, uint8_t sensor)
|
||||||
|
{
|
||||||
|
struct ipmi_rq req;
|
||||||
|
uint8_t rqdata[2];
|
||||||
|
|
||||||
|
rqdata[0] = sensor;
|
||||||
|
rqdata[1] = 0xff; /* reserved */
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
req.msg.netfn = IPMI_NETFN_SE;
|
||||||
|
req.msg.cmd = GET_SENSOR_HYSTERESIS;
|
||||||
|
req.msg.data = rqdata;
|
||||||
|
req.msg.data_len = 2;
|
||||||
|
|
||||||
|
return intf->sendrecv(intf, &req);
|
||||||
|
}
|
||||||
|
|
||||||
/* ipmi_sdr_get_sensor_reading - retrieve a raw sensor reading
|
/* ipmi_sdr_get_sensor_reading - retrieve a raw sensor reading
|
||||||
*
|
*
|
||||||
* @intf: ipmi interface
|
* @intf: ipmi interface
|
||||||
@ -1151,6 +1206,20 @@ ipmi_sdr_print_sensor_full(struct ipmi_intf * intf,
|
|||||||
SENSOR_PRINT_THRESH("Lower critical", lower.critical, lcr);
|
SENSOR_PRINT_THRESH("Lower critical", lower.critical, lcr);
|
||||||
SENSOR_PRINT_THRESH("Lower non-critical", lower.non_critical, lnc);
|
SENSOR_PRINT_THRESH("Lower non-critical", lower.non_critical, lnc);
|
||||||
|
|
||||||
|
min_reading = (uint8_t)sdr_convert_sensor_reading(
|
||||||
|
sensor, sensor->threshold.hysteresis.positive);
|
||||||
|
if (min_reading == 0 || min_reading == 0xff)
|
||||||
|
printf(" Positive Hysteresis : Unspecified\n");
|
||||||
|
else
|
||||||
|
printf(" Positive Hysteresis : %.3f\n", (double)min_reading);
|
||||||
|
|
||||||
|
min_reading = (uint8_t)sdr_convert_sensor_reading(
|
||||||
|
sensor, sensor->threshold.hysteresis.negative);
|
||||||
|
if (min_reading == 0 || min_reading == 0xff)
|
||||||
|
printf(" Negative Hysteresis : Unspecified\n");
|
||||||
|
else
|
||||||
|
printf(" Negative Hysteresis : %.3f\n", (double)min_reading);
|
||||||
|
|
||||||
min_reading = (uint8_t)sdr_convert_sensor_reading(
|
min_reading = (uint8_t)sdr_convert_sensor_reading(
|
||||||
sensor, sensor->sensor_min);
|
sensor, sensor->sensor_min);
|
||||||
if ((sensor->unit.analog == 0 && sensor->sensor_min == 0x00) ||
|
if ((sensor->unit.analog == 0 && sensor->sensor_min == 0x00) ||
|
||||||
@ -1300,9 +1369,10 @@ get_offset(uint8_t x)
|
|||||||
*
|
*
|
||||||
* no meaningful return value
|
* no meaningful return value
|
||||||
*/
|
*/
|
||||||
static void ipmi_sdr_print_discrete_state_mini(
|
void ipmi_sdr_print_discrete_state_mini(
|
||||||
uint8_t sensor_type, uint8_t event_type,
|
const char * separator,
|
||||||
uint8_t state1, uint8_t state2)
|
uint8_t sensor_type, uint8_t event_type,
|
||||||
|
uint8_t state1, uint8_t state2)
|
||||||
{
|
{
|
||||||
uint8_t typ;
|
uint8_t typ;
|
||||||
struct ipmi_event_sensor_types *evt;
|
struct ipmi_event_sensor_types *evt;
|
||||||
@ -1326,14 +1396,14 @@ static void ipmi_sdr_print_discrete_state_mini(
|
|||||||
if (evt->offset > 7) {
|
if (evt->offset > 7) {
|
||||||
if ((1<<(evt->offset-8)) & state2) {
|
if ((1<<(evt->offset-8)) & state2) {
|
||||||
if (pre++ != 0)
|
if (pre++ != 0)
|
||||||
printf(", ");
|
printf("%s", separator);
|
||||||
printf("%s ", evt->desc);
|
printf("%s", evt->desc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((1<<evt->offset) & state1) {
|
if ((1<<evt->offset) & state1) {
|
||||||
if (pre++ != 0)
|
if (pre++ != 0)
|
||||||
printf(", ");
|
printf("%s", separator);
|
||||||
printf("%s ", evt->desc);
|
printf("%s", evt->desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
@ -1555,7 +1625,8 @@ ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dostate)
|
if (dostate)
|
||||||
ipmi_sdr_print_discrete_state_mini(sensor->sensor.type,
|
ipmi_sdr_print_discrete_state_mini(", ",
|
||||||
|
sensor->sensor.type,
|
||||||
sensor->event_type,
|
sensor->event_type,
|
||||||
rsp->data[2],
|
rsp->data[2],
|
||||||
rsp->data[3]);
|
rsp->data[3]);
|
||||||
@ -3615,7 +3686,6 @@ ipmi_sdr_print_type(struct ipmi_intf * intf, char * type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ipmi_sdr_print_entity - print entity's for an id/instance
|
/* ipmi_sdr_print_entity - print entity's for an id/instance
|
||||||
*
|
*
|
||||||
* @intf: ipmi interface
|
* @intf: ipmi interface
|
||||||
@ -3666,6 +3736,46 @@ ipmi_sdr_print_entity(struct ipmi_intf * intf, char * entitystr)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ipmi_sdr_print_entry_byid - print sdr entries identified by sensor id
|
||||||
|
*
|
||||||
|
* @intf: ipmi interface
|
||||||
|
* @argc: number of entries to print
|
||||||
|
* @argv: list of sensor ids
|
||||||
|
*
|
||||||
|
* returns 0 on success
|
||||||
|
* returns -1 on error
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
ipmi_sdr_print_entry_byid(struct ipmi_intf * intf, int argc, char ** argv)
|
||||||
|
{
|
||||||
|
struct sdr_record_list * sdr;
|
||||||
|
int rc = 0;
|
||||||
|
int v, i;
|
||||||
|
|
||||||
|
if (argc < 1) {
|
||||||
|
lprintf(LOG_ERR, "No Sensor ID supplied");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
v = verbose;
|
||||||
|
verbose = 1;
|
||||||
|
|
||||||
|
for (i=0; i<argc; i++) {
|
||||||
|
sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]);
|
||||||
|
if (sdr == NULL) {
|
||||||
|
lprintf(LOG_ERR, "Unable to find sensor id '%s'", argv[i]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ipmi_sdr_print_listentry(intf, sdr) < 0)
|
||||||
|
rc = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
verbose = v;
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/* ipmi_sdr_main - top-level handler for SDR subsystem
|
/* ipmi_sdr_main - top-level handler for SDR subsystem
|
||||||
*
|
*
|
||||||
* @intf: ipmi interface
|
* @intf: ipmi interface
|
||||||
@ -3741,6 +3851,9 @@ ipmi_sdr_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
else if (strncmp(argv[0], "info", 4) == 0) {
|
else if (strncmp(argv[0], "info", 4) == 0) {
|
||||||
rc = ipmi_sdr_print_info(intf);
|
rc = ipmi_sdr_print_info(intf);
|
||||||
}
|
}
|
||||||
|
else if (strncmp(argv[0], "get", 4) == 0) {
|
||||||
|
rc = ipmi_sdr_print_entry_byid(intf, argc-1, &argv[1]);
|
||||||
|
}
|
||||||
else if (strncmp(argv[0], "dump", 4) == 0) {
|
else if (strncmp(argv[0], "dump", 4) == 0) {
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
lprintf(LOG_ERR, "usage: sdr dump <filename>");
|
lprintf(LOG_ERR, "usage: sdr dump <filename>");
|
||||||
|
@ -49,21 +49,6 @@ extern int verbose;
|
|||||||
|
|
||||||
#define READING_UNAVAILABLE 0x20
|
#define READING_UNAVAILABLE 0x20
|
||||||
|
|
||||||
static
|
|
||||||
struct ipmi_rs *
|
|
||||||
ipmi_sensor_get_sensor_thresholds(struct ipmi_intf * intf, uint8_t sensor)
|
|
||||||
{
|
|
||||||
struct ipmi_rq req;
|
|
||||||
|
|
||||||
memset(&req, 0, sizeof(req));
|
|
||||||
req.msg.netfn = IPMI_NETFN_SE;
|
|
||||||
req.msg.cmd = GET_SENSOR_THRESHOLDS;
|
|
||||||
req.msg.data = &sensor;
|
|
||||||
req.msg.data_len = sizeof(sensor);
|
|
||||||
|
|
||||||
return intf->sendrecv(intf, &req);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
struct ipmi_rs *
|
struct ipmi_rs *
|
||||||
ipmi_sensor_set_sensor_thresholds(struct ipmi_intf * intf,
|
ipmi_sensor_set_sensor_thresholds(struct ipmi_intf * intf,
|
||||||
@ -248,7 +233,7 @@ ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
|
|||||||
/*
|
/*
|
||||||
* Get sensor thresholds
|
* Get sensor thresholds
|
||||||
*/
|
*/
|
||||||
rsp = ipmi_sensor_get_sensor_thresholds(intf, sensor->keys.sensor_num);
|
rsp = ipmi_sdr_get_sensor_thresholds(intf, sensor->keys.sensor_num);
|
||||||
if (rsp == NULL)
|
if (rsp == NULL)
|
||||||
thresh_available = 0;
|
thresh_available = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user