Writing remote xml parsed data to db

Hi,

I have been trying figure out how to write parsed data to influx, but failing. any ideas
welcome.

Here are the facts;

This file state.xml comes from a temperature plc sitting on my network.
administrator@openmaint01:~$ curl -i http://192.168.253.230/state.xml
?xml version=“1.0” encoding=“utf-8”?>
datavalues>
units>C
sensor1temp>-24.6/sensor1temp>
sensor2temp>x.x/sensor2temp>
sensor3temp>x.x/sensor3temp>
sensor4temp>x.x/sensor4temp>
relay1state>0/relay1state>
relay2state>0/relay2state>

I want to parse the sensor1temp value and write it to my influx database.

Thanks
Morgan

You’ll need to use your programming language of choice to write a program to parse the XML and then either:

1 Like

Mark,

Thanks for the reply the most simple I know for my is.

cat /home/administrator/ktemp/state.xml | sed -ne ‘//s#\s*<[^>]>\s##gp
=-24.6

As you can see I have downloaded the state.xml and than ran cat on it to parse the info.

This is going to be basically three steps ①curl download the xml file. ② cat parse the file data.
③ write the parsed data to influxdb. correct?

Can all this be done in one prog, download, parsed on the fly with Curl or something? I tried the following but fail, I am just not savvy enough.

curl -POST ‘http://localhost:8086/write?db=ktemp’ --data-binary ‘sensor1temp’ value=cat /home/administrator/ktemp/state.xml | sed -ne '/<sensor1temp>/s#\s*<[^>]*>\s*##gp'

Thanks in advance

Morgan