Bug 219113 - [feature request][patch] Make ruptime(1) more specific about number of users
Summary: [feature request][patch] Make ruptime(1) more specific about number of users
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-05-06 23:47 UTC by Andy Farkas
Modified: 2017-10-17 01:32 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Farkas 2017-05-06 23:47:10 UTC
I had to think twice and read the man page for ruptime(1) when it reported
0 users on machines I knew I was logged in to multiple times (see -a flag).

I propose the following simple patch:

--- /usr/src/usr.bin/ruptime/ruptime.c	2017-05-07 09:24:38.767786000 +1000
+++ ./ruptime.c	2016-12-11 09:39:26.693397000 +1000
@@ -242,11 +242,12 @@
 			continue;
 		}
 		(void)printf(
-		    "%-25.25s%s,  %4d user%s  load %*.2f, %*.2f, %*.2f\n",
+		    "%-25.25s%s,  %4d %suser%s  load %*.2f, %*.2f, %*.2f\n",
 		    wd->wd_hostname,
 		    interval((time_t)wd->wd_sendtime -
 		        (time_t)wd->wd_boottime, "  up"),
 		    hsp->hs_nusers,
+		    aflg ? "" : "active ",
 		    hsp->hs_nusers == 1 ? ", " : "s,",
 		    maxloadav >= 1000 ? 5 : 4,
 		        wd->wd_loadav[0] / 100.0,

which produces an output like this:

andyf@deepthink:~ % ruptime
deepthink          up   36+16:20,     1 active user,   load 0.20, 0.28, 0.44
drunkfish          up   55+14:37,     3 active users,  load 0.60, 0.26, 0.20
hummer             up   42+23:15,     1 active user,   load 0.11, 0.08, 0.05
snuggles           up  131+15:26,     8 active users,  load 0.20, 0.21, 0.17
andyf@deepthink:~ % ruptime -a
deepthink                  up   36+16:20,     3 users,  load 0.20, 0.28, 0.44
drunkfish                  up   55+14:37,     8 users,  load 0.60, 0.26, 0.20
hummer                     up   42+23:15,     2 users,  load 0.11, 0.08, 0.05
snuggles                   up  131+15:26,    13 users,  load 0.20, 0.21, 0.17
andyf@deepthink:~ % 

(note: I've deleted 8 spaces from the first column to stop line-wrap)
Comment 1 Timur I. Bakeyev freebsd_committer 2017-10-17 01:32:36 UTC
The true(tm) fix here would be to add libxo usage, as it's done with the uptime/w.