users: report number of unique users instead of counting all sshd processes / use who

Bug #900663 reported by Daniel Hahler on 2011-12-06
This bug affects 1 person
Affects Status Importance Assigned to Milestone
byobu (Ubuntu)

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
 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/oh-my-zsh/plugins/byobu/lib
 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..

Daniel Hahler (blueyed) on 2011-12-06
summary: users: report number of unique users instead of counting all sshd
- processes
+ processes / use who
description: updated
Dustin Kirkland  (kirkland) wrote :

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?

Changed in byobu:
importance: Undecided → Wishlist
status: New → Incomplete
Dustin Kirkland  (kirkland) wrote :

Okay, I added support for USERS_DISTINCT=1 status configuration variable. Hopefully this suffices for your usecase!

Changed in byobu:
status: Incomplete → Fix Committed
Changed in byobu (Ubuntu):
status: New → Fix Committed
importance: Undecided → Wishlist
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package byobu - 4.53-0ubuntu1

byobu (4.53-0ubuntu1) precise; urgency=low

  [ Dustin Kirkland ]
  * usr/share/byobu/profiles/common: LP: #900812
    - start screen with at least a 1 second message wait
  * usr/bin/byobu, usr/bin/byobu-ctrl-a, usr/bin/byobu-disable,
    usr/bin/byobu-enable, usr/bin/byobu-export, usr/bin/byobu-janitor,
    usr/bin/byobu-launch, usr/bin/byobu-launcher, usr/bin/byobu-
    launcher-install, usr/bin/byobu-launcher-uninstall, usr/bin/byobu-
    quiet, usr/bin/byobu-reconnect-sockets, usr/bin/byobu-select-
    backend, usr/bin/byobu-select-profile, usr/bin/byobu-shell,
    usr/bin/byobu-silent, usr/bin/byobu-status, usr/bin/byobu-status-
    detail, usr/bin/byobu-ugraph, usr/bin/byobu-ulevel,
    usr/lib/byobu/include/dirs, usr/share/byobu/profiles/byoburc:
    - big changeset to solve a few bugs, LP: #897473, #861291, #897048
    - take over ~/.byoburc, and use it for storing global byobu shell
      configuration, namely BYOBU_PREFIX when necessary
      + note that some users might have previously used ~/.byoburc to
        store byobu-only screen configuration
      + these users should now use ~/.byobu/.screenrc instead (also
        because byobu now supports both screen and tmux)
    - on first run, if byobu is running outside of its normal location
      in /usr/bin/byobu, it will automatically detect and append the
      correct BYOBU_PREFIX value and store it in ~/.byoburc
    - ~/.byoburc is now read by all usr/bin/* in order to find the
      correct prefix
  * usr/lib/byobu/include/dirs: LP: #780081
    - use ~/.local/share/byobu as BYOBU_CONFIG_DIR, if it happens to exist
  * usr/lib/byobu/include/dirs: LP: #899271
    - allow explicit BYOBU_CONFIG_DIR selection in ~/.byoburc
  * usr/lib/byobu/users, usr/share/byobu/status/statusrc,
    usr/share/man/man1/byobu.1: LP: #900663
    - add support for a USERS_DISTINCT=1 status configuration setting
      to count the number of distinct users, rather than open ssh sessions

  [ Andrew McCarthy ]
  * usr/bin/byobu-status: LP: #898801
    - fix status detailing, skip include, as it's a directory
 -- Dustin Kirkland <email address hidden> Mon, 05 Dec 2011 08:59:08 -0600

Changed in byobu (Ubuntu):
status: Fix Committed → Fix Released
Changed in byobu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers