1. 6

FreeBSD mailing list discussion regarding additions of code (libxo library) to add native json/xml output for core unix tooling.


  2. 2

    Well, it doesn’t break everything (yet). Only w supports libxo output, but who does not. So you just need to switch to the unbroken version. :)

    1. 1

      It’s an interesting discussion. On one hand, reworking the core tools to have better output is great, on the other hand I feel that Julian makes a great point: what about third party apps? This only solves half the problem. Alfred wants to shame them into supporting libxo, but I just don’t buy that as happening. Hopefully I’m wrong.

      I think externalizing the machine readableness of these programs somehow is the right thing to do, but not sure exactly how. The approach of replacing uptime with a script that does:

      uptime_generic $@ | uptime_fmt_legacy

      Seems like it could work well. If one could come up with a description language suitably generic then you can just do uptime_generic $@ | fmt_human.

      I’m also not convinced XML or JSON are actually right as an intermediate language, but I don’t have one better either.

      1. 3

        If I were going to go down this road, I would start from scratch. Finding the answer to a question is already this crazy jumble of netstat, vmstat, systat, iostat, etc. slapping json output on doesn’t make it any less ad hoc. There’s a lost opportunity here to reflect on what information is useful and how to present. Like really how to present it, not just the markup tags surrounding it.

        I’d probably start with an entirely new daemon. Maybe an http mode and a “raw” mode, though they’d both probably dump nothing but json.

        That would also solve another problem: fork and exec. dlg has a funny story about a gigabyte sized riak process that needed to run uptime for some reason. Every second, fork and exec of this enormous process to run one tiny little program.

        1. 1

          posix_spawn exists.

          1. 1

            Which is nothing more than a wrapper on FreeBSD, and even as a syscall would still leave leave you with basic exec, stdio init, exit overhead.

    2. 2

      I don’t know about FreeBSD, but I thought everything would need a switch to output to xml/json?
      wc –libxo xml,pretty,warn /etc/motd

      1. 2

        Yes, but all the plain text output goes through libxo as well. And of course the program internals need to be reworked, in some cases substantially, to call libxo instead of printf. Mistakes get made.