Ok, here's how to get a really basic JSON output. First grab the stat_output.txt file and put it in a directory.
Then, install GNU m4 on your linux machine, put this m4 macro script into a file called jsonify.m4 in same directory
divert(-1)dnl
define(`delfirstbrack',`define(`delfirstbrack',`')dnl')
define(`delcomma',`')
pushdef(`delcomma',`dnl')
define(`cpuent0',["$1"`,translit('$2`,` ',`,')]')
define(`cpuentn',`,'["$1"`,translit('$2`,` ',`,')]')
define(`date',`delfirstbrack]}
delcomma,
{
"time" : popdef(`delcomma')')
define(`procstat',`,
"cpuvals" :[')
define(`ctxt',`] dnl')
define(`intr',`dnl')
define(btime,`dnl')
define(processes,`dnl')
define(procs_running,`dnl')
define(procs_blocked,`dnl')
define(softirq,`dnl')
define(procnetdev,`,
"interfaces" :[pushdef(`delcomma',`dnl')dnl')
define(Inter,`
dnl')
define(face,`dnl')
define(interfacedata,`delcomma,
define(`delcomma',`')dnl
[patsubst("'$1`",` +',`')`,' patsubst('$2`,` +',`,')]')
divert dnl
m4wrap(]}])dnl
[
Then put this script called jsonify.sh into the same directory:
#!/bin/sh
cat jsonify.m4 $1 | sed -E -e "s:#*::g"\
-e "s:/proc/stat:procstat:"\
-e "s:/proc/net/dev:procnetdev:"\
-e "s:(cpu) (.*):cpuent0(\1,\2):"\
-e "s:(cpu[0-9]+) (.*):cpuentn(\1,\2):"\
-e "/^ face/,/date/ s/(.*):(.*)/interfacedata(\1,\2)/" | m4
Then chmod u+x jsonify.sh
and run
./jsonify.sh stat_output.txt
It should give you a sequence of JSON objects
EDIT: It should but I haven't actually tried to parse it, so if you find errors let me know. I'll get a chance to test reading it in probably some time next week.
EDIT: ok, I admit I screwed a few things up so fixing them...