3 ms·
`sysctl -b kern.boottime` works wonderfully. The output is two 64-bit integers, so the script pipes it through `od -t uI`. I would've liked to use `-t uL` but `
by Arnavion 7y ago
`sysctl -b kern.boottime` works wonderfully. The output is two 64-bit integers, so the script pipes it through `od -t uI`. I would've liked to use `-t uL` but `od` complains that it's a "bad byte count", so the script has to manually add the two components together. (`-t dL` also raises the same error, even though the man page implies that at least should work. Strange. I did not investigate why.)
It also works for the thermal sysctls - they appear to output 4-byte unsigned integers in deci-Kelvins. Eg 3061 is 306.1 K == 33.0 degrees Celsius.
`netstat ... --libxo json` does work, though parsing JSON from awk isn't trivial either. The best way I can think of is to use `json,pretty` which puts one key-value-pair per line, which I could then filter for the specific keys I want. But it would amount to as much or more effort as the non-JSON parser makes.
pfSense doesn't have `jq` by default but does have `uclcmd`. I got as far as `netstat -I em0 -bin --libxo json | uclcmd get -f - -j '.statistics.interface'` to get an array of JSON objects, but any attempt to apply a transformation to each element of this array (there are no manpages for it online, but its Github readme implies the existence of an `each` function) caused the program to segfault.