LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-18-2009, 07:07 AM   #1
markseger
Member
 
Registered: Jul 2003
Posts: 244

Rep: Reputation: 26
What is the most efficient way to get the number of users logged in?


Let me begin by saying I want to do this every 10 seconds and running the commands 'who' or 'finger' are in my opinion too slow, taking about 20 seconds/day to do the job. Makes me wonder if there might be a faster way, possibly via perl, that might get it done in 5 or 10 seconds. It may just be that there are too many internal system structures to transverse to get this data, but I thought I'd ask anyway.
-mark
 
Old 04-18-2009, 10:09 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
who and finger take too long ??? ...

try 'w' ?
 
Old 04-18-2009, 11:51 AM   #3
markseger
Member
 
Registered: Jul 2003
Posts: 244

Original Poster
Rep: Reputation: 26
I tried 'w' as well and it was even slower. If anyone is curious why I'm being so anal about this is I'm the author of collectl and one of the ways I'm able to sample hundreds of counters every 10 seconds at less then 0.1% cpu and in some cases come closer to 0.01% is by being very careful. I'm sure the expense of actually having to run an image is contributing to the problem. For example I even wrote my own 'cat' routine because I can open/search a file quicker than having to run another program. Of course for most cases 'cat' and 'who' are just fine and it's only when you run them a LOT that the overhead actually turns into something real.
-mark
 
  


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
Efficient way to read only 1st line from number of files anurade Other *NIX 2 03-31-2008 10:55 AM
4 of the same users logged on... true_atlantis Linux - Newbie 1 04-13-2006 11:54 PM
Computer incorrectly reports number of logged in users phil.d.g Linux - General 5 10-22-2005 04:09 AM
No Users logged in X kaise_sose Linux - Software 2 10-19-2004 02:57 AM
iptables and limiting the number of times an event gets logged drexel Linux - Security 3 02-09-2004 08:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:17 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