mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
ID: 3601106 - # ipmitool sensor get NACname; output incorrect/inconsistent
Commit re-works output of # ipmitool sensor get; command. It removes calls to sensor specific functions with call to ipmi_sdr_print_listentry(). This way, output is unified with the output of '-v sdr list' and actually has corrent information. Well, at least errors are gone and no information seems to be missing. Commit fixes help and return codes as well.
This commit is contained in:
parent
76ed820e03
commit
c97d9d5b85
@ -42,6 +42,8 @@
|
|||||||
#include <ipmitool/ipmi_sensor.h>
|
#include <ipmitool/ipmi_sensor.h>
|
||||||
|
|
||||||
extern int verbose;
|
extern int verbose;
|
||||||
|
void printf_sensor_get_usage();
|
||||||
|
|
||||||
// Macro's for Reading the current sensor Data.
|
// Macro's for Reading the current sensor Data.
|
||||||
#define SCANNING_DISABLED 0x40
|
#define SCANNING_DISABLED 0x40
|
||||||
#define READING_UNAVAILABLE 0x20
|
#define READING_UNAVAILABLE 0x20
|
||||||
@ -847,17 +849,18 @@ ipmi_sensor_get(struct ipmi_intf *intf, int argc, char **argv)
|
|||||||
int i, v;
|
int i, v;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
|
if (argc < 1) {
|
||||||
lprintf(LOG_NOTICE, "sensor get <id> ... [id]");
|
lprintf(LOG_ERR, "Not enough parameters given.");
|
||||||
lprintf(LOG_NOTICE, " id : name of desired sensor");
|
printf_sensor_get_usage();
|
||||||
return -1;
|
return (-1);
|
||||||
|
} else if (strcmp(argv[0], "help") == 0) {
|
||||||
|
printf_sensor_get_usage();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
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 == NULL) {
|
if (sdr == NULL) {
|
||||||
lprintf(LOG_ERR, "Sensor data record \"%s\" not found!",
|
lprintf(LOG_ERR, "Sensor data record \"%s\" not found!",
|
||||||
@ -865,37 +868,14 @@ ipmi_sensor_get(struct ipmi_intf *intf, int argc, char **argv)
|
|||||||
rc = -1;
|
rc = -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* need to set verbose level to 1 */
|
/* need to set verbose level to 1 */
|
||||||
v = verbose;
|
v = verbose;
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
switch (sdr->type) {
|
if (ipmi_sdr_print_listentry(intf, sdr) < 0) {
|
||||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
rc = (-1);
|
||||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
|
||||||
r = ipmi_sensor_print_fc(intf, sdr->record.common,
|
|
||||||
sdr->type);
|
|
||||||
break;
|
|
||||||
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
|
|
||||||
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);
|
|
||||||
break;
|
|
||||||
case SDR_RECORD_TYPE_MC_DEVICE_LOCATOR:
|
|
||||||
r = ipmi_sdr_print_sensor_mc_locator(intf,
|
|
||||||
sdr->record.mcloc);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
verbose = v;
|
verbose = v;
|
||||||
|
|
||||||
/* save errors */
|
|
||||||
rc = (r == 0) ? rc : r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -923,3 +903,14 @@ ipmi_sensor_main(struct ipmi_intf *intf, int argc, char **argv)
|
|||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* printf_sensor_get_usage - print usage for # ipmitool sensor get NAC;
|
||||||
|
*
|
||||||
|
* @returns: void
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
printf_sensor_get_usage()
|
||||||
|
{
|
||||||
|
lprintf(LOG_NOTICE, "sensor get <id> ... [id]");
|
||||||
|
lprintf(LOG_NOTICE, " id : name of desired sensor");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user