There are some options to the df
command that will make parsing the information easier, I think. For instance, you can ask for only the output fields you need for one mount point by using the command line:
df -h --output=size,used,avail,pcent /dev/xvda1
This produces output on my system like this:
Size Used Avail Use%
30G 12G 19G 39%
which should be able to be parsed by the csv
node into a a payload like:
{
"Size": "30G",
"Used": "12G",
"Avail": "19G",
"Use%": "39%"
}
Here is my test flow…
[{"id":"2df68268.9aa99e","type":"inject","z":"58c8eb7a.5496c4","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":3000,"wires":[["3c76d35d.4ad61c"]]},{"id":"35d484b6.6e879c","type":"csv","z":"58c8eb7a.5496c4","name":"","sep":" ","hdrin":true,"hdrout":"","multi":"one","ret":"\\n","temp":"","skip":"0","x":470,"y":3040,"wires":[["bf4993f5.17586"]]},{"id":"bf4993f5.17586","type":"debug","z":"58c8eb7a.5496c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":3000,"wires":[]},{"id":"d43b7157.d1a9c","type":"comment","z":"58c8eb7a.5496c4","name":"df -h output","info":"","x":170,"y":2960,"wires":[]},{"id":"3c76d35d.4ad61c","type":"template","z":"58c8eb7a.5496c4","name":"","field":"payload","fieldType":"msg","format":"text","syntax":"plain","template":" Size Used Avail Use%\n 30G 12G 19G 39%\n","output":"str","x":320,"y":3000,"wires":[["35d484b6.6e879c","bf4993f5.17586"]]}]
Unfortunately, I just tried it, and get this confusing output as the result:
{"Use%":"12G"}
I suspect that the parser treats consecutive spaces as a delimiting empty fields – which is why the 12G “Used” value is being paired with the “Use%” column. But what has happened to the other three columns? Perhaps we need a new feature like the Excel “treat consecutive delimiters as one” option…