[Machine readable output from userland utilities] report

Zaro Korchev zkorchev at mail.bg
Mon Jun 2 11:43:27 UTC 2014


This week I made some improvements to the output library libsol to allow more flexibility.

I have modified the base system's versions of ls and vmstat to support the new output library. There are some things to fix but both tools can now produce JSON output.

The changes are available at my GSoC svn repository:
https://socsvn.freebsd.org/socsvn/soc2014/zkorchev/

At the moment both ls and vmstat are told to output JSON by specifying the -O option. However as I discussed with my mentor, this will be changed. The idea is to use an environment variable instead of the -O flag.

Here are some examples of the output of vmstat (I formatted the JSON in this email to be more readable for humans):

# vmstat -O
{
    "procs_r": 0,
    "procs_b": 0,
    "procs_w": 0,
    "mem_avg": 541240,
    "mem_free": 887156,
    "page_flt": 15,
    "page_re": 0,
    "page_pi": 0,
    "page_po": 0,
    "page_fr": 18,
    "page_sr": 5,
    "ad0": 0,
    "cd0": 0,
    "fault_in": 2,
    "fault_sy": 41,
    "fault_cs": 61,
    "cpu_user": 0.09950441105699527,
    "cpu_sys": 1.5893235226189397,
    "cpu_idle": 98.31117206632406
}

# vmstat -Of
{
    "fork": {
        "count": 605,
        "pages": 23192,
        "average": 38.33388429752066
    },
    "vfork": {
        "count": 319,
        "pages": 11546,
        "average": 36.19435736677116
    },
    "rfork": {
        "count": 0,
        "pages": 0,
        "average": 0
    }
}

I'm thinking about rounding the floating point numbers.

Any suggestions for improvement are welcome :)


Zaro


More information about the soc-status mailing list