IPMI:如何使用ipmimonitoring-sensors.c找到阈值

时间:2017-05-18 09:53:26

标签: c ipmi

我正在编写一个API来报告由Socket守护程序查询的IPMI硬件信息,Socket守护程序在客户端上托管,远程服务器将发送命令来查询主机硬件状态。

我已成功编写API,API使用FreeIPMI库来获取CPU和M / B的温度。潜水到ipmi-sensors源代码后,我发现很难跳过输出到stdout。要获取stdout,我使用dup(STDOUT_FILENO)并重定向到管道,刷新管道,解析字符串内容,提取我需要的信息。

现在一切都还可以,但我面临另一个问题,我需要将FreeIPMI编译为静态库。

我找到了一个链接HOW to build freeipmi commands with static libraries instead of shared libraries,FreeIPMI Albert Chu的维护者说

./configure CFLAGS="-static"

成功构建静态库,但无法构建ipmi-sensors,存在许多编译器错误。很沮丧。

之后,我在FreeIPMI项目文件夹ipmimonitoring-sensors.c中找到另一个文件,使用命令

进行编译
gcc -o ipmimonitoring-sensors ipmimonitoring-sensors.c -lipmimonitoring

是的,它有效。

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'

但是,我怎样才能将阈值设为ipmi-sensors -v,我知道会报告NominalWarningCritical。但我想报告LowHigh,而不仅仅是OK事件。

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'

提前致谢。

1 个答案:

答案 0 :(得分:1)

FreeIPMI维护者在这里。我担心ipmimonitoring库中没有阈值信息。该库的主要目的是将这些信息从用户那里抽象出来。

可以通过从SDR获取信息来检索每个传感器的阈值信​​息,您可以使用libfreeipmi SDR库。 Ipmi监控确实为您提供了与每个传感器读取相关的SDR记录ID,以便您可以将传感器映射到正确的SDR记录ID。