I'm writing a script which utilises the salt-cli (SaltStack) as well as generic command line arguments to produce a simple HTML-based table outlining all of our servers' Hardware specs and software versions.
It's as simple as it sounds, however my only challenge is stripping my commands outputs so that they can be presented nicely in a table (e.g. one word/number rather than the whole output).
My latest challenge that I'm yet to strip effectively is the output of a simple 'df -Ph. So far I have got it down to this:
'df -Ph /'
My output:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vhfhuffu 50G 8.0G 39G 18% /
I would like it to only show the available for each server, I can't find a reliable way to do this for ever Unix server.
I ended up going with this due to my need to run this command from a script via Salt which requires '' around the cmd.run
df -Ph / | grep / | awk '"'"'{ print $4}'"'"''
Ugly but it's the only thing that works in such a niche case