A few years ago a close friend got me really interested in keeping track of my active and idle periods. I started keeping track of my active and idle times on OS X.
I got really excited when I found this article called "Maximising Development Productivity":
The article showed several examples of "Chaplin Productivity Graphs":

This was the inspiration for the idle/active time graphs.
![]()
Installing Panoptes
Before continuing, read and follow the instructions in the 'installing panoptes' document in this directory..
Installing RRDtool
Before proceeding, see the 'installing rrd tools' document.
If you have trouble installing RRD, note that you can now do this without RRD. Continue to read this document, ignoring the rrd-specific bits, and see also:
Panoptes Configuration
Before continuing, read and follow the instructions in the 'configuring panoptes' document to create a host.conf file.
Idle Monitor
To enable the idle monitor, simply add a Panoptes::Monitor::IdleOSX block your host in your host.conf. Here is an example of the monitoring plugin configuration:
---
myhostname:
plugins:
Panoptes-Monitor-IdleOSX:
enable: 1
The monitor uses runs the 'ioreg' command every 60 seconds to determine your idle time. This provides the number of seconds since the last input on any input device.
This will generate a message with two fields:
- idle_min - how long the user has been idle
- active_min - how long the user has been active
The idle threshold is currently hard-coded to 10 minutes. Once the user is idle for 10 minutes, the state will be changed from active to idle.
Note that both active_min and idle_min may have non-zero values. For example, the user may be active for over an hour, but may have been idle for less than the idle threshold (e.g. 3 minutes).
Once the idle monitor is configured, engage the monitoring engine by setting into the root of the panoptes project and running:
./panoptes -monitor -start -tail
For more information, see the 'getting started' document.
Idle Rule
Now that you are collecting idle/active data, you will want to store it. To do that, you will need to create a rule.
First, you'll need a condition to select messages generated by the IdleOSX monitoring plugin. That one's pretty easy:
condition:
plugin: Panoptes-Monitor-IdleOSX
Next, you'll need an action to generate and update the RRD and also to generate the graphs. You may want to see the 'rrd graphing' document for more information. Here is a simplistic rule:
action:
rrd:
rrd_name: idle
rrd_schema:
idle_min: GAUGE
active_min: GAUGE
graph_refresh: 5
graph_options:
title: idle/active
vertical_label: minutes
sources:
- active_min
- idle_min
Putting it all together
Here is a host config with
---
myhostname:
plugins:
Panoptes-Monitor-IdleOSX:
enable: 1
rules:
80_rrd_idle:
condition:
plugin: Panoptes-Monitor-IdleOSX
action:
rrd:
rrd_name: idle
rrd_schema:
idle_min: GAUGE
active_min: GAUGE
graph_refresh: 5
graph_options:
title: idle/active
vertical_label: minutes
upper_limit: 60
lower_limit: 0
rigid: ''
sources:
- active_min
- idle_min
source_drawtypes:
- AREA
- AREA
source_colors:
- 8500FFCC
- FF8500CC
width: 1100
color:
- BACK#6F6F6F
- CANVAS#3F3F3F
- SHADEA#000000
- SHADEB#000000
- ARROW#61B51B
- GRID#00FFFF
- MGRID#FF00FF
- FONT#000000
- AXIS#FF00FF
- FRAME#000000
periods:
- day
- week
- month
The 'rrd graphing' document may have a bit more information.
Once you have the config set up, you're ready to launch the rules engine:
panoptirules
The 'getting started' document may have more to say about this.
Preserving historical data
In a Round Robin Database, the data decays over time. This is because the database is set to a fixed size at creation time, and once the database is filled, old data is automatically removed and replaced with new data. A single RRD file will typically store historical data over multiple time intervals, so older data is generally still available for analysis but at lower resolutions (i.e. less points of data per given interval).
In some cases you may want to preserve the raw active/idle data over longer periods of time. For that purpose, you may want to create a rule to store the active and idle periods in a log file or SQLite database.
Log File
Here is a rule that will search for every message generated by the Panoptes-Monitor-IdleOSX plugin that contains an idle_min field. When such a message is located, the timestamp, idle_min, and active_min will be stored in a csv-style log file in ~/.panoptes/logs/idle.log.
condition:
plugin: Panoptes-Monitor-IdleOSX
contains:
idle_min: 1
action:
log:
filename: idle
fields:
- timestamp
- idle_min
- active_min
SQLite
The following rule will store the active_min, idle_min, and timestamp of every idle message in an 'idle' table in ~/.panoptes/sqlite. Like the RRD rule, the database will be created automatically if it doesn't already exist when a message arrives.
condition:
plugin: Panoptes-Monitor-IdleOSX
action:
sqlite:
table: idle
schema:
active_min: int
idle_min: int
timestamp: int
For more information on sqlite, see:
Graphs
The graphs will automatically be generated to ~/.panoptes/rrd.
Synergy
If you work on more than one machine at a time, you may want to keep track of your active/idle times on a single machine. One way to do this is to use 'synergy', an application that can be used to share the keyboard/mouse of one machine to another.
- http://sourceforge.net/projects/synergykm/
Run the synergy server on your main machine (the one that you will be typing on, that is running the panoptes idle monitor), and then run the client on the additional machines. As long as you use the keyboard/mouse on the main machine, all your idle time will be recorded appropriately.
There are other tools designed to do this, but I've used synergy for a long time and have been very happy with it.
Note that the Grid component of panoptes is not yet complete--but when it is, you will have the option of running the idle monitor on an agent deployed to multiple machines, and aggregating the distributed data.
Road Map
This monitor violates one of the design philosophies of panoptes by performing too much processing in the monitor. The monitor should ideally only be sending a message containing the number of seconds idle (as read directly from the ioreg command). However the rules system has not yet evolved to be able to handle the state information. This should be fixed soon.
Once this is done, it will be possible to reference the idle state in a rule, e.g. 'if i am not idle, display a pop-up notification, else if I am idle, then send a text message to my phone'.
I also plan to create some example rules to give me a friendly reminder if I am active for too long and need to take a break.
The sliding time window rules will also be interesting here, e.g. for tracking the number of hours/minutes that have been active/idle over periods of time. I've have been doing some prototyping here and have come with some interesting visualizations.