diff options
author | lassulus <lassulus@googlemail.com> | 2013-01-31 19:41:11 +0100 |
---|---|---|
committer | lassulus <lassulus@googlemail.com> | 2013-01-31 19:41:11 +0100 |
commit | 5f8f9ea9e5f10abcef9c12d48345c098dca78199 (patch) | |
tree | c4dd748d5c152445569d7dfd2d0877ef66a95daa /ext/solus/lib/parse-return-data | |
parent | 7c050acc2559c622b831d9193e2336c15f42de6d (diff) | |
parent | 9461f6ece9f674588327c6dc3199fc0d7618ac48 (diff) |
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'ext/solus/lib/parse-return-data')
-rwxr-xr-x | ext/solus/lib/parse-return-data | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/solus/lib/parse-return-data b/ext/solus/lib/parse-return-data new file mode 100755 index 00000000..85219727 --- /dev/null +++ b/ext/solus/lib/parse-return-data @@ -0,0 +1,20 @@ +#! /bin/sh +set -euf +sed ' + # transform "XML" into lines {key}<tab>{value}-lines + s|</[^>]*>|\n|g + s|<\([^>]*\)>|\1\t|g +' | +sed ' + # transform ipaddr list into multiple ipaddr_[46]<tab>{ipaddr}-lines + /^ipaddr\t/{ + s|,|\nipaddr\t|g + s/\t\([0-9]*[.]\)/_4&/g + s/\t\([0-9]*[:]\)/_6&/g + } + # parse CSVs into multiple lines with proper labels + s:^\(hdd\|mem\|bw\)\t\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\)$:\1_total\t\2\ +\1_used\t\3\ +\1_free\t\4\ +\1_percentused\t\5: +' |