Comment 0 for bug 900663

Revision history for this message
Daniel Hahler (blueyed) wrote : users: report number of unique users instead of counting all sshd processes

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

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/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..