Posting ipmitool data to influxdb for use in grafana

284 views Asked by At

My Linux bash skills are rudimentary so I am seeking some help. I am attempting to insert some CPU temperature data into an influx database so that it can be displayed on a Grafana dashboard.

So far I have been able to retrieve the CPU temperatures via ipmitool in Linux, see below example... which shows the command I run, and the resulting temperature figures.

ipmitool sdr elist full | grep CPU | grep Temp | cut -d "|" -f 5 | cut -d " " -f 2
40
47

I want to feed these numbers into variables so I can insert them into the influx database using a command something like below.

curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'server_temps,sensor=CPU1, value=23' 

The command above works manually, and inserts the value 23 into the influx database. What I'd like to do is automate the data collection and insertion into the influx database... but for both CPU1 and CPU2.

Initially I am thinking I may need several curl sections, to enable the temperatures for CPU1 and CPU2 to be added to the database every 30 seconds or so. If I can get this to work it is possible I will want to add additional data from ipmitool.

I suspect I may not be doing this the best method? So all ideas, help, very much appreciated.

1

There are 1 answers

1
Łukasz Ślusarczyk On

Would using simple bash loop sufficient?

for temperature in $(ipmitool sdr elist full | grep CPU | grep Temp | cut -d "|" -f 5 | cut -d " " -f 2)
do 
  curl -i -XPOST "http://localhost:8086/write?db=mydb' --data-binary 'server_temps,sensor=inlet, value=$temperature"
done