LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Incorrect usercount reported by 'w' and 'top' (http://www.linuxquestions.org/questions/slackware-14/incorrect-usercount-reported-by-w-and-top-565167/)

Yalla-One 06-28-2007 03:12 PM

Incorrect usercount reported by 'w' and 'top'
 
Hello,

Does anyone else experience incorrect user-counts by the 'w' and 'top' applications (among others) ?

The problem is always that the usercount reported is higher than the actual number of login shells present, and then even when logging out of KDE, shutting down X, and logging in on virtual console 6 as root, it incorrectly displays usercount as 2, 3 or even 4 (depending on how long since last reboot).

The problem as existed at least since Slackware 10, is on multiple of my PCs and isn't really important enough to give serious attention - it's more like it's nagging me... :)

-y1

erklaerbaer 06-28-2007 03:15 PM

works for me..

it just counts the lines though, not the distinct users if that was what you had in mind

dive 06-28-2007 03:53 PM

Running x I get

dive tty1 startx
dive pts0 kdeinit
dive pts1 irrsi
dive pts2 w

all correct really

Yalla-One 06-28-2007 03:57 PM

Hello, and thanks for answering!

Quote:

Originally Posted by dive
Running x I get

dive tty1 startx
dive pts0 kdeinit
dive pts1 irrsi
dive pts2 w

all correct really

Of course, because while in X, all of these applications are listed as "login shells".

However, when you log out of X, some times the usercount remains at 2, even though there's only one user logged in on the console (and X isn't even running anymore), as per the original post.

Hence one login shell, but two users reported.

One way to provoke this seems to be multiple jumps from runlevel 3 to runlevel 1 and back.

-y1

winfinit 06-29-2007 02:48 PM

not sure what you are talking about, i am running slackware since ver 8.0 never had this issue, here is my output

15:20:47 up 1 day, 21:25, 3 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - Thu08 7:37m 0.02s 0.02s -bash
root pts/0 boca-rjurkov.ver 08:42 0.00s 0.08s 0.00s w
winfinit pts/1 boca-rjurkov.ver 09:26 5:33m 0.00s 0.00s -bash

pts ttys are remote connections, and tty1 is local terminal connection.

also when you saying that you are switching to runlevel 1 meaning you are doing telinit 1 and then back to 3 ? so yah that will kick everybody out, so it is going to fix it, since 1 is single user more, it will log all of your users out, as well as users in vshells.

