Skip to contentSkip to conversation

How can I know the number of current users in the system?

DISCUSSION Terje Eggestad 2 participants 2 messages Nov 6, 2001 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Absolutly true.

You can get a 90% solution by testing for tty and for proces that has a connection to a tcp port between 6000 and 6100 somewhere or has a unix socket to /tmp/.X11-unix/X0 (or whereever X chooses to place the unix socket).

But thats definitly not good enough to base your scheduling on.

TJ

tir, 2001-11-06 kl. 13:38 skrev Nicholas Berry:
It depends whether you're looking for an idea of who's on, or you want a definitive count. The lattter is basically almost impossible. What if a logged-in user nohups two xterms to different X-servers, then logs out - how many people are logged in? I've spent a hell of a long time working on this on AIX for a certain German bank, and the bottom line is that it can't be done. What is 'logged on' anyway? Someone running bash or ksh, that's cool, but what about someone running /home/fred/myprog? Is it a shell?

Basically once Unix went beyond serial terminals connected to dumb serial ports, we lost the ability to track users.

Nik

> Hmmm, you should be able to count the number of pty's and tty's. > Every logged in user is attached to some sort of getty > whose parent is the init task (1). That might be a basis for > a count.

Signature · 10 lines
_________________________________________________________________________

Terje Eggestad                  [email protected]
Scali Scalable Linux Systems    http://www.scali.com

Olaf Helsets Vei 6              tel:    +47 22 62 89 61 (OFFICE)
P.O.Box 70 Bogerud                      +47 975 31 574  (MOBILE)
N-0621 Oslo                     fax:    +47 22 62 89 51
NORWAY            
_________________________________________________________________________
#2 lore raw
Quoted 10 lines · Terje Eggestad

Absolutly true.

You can get a 90% solution by testing for tty and for proces that has a connection to a tcp port between 6000 and 6100 somewhere or has a unix socket to /tmp/.X11-unix/X0 (or whereever X chooses to place the unix socket).

But thats definitly not good enough to base your scheduling on.

TJ

If you don't mind having your Web-Server with 1000 connections/second be a "single user", just scan for all the unique UID/GID pairs. All the root processes are one "user", the lpd is another user, Apache is another user, login-joe is another user, etc. The total number of tasks is the number of directories that represent digits in /proc.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

I was going to compile a list of innovations that could be attributed to Microsoft. Once I realized that Ctrl-Alt-Del was handled in the BIOS, I found that there aren't any.