Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Keep track of a Mac's usage pattern UNIX
I was happy to find this tip, which explains how to measure idle time on input devices, but I wanted something that would actually keep track of when the system was idle and when it wasn't -- that way, I could tell how much my wife was actually using her Mac. This tip creates a log with entries for when the machine changes state from idle to non-idle, or vice-versa; the parameters and defaults are straightforward. To run it in the background and immune to SIGHUP, I use the following:
nohup ./idlemonitor.sh -o /tmp/mac_usage.log &
I'll probably write somehting that renders an HTML page with a pretty graph of when the machine was in use. This will probably require input in the form generated with -d '%s'. For those adverse to copy and paste, you can download a copy of the script with this command:
curl -O 'http://marty.feebleandfrail.org/macosxhints/idlemonitor/idlemonitor.sh'
[robg adds: I haven't tested this one, but I did mirror the script here on hints, so download it from either location if you're interested in checking it out. Remember to make it executable (chmod +x script_name).]
    •    
  • Currently 2.80 / 5
  You rated: 3 / 5 (5 votes cast)
 
[10,035 views]  

Keep track of a Mac's usage pattern | 15 comments | Create New Account
Click here to return to the 'Keep track of a Mac's usage pattern' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Keep track of a wife's (?) Mac usage pattern
Authored by: Krioni on Mar 16, '05 11:45:00AM

Are you billing your wife for time she uses the computer, or are you making sure she works hard? :-)



[ Reply to This | # ]
Keep track of a wife's (?) Mac usage pattern
Authored by: voldenuit on Mar 16, '05 11:57:32AM

...and how about remote logging, so you can call her whenever she gets lazy ;) ?



[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: derekhed on Mar 16, '05 11:52:01AM

Now just compare this with the accounting done every month by 'ac -p' and you can let your wife know just how productive she is! :-D



[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: n1mie on Mar 16, '05 08:37:47PM

What units of measure does "ac -p" use? How/when is it reset? (Didn't get answers from the 'man' file.)

---
--Chip



[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: MartySells on Mar 16, '05 11:55:03PM
Wierd - my man page seems to have details. ac gets information from /var/log/wtmp (written to by by init(8) and login(8)) which is the same place that 'last' gets information from. On OSX the wtmp file gets rotated monthly by /etc/periodic/monthly/500.monthly to wtmp.#.gz

The ac man page suggests that the units are hours and testing with ac -p ; sleep 36 ; ac -p seems to confirm this. Realize that ac measures total login time in the Unix sense, not in the OSX sense. If you have multiple shells open (check the output of 'w') then login time will grow faster than 1 hour per real hour of time.

There's also wierd behavior when using ac on rotated wtmp files. When the logs get rotated at end-of-month it's possible for a user to still be logged in. For example a wtmp file for November shows:
$ last -f wtmp.2 jsells | head -1
jsells    console  tinywife.local   Tue Nov 30 21:55   still logged in
This confuses ac into thinking that that session is still logged in as of the date that you run it! So:
$ ac -d -w wtmp.2 jsells | tail -4
Nov 28  total       24.00
Nov 29  total       24.00
Mar 15  total     2543.98
Mar 16  total       23.88
-m

[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: jporten on Mar 16, '05 02:26:19PM

I'd love a utility that tracks which application is frontmost. Does anyone know of such a beast?



[ Reply to This | # ]
Tracking front most app
Authored by: MartySells on Mar 16, '05 10:58:52PM
Great idea! I did a little googling and found some Applescript bits which return the front most app (FMA) and modified the orignal script to support a -a option to include the FMA in the log.

Download with
curl -O 'http://marty.feebleandfrail.org/macosxhints/idlemonitor/idlemonitor2.sh'
Rob will hopefully mirror this one as well.

I tried to make the Applescript part as robust as possible, but you probably need to run this as root since it will fail if the user it's running as is not the same as the logged in user or root. Some intersting FMA names: ScreenSaverEngine, loginwindow, SecurityAgent.

-m

[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: meikokun on Mar 17, '05 06:37:14AM

I use mac minder at our office. Not only keeps an eye on what apps are foremost and for how long, but you can set if you wish to many, many other things for security too, like within what time window a particular app may operate, and even for how long within that window - for example if you only want your kids to use safari for up to 1 hour a day, at any time throughout the day, but never after 9pm or before 7am, and so on. Very useful, and well worth the shareware fee.
cheers
DD

http://www.macupdate.com/info.php/id/8806



[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: derekhed on Mar 17, '05 12:45:32PM
mac minder

Yes, but what he needed was a 'wife-minder'. :-)

[ Reply to This | # ]

Keep track of a Mac's usage pattern
Authored by: MartySells on Mar 20, '05 02:25:56AM

I'll have to check it out. I'm always happily amazed when I implement what I think is the wheel in some scripts
only to find out that there's a native mac application that's already a 4 wheel drive.

I'm nearly ready to publish a HTML reporter for my original script and if I have time I"ll look at making it compatible with this app.

-m



[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: p2cardon on Mar 17, '05 10:16:40AM

Hello,

You should test my shareware YooZ:
http://mcardon.free.fr/yooz/

Best regards



[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: Han Solo on Mar 16, '05 09:41:19PM

Did you ever think of just asking her? Sometimes the best solutions are the simplest -- not to mention the most personable.



[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: nmerriam on Mar 17, '05 03:03:10PM

Can I nominate this for Creepiest Hint of the Year?



[ Reply to This | # ]
Keep track of a Mac's usage pattern
Authored by: Tonex on Mar 17, '05 03:28:43PM

...or maybe he's just trying to help his wife keep track of work time for billing etc. Cmon, let's give him the benefit of the doubt!

---
Remember - in a million years we'll all be dust, and none of this will matter



[ Reply to This | # ]
Ha..
Authored by: MartySells on Mar 20, '05 02:20:03AM

Ha.. It's much less creepy than y'all think. It's more of an "amuse the husband" type thing than a watch the wife thing. Although I will admit to checking her idle time with one of the original scripts before sending her email asking her to bring something to the other end of the house.. :)

-m



[ Reply to This | # ]