users: report number of unique users instead of counting all sshd processes / use who
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
byobu |
Fix Released
|
Wishlist
|
Unassigned | ||
byobu (Ubuntu) |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
I have noticed that byobu tends to report too many users for me.
Currently it says "9#", and when looking for the processes like byobu does I see:
% pgrep -fl 'sshd:.*@'
1335 sshd: user@pts/0
1731 sshd: user@pts/0
8522 sshd: user@pts/2
8600 sshd: user@pts/2
8804 sshd: user@pts/4
12344 sshd: user@pts/0
17048 sshd: user@pts/0
25590 sshd: user@pts/6
30121 sshd: user@pts/0
I think that this status notification / plugin should only count the number of distinct users.
What do you think about using something more in line of the following?
pgrep -fl 'sshd:.*@' | cut -f3 -d\ | cut -f1 -d@ | sort -u | wc -l
Or even better use "who" to get a list of all logins, including local ones:
who | cut -f1 -d\ | sort -u | wc -l
If you really want to count only remote/sshd logins, you could filter by the 5th column of "who", or use some of its options maybe.
Besides, looking at the output of "w", I only see the following:
% w
[snip]
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
user pts/1 192.168.x.x:S Thu18 22.00s 0.49s 0.49s /usr/bin/zsh
user pts/3 192.168.x.x:S 09:56 6:53 1.01s 0.57s vim .dotfiles/
user pts/2 192.168.x.x:S 09:53 11:03 0.34s 0.34s /usr/bin/zsh
user pts/4 192.168.x.x:S 10:00 0.00s 0.31s 0.00s w
This appears to reflect the 4 windows in the byobu/screen session.
I do not know where the other sshd processes are coming from..
summary: |
users: report number of unique users instead of counting all sshd - processes + processes / use who |
description: | updated |
Changed in byobu: | |
status: | Fix Committed → Fix Released |
Hmm, well, I think I disagree with the premise. But perhaps the notification needs to be renamed.
What I'm really interested in is how many ssh sessions are open to my server. Generally speaking, if I'm the only user of the server, and that number is more than 1, I want to know about it :-)
I also use it extensively when conducting education with a shared byobu session. I can see how many users/sessions connect to the classroom. All of these users are coming in as the same "guest" user.
I suppose it would be most easy to support a configuration option in ~/.byobu/statusrc where you could set whether you want to count distinct ssh sessions, or unique users connected to the system. If I solve this at all, that's probably how I'd handle it. Would that be useful to you, Daniel?