LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-28-2007, 03:12 PM   #1
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Rep: Reputation: 36
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
 
Old 06-28-2007, 03:15 PM   #2
erklaerbaer
Member
 
Registered: Mar 2006
Posts: 381

Rep: Reputation: 30
works for me..

it just counts the lines though, not the distinct users if that was what you had in mind
 
Old 06-28-2007, 03:53 PM   #3
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
Running x I get

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

all correct really
 
Old 06-28-2007, 03:57 PM   #4
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
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
 
Old 06-29-2007, 02:48 PM   #5
winfinit
Member
 
Registered: Jul 2006
Location: FL, Delray Beach
Distribution: Slackware11, LFS
Posts: 67

Rep: Reputation: 15
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
 
Old 07-01-2007, 12:53 PM   #6
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
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
 
Old 07-01-2007, 03:05 PM   #7
Road_map
Member
 
Registered: Jan 2007
Distribution: Slackware
Posts: 341

Rep: Reputation: 31
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.
 
Old 07-01-2007, 03:18 PM   #8
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
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
 
Old 07-01-2007, 06:48 PM   #9
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
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
 
Old 07-02-2007, 02:16 AM   #10
winfinit
Member
 
Registered: Jul 2006
Location: FL, Delray Beach
Distribution: Slackware11, LFS
Posts: 67

Rep: Reputation: 15
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.
 
Old 07-02-2007, 03:40 AM   #11
Ilgar
Senior Member
 
Registered: Jan 2005
Location: Istanbul, Turkey
Distribution: Slackware64 15.0, Slackwarearm 14.2
Posts: 1,157

Rep: Reputation: 237Reputation: 237Reputation: 237
The man page says /var/run/utmp is the relevant file. Can you get anything by inspecting it?
 
Old 07-02-2007, 07:43 AM   #12
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 641

Original Poster
Rep: Reputation: 36
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
 
Old 07-02-2007, 10:09 AM   #13
Road_map
Member
 
Registered: Jan 2007
Distribution: Slackware
Posts: 341

Rep: Reputation: 31
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)

Last edited by Road_map; 07-02-2007 at 10:48 AM.
 
Old 07-02-2007, 11:48 AM   #14
Road_map
Member
 
Registered: Jan 2007
Distribution: Slackware
Posts: 341

Rep: Reputation: 31
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

Last edited by Road_map; 07-02-2007 at 03:02 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
top and ps commands show incorrect pids joepgjm Linux - Newbie 3 04-25-2007 11:23 AM
pkg-config version is reported incorrect after install (Mandriva 10.2) Luna-tic Linux - Software 8 04-29-2006 08:31 AM
incorrect memory size reported tintapok Slackware 3 10-29-2005 01:11 AM
Incorrect Mouse, Incorrect Keymap, and Trapped in X Kenji Miyamoto Debian 8 08-24-2005 02:42 PM
Memory usage reported using TOP Kdiver58 Linux - Newbie 1 02-03-2003 01:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration