Uptime on FreeBSD (potentially others?)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
byobu |
Incomplete
|
Medium
|
Unassigned |
Bug Description
Hi Dustin,
Thanks for merging my uptime fix for OS X. I did a quick test on FreeBSD 10.3, which I admittedly have no experience with until just now, and it looks like the same uptime method works there as well. The difference being the sysctl utility is /usr/sbin/sysctl on OS X and /sbin/sysctl on FreeBSD.
My quick fix for this was to change the else-if to:
elif type "sysctl" > /dev/null ; then
and removed the absolute path to sysctl below it. I didn't submit this a merge request since I didn't know how or if you'd like to handle it. Checking for any sysctl utility in the path could potentially increase the risk we're calling a different/
The uptime sed fallback seems to work well after 1 hour of uptime (when the format changes) which is probably good enough. I've been able to resolve some of the issues with the following:
sed -e "s/.* up *//" -e "s/ *days, */d/" -e "s/ *day, */d/" -e "s/:/h/" -e "s/ mins, .*/m/" -e "s/ min, .*/m/" -e "s/ secs, .*/s/" -e "s/ sec, .*/s/" -e "s/,.*/m/"
which does not require gsed. If it's possible to use the GNU extensions it could be shortened up. I can't guarantee it doesn't break places it already works but I've done some testing across Linux/Mac/FreeBSD and haven't seen it fail yet. It still could fail if the uptime is exactly "1 day". I imagine this is a losing battle since the uptime format doesn't appear to be standardized in any way and it could break as soon as the uptime format includes months/years.
Thanks,
Kevin
Would you mind attaching a patch here? And then set the bug back to "Confirmed". I'm happy to take a patch that improves uptime on other BSDs :-)