Attempt to modify existing plugin for telegraf

I’m very new to telegraf and programing in general.
my goal is to modify existing telegraf plugin: ipmi_sensor.
using multiple resources on web I completed these steps, hope I’m on correct track.

1: Fork the Telegraf Repository
2: Clone Fork Locally
3. mkdir ipmi_sensor_1 in plugins/inputs/ and copied content of the folder ipmi_sensor to the folder ipmi_sensor_1
4. renamed ipmi_sensor.go to ipmi_sensor_1.go, renamed ipmi_sensor_test.go to ipmi_sensor_test_1.go
5. replaced references to ipmi_sensor to ipmi_sensor_1 in ipmi_sensor_1.go and ipmi_sensor_test_1.go
6. added ipmi_sensor_1.go to plugins/inputs/all

I think I need to register ipmi_sensor_1.go on github before compiling telegraf?
reading this:telegraf/docs/INPUTS.md at master · influxdata/telegraf · GitHub

Not sure how to execute this code:
//go:build !custom || inputs || inputs.simple
package all
import _ “github.com/influxdata/telegraf/plugins/inputs/simple” // register plugin

Thank you.

Hello @AlexV,
That’s awesome!
Have you checked out the execd plugins though?
It might be easier than modifyign a plugin.
What is your end goal?

This is the correct way to register your plugin. This import _ syntax ensures that your plugin gets compiled even though its symbols are not explicitly used in the code.

import _ "github.com/influxdata/telegraf/plugins/inputs/ipmi_sensor_1"

For the build tag you’ll want

//go:build !custom || inputs || inputs.ipmi_sensor_1

Then to compile you just do

make telegraf

i do believe

Hi, Anaisdg,
We started to use telegraf to collect data during hardware validation from multiple platforms from different suppliers. Dell was first, Intel is next. But Intel does not support Cipher suit 3 and need -C17 switch included with ipmitool command. This is why my colleague and me experimenting with custom plugin.
The /plugins/inputs/all/ipmi_sensors/all/ipmi_sensor_1.go was modified, and compiler works for last 10min (it’s lean VM so may take a while)
I have time to check execd now. Thank you!

Anaisdg, on the same subject, here is the Intel TA describing the situation with Cipher3
Technical Advisory (intel.com)
The issue is that Intel sold Server business to MiTAC. And new FW from MiTAC does not have option to enable Cipher3 so far.
https://www.datacenterdynamics.com/en/news/intel-to-sell-dedicated-server-business-to-mitac/

@AlexV with registration, do you mean to add it to a released version? If so, please push your local changes to your fork and then open a pull request against the master branch of the Telegraf repository!

Btw: It would be nice if you could integrate your changes into the existing plugin instead of copying the code and change it…

@srebhan, yes I will push my local changes, its fine. Unfortunately, there is problem. My goal is to add -C17. So command line executed by telegraf/ input plugin would look like this:
“/usr/bin/ipmitool -H 192.168.100.24 -U sysadmin -P REDACTED -I lanplus -C17 sdr elist”
The switch -C17 was added to line 53 in the ipmi_sensor_1.go
The line looks like this now: const cmd = “ipmitool -C17”. But it is wrong because debug log show: 2024-08-26T20:29:01Z E! [telegraf] Error running agent: could not initialize input inputs.ipmi_sensor_c17: looking up “ipmitool -C17” failed: exec: “ipmitool -C17”: executable file not found in $PATH. Can you please advise how to handle this -C17 switch? Thank you. Alex

You are specifying the command ipmitool -C17 but what you want is to add an argument. So you should add a list entry to command in the parse function (line 116ff)… Please do so by adding a new option in the ipmi_sensor plugin (e.g. additional_flags) if the flag does not change the output format. Otherwise, you should add a dedicated flag…

@srebhan [quote=“AlexV, post:4, topic:35424”]
on the same subject, here is the Intel TA describing the situation with Cipher3
Technical Advisory (intel.com)
[/quote]
I got a message that the requirement to select the cipher level in IPMItool was a IPMItool bug. Normally IPMItool will attempt different ciphers until it gets connection. IPMItool 1.8.18 and below, did not include cipher 17 in this communication attempt. Using 1.8.19-5 from command line I was able to read ipmi sensors. But telegraf with generic ipmi_sensor plugin shows this error in the debug log: [inputs.ipmi_sensor] Error in plugin: failed to run command “/usr/bin/ipmitool -H xxx.xxx.xxx.xxx -U xxxxx -P REDACTED -I lanplus sdr elist”: exit status 1 - Error in open session response message : invalid authen>

This how executing the same command from bash looks like: ipmitool -H xxx.xxx.xxx.xxx -U xxxx -P xxxxxxxx -I lanplus sdr elist
IANA PEN registry open failed: No such file or directory
System Airflow | 00h | ns | 0.1 | No Reading
PSU1 Out Current | 01h | ok | 0.1 | 0 Amps
Pwm 1 | 02h | ns | 0.1 | No Reading
.
Of course I’ll review my testing, still wondering if ipmitool 1.8.19 was used with telegraf?
.

@AlexV we use whatever is installed on the system IIRC. Maybe the old version of the tool is still in the path for the telegraf user?

I’ll look, may take a few days, as priorities are changing.

1 Like

Ok, looks like it works with ipmitool 1.8.19-5 and ipmi_sensor plugin.
after purging all ipmitool related packages and installing ipmitool_1.8.19-5_amd64.deb

dpkg --list
sudo apt-get remove ipmitool
sudo apt-get purge ipmitool
sudo apt-get autoremove
sudo apt-get clean
‘sudo apt install ./ipmitool_1.8.19-5_amd64.deb’
Thank you.

1 Like