mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
Fix chassis poh command:
- The counter value was always interpreted as hours, the minutes-per-count value wasn't regarded. - No attention was paid to CPU endianness when reading the 32-bit counter value. Patch submitted by Ingo van Lil (inguin at users dot sourceforge dot net). Sourceforge patch ID: 1592950
This commit is contained in:
parent
798228cb72
commit
b06f6bdbb5
@ -188,7 +188,10 @@ ipmi_chassis_poh(struct ipmi_intf * intf)
|
|||||||
{
|
{
|
||||||
struct ipmi_rs * rsp;
|
struct ipmi_rs * rsp;
|
||||||
struct ipmi_rq req;
|
struct ipmi_rq req;
|
||||||
|
uint8_t mins_per_count;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
|
float minutes;
|
||||||
|
uint32_t days, hours;
|
||||||
|
|
||||||
memset(&req, 0, sizeof(req));
|
memset(&req, 0, sizeof(req));
|
||||||
req.msg.netfn = IPMI_NETFN_CHASSIS;
|
req.msg.netfn = IPMI_NETFN_CHASSIS;
|
||||||
@ -205,10 +208,24 @@ ipmi_chassis_poh(struct ipmi_intf * intf)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mins_per_count = rsp->data[0];
|
||||||
memcpy(&count, rsp->data+1, 4);
|
memcpy(&count, rsp->data+1, 4);
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
count = BSWAP_32(count);
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("POH Counter : %li hours total (%li days, %li hours)\n",
|
minutes = (float)count * mins_per_count;
|
||||||
(long)count, (long)(count / 24), (long)(count % 24));
|
days = minutes / 1440;
|
||||||
|
minutes -= (float)days * 1440;
|
||||||
|
hours = minutes / 60;
|
||||||
|
minutes -= hours * 60;
|
||||||
|
|
||||||
|
if (mins_per_count < 60) {
|
||||||
|
printf("POH Counter : %li days, %li hours, %li minutes\n",
|
||||||
|
days, hours, (long)minutes);
|
||||||
|
} else {
|
||||||
|
printf("POH Counter : %li days, %li hours\n", days, hours);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user