when you have all those users logged in make sure that you go though vshells (CTRL+ALT+F#) and make sure all of them are showing login screen and not shell. if you are in visual 1 will show you your current X session and 7 i think actaul visual but rest of them should show login screen, if they are not just type exit there, and it will go back to login screen.

please send your "w" output when you have bunch of those users logged in, so i can see TTY and see if FROM is just - or actual domain

Yalla-One 07-01-2007 12:53 PM

Thanks for answering! See inline/below

Quote:

Originally Posted by winfinit
not sure what you are talking about, i am running slackware since ver 8.0 never had this issue, here is my output

15:20:47 up 1 day, 21:25, 3 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - Thu08 7:37m 0.02s 0.02s -bash
root pts/0 boca-rjurkov.ver 08:42 0.00s 0.08s 0.00s w
winfinit pts/1 boca-rjurkov.ver 09:26 5:33m 0.00s 0.00s -bash

pts ttys are remote connections, and tty1 is local terminal connection.

This I know and the input above is clearly logged in and the count is correct. My issue is that the usercount (or terminal count) sometimes is left too high when only one user is logged in

Quote:

Originally Posted by winfinit
also when you saying that you are switching to runlevel 1 meaning you are doing telinit 1 and then back to 3 ? so yah that will kick everybody out, so it is going to fix it, since 1 is single user more, it will log all of your users out, as well as users in vshells.

Ofcourse the users are nuked when I'm doing runlevel 1, which is exactly why I'm curious as to why the usercount sometimes (not always) remains at two or three, even though at runlevel one, I am only logged in as root (and there are no screen processes running, no other userids active etc etc).


Quote:

Originally Posted by winfinit
when you have all those users logged in make sure that you go though vshells (CTRL+ALT+F#) and make sure all of them are showing login screen and not shell. if you are in visual 1 will show you your current X session and 7 i think actaul visual but rest of them should show login screen, if they are not just type exit there, and it will go back to login screen.

Not sure what you mean by "all those users" - my problem is the opposite. Only one user logged in, while w and top etc reports two or three. And like I stated before - this is obviously not in X, where "every" terminal counts as a login shell :-)

Quote:

Originally Posted by winfinit
please send your "w" output when you have bunch of those users logged in, so i can see TTY and see if FROM is just - or actual domain

When it happens again, I'll send you a "w" output with no users logged in besides root, and still a usercount of 2 or 3..

Hope I haven't expressed myself too poorly here, but the quirk is about more users than current logged in being reported, not ghost users or incorrect number of ptys etc..

-y1

Road_map 07-01-2007 03:05 PM

Very strange. I get only this output:
Quote:

Rmap@MyLinuxBox:/$ w
22:55:29 up 2:13, 1 user, load average: 0.03, 0.18, 0.17
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
Rmap tty1 - 20:53 2:01m 0.25s 0.00s /bin/sh /usr/X11R6/bin/startx
Maybe you don't have anymore /var/log/wtmp log file or it has incorrect rights.

Yalla-One 07-01-2007 03:18 PM

Good call, but nope - it's all correct - also because 9 out of 10 times it works just fine, but especially when I mess a lot back and forth between "console" (Ctrl-F6) and X (Ctrl-F7), and also change to single-user, runlevel 3 and runlevel 4, the system sometimes gets stuck with an artificially high user count, most often reporting 2 logged in users when only one terminal is in use by one user.

The weirdest part is that this happens every blue moon on 5 different computers...

I'll try to provoke an instance of this and post a screenshot..

-y1

gilead 07-01-2007 06:48 PM

I get the same thing here. The following is for my current SSH session to my home box with no other users logged in. The list of users is correct (just me on pts/2) but the user count is 3:
Code:

steve@fender:~$ w
 09:41:18 up 149 days,  4:11,  3 users,  load average: 0.00, 0.00, 0.00
USER    TTY      FROM              LOGIN@  IDLE  JCPU  PCPU WHAT
steve    pts/2    203.202.23.xxx  09:41    0.00s  0.01s  0.00s w

If I create a second SSH connection, the list of users shows the 2 sessions, but the count of users is 4. Again, there are no other users logged in. If I'm interpreting the output wrongly, I'd like to know what I'm really seeing...
Code:

steve@fender:~$ w
 09:46:08 up 149 days,  4:16,  4 users,  load average: 0.00, 0.00, 0.00
USER    TTY      FROM              LOGIN@  IDLE  JCPU  PCPU WHAT
steve    pts/2    203.202.23.xxx  09:41    0.00s  0.01s  0.00s w
steve    pts/3    203.202.23.xxx  09:45  10.00s  0.01s  0.01s -bash


winfinit 07-02-2007 02:16 AM

it is not a slackware bug, here is a fully functional FreeBSD webserver, and by doing 'w' user count will display incorrect result

6:59AM up 117 days, 12:59, 7 users, load averages: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE WHAT
###### p0 ???.????????.??. Fri01PM 2days -tcsh (tcsh)
###### p2 ???.????????.??. 15Jun07 2days -tcsh (tcsh)
###### p4 ???.????????.??. 15Jun07 2days -tcsh (tcsh)
###### p5 ????-???-???-??? Sun12AM 1 -tcsh (tcsh)
###### p6 ????-???-???-??? 6:59AM - w
[######]:%

[??????]:% uname -a
FreeBSD ?????-??????.?????.??? 4.10-RELEASE FreeBSD 4.10-RELEASE #6: Fri May 27 16:25:57 MDT 2005 root@cc:/usr/src/sys/compile/VKERN i386


now the reason why it shows 7 logged in users is because w counts TTY's starting with 0 and last one is 6 which is total of 7

now look at the above post, same thing tty ending with 3, which is 0 through 3 is 4.

i was trying to find a source for w or who and i didnt find one :)

anyways if someone has a source for w please post a link.

Ilgar 07-02-2007 03:40 AM

The man page says /var/run/utmp is the relevant file. Can you get anything by inspecting it?

Yalla-One 07-02-2007 07:43 AM

Ahh - now I feel silly not having thought of ssh, as that is indeed also a common denominator.

As for the sources of "top" and "w", check the procps package, which lives at : http://procps.sourceforge.net/

-y1

Road_map 07-02-2007 10:09 AM

I reproduce this "error" (?) with Root Shell - Console:
Quote:

Rmap@MyLinuxBox:~$ w
17:59:16 up 35 min, 3 users, load average: 0.02, 0.09, 0.14
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
Rmap tty1 - 17:24 32:01 0.23s 0.00s /bin/sh /usr/X11R6/bin/startx
and "top" command too:
Quote:

top - 18:06:20 up 42 min, 3 users, load average: 0.25, 0.16, 0.13
Tasks: 73 total, 2 running, 71 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.7%us, 0.3%sy, 0.0%ni, 95.3%id, 0.0%wa, 0.7%hi, 0.0%si, 0.0%st
Mem: 516088k total, 506924k used, 9164k free, 34456k buffers
Swap: 1036184k total, 2668k used, 1033516k free, 250856k cached
Later add:
Quote:

Rmap@MyLinuxBox:/$ who /var/log/wtmp
Rmap tty1 2007-07-02 17:24
Rmap pts/2 2007-07-02 17:48
Rmap pts/3 2007-07-02 17:49
Quote:

Rmap@MyLinuxBox:/$ who /var/run/utmp
Rmap tty1 2007-07-02 17:24
Rmap pts/2 2007-07-02 17:48
Rmap pts/3 2007-07-02 17:48
But there is only 1 user logged in:
Quote:

Rmap@MyLinuxBox:/$ who -q
Rmap
# users=1
Could /var/run/utmp file has incorrect rights?
Quote:

-rw-rw-r-- 1 0 22 4608 2007-07-02 18:19 utmp
(mode 0664)

Road_map 07-02-2007 11:48 AM

It is a bug or not?
 
From man utmp:
Quote:

When init(8) finds that a process has exited, it locates its utmp entry by ut_pid, sets ut_type to DEAD_PROCESS, and clears ut_user, ut_host and ut_time with null bytes.
Q: The file /var/run/utmp doesn't decrease number of exited processes?

Later add:
I think is a Konsole issue, because X Terminal works correct. I found this:
http://www.kde.org/announcements/cha...2_1to2_2_2.php
konsole: remove kwrited's utmp entry at logout.

http://www.kde.org/announcements/cha...2_2_2to3_0.php
Konsole: Write utmp entries (requires installed utempter library).

http://osdir.com/ml/kde.devel.konsol.../msg00131.html


All times are GMT -5. The time now is 03:34 AM.