I am writing an API to report IPMI hardware information queried by a Socket Daemon, the Socket Daemon is hosting on a client, and a remote server will send command to query the host hardware status.
I've successfully write an API, the API use FreeIPMI library, to get the CPU and M/B's temperature. After diving to ipmi-sensors source code, I found that is very difficult to skip output to stdout. To get the stdout, I use dup(STDOUT_FILENO)
and redirect to a pipe, flush the pipe, parse the string content, extract information I need.
Everything is OK now, but I face another problem, I need to compile FreeIPMI as a static library.
I found a link HOW to build freeipmi commands with static libraries instead of shared libraries, and the maintainer of FreeIPMI Albert Chu said that
./configure CFLAGS="-static"
Build static libraries successfully, but fail to build the ipmi-sensors, there are many compiler error. So frustrated.
After that, I find another file in FreeIPMI project folder ipmimonitoring-sensors.c, compile with command
gcc -o ipmimonitoring-sensors ipmimonitoring-sensors.c -lipmimonitoring
Yes, it works.
sudo ./ipmimonitoring-sensors
Record ID, Sensor Name, Sensor Number, Sensor Type, Sensor State, Sensor Reading, Sensor Units, Sensor Event/Reading Type Code, Sensor Event Bitmask, Sensor Event String
3, CPU0_TEMP, 33, Temperature, Nominal, 46.00, C, 1h, C0h, 'OK'
12, DIMM_P0_B0, 4, Temperature, Nominal, 39.00, C, 1h, C0h, 'OK'
13, DIMM_P0_B1, 5, Temperature, Nominal, 40.00, C, 1h, C0h, 'OK'
59, P12V, 64, Voltage, Nominal, 12.06, V, 1h, C0h, 'OK'
60, P5V, 65, Voltage, Nominal, 4.99, V, 1h, C0h, 'OK'
61, P3V3, 66, Voltage, Nominal, 3.27, V, 1h, C0h, 'OK'
62, P5V_STBY, 67, Voltage, Nominal, 4.99, V, 1h, C0h, 'OK'
64, P_VBAT, 69, Voltage, Nominal, 3.22, V, 1h, C0h, 'OK'
65, P_VCCIN_P0, 70, Voltage, Nominal, 1.80, V, 1h, C0h, 'OK'
67, P_1V2_BXD, 72, Voltage, Nominal, 1.23, V, 1h, C0h, 'OK'
71, P_1V05_BXD, 76, Voltage, Nominal, 1.06, V, 1h, C0h, 'OK'
72, P_1V5_BXD, 77, Voltage, Nominal, 1.53, V, 1h, C0h, 'OK'
73, P_VCCSCFUSESUS, 78, Voltage, Nominal, 1.72, V, 1h, C0h, 'OK'
74, P_VCCKRHV_BXD, 79, Voltage, Nominal, 1.32, V, 1h, C0h, 'OK'
136, CPU0_FAN, 96, Fan, Nominal, 2700.00, RPM, 1h, C0h, 'OK'
185, CPU0, 156, Processor, Nominal, N/A, N/A, 6Fh, 80h, 'Processor Presence detected'
202, MB_TEMP1, 51, Temperature, Nominal, 50.00, C, 1h, C0h, 'OK'
205, SEL, 152, Event Logging Disabled, Nominal, N/A, N/A, 6Fh, 0h, 'OK'
But, how can I get the threshold values as ipmi-sensors -v
, I know that will report Nominal
, Warning
and Critical
. But I'd like to report Low
, High
, not just only OK
event.
Entity Instance Type: Physical Entity
Event/Reading Type Code: 1h
Lower Critical Threshold: 0.000000 C
Upper Critical Threshold: 60.000000 C
Lower Non-Critical Threshold: 5.000000 C
Upper Non-Critical Threshold: 55.000000 C
Lower Non-Recoverable Threshold: N/A
Upper Non-Recoverable Threshold: N/A
Sensor Min. Reading: -128.000000 C
Sensor Max. Reading: 127.000000 C
Normal Min.: 0.000000 C
Normal Max.: 54.000000 C
Nominal Reading: 35.000000 C
Sensor Reading: 50.000000 C
Sensor Event: 'OK'
Thanks in advance.