Ipmitool value import curl

Hi,

Please take a look at this and let me know if It can be done. Thanks in advance.

administrator@openmaint01:~$ curl -i -XPOST http://localhost:8086/write?db=stemp --data-binary “Room_Temp,Inlet Amb Temp,host=HP_ML150 value=sudo ipmitool -c sensor reading "Inlet Amb Temp"
HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: 6dbb3dbb-7b44-11e7-8bd9-000000000000
X-Influxdb-Version: 1.3.1
Date: Mon, 07 Aug 2017 07:45:48 GMT
Content-Length: 117

{“error”:“unable to parse ‘Room_Temp\,Inlet Amb Temp,host=HP_ML150 value=Inlet Amb Temp,22’: invalid field format”}

Looks like the field format isn’t a match (The value is String + number). You may want to run the command first like below

sudo ipmitool -c sensor reading “Inlet Amb Temp” | while read line; do curl -i -XPOST http://localhost:8086/write?db=stemp --data-binary “Room_Temp,Inlet Amb Temp,host=HP_ML150 value=$line”;done

If the command prints the value like
sudo ipmitool -c sensor reading “Inlet Amb Temp”
Output: Inlet Amb Temp,22

Further run it through awk or cut to remove the “String” value

Ok, so you’re trying to pull ipmi data and put it into influx. I see multiple problems with the line feed protocol in this example.
commas are key characters in influx.
Please read Error Messages | InfluxDB OSS 1.3 Documentation
You can simply leave off the word insert when using the /write api
For spaces in your measurement or tags, try putting back slashes before the spaces in your tags or field keys. I.E. Inlet\ Amb\ Temp
I believe this is what you should be doing:
curl -i -XPOST http://localhost:8086/write?db=stemp --data-binary “Room_Temp,host=HP_ML150 Inlet\ Amb\ Temp=sudo ipmitool -c sensor reading “Inlet Amb Temp””
But this will still have a problem because the value after the = sign should only be the 22, and not “Inlet Amb Temp,22”
You’ll need to use a text processor like awk, or grep, etc, to strip off that first part of the return from the ipmitool, so that the only thing you get back is the value.

You can add some other tags into the insert like hostname=xxxxxxxxx, and just put the dnsName of the server in place of xxxxxxxxxxx. This will just give another way to pull the data instead of only using host=HP_ML150. What if one day there are 2 HP_ML150 servers?

Jeffery,

Thanks for the reply, I`m thinking maybe just save as overwriiten text file then run cat sed parse the value into influx, not efficient but…
Any other ideas would be wellcome. Thanks for the input.

By the way here is your code result.

administrator@openmaint01:~$ curl -i -XPOST http://localhost:8086/write?db=stemp --data-binary “Room_Temp,host=HP_ML150 Inlet\ Amb\ Temp=sudo ipmitool -c sensor reading “Inlet Amb Temp””
HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: bf5f0c4a-7bc7-11e7-bfff-000000000000
X-Influxdb-Version: 1.3.1
Date: Mon, 07 Aug 2017 23:25:49 GMT
Content-Length: 143

{“error”:“unable to parse ‘Room_Temp,host=HP_ML150 Inlet\ Amb\ Temp=sudo ipmitool -c sensor reading “Inlet Amb Temp”’: invalid boolean”}

Please take a little bit of time and review what I provided. It was not provided with the expectation that a copy +paste would work.
Reviewing that error, it’s because the sudo ipmitool blah blah blah command was not in quotes, therefor, was not executed.

But, as I said in the last post, even if it was, you’d need to strip out the first part, so that you have a command that only returns the number 22. Once you have that, simply provide it in quotes after the “Inlet\ Amb\ Temp=” part of the insert.