Office Days Agent
This is the background agent for the automated office days tracker.
What does it do?
- it periodically checks if you are connected to the office Wi-Fi, and records the days (it does not store any other data)
- it provides a REST API for other processes to use this information
Prerequisites
Important:
- On Mac you must setup wifi-unredactor first.
- On Linux you should install the
iw package.
Installation
You can use the included Makefile to build and install the agent:
make
Note: do not use sudo to execute the makefile.
In order to check if the agent is running properly, you can use launchctl on Mac:
launchctl list | grep office-days-agent
...or use systemctl on Linux:
systemctl --user status office-days-agent
You should see the agent and the associated process id listed in the response.
If you don't see it, check the Troubleshooting section of this readme.
API
| Path |
Method |
Description |
/list |
GET |
Get the stored days. Example response: {"20240101": true, "20240102": false} |
/clear |
POST |
Clear the stored days. |
By default, the API can be reached on http://localhost:23460/.
Troubleshooting
I can't see the agent in the list
Do not use sudo for installing or querying launchctl, otherwise the agent will be installed as a system daemon isntead of a user-agent. This will cause problems when executing wifi-unredactor as well as when writing/reading the database.
How can I check if the agent is running properly?
- check if the binary is installed correctly to
~/.local/bin
- (darwin) check if the launch agent is installed properly:
~/Library/LaunchAgents/hu.okki.office-days-agent.plist.
- (linux) check the presence & status of the systemd user service
- check that the agent has started up (see previous step)
- check if there is anything in the log files:
/tmp/office-days-agent-stdout.log
/tmp/office-days-agent-stderr.log
FAQ
How can I change the Office Wi-Fi Name?
In case you want the agent to monitor a different SSID, you can use the OFFICE_DAYS_WIFI_NAME environment variable.
If you used the Mac Launch Agent, you will need to change this environment variable in ~/Library/LaunchAgents/hu.okki.office-days-agent.plist.
What configuration options are supported?
Here is a comprehensive list:
| Environment Variable |
Mandatory/Default |
Description |
OFFICE_DAYS_API_SERVER_PORT |
23460 |
the port the api server is opened on |
OFFICE_DAYS_DB_PATH |
mandatory |
database for the agent |
OFFICE_DAYS_POLL_INTERVAL_SECONDS |
600 |
how frequently the agent checks the wifi ssid |
OFFICE_DAYS_WIFI_NAME |
mandatory |
the office wifi ssid |
OFFICE_DAYS_WIFI_DEVICE_NAME |
en0 |
the wireless network adapter name |