[CFR][CFT] counter(9): new API for faster and raceless counters

Erik Cederstrand erik at cederstrand.it
Fri Apr 5 08:10:33 UTC 2013


Den 05/04/2013 kl. 00.30 skrev Alfred Perlstein <bright at mu.org>:

> On 4/4/13 2:08 AM, Pawel Jakub Dawidek wrote:
>> XML is no go for me, as it is not really easy to use in scripts.
>> We would need to create a tool to parse it and then I'd much prefer to
>> import my API for dealing with name/value pairs that could be used in so
>> many more places.
>> 
> Do you have a link to this format?
> 
> I'm looking at YAML and it's interesting, although I'm not sure if a more abbreviated format wouldn't be better.
> 
> What I'm currently using is like:
> 
> date|vfs.freebuffers:5000|vfs.highbuffers: 343433|...|

If you want to implement of machine-parseable output of sysctl that supports key-value output, then please use a generally-accepted format. This would make it so much easier for third-party software to use the output. YAML or JSON are obvious choices.

Powershell from Microsoft solves this generally by having all tools pipe output as objects with a well-defined contract to the next command. Whatever is printed to stdout is just human-friendly output. It's nice because you can skip a lot of grep/sed/awk/cut trickery and just filter and pick fields in a more object-oriented way. But it's also a PITA because what's printed to the terminal is not what's piped to the next command, so you need to look up the object spec every time you add a pipe.

I think it would be going overboard to add a --yaml or --json flag to every single userland tool in FreeBSD, but designing key-value output for sysctl so it can be applied to other tools would be really nice.

Thanks,
Erik


More information about the freebsd-arch mailing list