Legba allows you to track how long devices have been online on your LAN for the current day. Ideal for parents who want to have and open dialog with their kids about how long they should be online on a day-to-day basis. These same parents need to also enjoy setting up random Python projects ;)
Features:
- Aggregate one person's time across multiple devices
- Display a different histogram for each person
- Optionally get alerts for specific people every 15 minutes of time they use
- Supports light mode or dark mode for UI
The tracking results are shown in an HTML page that automatically reloads the data via AJAX every 60 seconds like this:
Named after Papa Legba
If you like the histograms, check out either Happy Day Histogram (HDH), which Legba uses for a day's activity, or the original Happy Histogram to show a year's activity!
Legba is happy to run on bare-metal via a pip3
and you bring your own web server, or there's a docker-compose
file that will build a small layer on top of the official Python 3 Alpine image and lighttpd is used as the web server.
If you're going to use the alert feature in either bare-metal or Docker, you need to run your instance in a Secure Context (aka with TLS).
- python
- web accessible directory to view output - defaults to
/var/www/html/index.html
- each network device has been statically assigned an IP by your DHCP server.
-
Create a
legba
user who's home directory is/home/legba
-
Clone this repo,
cd
into it so you're in/home/legba/legba
-
Copy
conf.example.py
toconf.py
-
Add your devices to
conf.py
in thetrackme
variable. -
Set your output path in
conf.py
in thehtml_file
variable. Ensure thelegba
user can write to this file. The defaulthtml_file
value assumes you're runninglighttpd
per the Docker setup, but can be set to any path you'd like. Be sure to include the file name too (egindex.html
). -
Install all the python prerequisites with
pip3 install -r requirements.txt
-
Copy the systemd file into place, reload systemd, start and enable it:
sudo cp legba.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable legba sudo systemctl start legba
In step 4, you can assign more than one IP to a person. For example if they use a dock with Ethernet which gets a different IP than their WiFi card.
- Clone this repo,
cd
into it - Copy
conf.example.py
toconf.py
- Create a new directory called
data
in the base of the repo. - Add your devices to
conf.py
in thetrackme
variable. - Run docker:
docker-compose up
- first time run the image will have to be built.
Legba should be available on http://localhost:9880
In step 3, you can assign more than one IP to a person. For example if they use a dock with Ethernet which gets a different IP than their WiFi card. Or if a someone uses a Nintendo Switch and also an iPad.
In step 5, you can assign a different port with the LEGBA_PORT
environment variable like this: LEGBA_PORT=9000 docker-compose up
The install steps has you run the service as an unprivileged user legba
. Make sure this user exists, owns all the folders and files in /home/legba
and can write to the html_file
destination. For me, I just did a chown legba /var/www/html
.
Check the service to see if it has any errors: sudo systemctl status legba
. You can also watch the syslog
realtime to further debug: sudo tail -f /var/log/syslog
- Add github link to output
- Make it a bit more responsive on mobile
- Add first and last time online
- Maybe AJAX or autorefresh or both?
- Add better running instructions - daemonize this!
- Add
docker-compose
support