freeipmi_plugin.c 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. /*
  3. * netdata freeipmi.plugin
  4. * Copyright (C) 2017 Costa Tsaousis
  5. * GPL v3+
  6. *
  7. * Based on:
  8. * ipmimonitoring-sensors.c,v 1.51 2016/11/02 23:46:24 chu11 Exp
  9. * ipmimonitoring-sel.c,v 1.51 2016/11/02 23:46:24 chu11 Exp
  10. *
  11. * Copyright (C) 2007-2015 Lawrence Livermore National Security, LLC.
  12. * Copyright (C) 2006-2007 The Regents of the University of California.
  13. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  14. * Written by Albert Chu <chu11@llnl.gov>
  15. * UCRL-CODE-222073
  16. */
  17. #include "../../libnetdata/libnetdata.h"
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <stdint.h>
  21. #include <string.h>
  22. #include <assert.h>
  23. #include <errno.h>
  24. #include <unistd.h>
  25. #include <sys/time.h>
  26. #ifdef HAVE_FREEIPMI
  27. // ----------------------------------------------------------------------------
  28. // callback required by fatal()
  29. void netdata_cleanup_and_exit(int ret) {
  30. exit(ret);
  31. }
  32. // callbacks required by popen()
  33. void signals_block(void) {};
  34. void signals_unblock(void) {};
  35. void signals_reset(void) {};
  36. // callback required by eval()
  37. int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) {
  38. (void)variable;
  39. (void)hash;
  40. (void)rc;
  41. (void)result;
  42. return 0;
  43. };
  44. // required by get_system_cpus()
  45. char *netdata_configured_host_prefix = "";
  46. // ----------------------------------------------------------------------------
  47. #include <ipmi_monitoring.h>
  48. #include <ipmi_monitoring_bitmasks.h>
  49. /* Communication Configuration - Initialize accordingly */
  50. /* Hostname, NULL for In-band communication, non-null for a hostname */
  51. char *hostname = NULL;
  52. /* In-band Communication Configuration */
  53. int driver_type = -1; // IPMI_MONITORING_DRIVER_TYPE_KCS; /* or -1 for default */
  54. int disable_auto_probe = 0; /* probe for in-band device */
  55. unsigned int driver_address = 0; /* not used if probing */
  56. unsigned int register_spacing = 0; /* not used if probing */
  57. char *driver_device = NULL; /* not used if probing */
  58. /* Out-of-band Communication Configuration */
  59. int protocol_version = -1; //IPMI_MONITORING_PROTOCOL_VERSION_1_5; /* or -1 for default */
  60. char *username = "foousername";
  61. char *password = "foopassword";
  62. unsigned char *ipmi_k_g = NULL;
  63. unsigned int ipmi_k_g_len = 0;
  64. int privilege_level = -1; // IPMI_MONITORING_PRIVILEGE_LEVEL_USER; /* or -1 for default */
  65. int authentication_type = -1; // IPMI_MONITORING_AUTHENTICATION_TYPE_MD5; /* or -1 for default */
  66. int cipher_suite_id = 0; /* or -1 for default */
  67. int session_timeout = 0; /* 0 for default */
  68. int retransmission_timeout = 0; /* 0 for default */
  69. /* Workarounds - specify workaround flags if necessary */
  70. unsigned int workaround_flags = 0;
  71. /* Initialize w/ record id numbers to only monitor specific record ids */
  72. unsigned int record_ids[] = {0};
  73. unsigned int record_ids_length = 0;
  74. /* Initialize w/ sensor types to only monitor specific sensor types
  75. * see ipmi_monitoring.h sensor types list.
  76. */
  77. unsigned int sensor_types[] = {0};
  78. unsigned int sensor_types_length = 0;
  79. /* Set to an appropriate alternate if desired */
  80. char *sdr_cache_directory = "/tmp";
  81. char *sensor_config_file = NULL;
  82. /* Set to 1 or 0 to enable these sensor reading flags
  83. * - See ipmi_monitoring.h for descriptions of these flags.
  84. */
  85. int reread_sdr_cache = 0;
  86. int ignore_non_interpretable_sensors = 1;
  87. int bridge_sensors = 0;
  88. int interpret_oem_data = 0;
  89. int shared_sensors = 0;
  90. int discrete_reading = 0;
  91. int ignore_scanning_disabled = 0;
  92. int assume_bmc_owner = 0;
  93. int entity_sensor_names = 0;
  94. /* Initialization flags
  95. *
  96. * Most commonly bitwise OR IPMI_MONITORING_FLAGS_DEBUG and/or
  97. * IPMI_MONITORING_FLAGS_DEBUG_IPMI_PACKETS for extra debugging
  98. * information.
  99. */
  100. unsigned int ipmimonitoring_init_flags = 0;
  101. int errnum;
  102. // ----------------------------------------------------------------------------
  103. // SEL only variables
  104. /* Initialize w/ date range to only monitoring specific date range */
  105. char *date_begin = NULL; /* use MM/DD/YYYY format */
  106. char *date_end = NULL; /* use MM/DD/YYYY format */
  107. int assume_system_event_record = 0;
  108. char *sel_config_file = NULL;
  109. // ----------------------------------------------------------------------------
  110. // functions common to sensors and SEL
  111. static void
  112. _init_ipmi_config (struct ipmi_monitoring_ipmi_config *ipmi_config)
  113. {
  114. assert (ipmi_config);
  115. ipmi_config->driver_type = driver_type;
  116. ipmi_config->disable_auto_probe = disable_auto_probe;
  117. ipmi_config->driver_address = driver_address;
  118. ipmi_config->register_spacing = register_spacing;
  119. ipmi_config->driver_device = driver_device;
  120. ipmi_config->protocol_version = protocol_version;
  121. ipmi_config->username = username;
  122. ipmi_config->password = password;
  123. ipmi_config->k_g = ipmi_k_g;
  124. ipmi_config->k_g_len = ipmi_k_g_len;
  125. ipmi_config->privilege_level = privilege_level;
  126. ipmi_config->authentication_type = authentication_type;
  127. ipmi_config->cipher_suite_id = cipher_suite_id;
  128. ipmi_config->session_timeout_len = session_timeout;
  129. ipmi_config->retransmission_timeout_len = retransmission_timeout;
  130. ipmi_config->workaround_flags = workaround_flags;
  131. }
  132. #ifdef NETDATA_COMMENTED
  133. static const char *
  134. _get_sensor_type_string (int sensor_type)
  135. {
  136. switch (sensor_type)
  137. {
  138. case IPMI_MONITORING_SENSOR_TYPE_RESERVED:
  139. return ("Reserved");
  140. case IPMI_MONITORING_SENSOR_TYPE_TEMPERATURE:
  141. return ("Temperature");
  142. case IPMI_MONITORING_SENSOR_TYPE_VOLTAGE:
  143. return ("Voltage");
  144. case IPMI_MONITORING_SENSOR_TYPE_CURRENT:
  145. return ("Current");
  146. case IPMI_MONITORING_SENSOR_TYPE_FAN:
  147. return ("Fan");
  148. case IPMI_MONITORING_SENSOR_TYPE_PHYSICAL_SECURITY:
  149. return ("Physical Security");
  150. case IPMI_MONITORING_SENSOR_TYPE_PLATFORM_SECURITY_VIOLATION_ATTEMPT:
  151. return ("Platform Security Violation Attempt");
  152. case IPMI_MONITORING_SENSOR_TYPE_PROCESSOR:
  153. return ("Processor");
  154. case IPMI_MONITORING_SENSOR_TYPE_POWER_SUPPLY:
  155. return ("Power Supply");
  156. case IPMI_MONITORING_SENSOR_TYPE_POWER_UNIT:
  157. return ("Power Unit");
  158. case IPMI_MONITORING_SENSOR_TYPE_COOLING_DEVICE:
  159. return ("Cooling Device");
  160. case IPMI_MONITORING_SENSOR_TYPE_OTHER_UNITS_BASED_SENSOR:
  161. return ("Other Units Based Sensor");
  162. case IPMI_MONITORING_SENSOR_TYPE_MEMORY:
  163. return ("Memory");
  164. case IPMI_MONITORING_SENSOR_TYPE_DRIVE_SLOT:
  165. return ("Drive Slot");
  166. case IPMI_MONITORING_SENSOR_TYPE_POST_MEMORY_RESIZE:
  167. return ("POST Memory Resize");
  168. case IPMI_MONITORING_SENSOR_TYPE_SYSTEM_FIRMWARE_PROGRESS:
  169. return ("System Firmware Progress");
  170. case IPMI_MONITORING_SENSOR_TYPE_EVENT_LOGGING_DISABLED:
  171. return ("Event Logging Disabled");
  172. case IPMI_MONITORING_SENSOR_TYPE_WATCHDOG1:
  173. return ("Watchdog 1");
  174. case IPMI_MONITORING_SENSOR_TYPE_SYSTEM_EVENT:
  175. return ("System Event");
  176. case IPMI_MONITORING_SENSOR_TYPE_CRITICAL_INTERRUPT:
  177. return ("Critical Interrupt");
  178. case IPMI_MONITORING_SENSOR_TYPE_BUTTON_SWITCH:
  179. return ("Button/Switch");
  180. case IPMI_MONITORING_SENSOR_TYPE_MODULE_BOARD:
  181. return ("Module/Board");
  182. case IPMI_MONITORING_SENSOR_TYPE_MICROCONTROLLER_COPROCESSOR:
  183. return ("Microcontroller/Coprocessor");
  184. case IPMI_MONITORING_SENSOR_TYPE_ADD_IN_CARD:
  185. return ("Add In Card");
  186. case IPMI_MONITORING_SENSOR_TYPE_CHASSIS:
  187. return ("Chassis");
  188. case IPMI_MONITORING_SENSOR_TYPE_CHIP_SET:
  189. return ("Chip Set");
  190. case IPMI_MONITORING_SENSOR_TYPE_OTHER_FRU:
  191. return ("Other Fru");
  192. case IPMI_MONITORING_SENSOR_TYPE_CABLE_INTERCONNECT:
  193. return ("Cable/Interconnect");
  194. case IPMI_MONITORING_SENSOR_TYPE_TERMINATOR:
  195. return ("Terminator");
  196. case IPMI_MONITORING_SENSOR_TYPE_SYSTEM_BOOT_INITIATED:
  197. return ("System Boot Initiated");
  198. case IPMI_MONITORING_SENSOR_TYPE_BOOT_ERROR:
  199. return ("Boot Error");
  200. case IPMI_MONITORING_SENSOR_TYPE_OS_BOOT:
  201. return ("OS Boot");
  202. case IPMI_MONITORING_SENSOR_TYPE_OS_CRITICAL_STOP:
  203. return ("OS Critical Stop");
  204. case IPMI_MONITORING_SENSOR_TYPE_SLOT_CONNECTOR:
  205. return ("Slot/Connector");
  206. case IPMI_MONITORING_SENSOR_TYPE_SYSTEM_ACPI_POWER_STATE:
  207. return ("System ACPI Power State");
  208. case IPMI_MONITORING_SENSOR_TYPE_WATCHDOG2:
  209. return ("Watchdog 2");
  210. case IPMI_MONITORING_SENSOR_TYPE_PLATFORM_ALERT:
  211. return ("Platform Alert");
  212. case IPMI_MONITORING_SENSOR_TYPE_ENTITY_PRESENCE:
  213. return ("Entity Presence");
  214. case IPMI_MONITORING_SENSOR_TYPE_MONITOR_ASIC_IC:
  215. return ("Monitor ASIC/IC");
  216. case IPMI_MONITORING_SENSOR_TYPE_LAN:
  217. return ("LAN");
  218. case IPMI_MONITORING_SENSOR_TYPE_MANAGEMENT_SUBSYSTEM_HEALTH:
  219. return ("Management Subsystem Health");
  220. case IPMI_MONITORING_SENSOR_TYPE_BATTERY:
  221. return ("Battery");
  222. case IPMI_MONITORING_SENSOR_TYPE_SESSION_AUDIT:
  223. return ("Session Audit");
  224. case IPMI_MONITORING_SENSOR_TYPE_VERSION_CHANGE:
  225. return ("Version Change");
  226. case IPMI_MONITORING_SENSOR_TYPE_FRU_STATE:
  227. return ("FRU State");
  228. }
  229. return ("Unrecognized");
  230. }
  231. #endif // NETDATA_COMMENTED
  232. // ----------------------------------------------------------------------------
  233. // BEGIN NETDATA CODE
  234. static int debug = 0;
  235. static int netdata_update_every = 5; // this is the minimum update frequency
  236. static int netdata_priority = 90000;
  237. static int netdata_do_sel = 1;
  238. static size_t netdata_sensors_updated = 0;
  239. static size_t netdata_sensors_collected = 0;
  240. static size_t netdata_sel_events = 0;
  241. static size_t netdata_sensors_states_nominal = 0;
  242. static size_t netdata_sensors_states_warning = 0;
  243. static size_t netdata_sensors_states_critical = 0;
  244. struct sensor {
  245. int record_id;
  246. int sensor_number;
  247. int sensor_type;
  248. int sensor_state;
  249. int sensor_units;
  250. char *sensor_name;
  251. int sensor_reading_type;
  252. union {
  253. uint8_t bool_value;
  254. uint32_t uint32_value;
  255. double double_value;
  256. } sensor_reading;
  257. int sent;
  258. int ignore;
  259. int exposed;
  260. int updated;
  261. struct sensor *next;
  262. } *sensors_root = NULL;
  263. static void netdata_mark_as_not_updated() {
  264. struct sensor *sn;
  265. for(sn = sensors_root; sn ;sn = sn->next)
  266. sn->updated = sn->sent = 0;
  267. netdata_sensors_updated = 0;
  268. netdata_sensors_collected = 0;
  269. netdata_sel_events = 0;
  270. netdata_sensors_states_nominal = 0;
  271. netdata_sensors_states_warning = 0;
  272. netdata_sensors_states_critical = 0;
  273. }
  274. static void send_chart_to_netdata_for_units(int units) {
  275. struct sensor *sn;
  276. switch(units) {
  277. case IPMI_MONITORING_SENSOR_UNITS_CELSIUS:
  278. printf("CHART ipmi.temperatures_c '' 'System Celcius Temperatures read by IPMI' 'Celcius' 'temperatures' 'ipmi.temperatures_c' 'line' %d %d\n"
  279. , netdata_priority + 10
  280. , netdata_update_every
  281. );
  282. break;
  283. case IPMI_MONITORING_SENSOR_UNITS_FAHRENHEIT:
  284. printf("CHART ipmi.temperatures_f '' 'System Fahrenheit Temperatures read by IPMI' 'Fahrenheit' 'temperatures' 'ipmi.temperatures_f' 'line' %d %d\n"
  285. , netdata_priority + 11
  286. , netdata_update_every
  287. );
  288. break;
  289. case IPMI_MONITORING_SENSOR_UNITS_VOLTS:
  290. printf("CHART ipmi.volts '' 'System Voltages read by IPMI' 'Volts' 'voltages' 'ipmi.voltages' 'line' %d %d\n"
  291. , netdata_priority + 12
  292. , netdata_update_every
  293. );
  294. break;
  295. case IPMI_MONITORING_SENSOR_UNITS_AMPS:
  296. printf("CHART ipmi.amps '' 'System Current read by IPMI' 'Amps' 'current' 'ipmi.amps' 'line' %d %d\n"
  297. , netdata_priority + 13
  298. , netdata_update_every
  299. );
  300. break;
  301. case IPMI_MONITORING_SENSOR_UNITS_RPM:
  302. printf("CHART ipmi.rpm '' 'System Fans read by IPMI' 'RPM' 'fans' 'ipmi.rpm' 'line' %d %d\n"
  303. , netdata_priority + 14
  304. , netdata_update_every
  305. );
  306. break;
  307. case IPMI_MONITORING_SENSOR_UNITS_WATTS:
  308. printf("CHART ipmi.watts '' 'System Power read by IPMI' 'Watts' 'power' 'ipmi.watts' 'line' %d %d\n"
  309. , netdata_priority + 5
  310. , netdata_update_every
  311. );
  312. break;
  313. case IPMI_MONITORING_SENSOR_UNITS_PERCENT:
  314. printf("CHART ipmi.percent '' 'System Metrics read by IPMI' '%%' 'other' 'ipmi.percent' 'line' %d %d\n"
  315. , netdata_priority + 15
  316. , netdata_update_every
  317. );
  318. break;
  319. default:
  320. for(sn = sensors_root; sn; sn = sn->next)
  321. if(sn->sensor_units == units)
  322. sn->ignore = 1;
  323. return;
  324. }
  325. for(sn = sensors_root; sn; sn = sn->next) {
  326. if(sn->sensor_units == units && sn->updated && !sn->ignore) {
  327. sn->exposed = 1;
  328. switch(sn->sensor_reading_type) {
  329. case IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER8_BOOL:
  330. case IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER32:
  331. printf("DIMENSION i%d_n%d_r%d '%s i%d' absolute 1 1\n"
  332. , sn->sensor_number
  333. , sn->record_id
  334. , sn->sensor_reading_type
  335. , sn->sensor_name
  336. , sn->sensor_number
  337. );
  338. break;
  339. case IPMI_MONITORING_SENSOR_READING_TYPE_DOUBLE:
  340. printf("DIMENSION i%d_n%d_r%d '%s i%d' absolute 1 1000\n"
  341. , sn->sensor_number
  342. , sn->record_id
  343. , sn->sensor_reading_type
  344. , sn->sensor_name
  345. , sn->sensor_number
  346. );
  347. break;
  348. default:
  349. sn->ignore = 1;
  350. break;
  351. }
  352. }
  353. }
  354. }
  355. static void send_metrics_to_netdata_for_units(int units) {
  356. struct sensor *sn;
  357. switch(units) {
  358. case IPMI_MONITORING_SENSOR_UNITS_CELSIUS:
  359. printf("BEGIN ipmi.temperatures_c\n");
  360. break;
  361. case IPMI_MONITORING_SENSOR_UNITS_FAHRENHEIT:
  362. printf("BEGIN ipmi.temperatures_f\n");
  363. break;
  364. case IPMI_MONITORING_SENSOR_UNITS_VOLTS:
  365. printf("BEGIN ipmi.volts\n");
  366. break;
  367. case IPMI_MONITORING_SENSOR_UNITS_AMPS:
  368. printf("BEGIN ipmi.amps\n");
  369. break;
  370. case IPMI_MONITORING_SENSOR_UNITS_RPM:
  371. printf("BEGIN ipmi.rpm\n");
  372. break;
  373. case IPMI_MONITORING_SENSOR_UNITS_WATTS:
  374. printf("BEGIN ipmi.watts\n");
  375. break;
  376. case IPMI_MONITORING_SENSOR_UNITS_PERCENT:
  377. printf("BEGIN ipmi.percent\n");
  378. break;
  379. default:
  380. for(sn = sensors_root; sn; sn = sn->next)
  381. if(sn->sensor_units == units)
  382. sn->ignore = 1;
  383. return;
  384. }
  385. for(sn = sensors_root; sn; sn = sn->next) {
  386. if(sn->sensor_units == units && sn->updated && !sn->sent && !sn->ignore) {
  387. netdata_sensors_updated++;
  388. sn->sent = 1;
  389. switch(sn->sensor_reading_type) {
  390. case IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER8_BOOL:
  391. printf("SET i%d_n%d_r%d = %u\n"
  392. , sn->sensor_number
  393. , sn->record_id
  394. , sn->sensor_reading_type
  395. , sn->sensor_reading.bool_value
  396. );
  397. break;
  398. case IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER32:
  399. printf("SET i%d_n%d_r%d = %u\n"
  400. , sn->sensor_number
  401. , sn->record_id
  402. , sn->sensor_reading_type
  403. , sn->sensor_reading.uint32_value
  404. );
  405. break;
  406. case IPMI_MONITORING_SENSOR_READING_TYPE_DOUBLE:
  407. printf("SET i%d_n%d_r%d = %lld\n"
  408. , sn->sensor_number
  409. , sn->record_id
  410. , sn->sensor_reading_type
  411. , (long long int)(sn->sensor_reading.double_value * 1000)
  412. );
  413. break;
  414. default:
  415. sn->ignore = 1;
  416. break;
  417. }
  418. }
  419. }
  420. printf("END\n");
  421. }
  422. static void send_metrics_to_netdata() {
  423. static int sel_chart_generated = 0, sensors_states_chart_generated = 0;
  424. struct sensor *sn;
  425. if(netdata_do_sel && !sel_chart_generated) {
  426. sel_chart_generated = 1;
  427. printf("CHART ipmi.events '' 'IPMI Events' 'events' 'events' ipmi.sel area %d %d\n"
  428. , netdata_priority + 2
  429. , netdata_update_every
  430. );
  431. printf("DIMENSION events '' absolute 1 1\n");
  432. }
  433. if(!sensors_states_chart_generated) {
  434. sensors_states_chart_generated = 1;
  435. printf("CHART ipmi.sensors_states '' 'IPMI Sensors State' 'sensors' 'states' ipmi.sensors_states line %d %d\n"
  436. , netdata_priority + 1
  437. , netdata_update_every
  438. );
  439. printf("DIMENSION nominal '' absolute 1 1\n");
  440. printf("DIMENSION critical '' absolute 1 1\n");
  441. printf("DIMENSION warning '' absolute 1 1\n");
  442. }
  443. // generate the CHART/DIMENSION lines, if we have to
  444. for(sn = sensors_root; sn; sn = sn->next)
  445. if(sn->updated && !sn->exposed && !sn->ignore)
  446. send_chart_to_netdata_for_units(sn->sensor_units);
  447. if(netdata_do_sel) {
  448. printf(
  449. "BEGIN ipmi.events\n"
  450. "SET events = %zu\n"
  451. "END\n"
  452. , netdata_sel_events
  453. );
  454. }
  455. printf(
  456. "BEGIN ipmi.sensors_states\n"
  457. "SET nominal = %zu\n"
  458. "SET warning = %zu\n"
  459. "SET critical = %zu\n"
  460. "END\n"
  461. , netdata_sensors_states_nominal
  462. , netdata_sensors_states_warning
  463. , netdata_sensors_states_critical
  464. );
  465. // send metrics to netdata
  466. for(sn = sensors_root; sn; sn = sn->next)
  467. if(sn->updated && sn->exposed && !sn->sent && !sn->ignore)
  468. send_metrics_to_netdata_for_units(sn->sensor_units);
  469. }
  470. static int *excluded_record_ids = NULL;
  471. size_t excluded_record_ids_length = 0;
  472. static void excluded_record_ids_parse(const char *s) {
  473. if(!s) return;
  474. while(*s) {
  475. while(*s && !isdigit(*s)) s++;
  476. if(isdigit(*s)) {
  477. char *e;
  478. unsigned long n = strtoul(s, &e, 10);
  479. s = e;
  480. if(n != 0) {
  481. excluded_record_ids = realloc(excluded_record_ids, (excluded_record_ids_length + 1) * sizeof(int));
  482. if(!excluded_record_ids) {
  483. fprintf(stderr, "freeipmi.plugin: failed to allocate memory. Exiting.");
  484. exit(1);
  485. }
  486. excluded_record_ids[excluded_record_ids_length++] = (int)n;
  487. }
  488. }
  489. }
  490. if(debug) {
  491. fprintf(stderr, "freeipmi.plugin: excluded record ids:");
  492. size_t i;
  493. for(i = 0; i < excluded_record_ids_length; i++) {
  494. fprintf(stderr, " %d", excluded_record_ids[i]);
  495. }
  496. fprintf(stderr, "\n");
  497. }
  498. }
  499. static int *excluded_status_record_ids = NULL;
  500. size_t excluded_status_record_ids_length = 0;
  501. static void excluded_status_record_ids_parse(const char *s) {
  502. if(!s) return;
  503. while(*s) {
  504. while(*s && !isdigit(*s)) s++;
  505. if(isdigit(*s)) {
  506. char *e;
  507. unsigned long n = strtoul(s, &e, 10);
  508. s = e;
  509. if(n != 0) {
  510. excluded_status_record_ids = realloc(excluded_status_record_ids, (excluded_status_record_ids_length + 1) * sizeof(int));
  511. if(!excluded_status_record_ids) {
  512. fprintf(stderr, "freeipmi.plugin: failed to allocate memory. Exiting.");
  513. exit(1);
  514. }
  515. excluded_status_record_ids[excluded_status_record_ids_length++] = (int)n;
  516. }
  517. }
  518. }
  519. if(debug) {
  520. fprintf(stderr, "freeipmi.plugin: excluded status record ids:");
  521. size_t i;
  522. for(i = 0; i < excluded_status_record_ids_length; i++) {
  523. fprintf(stderr, " %d", excluded_status_record_ids[i]);
  524. }
  525. fprintf(stderr, "\n");
  526. }
  527. }
  528. static int excluded_record_ids_check(int record_id) {
  529. size_t i;
  530. for(i = 0; i < excluded_record_ids_length; i++) {
  531. if(excluded_record_ids[i] == record_id)
  532. return 1;
  533. }
  534. return 0;
  535. }
  536. static int excluded_status_record_ids_check(int record_id) {
  537. size_t i;
  538. for(i = 0; i < excluded_status_record_ids_length; i++) {
  539. if(excluded_status_record_ids[i] == record_id)
  540. return 1;
  541. }
  542. return 0;
  543. }
  544. static void netdata_get_sensor(
  545. int record_id
  546. , int sensor_number
  547. , int sensor_type
  548. , int sensor_state
  549. , int sensor_units
  550. , int sensor_reading_type
  551. , char *sensor_name
  552. , void *sensor_reading
  553. ) {
  554. // find the sensor record
  555. struct sensor *sn;
  556. for(sn = sensors_root; sn ;sn = sn->next)
  557. if( sn->record_id == record_id &&
  558. sn->sensor_number == sensor_number &&
  559. sn->sensor_reading_type == sensor_reading_type &&
  560. sn->sensor_units == sensor_units &&
  561. !strcmp(sn->sensor_name, sensor_name)
  562. )
  563. break;
  564. if(!sn) {
  565. // not found, create it
  566. // check if it is excluded
  567. if(excluded_record_ids_check(record_id))
  568. return;
  569. sn = calloc(1, sizeof(struct sensor));
  570. if(!sn) {
  571. fatal("cannot allocate %zu bytes of memory.", sizeof(struct sensor));
  572. }
  573. sn->record_id = record_id;
  574. sn->sensor_number = sensor_number;
  575. sn->sensor_type = sensor_type;
  576. sn->sensor_state = sensor_state;
  577. sn->sensor_units = sensor_units;
  578. sn->sensor_reading_type = sensor_reading_type;
  579. sn->sensor_name = strdup(sensor_name);
  580. if(!sn->sensor_name) {
  581. fatal("cannot allocate %zu bytes of memory.", strlen(sensor_name));
  582. }
  583. sn->next = sensors_root;
  584. sensors_root = sn;
  585. }
  586. switch(sensor_reading_type) {
  587. case IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER8_BOOL:
  588. sn->sensor_reading.bool_value = *((uint8_t *)sensor_reading);
  589. sn->updated = 1;
  590. netdata_sensors_collected++;
  591. break;
  592. case IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER32:
  593. sn->sensor_reading.uint32_value = *((uint32_t *)sensor_reading);
  594. sn->updated = 1;
  595. netdata_sensors_collected++;
  596. break;
  597. case IPMI_MONITORING_SENSOR_READING_TYPE_DOUBLE:
  598. sn->sensor_reading.double_value = *((double *)sensor_reading);
  599. sn->updated = 1;
  600. netdata_sensors_collected++;
  601. break;
  602. default:
  603. sn->ignore = 1;
  604. break;
  605. }
  606. // check if it is excluded
  607. if(excluded_status_record_ids_check(record_id))
  608. return;
  609. switch(sensor_state) {
  610. case IPMI_MONITORING_STATE_NOMINAL:
  611. netdata_sensors_states_nominal++;
  612. break;
  613. case IPMI_MONITORING_STATE_WARNING:
  614. netdata_sensors_states_warning++;
  615. break;
  616. case IPMI_MONITORING_STATE_CRITICAL:
  617. netdata_sensors_states_critical++;
  618. break;
  619. default:
  620. break;
  621. }
  622. }
  623. static void netdata_get_sel(
  624. int record_id
  625. , int record_type_class
  626. , int sel_state
  627. ) {
  628. (void)record_id;
  629. (void)record_type_class;
  630. (void)sel_state;
  631. netdata_sel_events++;
  632. }
  633. // END NETDATA CODE
  634. // ----------------------------------------------------------------------------
  635. static int
  636. _ipmimonitoring_sensors (struct ipmi_monitoring_ipmi_config *ipmi_config)
  637. {
  638. ipmi_monitoring_ctx_t ctx = NULL;
  639. unsigned int sensor_reading_flags = 0;
  640. int i;
  641. int sensor_count;
  642. int rv = -1;
  643. if (!(ctx = ipmi_monitoring_ctx_create ())) {
  644. error("ipmi_monitoring_ctx_create()");
  645. goto cleanup;
  646. }
  647. if (sdr_cache_directory)
  648. {
  649. if (ipmi_monitoring_ctx_sdr_cache_directory (ctx,
  650. sdr_cache_directory) < 0)
  651. {
  652. error("ipmi_monitoring_ctx_sdr_cache_directory(): %s\n",
  653. ipmi_monitoring_ctx_errormsg (ctx));
  654. goto cleanup;
  655. }
  656. }
  657. /* Must call otherwise only default interpretations ever used */
  658. if (sensor_config_file)
  659. {
  660. if (ipmi_monitoring_ctx_sensor_config_file (ctx,
  661. sensor_config_file) < 0)
  662. {
  663. error( "ipmi_monitoring_ctx_sensor_config_file(): %s\n",
  664. ipmi_monitoring_ctx_errormsg (ctx));
  665. goto cleanup;
  666. }
  667. }
  668. else
  669. {
  670. if (ipmi_monitoring_ctx_sensor_config_file (ctx, NULL) < 0)
  671. {
  672. error( "ipmi_monitoring_ctx_sensor_config_file(): %s\n",
  673. ipmi_monitoring_ctx_errormsg (ctx));
  674. goto cleanup;
  675. }
  676. }
  677. if (reread_sdr_cache)
  678. sensor_reading_flags |= IPMI_MONITORING_SENSOR_READING_FLAGS_REREAD_SDR_CACHE;
  679. if (ignore_non_interpretable_sensors)
  680. sensor_reading_flags |= IPMI_MONITORING_SENSOR_READING_FLAGS_IGNORE_NON_INTERPRETABLE_SENSORS;
  681. if (bridge_sensors)
  682. sensor_reading_flags |= IPMI_MONITORING_SENSOR_READING_FLAGS_BRIDGE_SENSORS;
  683. if (interpret_oem_data)
  684. sensor_reading_flags |= IPMI_MONITORING_SENSOR_READING_FLAGS_INTERPRET_OEM_DATA;
  685. if (shared_sensors)
  686. sensor_reading_flags |= IPMI_MONITORING_SENSOR_READING_FLAGS_SHARED_SENSORS;
  687. if (discrete_reading)
  688. sensor_reading_flags |= IPMI_MONITORING_SENSOR_READING_FLAGS_DISCRETE_READING;
  689. if (ignore_scanning_disabled)
  690. sensor_reading_flags |= IPMI_MONITORING_SENSOR_READING_FLAGS_IGNORE_SCANNING_DISABLED;
  691. if (assume_bmc_owner)
  692. sensor_reading_flags |= IPMI_MONITORING_SENSOR_READING_FLAGS_ASSUME_BMC_OWNER;
  693. #ifdef IPMI_MONITORING_SENSOR_READING_FLAGS_ENTITY_SENSOR_NAMES
  694. if (entity_sensor_names)
  695. sensor_reading_flags |= IPMI_MONITORING_SENSOR_READING_FLAGS_ENTITY_SENSOR_NAMES;
  696. #endif // IPMI_MONITORING_SENSOR_READING_FLAGS_ENTITY_SENSOR_NAMES
  697. if (!record_ids_length && !sensor_types_length)
  698. {
  699. if ((sensor_count = ipmi_monitoring_sensor_readings_by_record_id (ctx,
  700. hostname,
  701. ipmi_config,
  702. sensor_reading_flags,
  703. NULL,
  704. 0,
  705. NULL,
  706. NULL)) < 0)
  707. {
  708. error( "ipmi_monitoring_sensor_readings_by_record_id(): %s",
  709. ipmi_monitoring_ctx_errormsg (ctx));
  710. goto cleanup;
  711. }
  712. }
  713. else if (record_ids_length)
  714. {
  715. if ((sensor_count = ipmi_monitoring_sensor_readings_by_record_id (ctx,
  716. hostname,
  717. ipmi_config,
  718. sensor_reading_flags,
  719. record_ids,
  720. record_ids_length,
  721. NULL,
  722. NULL)) < 0)
  723. {
  724. error( "ipmi_monitoring_sensor_readings_by_record_id(): %s",
  725. ipmi_monitoring_ctx_errormsg (ctx));
  726. goto cleanup;
  727. }
  728. }
  729. else
  730. {
  731. if ((sensor_count = ipmi_monitoring_sensor_readings_by_sensor_type (ctx,
  732. hostname,
  733. ipmi_config,
  734. sensor_reading_flags,
  735. sensor_types,
  736. sensor_types_length,
  737. NULL,
  738. NULL)) < 0)
  739. {
  740. error( "ipmi_monitoring_sensor_readings_by_sensor_type(): %s",
  741. ipmi_monitoring_ctx_errormsg (ctx));
  742. goto cleanup;
  743. }
  744. }
  745. #ifdef NETDATA_COMMENTED
  746. printf ("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s\n",
  747. "Record ID",
  748. "Sensor Name",
  749. "Sensor Number",
  750. "Sensor Type",
  751. "Sensor State",
  752. "Sensor Reading",
  753. "Sensor Units",
  754. "Sensor Event/Reading Type Code",
  755. "Sensor Event Bitmask",
  756. "Sensor Event String");
  757. #endif // NETDATA_COMMENTED
  758. for (i = 0; i < sensor_count; i++, ipmi_monitoring_sensor_iterator_next (ctx))
  759. {
  760. int record_id, sensor_number, sensor_type, sensor_state, sensor_units,
  761. sensor_reading_type;
  762. #ifdef NETDATA_COMMENTED
  763. int sensor_bitmask_type, sensor_bitmask, event_reading_type_code;
  764. char **sensor_bitmask_strings = NULL;
  765. const char *sensor_type_str;
  766. const char *sensor_state_str;
  767. #endif // NETDATA_COMMENTED
  768. char *sensor_name = NULL;
  769. void *sensor_reading;
  770. if ((record_id = ipmi_monitoring_sensor_read_record_id (ctx)) < 0)
  771. {
  772. error( "ipmi_monitoring_sensor_read_record_id(): %s",
  773. ipmi_monitoring_ctx_errormsg (ctx));
  774. goto cleanup;
  775. }
  776. if ((sensor_number = ipmi_monitoring_sensor_read_sensor_number (ctx)) < 0)
  777. {
  778. error( "ipmi_monitoring_sensor_read_sensor_number(): %s",
  779. ipmi_monitoring_ctx_errormsg (ctx));
  780. goto cleanup;
  781. }
  782. if ((sensor_type = ipmi_monitoring_sensor_read_sensor_type (ctx)) < 0)
  783. {
  784. error( "ipmi_monitoring_sensor_read_sensor_type(): %s",
  785. ipmi_monitoring_ctx_errormsg (ctx));
  786. goto cleanup;
  787. }
  788. if (!(sensor_name = ipmi_monitoring_sensor_read_sensor_name (ctx)))
  789. {
  790. error( "ipmi_monitoring_sensor_read_sensor_name(): %s",
  791. ipmi_monitoring_ctx_errormsg (ctx));
  792. goto cleanup;
  793. }
  794. if ((sensor_state = ipmi_monitoring_sensor_read_sensor_state (ctx)) < 0)
  795. {
  796. error( "ipmi_monitoring_sensor_read_sensor_state(): %s",
  797. ipmi_monitoring_ctx_errormsg (ctx));
  798. goto cleanup;
  799. }
  800. if ((sensor_units = ipmi_monitoring_sensor_read_sensor_units (ctx)) < 0)
  801. {
  802. error( "ipmi_monitoring_sensor_read_sensor_units(): %s",
  803. ipmi_monitoring_ctx_errormsg (ctx));
  804. goto cleanup;
  805. }
  806. #ifdef NETDATA_COMMENTED
  807. if ((sensor_bitmask_type = ipmi_monitoring_sensor_read_sensor_bitmask_type (ctx)) < 0)
  808. {
  809. error( "ipmi_monitoring_sensor_read_sensor_bitmask_type(): %s",
  810. ipmi_monitoring_ctx_errormsg (ctx));
  811. goto cleanup;
  812. }
  813. if ((sensor_bitmask = ipmi_monitoring_sensor_read_sensor_bitmask (ctx)) < 0)
  814. {
  815. error(
  816. "ipmi_monitoring_sensor_read_sensor_bitmask(): %s",
  817. ipmi_monitoring_ctx_errormsg (ctx));
  818. goto cleanup;
  819. }
  820. if (!(sensor_bitmask_strings = ipmi_monitoring_sensor_read_sensor_bitmask_strings (ctx)))
  821. {
  822. error( "ipmi_monitoring_sensor_read_sensor_bitmask_strings(): %s",
  823. ipmi_monitoring_ctx_errormsg (ctx));
  824. goto cleanup;
  825. }
  826. #endif // NETDATA_COMMENTED
  827. if ((sensor_reading_type = ipmi_monitoring_sensor_read_sensor_reading_type (ctx)) < 0)
  828. {
  829. error( "ipmi_monitoring_sensor_read_sensor_reading_type(): %s",
  830. ipmi_monitoring_ctx_errormsg (ctx));
  831. goto cleanup;
  832. }
  833. sensor_reading = ipmi_monitoring_sensor_read_sensor_reading (ctx);
  834. #ifdef NETDATA_COMMENTED
  835. if ((event_reading_type_code = ipmi_monitoring_sensor_read_event_reading_type_code (ctx)) < 0)
  836. {
  837. error( "ipmi_monitoring_sensor_read_event_reading_type_code(): %s",
  838. ipmi_monitoring_ctx_errormsg (ctx));
  839. goto cleanup;
  840. }
  841. #endif // NETDATA_COMMENTED
  842. netdata_get_sensor(
  843. record_id
  844. , sensor_number
  845. , sensor_type
  846. , sensor_state
  847. , sensor_units
  848. , sensor_reading_type
  849. , sensor_name
  850. , sensor_reading
  851. );
  852. #ifdef NETDATA_COMMENTED
  853. if (!strlen (sensor_name))
  854. sensor_name = "N/A";
  855. sensor_type_str = _get_sensor_type_string (sensor_type);
  856. printf ("%d, %s, %d, %s",
  857. record_id,
  858. sensor_name,
  859. sensor_number,
  860. sensor_type_str);
  861. if (sensor_state == IPMI_MONITORING_STATE_NOMINAL)
  862. sensor_state_str = "Nominal";
  863. else if (sensor_state == IPMI_MONITORING_STATE_WARNING)
  864. sensor_state_str = "Warning";
  865. else if (sensor_state == IPMI_MONITORING_STATE_CRITICAL)
  866. sensor_state_str = "Critical";
  867. else
  868. sensor_state_str = "N/A";
  869. printf (", %s", sensor_state_str);
  870. if (sensor_reading)
  871. {
  872. const char *sensor_units_str;
  873. if (sensor_reading_type == IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER8_BOOL)
  874. printf (", %s",
  875. (*((uint8_t *)sensor_reading) ? "true" : "false"));
  876. else if (sensor_reading_type == IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER32)
  877. printf (", %u",
  878. *((uint32_t *)sensor_reading));
  879. else if (sensor_reading_type == IPMI_MONITORING_SENSOR_READING_TYPE_DOUBLE)
  880. printf (", %.2f",
  881. *((double *)sensor_reading));
  882. else
  883. printf (", N/A");
  884. if (sensor_units == IPMI_MONITORING_SENSOR_UNITS_CELSIUS)
  885. sensor_units_str = "C";
  886. else if (sensor_units == IPMI_MONITORING_SENSOR_UNITS_FAHRENHEIT)
  887. sensor_units_str = "F";
  888. else if (sensor_units == IPMI_MONITORING_SENSOR_UNITS_VOLTS)
  889. sensor_units_str = "V";
  890. else if (sensor_units == IPMI_MONITORING_SENSOR_UNITS_AMPS)
  891. sensor_units_str = "A";
  892. else if (sensor_units == IPMI_MONITORING_SENSOR_UNITS_RPM)
  893. sensor_units_str = "RPM";
  894. else if (sensor_units == IPMI_MONITORING_SENSOR_UNITS_WATTS)
  895. sensor_units_str = "W";
  896. else if (sensor_units == IPMI_MONITORING_SENSOR_UNITS_PERCENT)
  897. sensor_units_str = "%";
  898. else
  899. sensor_units_str = "N/A";
  900. printf (", %s", sensor_units_str);
  901. }
  902. else
  903. printf (", N/A, N/A");
  904. printf (", %Xh", event_reading_type_code);
  905. /* It is possible you may want to monitor specific event
  906. * conditions that may occur. If that is the case, you may want
  907. * to check out what specific bitmask type and bitmask events
  908. * occurred. See ipmi_monitoring_bitmasks.h for a list of
  909. * bitmasks and types.
  910. */
  911. if (sensor_bitmask_type != IPMI_MONITORING_SENSOR_BITMASK_TYPE_UNKNOWN)
  912. printf (", %Xh", sensor_bitmask);
  913. else
  914. printf (", N/A");
  915. if (sensor_bitmask_type != IPMI_MONITORING_SENSOR_BITMASK_TYPE_UNKNOWN)
  916. {
  917. unsigned int i = 0;
  918. printf (",");
  919. while (sensor_bitmask_strings[i])
  920. {
  921. printf (" ");
  922. printf ("'%s'",
  923. sensor_bitmask_strings[i]);
  924. i++;
  925. }
  926. }
  927. else
  928. printf (", N/A");
  929. printf ("\n");
  930. #endif // NETDATA_COMMENTED
  931. }
  932. rv = 0;
  933. cleanup:
  934. if (ctx)
  935. ipmi_monitoring_ctx_destroy (ctx);
  936. return (rv);
  937. }
  938. static int
  939. _ipmimonitoring_sel (struct ipmi_monitoring_ipmi_config *ipmi_config)
  940. {
  941. ipmi_monitoring_ctx_t ctx = NULL;
  942. unsigned int sel_flags = 0;
  943. int i;
  944. int sel_count;
  945. int rv = -1;
  946. if (!(ctx = ipmi_monitoring_ctx_create ()))
  947. {
  948. error("ipmi_monitoring_ctx_create()");
  949. goto cleanup;
  950. }
  951. if (sdr_cache_directory)
  952. {
  953. if (ipmi_monitoring_ctx_sdr_cache_directory (ctx,
  954. sdr_cache_directory) < 0)
  955. {
  956. error( "ipmi_monitoring_ctx_sdr_cache_directory(): %s",
  957. ipmi_monitoring_ctx_errormsg (ctx));
  958. goto cleanup;
  959. }
  960. }
  961. /* Must call otherwise only default interpretations ever used */
  962. if (sel_config_file)
  963. {
  964. if (ipmi_monitoring_ctx_sel_config_file (ctx,
  965. sel_config_file) < 0)
  966. {
  967. error( "ipmi_monitoring_ctx_sel_config_file(): %s",
  968. ipmi_monitoring_ctx_errormsg (ctx));
  969. goto cleanup;
  970. }
  971. }
  972. else
  973. {
  974. if (ipmi_monitoring_ctx_sel_config_file (ctx, NULL) < 0)
  975. {
  976. error( "ipmi_monitoring_ctx_sel_config_file(): %s",
  977. ipmi_monitoring_ctx_errormsg (ctx));
  978. goto cleanup;
  979. }
  980. }
  981. if (reread_sdr_cache)
  982. sel_flags |= IPMI_MONITORING_SEL_FLAGS_REREAD_SDR_CACHE;
  983. if (interpret_oem_data)
  984. sel_flags |= IPMI_MONITORING_SEL_FLAGS_INTERPRET_OEM_DATA;
  985. if (assume_system_event_record)
  986. sel_flags |= IPMI_MONITORING_SEL_FLAGS_ASSUME_SYSTEM_EVENT_RECORD;
  987. #ifdef IPMI_MONITORING_SEL_FLAGS_ENTITY_SENSOR_NAMES
  988. if (entity_sensor_names)
  989. sel_flags |= IPMI_MONITORING_SEL_FLAGS_ENTITY_SENSOR_NAMES;
  990. #endif // IPMI_MONITORING_SEL_FLAGS_ENTITY_SENSOR_NAMES
  991. if (record_ids_length)
  992. {
  993. if ((sel_count = ipmi_monitoring_sel_by_record_id (ctx,
  994. hostname,
  995. ipmi_config,
  996. sel_flags,
  997. record_ids,
  998. record_ids_length,
  999. NULL,
  1000. NULL)) < 0)
  1001. {
  1002. error( "ipmi_monitoring_sel_by_record_id(): %s",
  1003. ipmi_monitoring_ctx_errormsg (ctx));
  1004. goto cleanup;
  1005. }
  1006. }
  1007. else if (sensor_types_length)
  1008. {
  1009. if ((sel_count = ipmi_monitoring_sel_by_sensor_type (ctx,
  1010. hostname,
  1011. ipmi_config,
  1012. sel_flags,
  1013. sensor_types,
  1014. sensor_types_length,
  1015. NULL,
  1016. NULL)) < 0)
  1017. {
  1018. error( "ipmi_monitoring_sel_by_sensor_type(): %s",
  1019. ipmi_monitoring_ctx_errormsg (ctx));
  1020. goto cleanup;
  1021. }
  1022. }
  1023. else if (date_begin
  1024. || date_end)
  1025. {
  1026. if ((sel_count = ipmi_monitoring_sel_by_date_range (ctx,
  1027. hostname,
  1028. ipmi_config,
  1029. sel_flags,
  1030. date_begin,
  1031. date_end,
  1032. NULL,
  1033. NULL)) < 0)
  1034. {
  1035. error( "ipmi_monitoring_sel_by_sensor_type(): %s",
  1036. ipmi_monitoring_ctx_errormsg (ctx));
  1037. goto cleanup;
  1038. }
  1039. }
  1040. else
  1041. {
  1042. if ((sel_count = ipmi_monitoring_sel_by_record_id (ctx,
  1043. hostname,
  1044. ipmi_config,
  1045. sel_flags,
  1046. NULL,
  1047. 0,
  1048. NULL,
  1049. NULL)) < 0)
  1050. {
  1051. error( "ipmi_monitoring_sel_by_record_id(): %s",
  1052. ipmi_monitoring_ctx_errormsg (ctx));
  1053. goto cleanup;
  1054. }
  1055. }
  1056. #ifdef NETDATA_COMMENTED
  1057. printf ("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s\n",
  1058. "Record ID",
  1059. "Record Type",
  1060. "SEL State",
  1061. "Timestamp",
  1062. "Sensor Name",
  1063. "Sensor Type",
  1064. "Event Direction",
  1065. "Event Type Code",
  1066. "Event Data",
  1067. "Event Offset",
  1068. "Event Offset String");
  1069. #endif // NETDATA_COMMENTED
  1070. for (i = 0; i < sel_count; i++, ipmi_monitoring_sel_iterator_next (ctx))
  1071. {
  1072. int record_id, record_type, sel_state, record_type_class;
  1073. #ifdef NETDATA_COMMENTED
  1074. int sensor_type, sensor_number, event_direction,
  1075. event_offset_type, event_offset, event_type_code, manufacturer_id;
  1076. unsigned int timestamp, event_data1, event_data2, event_data3;
  1077. char *event_offset_string = NULL;
  1078. const char *sensor_type_str;
  1079. const char *event_direction_str;
  1080. const char *sel_state_str;
  1081. char *sensor_name = NULL;
  1082. unsigned char oem_data[64];
  1083. int oem_data_len;
  1084. unsigned int j;
  1085. #endif // NETDATA_COMMENTED
  1086. if ((record_id = ipmi_monitoring_sel_read_record_id (ctx)) < 0)
  1087. {
  1088. error( "ipmi_monitoring_sel_read_record_id(): %s",
  1089. ipmi_monitoring_ctx_errormsg (ctx));
  1090. goto cleanup;
  1091. }
  1092. if ((record_type = ipmi_monitoring_sel_read_record_type (ctx)) < 0)
  1093. {
  1094. error( "ipmi_monitoring_sel_read_record_type(): %s",
  1095. ipmi_monitoring_ctx_errormsg (ctx));
  1096. goto cleanup;
  1097. }
  1098. if ((record_type_class = ipmi_monitoring_sel_read_record_type_class (ctx)) < 0)
  1099. {
  1100. error( "ipmi_monitoring_sel_read_record_type_class(): %s",
  1101. ipmi_monitoring_ctx_errormsg (ctx));
  1102. goto cleanup;
  1103. }
  1104. if ((sel_state = ipmi_monitoring_sel_read_sel_state (ctx)) < 0)
  1105. {
  1106. error( "ipmi_monitoring_sel_read_sel_state(): %s",
  1107. ipmi_monitoring_ctx_errormsg (ctx));
  1108. goto cleanup;
  1109. }
  1110. netdata_get_sel(
  1111. record_id
  1112. , record_type_class
  1113. , sel_state
  1114. );
  1115. #ifdef NETDATA_COMMENTED
  1116. if (sel_state == IPMI_MONITORING_STATE_NOMINAL)
  1117. sel_state_str = "Nominal";
  1118. else if (sel_state == IPMI_MONITORING_STATE_WARNING)
  1119. sel_state_str = "Warning";
  1120. else if (sel_state == IPMI_MONITORING_STATE_CRITICAL)
  1121. sel_state_str = "Critical";
  1122. else
  1123. sel_state_str = "N/A";
  1124. printf ("%d, %d, %s",
  1125. record_id,
  1126. record_type,
  1127. sel_state_str);
  1128. if (record_type_class == IPMI_MONITORING_SEL_RECORD_TYPE_CLASS_SYSTEM_EVENT_RECORD
  1129. || record_type_class == IPMI_MONITORING_SEL_RECORD_TYPE_CLASS_TIMESTAMPED_OEM_RECORD)
  1130. {
  1131. if (ipmi_monitoring_sel_read_timestamp (ctx, &timestamp) < 0)
  1132. {
  1133. error( "ipmi_monitoring_sel_read_timestamp(): %s",
  1134. ipmi_monitoring_ctx_errormsg (ctx));
  1135. goto cleanup;
  1136. }
  1137. /* XXX: This should be converted to a nice date output using
  1138. * your favorite timestamp -> string conversion functions.
  1139. */
  1140. printf (", %u", timestamp);
  1141. }
  1142. else
  1143. printf (", N/A");
  1144. if (record_type_class == IPMI_MONITORING_SEL_RECORD_TYPE_CLASS_SYSTEM_EVENT_RECORD)
  1145. {
  1146. /* If you are integrating ipmimonitoring SEL into a monitoring application,
  1147. * you may wish to count the number of times a specific error occurred
  1148. * and report that to the monitoring application.
  1149. *
  1150. * In this particular case, you'll probably want to check out
  1151. * what sensor type each SEL event is reporting, the
  1152. * event offset type, and the specific event offset that occurred.
  1153. *
  1154. * See ipmi_monitoring_offsets.h for a list of event offsets
  1155. * and types.
  1156. */
  1157. if (!(sensor_name = ipmi_monitoring_sel_read_sensor_name (ctx)))
  1158. {
  1159. error( "ipmi_monitoring_sel_read_sensor_name(): %s",
  1160. ipmi_monitoring_ctx_errormsg (ctx));
  1161. goto cleanup;
  1162. }
  1163. if ((sensor_type = ipmi_monitoring_sel_read_sensor_type (ctx)) < 0)
  1164. {
  1165. error( "ipmi_monitoring_sel_read_sensor_type(): %s",
  1166. ipmi_monitoring_ctx_errormsg (ctx));
  1167. goto cleanup;
  1168. }
  1169. if ((sensor_number = ipmi_monitoring_sel_read_sensor_number (ctx)) < 0)
  1170. {
  1171. error( "ipmi_monitoring_sel_read_sensor_number(): %s",
  1172. ipmi_monitoring_ctx_errormsg (ctx));
  1173. goto cleanup;
  1174. }
  1175. if ((event_direction = ipmi_monitoring_sel_read_event_direction (ctx)) < 0)
  1176. {
  1177. error( "ipmi_monitoring_sel_read_event_direction(): %s",
  1178. ipmi_monitoring_ctx_errormsg (ctx));
  1179. goto cleanup;
  1180. }
  1181. if ((event_type_code = ipmi_monitoring_sel_read_event_type_code (ctx)) < 0)
  1182. {
  1183. error( "ipmi_monitoring_sel_read_event_type_code(): %s",
  1184. ipmi_monitoring_ctx_errormsg (ctx));
  1185. goto cleanup;
  1186. }
  1187. if (ipmi_monitoring_sel_read_event_data (ctx,
  1188. &event_data1,
  1189. &event_data2,
  1190. &event_data3) < 0)
  1191. {
  1192. error( "ipmi_monitoring_sel_read_event_data(): %s",
  1193. ipmi_monitoring_ctx_errormsg (ctx));
  1194. goto cleanup;
  1195. }
  1196. if ((event_offset_type = ipmi_monitoring_sel_read_event_offset_type (ctx)) < 0)
  1197. {
  1198. error( "ipmi_monitoring_sel_read_event_offset_type(): %s",
  1199. ipmi_monitoring_ctx_errormsg (ctx));
  1200. goto cleanup;
  1201. }
  1202. if ((event_offset = ipmi_monitoring_sel_read_event_offset (ctx)) < 0)
  1203. {
  1204. error( "ipmi_monitoring_sel_read_event_offset(): %s",
  1205. ipmi_monitoring_ctx_errormsg (ctx));
  1206. goto cleanup;
  1207. }
  1208. if (!(event_offset_string = ipmi_monitoring_sel_read_event_offset_string (ctx)))
  1209. {
  1210. error( "ipmi_monitoring_sel_read_event_offset_string(): %s",
  1211. ipmi_monitoring_ctx_errormsg (ctx));
  1212. goto cleanup;
  1213. }
  1214. if (!strlen (sensor_name))
  1215. sensor_name = "N/A";
  1216. sensor_type_str = _get_sensor_type_string (sensor_type);
  1217. if (event_direction == IPMI_MONITORING_SEL_EVENT_DIRECTION_ASSERTION)
  1218. event_direction_str = "Assertion";
  1219. else
  1220. event_direction_str = "Deassertion";
  1221. printf (", %s, %s, %d, %s, %Xh, %Xh-%Xh-%Xh",
  1222. sensor_name,
  1223. sensor_type_str,
  1224. sensor_number,
  1225. event_direction_str,
  1226. event_type_code,
  1227. event_data1,
  1228. event_data2,
  1229. event_data3);
  1230. if (event_offset_type != IPMI_MONITORING_EVENT_OFFSET_TYPE_UNKNOWN)
  1231. printf (", %Xh", event_offset);
  1232. else
  1233. printf (", N/A");
  1234. if (event_offset_type != IPMI_MONITORING_EVENT_OFFSET_TYPE_UNKNOWN)
  1235. printf (", %s", event_offset_string);
  1236. else
  1237. printf (", N/A");
  1238. }
  1239. else if (record_type_class == IPMI_MONITORING_SEL_RECORD_TYPE_CLASS_TIMESTAMPED_OEM_RECORD
  1240. || record_type_class == IPMI_MONITORING_SEL_RECORD_TYPE_CLASS_NON_TIMESTAMPED_OEM_RECORD)
  1241. {
  1242. if (record_type_class == IPMI_MONITORING_SEL_RECORD_TYPE_CLASS_TIMESTAMPED_OEM_RECORD)
  1243. {
  1244. if ((manufacturer_id = ipmi_monitoring_sel_read_manufacturer_id (ctx)) < 0)
  1245. {
  1246. error( "ipmi_monitoring_sel_read_manufacturer_id(): %s",
  1247. ipmi_monitoring_ctx_errormsg (ctx));
  1248. goto cleanup;
  1249. }
  1250. printf (", Manufacturer ID = %Xh", manufacturer_id);
  1251. }
  1252. if ((oem_data_len = ipmi_monitoring_sel_read_oem_data (ctx, oem_data, 1024)) < 0)
  1253. {
  1254. error( "ipmi_monitoring_sel_read_oem_data(): %s",
  1255. ipmi_monitoring_ctx_errormsg (ctx));
  1256. goto cleanup;
  1257. }
  1258. printf (", OEM Data = ");
  1259. for (j = 0; j < oem_data_len; j++)
  1260. printf ("%02Xh ", oem_data[j]);
  1261. }
  1262. else
  1263. printf (", N/A, N/A, N/A, N/A, N/A, N/A, N/A");
  1264. printf ("\n");
  1265. #endif // NETDATA_COMMENTED
  1266. }
  1267. rv = 0;
  1268. cleanup:
  1269. if (ctx)
  1270. ipmi_monitoring_ctx_destroy (ctx);
  1271. return (rv);
  1272. }
  1273. // ----------------------------------------------------------------------------
  1274. // MAIN PROGRAM FOR NETDATA PLUGIN
  1275. int ipmi_collect_data(struct ipmi_monitoring_ipmi_config *ipmi_config) {
  1276. errno = 0;
  1277. if (_ipmimonitoring_sensors(ipmi_config) < 0) return -1;
  1278. if(netdata_do_sel) {
  1279. if(_ipmimonitoring_sel(ipmi_config) < 0) return -2;
  1280. }
  1281. return 0;
  1282. }
  1283. int ipmi_detect_speed_secs(struct ipmi_monitoring_ipmi_config *ipmi_config) {
  1284. int i, checks = 10;
  1285. unsigned long long total = 0;
  1286. for(i = 0 ; i < checks ; i++) {
  1287. if(debug) fprintf(stderr, "freeipmi.plugin: checking data collection speed iteration %d of %d\n", i+1, checks);
  1288. // measure the time a data collection needs
  1289. unsigned long long start = now_realtime_usec();
  1290. if(ipmi_collect_data(ipmi_config) < 0)
  1291. fatal("freeipmi.plugin: data collection failed.");
  1292. unsigned long long end = now_realtime_usec();
  1293. if(debug) fprintf(stderr, "freeipmi.plugin: data collection speed was %llu usec\n", end - start);
  1294. // add it to our total
  1295. total += end - start;
  1296. // wait the same time
  1297. // to avoid flooding the IPMI processor with requests
  1298. sleep_usec(end - start);
  1299. }
  1300. // so, we assume it needed 2x the time
  1301. // we find the average in microseconds
  1302. // and we round-up to the closest second
  1303. return (int)(( total * 2 / checks / 1000000 ) + 1);
  1304. }
  1305. int main (int argc, char **argv) {
  1306. // ------------------------------------------------------------------------
  1307. // initialization of netdata plugin
  1308. program_name = "freeipmi.plugin";
  1309. // disable syslog
  1310. error_log_syslog = 0;
  1311. // set errors flood protection to 100 logs per hour
  1312. error_log_errors_per_period = 100;
  1313. error_log_throttle_period = 3600;
  1314. // ------------------------------------------------------------------------
  1315. // parse command line parameters
  1316. int i, freq = 0;
  1317. for(i = 1; i < argc ; i++) {
  1318. if(isdigit(*argv[i]) && !freq) {
  1319. int n = str2i(argv[i]);
  1320. if(n > 0 && n < 86400) {
  1321. freq = n;
  1322. continue;
  1323. }
  1324. }
  1325. else if(strcmp("version", argv[i]) == 0 || strcmp("-version", argv[i]) == 0 || strcmp("--version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
  1326. printf("freeipmi.plugin %s\n", VERSION);
  1327. exit(0);
  1328. }
  1329. else if(strcmp("debug", argv[i]) == 0) {
  1330. debug = 1;
  1331. continue;
  1332. }
  1333. else if(strcmp("sel", argv[i]) == 0) {
  1334. netdata_do_sel = 1;
  1335. continue;
  1336. }
  1337. else if(strcmp("no-sel", argv[i]) == 0) {
  1338. netdata_do_sel = 0;
  1339. continue;
  1340. }
  1341. else if(strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
  1342. fprintf(stderr,
  1343. "\n"
  1344. " netdata freeipmi.plugin %s\n"
  1345. " Copyright (C) 2016-2017 Costa Tsaousis <costa@tsaousis.gr>\n"
  1346. " Released under GNU General Public License v3 or later.\n"
  1347. " All rights reserved.\n"
  1348. "\n"
  1349. " This program is a data collector plugin for netdata.\n"
  1350. "\n"
  1351. " Available command line options:\n"
  1352. "\n"
  1353. " SECONDS data collection frequency\n"
  1354. " minimum: %d\n"
  1355. "\n"
  1356. " debug enable verbose output\n"
  1357. " default: disabled\n"
  1358. "\n"
  1359. " sel\n"
  1360. " no-sel enable/disable SEL collection\n"
  1361. " default: %s\n"
  1362. "\n"
  1363. " hostname HOST\n"
  1364. " username USER\n"
  1365. " password PASS connect to remote IPMI host\n"
  1366. " default: local IPMI processor\n"
  1367. "\n"
  1368. " sdr-cache-dir PATH directory for SDR cache files\n"
  1369. " default: %s\n"
  1370. "\n"
  1371. " sensor-config-file FILE filename to read sensor configuration\n"
  1372. " default: %s\n"
  1373. "\n"
  1374. " ignore N1,N2,N3,... sensor IDs to ignore\n"
  1375. " default: none\n"
  1376. "\n"
  1377. " ignore-status N1,N2,N3,... sensor IDs to ignore status (nominal/warning/critical)\n"
  1378. " default: none\n"
  1379. "\n"
  1380. " -v\n"
  1381. " -V\n"
  1382. " version print version and exit\n"
  1383. "\n"
  1384. " Linux kernel module for IPMI is CPU hungry.\n"
  1385. " On Linux run this to lower kipmiN CPU utilization:\n"
  1386. " # echo 10 > /sys/module/ipmi_si/parameters/kipmid_max_busy_us\n"
  1387. "\n"
  1388. " or create: /etc/modprobe.d/ipmi.conf with these contents:\n"
  1389. " options ipmi_si kipmid_max_busy_us=10\n"
  1390. "\n"
  1391. " For more information:\n"
  1392. " https://github.com/ktsaou/netdata/tree/master/plugins/freeipmi.plugin\n"
  1393. "\n"
  1394. , VERSION
  1395. , netdata_update_every
  1396. , netdata_do_sel?"enabled":"disabled"
  1397. , sdr_cache_directory?sdr_cache_directory:"system default"
  1398. , sensor_config_file?sensor_config_file:"system default"
  1399. );
  1400. exit(1);
  1401. }
  1402. else if(i < argc && strcmp("hostname", argv[i]) == 0) {
  1403. hostname = strdupz(argv[++i]);
  1404. char *s = argv[i];
  1405. // mask it be hidden from the process tree
  1406. while(*s) *s++ = 'x';
  1407. if(debug) fprintf(stderr, "freeipmi.plugin: hostname set to '%s'\n", hostname);
  1408. continue;
  1409. }
  1410. else if(i < argc && strcmp("username", argv[i]) == 0) {
  1411. username = strdupz(argv[++i]);
  1412. char *s = argv[i];
  1413. // mask it be hidden from the process tree
  1414. while(*s) *s++ = 'x';
  1415. if(debug) fprintf(stderr, "freeipmi.plugin: username set to '%s'\n", username);
  1416. continue;
  1417. }
  1418. else if(i < argc && strcmp("password", argv[i]) == 0) {
  1419. password = strdupz(argv[++i]);
  1420. char *s = argv[i];
  1421. // mask it be hidden from the process tree
  1422. while(*s) *s++ = 'x';
  1423. if(debug) fprintf(stderr, "freeipmi.plugin: password set to '%s'\n", password);
  1424. continue;
  1425. }
  1426. else if(i < argc && strcmp("sdr-cache-dir", argv[i]) == 0) {
  1427. sdr_cache_directory = argv[++i];
  1428. if(debug) fprintf(stderr, "freeipmi.plugin: SDR cache directory set to '%s'\n", sdr_cache_directory);
  1429. continue;
  1430. }
  1431. else if(i < argc && strcmp("sensor-config-file", argv[i]) == 0) {
  1432. sensor_config_file = argv[++i];
  1433. if(debug) fprintf(stderr, "freeipmi.plugin: sensor config file set to '%s'\n", sensor_config_file);
  1434. continue;
  1435. }
  1436. else if(i < argc && strcmp("ignore", argv[i]) == 0) {
  1437. excluded_record_ids_parse(argv[++i]);
  1438. continue;
  1439. }
  1440. else if(i < argc && strcmp("ignore-status", argv[i]) == 0) {
  1441. excluded_status_record_ids_parse(argv[++i]);
  1442. continue;
  1443. }
  1444. error("freeipmi.plugin: ignoring parameter '%s'", argv[i]);
  1445. }
  1446. errno = 0;
  1447. if(freq > netdata_update_every)
  1448. netdata_update_every = freq;
  1449. else if(freq)
  1450. error("update frequency %d seconds is too small for IPMI. Using %d.", freq, netdata_update_every);
  1451. // ------------------------------------------------------------------------
  1452. // initialize IPMI
  1453. struct ipmi_monitoring_ipmi_config ipmi_config;
  1454. if(debug) fprintf(stderr, "freeipmi.plugin: calling _init_ipmi_config()\n");
  1455. _init_ipmi_config(&ipmi_config);
  1456. if(debug) fprintf(stderr, "freeipmi.plugin: calling ipmi_monitoring_init()\n");
  1457. if(ipmi_monitoring_init(ipmimonitoring_init_flags, &errnum) < 0)
  1458. fatal("ipmi_monitoring_init: %s", ipmi_monitoring_ctx_strerror(errnum));
  1459. if(debug) fprintf(stderr, "freeipmi.plugin: detecting IPMI minimum update frequency...\n");
  1460. freq = ipmi_detect_speed_secs(&ipmi_config);
  1461. if(debug) fprintf(stderr, "freeipmi.plugin: IPMI minimum update frequency was calculated to %d seconds.\n", freq);
  1462. if(freq > netdata_update_every) {
  1463. info("enforcing minimum data collection frequency, calculated to %d seconds.", freq);
  1464. netdata_update_every = freq;
  1465. }
  1466. // ------------------------------------------------------------------------
  1467. // the main loop
  1468. if(debug) fprintf(stderr, "freeipmi.plugin: starting data collection\n");
  1469. time_t started_t = now_monotonic_sec();
  1470. size_t iteration = 0;
  1471. usec_t step = netdata_update_every * USEC_PER_SEC;
  1472. heartbeat_t hb;
  1473. heartbeat_init(&hb);
  1474. for(iteration = 0; 1 ; iteration++) {
  1475. usec_t dt = heartbeat_next(&hb, step);
  1476. if(debug && iteration)
  1477. fprintf(stderr, "freeipmi.plugin: iteration %zu, dt %llu usec, sensors collected %zu, sensors sent to netdata %zu \n"
  1478. , iteration
  1479. , dt
  1480. , netdata_sensors_collected
  1481. , netdata_sensors_updated
  1482. );
  1483. netdata_mark_as_not_updated();
  1484. if(debug) fprintf(stderr, "freeipmi.plugin: calling ipmi_collect_data()\n");
  1485. if(ipmi_collect_data(&ipmi_config) < 0)
  1486. fatal("data collection failed.");
  1487. if(debug) fprintf(stderr, "freeipmi.plugin: calling send_metrics_to_netdata()\n");
  1488. send_metrics_to_netdata();
  1489. fflush(stdout);
  1490. // restart check (14400 seconds)
  1491. if(now_monotonic_sec() - started_t > 14400) exit(0);
  1492. }
  1493. }
  1494. #else // !HAVE_FREEIPMI
  1495. int main(int argc, char **argv) {
  1496. fatal("freeipmi.plugin is not compiled.");
  1497. }
  1498. #endif // !HAVE_FREEIPMI