0

I am trying to get some information from the output of ipmi-sensors, such as CPU_TEMP, CPU_FAN, ... and save the values for another API to use. A daemon will send command from remote to gather all the hosts' hardware status.

I'm tracing the code of ipmi-sensors.c and relative files, such as ipmi-sensors-simple-output.c and ipmi-sensors-detail-output.c. I find that the ipmi-sensors default output to stdout. In the main(), ipmi-sensors call ipmi_sensors_argp_parse first,

ipmi_sensors_argp_parse (/*argc, argv, */&cmd_args);

I'd like to get ipmi-sensors data from an API, I do not use the argc, argv, I mark out argc, argv and modify the content of function call for this purpose.

Then main() call another func pstdout_setup to setup the stdout for output

if ((hosts_count = pstdout_setup (&(prog_data.args->common_args.hostname),
                &(prog_data.args->common_args))) < 0)
    return (EXIT_FAILURE);

and launch it

if ((rv = pstdout_launch (prog_data.args->common_args.hostname,
                          _ipmi_sensors,
                          &prog_data)) < 0)

Does FreeIPMI have any API call in FreeIPMI to do ipmi-sensors's task? Or do I need to redirect the stdout to a stream or file using fork and dup2? Or do I need to rewrite the all part of ipmi-sensors?

Thanks for your help.

charles.cc.hsu
  • 689
  • 11
  • 15
  • maybe try to use this one [how-to-buffer-stdout-in-memory-and-write-it-from-a-dedicated-thread](http://stackoverflow.com/a/956269/3309645) – charles.cc.hsu May 17 '17 at 00:11

1 Answers1

1

FreeIPMI maintainer here. I believe the API you are looking for is "libipmimonitoring", it does about 90% of what is in ipmi-sensors.

Albert Chu
  • 313
  • 1
  • 5
  • Yes, I've read the ipmi-monitoring.c in the libipmimonitoring folder, but I have another question, compare with the result from ipmitool, the output are different, I would like to get the all DIMM information to check if DIMM have been plug-in but the information not found in ipmi-monitoring.c. – charles.cc.hsu May 31 '17 at 23:00
  • For those coming into this thread late, answer to prior comment followed up in this thread: https://stackoverflow.com/questions/44296332/get-all-dimm-information-from-ipmi-using-freeipmi-api – Albert Chu Jun 13 '17 at 15:40