send errors to stderr,

propogate return codes to top level
This commit is contained in:
Duncan Laurie 2005-01-07 22:15:56 +00:00
parent 14ee3f2362
commit 87234ecd0f

View File

@ -38,6 +38,8 @@
#include <math.h> #include <math.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_sdr.h> #include <ipmitool/ipmi_sdr.h>
#include <ipmitool/ipmi_sel.h> #include <ipmitool/ipmi_sel.h>
@ -51,7 +53,6 @@ static
struct ipmi_rs * struct ipmi_rs *
ipmi_sensor_get_sensor_thresholds(struct ipmi_intf * intf, uint8_t sensor) ipmi_sensor_get_sensor_thresholds(struct ipmi_intf * intf, uint8_t sensor)
{ {
struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
@ -60,9 +61,7 @@ ipmi_sensor_get_sensor_thresholds(struct ipmi_intf * intf, uint8_t sensor)
req.msg.data = &sensor; req.msg.data = &sensor;
req.msg.data_len = sizeof(sensor); req.msg.data_len = sizeof(sensor);
rsp = intf->sendrecv(intf, &req); return intf->sendrecv(intf, &req);
return rsp;
} }
static static
@ -72,7 +71,6 @@ ipmi_sensor_set_sensor_thresholds(struct ipmi_intf * intf,
uint8_t threshold, uint8_t threshold,
uint8_t setting) uint8_t setting)
{ {
struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
static struct sensor_set_thresh_rq set_thresh_rq; static struct sensor_set_thresh_rq set_thresh_rq;
@ -100,12 +98,10 @@ ipmi_sensor_set_sensor_thresholds(struct ipmi_intf * intf,
req.msg.data = (uint8_t *)&set_thresh_rq; req.msg.data = (uint8_t *)&set_thresh_rq;
req.msg.data_len = sizeof(set_thresh_rq); req.msg.data_len = sizeof(set_thresh_rq);
rsp = intf->sendrecv(intf, &req); return intf->sendrecv(intf, &req);
return rsp;
} }
static void static int
ipmi_sensor_print_full_discrete(struct ipmi_intf * intf, ipmi_sensor_print_full_discrete(struct ipmi_intf * intf,
struct sdr_record_full_sensor * sensor) struct sdr_record_full_sensor * sensor)
{ {
@ -115,7 +111,7 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf * intf,
uint8_t val = 0; uint8_t val = 0;
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
if (!sensor) if (sensor == NULL)
return; return;
memset(id, 0, sizeof(id)); memset(id, 0, sizeof(id));
@ -125,42 +121,35 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf * intf,
* Get current reading * Get current reading
*/ */
rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num); rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num);
if (!rsp) if (rsp == NULL) {
{ lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
printf("Error reading sensor %s (#%02x)\n", id, sensor->keys.sensor_num); id, sensor->keys.sensor_num);
return; return -1;
} } else if (rsp->ccode > 0 || (rsp->data[1] & READING_UNAVAILABLE)) {
else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE))
{
validread = 0; validread = 0;
} } else {
else
{
/* convert RAW reading into units */ /* convert RAW reading into units */
val = rsp->data[0]; val = rsp->data[0];
} }
if (csv_output) if (csv_output)
{ {
/* NOT IMPLEMENTED */
} }
else else
{ {
if (!verbose) if (verbose == 0) {
{
/* output format /* output format
* id value units status thresholds.... * id value units status thresholds....
*/ */
printf("%-16s ", id); printf("%-16s ", id);
if (validread) if (validread) {
{
printf("| 0x%-8x | %-10s | 0x%02x%02x", printf("| 0x%-8x | %-10s | 0x%02x%02x",
val, val,
unitstr, unitstr,
rsp->data[2], rsp->data[2],
rsp->data[3]); rsp->data[3]);
} } else {
else
{
printf("| %-10s | %-10s | %-6s", printf("| %-10s | %-10s | %-6s",
"na", "na",
unitstr, unitstr,
@ -170,22 +159,24 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf * intf,
"na", "na", "na", "na", "na", "na"); "na", "na", "na", "na", "na", "na");
printf("\n"); printf("\n");
} } else {
else
{
printf("Sensor ID : %s (0x%x)\n", printf("Sensor ID : %s (0x%x)\n",
id, sensor->keys.sensor_num); id, sensor->keys.sensor_num);
printf(" Entity ID : %d.%d\n", printf(" Entity ID : %d.%d\n",
sensor->entity.id, sensor->entity.instance); sensor->entity.id, sensor->entity.instance);
printf(" Sensor Type (Discrete): %s\n", 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(sensor->sensor.type, sensor->event_type, rsp->data[2]); ipmi_sdr_print_discrete_state(sensor->sensor.type,
sensor->event_type,
rsp->data[2]);
printf("\n"); printf("\n");
} }
} }
return 0;
} }
static void static int
ipmi_sensor_print_full_analog(struct ipmi_intf * intf, ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
struct sdr_record_full_sensor * sensor) struct sdr_record_full_sensor * sensor)
{ {
@ -195,13 +186,14 @@ ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
char * status = NULL; char * status = NULL;
if (!sensor) if (sensor == NULL)
return; return -1;
/* only handle linear sensors (for now) */ /* only handle linear sensors (for now) */
if (sensor->linearization) { if (sensor->linearization) {
printf("non-linear!\n"); lprintf(LOG_ERR, "Sensor #%02x is non-linear",
return; sensor->keys.sensor_num);
return -1;
} }
memset(id, 0, sizeof(id)); memset(id, 0, sizeof(id));
@ -211,19 +203,17 @@ ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
* Get current reading * Get current reading
*/ */
rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num); rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num);
if (!rsp) if (rsp == NULL) {
{ lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
printf("Error reading sensor %s (#%02x)\n", id, sensor->keys.sensor_num); id, sensor->keys.sensor_num);
return; return -1;
} } else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE)) {
else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE))
{
validread = 0; validread = 0;
} } else {
else
{
/* convert RAW reading into units */ /* convert RAW reading into units */
val = rsp->data[0] ? sdr_convert_sensor_reading(sensor, rsp->data[0]) : 0; val = (rsp->data[0] > 0)
? sdr_convert_sensor_reading(sensor, rsp->data[0])
: 0;
status = (char*)ipmi_sdr_get_status(rsp->data[2]); status = (char*)ipmi_sdr_get_status(rsp->data[2]);
} }
@ -254,33 +244,27 @@ 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_sensor_get_sensor_thresholds(intf, sensor->keys.sensor_num);
if (!rsp) if (rsp == NULL)
thresh_available = 0; thresh_available = 0;
if (csv_output) if (csv_output)
{ {
/* NOT IPMLEMENTED */
} }
else else
{ {
if (!verbose) if (verbose == 0)
{ {
/* output format /* output format
* id value units status thresholds.... * id value units status thresholds....
*/ */
printf("%-16s ", id); printf("%-16s ", id);
if (validread) if (validread) {
{
printf("| %-10.3f | %-10s | %-6s", printf("| %-10.3f | %-10s | %-6s",
val, val, unitstr, status ? : "");
unitstr, } else {
status ? : "");
}
else
{
printf("| %-10s | %-10s | %-6s", printf("| %-10s | %-10s | %-6s",
"na", "na", unitstr, "na");
unitstr,
"na");
} }
if (thresh_available) if (thresh_available)
{ {
@ -373,33 +357,38 @@ ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
else else
printf(" Upper Non-Recoverable : na\n"); printf(" Upper Non-Recoverable : na\n");
} }
} else }
else
{
printf("Not Present\n"); printf("Not Present\n");
}
printf("\n"); printf("\n");
} }
} }
} }
void ipmi_sensor_print_full(struct ipmi_intf * intf, int
ipmi_sensor_print_full(struct ipmi_intf * intf,
struct sdr_record_full_sensor * sensor) struct sdr_record_full_sensor * sensor)
{ {
if (sensor->unit.analog != 3) if (sensor->unit.analog != 3)
ipmi_sensor_print_full_analog(intf, sensor); return ipmi_sensor_print_full_analog(intf, sensor);
else else
ipmi_sensor_print_full_discrete(intf, sensor); return ipmi_sensor_print_full_discrete(intf, sensor);
} }
void ipmi_sensor_print_compact(struct ipmi_intf * intf, int
ipmi_sensor_print_compact(struct ipmi_intf * intf,
struct sdr_record_compact_sensor * sensor) struct sdr_record_compact_sensor * sensor)
{ {
char id[17]; char id[17];
char * unitstr = "discrete"; char * unitstr = "discrete";
int validread=1; int validread = 1;
uint8_t val = 0; uint8_t val = 0;
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
if (!sensor) if (sensor == NULL)
return; return -1;
memset(id, 0, sizeof(id)); memset(id, 0, sizeof(id));
memcpy(id, sensor->id_string, 16); memcpy(id, sensor->id_string, 16);
@ -408,23 +397,20 @@ void ipmi_sensor_print_compact(struct ipmi_intf * intf,
* Get current reading * Get current reading
*/ */
rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num); rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num);
if (!rsp) if (rsp == NULL) {
{ lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
printf("Error reading sensor %s (#%02x)\n", id, sensor->keys.sensor_num); id, sensor->keys.sensor_num);
return; return -1;
} } else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE)) {
else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE))
{
validread = 0; validread = 0;
} } else {
else
{
/* convert RAW reading into units */ /* convert RAW reading into units */
val = rsp->data[0]; val = rsp->data[0];
} }
if (csv_output) if (csv_output)
{ {
/* NOT IMPLEMENTED */
} }
else else
{ {
@ -434,24 +420,18 @@ void ipmi_sensor_print_compact(struct ipmi_intf * intf,
* id value units status thresholds.... * id value units status thresholds....
*/ */
printf("%-16s ", id); printf("%-16s ", id);
if (validread)
{ if (validread) {
printf("| 0x%-8x | %-10s | 0x%02x%02x", printf("| 0x%-8x | %-10s | 0x%02x%02x",
val, val, unitstr,
unitstr, rsp->data[2], rsp->data[3]);
rsp->data[2], } else {
rsp->data[3]);
}
else
{
printf("| %-10s | %-10s | %-6s", printf("| %-10s | %-10s | %-6s",
"na", "na", unitstr, "na");
unitstr,
"na");
} }
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s", printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
"na", "na", "na", "na", "na", "na"); "na", "na", "na", "na", "na", "na");
printf("\n"); printf("\n");
} }
else else
@ -466,42 +446,54 @@ void ipmi_sensor_print_compact(struct ipmi_intf * intf,
printf("\n"); printf("\n");
} }
} }
return 0;
} }
static void static int
ipmi_sensor_list(struct ipmi_intf * intf) ipmi_sensor_list(struct ipmi_intf * intf)
{ {
struct sdr_get_rs * header; struct sdr_get_rs * header;
struct ipmi_sdr_iterator * itr; struct ipmi_sdr_iterator * itr;
int rc = 0;
if (verbose > 1) lprintf(LOG_DEBUG, "Querying SDR for sensor list");
printf("Querying SDR for sensor list\n");
itr = ipmi_sdr_start(intf); itr = ipmi_sdr_start(intf);
if (!itr) if (itr == NULL) {
{ lprintf(LOG_ERR, "Unable to open SDR for reading");
printf("Unable to open SDR for reading\n"); return -1;
return;
} }
while ((header = ipmi_sdr_get_next_header(intf, itr)) != NULL) while ((header = ipmi_sdr_get_next_header(intf, itr)) != NULL)
{ {
uint8_t * rec = ipmi_sdr_get_record(intf, header, itr); int r = 0;
if (!rec) uint8_t * rec;
rec = ipmi_sdr_get_record(intf, header, itr);
if (rec == NULL)
continue; continue;
switch(header->type) switch(header->type)
{ {
case SDR_RECORD_TYPE_FULL_SENSOR: case SDR_RECORD_TYPE_FULL_SENSOR:
ipmi_sensor_print_full(intf, (struct sdr_record_full_sensor *) rec); r = ipmi_sensor_print_full(intf,
(struct sdr_record_full_sensor *)rec);
break; break;
case SDR_RECORD_TYPE_COMPACT_SENSOR: case SDR_RECORD_TYPE_COMPACT_SENSOR:
ipmi_sensor_print_compact(intf, (struct sdr_record_compact_sensor *) rec); r = ipmi_sensor_print_compact(intf,
(struct sdr_record_compact_sensor *)rec);
break; break;
} }
free(rec); free(rec);
/* save any errors */
rc = (r == 0) ? rc : r;
} }
ipmi_sdr_end(intf, itr); ipmi_sdr_end(intf, itr);
return rc;
} }
static const struct valstr threshold_vals[] = { static const struct valstr threshold_vals[] = {
@ -514,29 +506,28 @@ static const struct valstr threshold_vals[] = {
{ 0x00, NULL }, { 0x00, NULL },
}; };
static void static int
ipmi_sensor_set_threshold(struct ipmi_intf * intf, int argc, char ** argv) ipmi_sensor_set_threshold(struct ipmi_intf * intf, int argc, char ** argv)
{ {
char * id, char * id, * thresh;
* thresh;
uint8_t settingMask; uint8_t settingMask;
float setting; float setting;
struct sdr_record_list * sdr; struct sdr_record_list * sdr;
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
if (argc < 3 || !strncmp(argv[0], "help", 4)) if (argc < 3 || strncmp(argv[0], "help", 4) == 0)
{ {
printf("sensor thresh <id> <threshold> <setting>\n"); lprintf(LOG_NOTICE, "sensor thresh <id> <threshold> <setting>");
printf(" id : name of the sensor for which threshold is to be set\n"); lprintf(LOG_NOTICE, " id : name of the sensor for which threshold is to be set");
printf(" threshold : which threshold to set\n"); lprintf(LOG_NOTICE, " threshold : which threshold to set");
printf(" unr = upper non-recoverable\n"); lprintf(LOG_NOTICE, " unr = upper non-recoverable");
printf(" ucr = upper critical\n"); lprintf(LOG_NOTICE, " ucr = upper critical");
printf(" unc = upper non-critical\n"); lprintf(LOG_NOTICE, " unc = upper non-critical");
printf(" lnc = lower non-critical\n"); lprintf(LOG_NOTICE, " lnc = lower non-critical");
printf(" lcr = lower critical\n"); lprintf(LOG_NOTICE, " lcr = lower critical");
printf(" lnr = lower non-recoverable\n"); lprintf(LOG_NOTICE, " lnr = lower non-recoverable");
printf(" setting : the value to set the threshold to\n"); lprintf(LOG_NOTICE, " setting : the value to set the threshold to");
return; return 0;
} }
ipmi_intf_session_set_privlvl(intf, IPMI_SESSION_PRIV_ADMIN); ipmi_intf_session_set_privlvl(intf, IPMI_SESSION_PRIV_ADMIN);
@ -544,124 +535,138 @@ ipmi_sensor_set_threshold(struct ipmi_intf * intf, int argc, char ** argv)
id = argv[0]; id = argv[0];
thresh = argv[1]; thresh = argv[1];
setting = (float)atof(argv[2]); setting = (float)atof(argv[2]);
if (!strcmp(thresh, "unr")) if (strncmp(thresh, "unr", 3) == 0)
{
settingMask = UPPER_NON_RECOV_SPECIFIED; settingMask = UPPER_NON_RECOV_SPECIFIED;
} else if (strncmp(thresh, "ucr", 3) == 0)
else if (!strcmp(thresh, "ucr"))
{
settingMask = UPPER_CRIT_SPECIFIED; settingMask = UPPER_CRIT_SPECIFIED;
} else if (strncmp(thresh, "unc", 3) == 0)
else if (!strcmp(thresh, "unc"))
{
settingMask = UPPER_NON_CRIT_SPECIFIED; settingMask = UPPER_NON_CRIT_SPECIFIED;
} else if (strncmp(thresh, "lnc", 3) == 0)
else if (!strcmp(thresh, "lnc"))
{
settingMask = LOWER_NON_CRIT_SPECIFIED; settingMask = LOWER_NON_CRIT_SPECIFIED;
} else if (strncmp(thresh, "lcr", 3) == 0)
else if (!strcmp(thresh, "lcr"))
{
settingMask = LOWER_CRIT_SPECIFIED; settingMask = LOWER_CRIT_SPECIFIED;
} else if (strncmp(thresh, "lnr", 3) == 0)
else if (!strcmp(thresh, "lnr"))
{
settingMask = LOWER_NON_RECOV_SPECIFIED; settingMask = LOWER_NON_RECOV_SPECIFIED;
} else {
else lprintf(LOG_ERR, "Valid threshold not specified!");
{ return -1;
printf("Valid threshold not specified!\n");
return;
} }
printf("Locating sensor record...\n"); printf("Locating sensor record...\n");
/* lookup by sensor name */ /* lookup by sensor name */
sdr = ipmi_sdr_find_sdr_byid(intf, id); sdr = ipmi_sdr_find_sdr_byid(intf, id);
if (sdr) if (sdr == NULL) {
{ lprintf(LOG_ERR, "Sensor data record not found!");
if (sdr->type != SDR_RECORD_TYPE_FULL_SENSOR) return -1;
{
printf("Invalid sensor type %02x\n", sdr->type);
} }
else
{ if (sdr->type != SDR_RECORD_TYPE_FULL_SENSOR) {
lprintf(LOG_ERR, "Invalid sensor type %02x", sdr->type);
return -1;
}
printf("Setting sensor \"%s\" %s threshold to %.3f\n", printf("Setting sensor \"%s\" %s threshold to %.3f\n",
sdr->record.full->id_string, sdr->record.full->id_string,
val2str(settingMask, threshold_vals), setting); val2str(settingMask, threshold_vals), setting);
rsp = ipmi_sensor_set_sensor_thresholds(intf, rsp = ipmi_sensor_set_sensor_thresholds(intf,
sdr->record.full->keys.sensor_num, settingMask, sdr->record.full->keys.sensor_num, settingMask,
sdr_convert_sensor_value_to_raw(sdr->record.full, setting)); sdr_convert_sensor_value_to_raw(sdr->record.full, setting));
if (rsp && rsp->ccode)
printf("Error setting threshold: 0x%x\n", rsp->ccode); if (rsp == NULL) {
lprintf(LOG_ERR, "Error setting threshold");
return -1;
} }
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error setting threshold: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
} }
else
{ return 0;
printf("Sensor data record not found!\n");
}
} }
static void ipmi_sensor_get(struct ipmi_intf * intf, int argc, char ** argv) static int
ipmi_sensor_get(struct ipmi_intf * intf, int argc, char ** argv)
{ {
struct sdr_record_list * sdr; struct sdr_record_list * sdr;
int i, v; int i, v;
int rc = 0;
if (argc < 1 || !strncmp(argv[0], "help", 4)) { if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
printf("sensor get <id> ... [id]\n"); lprintf(LOG_NOTICE, "sensor get <id> ... [id]");
printf(" id : name of desired sensor\n"); lprintf(LOG_NOTICE, " id : name of desired sensor");
return; return -1;
} }
printf("Locating sensor record...\n"); printf("Locating sensor record...\n");
/* lookup by sensor name */ /* lookup by sensor name */
for (i=0; i<argc; i++) { for (i=0; i<argc; i++) {
int r = 0;
sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]); sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]);
if (sdr) { if (sdr == NULL) {
lprintf(LOG_ERR, "Sensor data record \"%s\" not found!",
argv[i]);
rc = -1;
continue;
}
/* need to set verbose level to 1 */
v = verbose; v = verbose;
verbose = 1; verbose = 1;
switch (sdr->type) { switch (sdr->type) {
case SDR_RECORD_TYPE_FULL_SENSOR: case SDR_RECORD_TYPE_FULL_SENSOR:
ipmi_sensor_print_full(intf, sdr->record.full); r = ipmi_sensor_print_full(intf, sdr->record.full);
break; break;
case SDR_RECORD_TYPE_COMPACT_SENSOR: case SDR_RECORD_TYPE_COMPACT_SENSOR:
ipmi_sensor_print_compact(intf, sdr->record.compact); r = ipmi_sensor_print_compact(intf, sdr->record.compact);
break; break;
case SDR_RECORD_TYPE_EVENTONLY_SENSOR: case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
ipmi_sdr_print_sensor_eventonly(intf, sdr->record.eventonly); r = ipmi_sdr_print_sensor_eventonly(intf, sdr->record.eventonly);
break; break;
case SDR_RECORD_TYPE_FRU_DEVICE_LOCATOR: case SDR_RECORD_TYPE_FRU_DEVICE_LOCATOR:
ipmi_sdr_print_sensor_fru_locator(intf, sdr->record.fruloc); r = ipmi_sdr_print_sensor_fru_locator(intf, sdr->record.fruloc);
break; break;
case SDR_RECORD_TYPE_MC_DEVICE_LOCATOR: case SDR_RECORD_TYPE_MC_DEVICE_LOCATOR:
ipmi_sdr_print_sensor_mc_locator(intf, sdr->record.mcloc); r = ipmi_sdr_print_sensor_mc_locator(intf, sdr->record.mcloc);
break; break;
} }
verbose = v; verbose = v;
} else {
printf("Sensor data record \"%s\" not found!\n", argv[i]); /* save errors */
} rc = (r == 0) ? rc : r;
} }
return rc;
} }
int int
ipmi_sensor_main(struct ipmi_intf * intf, int argc, char ** argv) ipmi_sensor_main(struct ipmi_intf * intf, int argc, char ** argv)
{ {
if (!argc) int rc = 0;
ipmi_sensor_list(intf);
else if (!strncmp(argv[0], "help", 4)) { if (argc == 0) {
printf("Sensor Commands: list thresh get\n"); rc = ipmi_sensor_list(intf);
} }
else if (!strncmp(argv[0], "list", 4)) { else if (strncmp(argv[0], "help", 4) == 0) {
ipmi_sensor_list(intf); lprintf(LOG_NOTICE, "Sensor Commands: list thresh get");
} }
else if (!strncmp(argv[0], "thresh", 5)) { else if (strncmp(argv[0], "list", 4) == 0) {
ipmi_sensor_set_threshold(intf, argc-1, &argv[1]); rc = ipmi_sensor_list(intf);
} }
else if (!strncmp(argv[0], "get", 3)) { else if (strncmp(argv[0], "thresh", 5) == 0) {
ipmi_sensor_get(intf, argc-1, &argv[1]); rc = ipmi_sensor_set_threshold(intf, argc-1, &argv[1]);
} }
else else if (strncmp(argv[0], "get", 3) == 0) {
printf("Invalid sensor command: %s\n", argv[0]); rc = ipmi_sensor_get(intf, argc-1, &argv[1]);
return 0; }
else {
lprintf(LOG_ERR, "Invalid sensor command: %s",
argv[0]);
rc = -1;
}
return rc;
} }