Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Keep the repo normalized to LF, but check Windows launchers out with CRLF:
# cmd.exe can misparse LF-only batch files (labels and parenthesized blocks).
* text=auto
*.cmd text eol=crlf
*.ps1 text eol=crlf
*.png binary
32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Runs the test suite on Windows (HogWatch uses Windows-only APIs: ICMP via
# iphlpapi and ETW) for every pull request and every push to main.
name: tests

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: windows-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: pip

- name: Install dependencies
run: python -m pip install -r requirements.txt

- name: Unit and integration tests
run: python -m unittest discover -s tests -v

- name: Dashboard script syntax
run: node --check hogwatch/static/app.js
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# HogWatch

[![tests](https://github.com/MSabacreationslab/hogwatch/actions/workflows/tests.yml/badge.svg)](https://github.com/MSabacreationslab/hogwatch/actions/workflows/tests.yml)

Finds out **who** is slowing the home internet to a crawl, **when**, and **what
they're probably doing**, and shows it on a dashboard at <http://127.0.0.1:8765/>.

<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/dashboard-dark.png">
<img alt="HogWatch dashboard during a slowdown: a roommate's upload is named as the cause, and short lag spikes are traced to the wireless link between two eeros" src="docs/dashboard-light.png">
</picture>

<sub>Screenshot uses demo data; device names and rooms are made up.</sub>

It watches three things at once:

| What | How | Needs |
Expand Down
Binary file added docs/dashboard-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/dashboard-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion hogwatch/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const s = (tag, attrs, ...kids) => build(document.createElementNS(SVGNS, tag), a
/* ------------------------------------------------------------------ formatting */

const fmtRate = (x) => (x == null ? "–" : x < 0.05 ? "0" : x < 10 ? x.toFixed(1) : Math.round(x).toLocaleString());
const fmtMs = (x) => (x == null ? "–" : Math.round(x).toLocaleString());
const fmtMs = (x) => (x == null ? "–" : x < 1 ? "<1" : Math.round(x).toLocaleString());
function fmtVolume(mb) {
if (mb == null) return "–";
if (mb >= 1000) return (mb / 1000).toFixed(mb >= 10000 ? 0 : 1) + " GB";
Expand Down Expand Up @@ -56,6 +56,9 @@ const KIND_LABEL = {

const state = { hours: 1, now: null, timeline: null, usage: null, incidents: null, incidentLimit: 15, offline: false };
try { const saved = +localStorage.getItem("hw-hours"); if (saved) state.hours = saved; } catch (e) { /* storage blocked */ }
// A link like /?hours=24 opens that range directly (handy for bookmarks).
const linkedHours = +new URLSearchParams(location.search).get("hours");
if ([1, 6, 24, 168].includes(linkedHours)) state.hours = linkedHours;

async function getJSON(path) {
const r = await fetch(path, { cache: "no-store" });
Expand Down
Loading