Page MenuHomeFreeBSD

Convert vmstat to use libxo
ClosedPublic

Authored by rodrigc on Oct 19 2015, 1:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 25 2024, 12:11 AM
Unknown Object (File)
Oct 20 2024, 11:38 AM
Unknown Object (File)
Oct 4 2024, 10:41 PM
Unknown Object (File)
Oct 2 2024, 5:39 AM
Unknown Object (File)
Oct 2 2024, 5:34 AM
Unknown Object (File)
Sep 21 2024, 11:10 AM
Unknown Object (File)
Sep 14 2024, 9:38 AM
Unknown Object (File)
Sep 8 2024, 8:16 AM
Subscribers

Details

Summary

Update patch from Juniper which converts vmstat to use libxo.

Test Plan

Ran the following:

vmstat -a -i
vmstat -f
vmstat -o
vmstat -m
vmstat -P
vmstat -a -i --libxo json | python2.7 -mjson.tool
vmstat -f --libxo json | python2.7 -mjson.tool
vmstat -o --libxo json | python2.7 -mjson.tool
vmstat -m --libxo json | python2.7 -mjson.tool
vmstat -P --libxo json | python2.7 -mjson.tool

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rodrigc retitled this revision from to Convert vmstat to use libxo.
rodrigc updated this object.
rodrigc edited the test plan for this revision. (Show Details)
rodrigc added reviewers: allanjude, marcel, alc, bapt, rwatson.
rodrigc set the repository for this revision to rS FreeBSD src repository - subversion.
allanjude edited edge metadata.

Please add a xo_version() somewhere before the start of the output

This revision now requires changes to proceed.Oct 29 2015, 9:41 PM
rodrigc edited edge metadata.
rodrigc removed rS FreeBSD src repository - subversion as the repository for this revision.

Use xo_set_version()

vmstat.c
671 ↗(On Diff #9494)

xo_attr doesn't really apply to JSON
rather than that, you can do: {:name/encoded version/text version}

so:

snprintf(fmt, sizeof(fmt), "{:%s/%%ju/%%s}", name);
xo_emit(fmt, (uintmax_t) val, size, buf);

805 ↗(On Diff #9494)

%1d %1d %1d became %1d %ld %ld (one one one, became one ell ell), was that indentional?

Any time the 'width' of the output is limited, you should use have an 'encoding' format version that is not limited

for example: xo_emit("{:name/%16s}", string);

should be: xo_emit("{:name/%s/%16s}", string, string);

so the xml/json version is not truncated (or padded), but the text version is

822 ↗(On Diff #9494)

fixed width number

886 ↗(On Diff #9494)

did you mean to add a literal dollar sign here?

989 ↗(On Diff #9494)

you could tag the 'usec' as the units, but probably not worth it

1380 ↗(On Diff #9494)

%-%s is meant to have a * isn't it?

Regarding xo_attr(), yes you are right that it applies to XML and not JSON. That part of the patch is from Juniper's original patch,
and Juniper relies more heavily on XML for some of their stuff, so I would rather leave that part of the patch in for them.

This revision was automatically updated to reflect the committed changes.
op added inline comments.
head/usr.bin/vmstat/vmstat.c
809

Are these %1d -> %ld conversion here intended?

1514

Why not {T:LIMIT/%-20s} and similar here, as in line 1654 or vica-versa?