|
|
A script to measure idle time on input devices
This does not work in 10.2.8 for some reason. There might be some difference in the output format of the ioreg command but I haven't really checked that.
A script to measure idle time on input devices
Yes, the ioreg subsystem is keeping track of time differently between 10.2.x and 10.3.x. Observe a 10.2 machine: $ sw_vers ProductName: Mac OS X ProductVersion: 10.2.8 BuildVersion: 6R73 $ sleep 2; ioreg -c IOHIDSystem | grep HIDIdleTime|sed 's#.*"HID#"HID#' "HIDIdleTime" = <0000396da619284f> "HIDIdleTime" = <0000396da64614ca> "HIDIdleTime" = <0000396da67986cd> "HIDIdleTime" = <0000396da71ab313> $ And here's the same commands on a 10.3 machine: $ sw_vers ProductName: Mac OS X ProductVersion: 10.3.3 BuildVersion: 7F44 $ sleep 3; ioreg -c IOHIDSystem | grep HIDIdleTime|sed 's#.*"HID#"HID#' "HIDIdleTime" = 2930089953 "HIDIdleTime" = 2932857364 "HIDIdleTime" = 2935033969 "HIDIdleTime" = 2936912079 "HIDIdleTime" = 2939724019 "HIDIdleTime" = 2941758207 "HIDIdleTime" = 2943638209 "HIDIdleTime" = 2952352977 So on 10.3, the HIDIdleTime is pretty recognizable: move the decimal to the left 9 times and you get 2.9...., which is about right. On 10.2 on the other hand, the value seems to be about the same no matter how many seconds I sleep before letting the command run, and there's all those letters suggesting that the number is probably a hexadecimal value. Someone would have to figure out how to convert those numbers into the decimal representation in seconds, but I'm not sure how to do it yet. For those that are interested, I've got a modified version of the script going:
$ cat ~/bin/osx_idle_time.sh
#!/bin/sh
echo -n "`date`: `uname -n` has been idle for "
secs=`ioreg -c IOHIDSystem | \
awk '/HIDIdleTime/ {print $NF/1000000000; exit}' | \
sed 's#\(\.[0-9][0-9]\)[0-9]*#\1#'`
echo "$secs seconds"
Which when run (on a remote machine, in this case), produces output like this: $ ssh myhomemac.dyndns.org "~/bin/osx_idle_time.sh" cdevers@myhomemac.dyndns.org's password: Fri Apr 9 11:06:42 EDT 2004: Myhomemac.local has been idle for 15650.6 seconds Nice! Thanks for the idea! ---
10.2
This should work in 10.2, it used to but I have made changes to the script since then:
This gives nicer output like this:
(I was ssh-ed in.)
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:Hints1 new Hints in the last 24 hoursComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.39 seconds |
|