'last' command doesn't show complete login times

'last' command doesn't show complete login times

Post by Juli » Sun, 04 Aug 2002 05:44:50



Hello,
I am trying to use the information from the "last" command to examine
how long users are logged into a certain machine for a research
project.  I wrote a perl script to parse the information into a comma
delimited file, opened it in a spreadsheet, and sorted the entries by
how long the users were logged in.  To my surprise, out of about 3200
entries, only 17 of them showed up as being logged in for more than an
hour!  I know this information is inaccurate, because these users work
on projects for hours at a time.  Another mystery is that when I run
"who", it shows about 50 users being logged in, whereas the "last"
command only shows about 10.  Running last using utmpx as the file
instead of the default wtmpx, it shows users being logged in for a lot
longer. (???)

I know that the "who" command uses the utmpx file, and the "last"
command uses the wtmpx file, but shouldn't the wtmpx file contain the
same information as the utmpx file, only a lot more of it?  Can anyone
think of an explanation to why the "last" output isn't showing the
entire session a user is logged in for?  Also, if there is data
missing, is there another way I can get the login and logout history
of all the users?

I would greatly appreciate any help you can give. :)

Thanks,
Julie

 
 
 

'last' command doesn't show complete login times

Post by Richard L. Hamilt » Sun, 04 Aug 2002 07:50:59




Quote:> Hello,
> I am trying to use the information from the "last" command to examine
> how long users are logged into a certain machine for a research
> project.  I wrote a perl script to parse the information into a comma
> delimited file, opened it in a spreadsheet, and sorted the entries by
> how long the users were logged in.  To my surprise, out of about 3200
> entries, only 17 of them showed up as being logged in for more than an
> hour!  I know this information is inaccurate, because these users work
> on projects for hours at a time.  Another mystery is that when I run
> "who", it shows about 50 users being logged in, whereas the "last"
> command only shows about 10.  Running last using utmpx as the file
> instead of the default wtmpx, it shows users being logged in for a lot
> longer. (???)

> I know that the "who" command uses the utmpx file, and the "last"
> command uses the wtmpx file, but shouldn't the wtmpx file contain the
> same information as the utmpx file, only a lot more of it?  Can anyone
> think of an explanation to why the "last" output isn't showing the
> entire session a user is logged in for?  Also, if there is data
> missing, is there another way I can get the login and logout history
> of all the users?

> I would greatly appreciate any help you can give. :)

Normally, /var/adm/wtmpx grows without bounds, which is a problem, because
disk space doesn't.  Either traditional process accounting or a simple
command to empty /var/adm/wtmpx being being run from crontab (or someone
clobbering it by hand) could be emptying the file; there might be other
possibilities as well.  Check for accounting by looking in adm's crontab
for lines something like:
0     *    *    *     *    /usr/lib/acct/ckpacct
0     4    *    *     *    /usr/lib/acct/runacct 2>/var/adm/acct/nite/fd2log
30    9    *    *     5    /usr/lib/acct/monacct

If the data's missing, it's missing*.  It might be sort of duplicated in
auditing records if you had auditing enabled, but in most configurations
auditing generates far more data than just logins/logouts, so it would be
even more difficult to retain a large amount of it.

Sounds like you need to talk to the administrator(s) for the system, or
if you're them, track down all the stuff you inherited that you didn't
know about.

* Some folks copy off /var/adm/wtmpx and archive it before truncating it;
that's a matter of local procedure and of talking to the local folks to
find out if they're doing that and where they're keeping it if they are.

--


 
 
 

'last' command doesn't show complete login times

Post by Ottomeist » Sun, 04 Aug 2002 12:53:33



> Hello,
> I am trying to use the information from the "last" command to examine
> how long users are logged into a certain machine for a research
> project.  I wrote a perl script to parse the information into a comma
> delimited file, opened it in a spreadsheet, and sorted the entries by
> how long the users were logged in.  To my surprise, out of about 3200
> entries, only 17 of them showed up as being logged in for more than an
> hour!

How are the users logging in?

'last' gets confused when it tries to report "dtremote" logins (from
X servers running elsewhere) and "dtlocal" logins (from X servers running
on this machine).  It thinks only one person at a time can have a
dtremote or dtlocal login, so when it sees successive dt* entries in
wtmpx it assumes that the earlier login ended when the newer one
started.  This bug was fixed for the dtremote case under bug ID 4125016
and for the dtlocal case under bug ID 4685817.  If you're running
Solaris 9 you should already have the fix for the dtremote case.  The
fix for the dtlocal case hasn't made it into a public release yet.

Quote:> Also, if there is data
> missing, is there another way I can get the login and logout history
> of all the users?

If this is the dtremote/dtlocal problem then the information is in
wtmpx, it's just being misreported by 'last'.  You could write a program
that uses getutxent() and friends to read the records from wtmpx and
extract the data you need.

You could also escalate the problem through your Sun support people
and ask for a patch that delivers the fixed 'last' executable, but that
takes time.

OttoM.
--

Disclaimer:  These are my opinions.  I do not speak for my employer.

 
 
 

1. last doesn't show user login in time

Why does the last command not show user login in time? On October 2, I
typed the command. It showed entries for Oct 2, followed by Sept 29,
Sept 28 etc, skipping Oct 1 and Sept 30. Today, the last command shows
a number of entries for those two days:

pts/13       DHCP-121-46.hous Mon Oct  2 09:09 - 14:38 (2+05:28)
pts/15       lurch            Mon Oct  2 08:47 - 11:58  (03:11)
dtremote     DHCP-121-61.hous Mon Oct  2 07:17 - 17:58  (10:40)
pts/28       lurch            Sun Oct  1 22:16 - 03:37  (05:20)
pts/12       lurch            Sun Oct  1 21:51 - 22:37  (00:45)
pts/14       lurch            Sun Oct  1 19:59 - 22:21  (02:22)
pts/11       lurch            Sun Oct  1 15:34 - 20:44  (05:10)
pts/4        lurch            Sat Sep 30 16:55 - 19:48 (3+02:52)
pts/28       rumbai.houston.i Sat Sep 30 15:41 - 15:42  (00:00)
pts/29       lurch            Sat Sep 30 15:33 - 17:45  (02:11)
pts/28       rumbai.houston.i Sat Sep 30 15:28 - 15:29  (00:00)
pts/20       lurch            Sat Sep 30 14:02 - 13:33 (3+23:31)

(I cut the first column for clarity)

Why does last show login info correctly only a few days later? We're
using Solaris 2.6.

--
Yong Huang


Sent via Deja.com http://www.deja.com/
Before you buy.

2. Verifying SMIME signature

3. Ximian Gnome local login doesn't show up in 'who' list

4. NFS problems under 3005

5. The 'last' command doesn't record users logout

6. 3com etho card

7. 'su --login user -c command' doesn't run loggin scripts

8. ultra2, creator or enterprise

9. 'time' command doesn't display memory usage

10. Solaris 7 last command output doesn't show the full name of host

11. finger doesn't show last login

12. 'date' and 'clock' show different times

13. Where's Finger's 'last login' info stored?