@sedge-hq/local
v0.3.2
Published
Webhooks, files, commands, syslog, presence and this machine for sedge: wake it when something posts to it, a folder changes, a command prints something new, a device logs or joins the network, or the battery runs low.
Maintainers
Readme
@sedge-hq/local
What happens on your machine and your network, for sedge, the always-on agent. Six signals:
webhook: each HTTP POST to a local address (defaulthttp://127.0.0.1:4747) is an event. Senders give the token you chose, asAuthorization: Bearer <token>,?token=<token>, or a GitHub webhook secret. A deploy hook, a home sensor, a form, any service that sends webhooks.files: files created, changed or removed in a folder (or one file), optionally only those matching a glob like**/*.csv.command: a shell command. A long-running one (tail -n0 -f app.log,mosquitto_sub -t sensors/#) reports each burst of lines it prints; withminutes, it runs on a schedule and reports when its output changes.syslog: syslog messages from a NAS, a router, a firewall or a server, over UDP and TCP.presence: a device (a phone, a laptop) joining or leaving the local network.system: this machine: unplugged or plugged in, the battery low, a disk nearly full, waking from sleep, and optionally the screen locking.
In sedge, say "tell me when a CSV lands in ~/Downloads/reports", "wake me when the deploy
webhook fires and the site is down", "tell me when the NAS logs an error", "when Ada's phone
comes home, remind me about the parcel" or "tell me when the disk is nearly full".
A webhook's details are its path and body (JSON as values), so a condition like
body.status = failed can pick the deliveries that matter.
files
It looks every seconds (default 10). A new or changed file is reported once it has held still
for settle seconds (default 2: the same size and time of change), so one save or one download is
one event, and what changed alongside it comes in the same event. A file that never holds still,
like a busy log, is reported anyway after a minute. settle: 0 reports what it sees at once.
It leaves out node_modules, .git, .DS_Store, editors' swap and backup files (*.swp,
*.swx, *~, .#*), and temporary and unfinished downloads (*.tmp, *.part,
*.crdownload, *.download, .~lock.*). Set skip to your own list instead: a name or glob is
matched against each file's and folder's name, a pattern with a / against its path in the folder
(build/**); an empty list leaves nothing out.
syslog
It listens on 127.0.0.1:5514, UDP and TCP (newline-separated or octet-counted), and reads RFC
5424 and the older BSD form (RFC 3164) that most routers and NASes send. Set port, and host to
0.0.0.0 (or this machine's address) to hear devices on your network; then point the device's
remote syslog at this machine and port. Port 514 needs root, so most devices let you change it.
Details: severity (emergency, alert, critical, error, warning, notice, info,
debug), level (0 to 7, the same as a number), facility, host (what the device calls
itself, or its address), app, pid, time, message, and from (the address it came from).
level <= 4 keeps warnings and worse.
presence
Every seconds (default 60) it pings the device and reads this machine's neighbour (ARP) table.
deviceis its address (192.168.1.20) or name (pixel.local);macis its hardware address, found in the ARP table, so it's known when its address changes. Give both where you can. With only a MAC, this machine has to have talked to the device lately.- It says when the device joins at once, and that it left only after
awayminutes without an answer (default 5): phones sleep their Wi-Fi. - On Linux a device that answers ARP but not ping counts as here; on macOS and Windows it has to answer ping, and the ARP table only finds its address. Phones that hide behind a private (randomised) MAC keep the same one per network, so set it once from the phone's Wi-Fi details.
Details: event (joined or left), present (true or false), device, name, ip, mac,
and lastSeen when it left.
system
Every seconds (default 60) it reads the battery and the disks, and reports changes only:
- unplugged or plugged in (
power: falseto stop), and the battery at or belowbatterypercent while unplugged (default 20;0never); - a disk at or above
diskpercent full (default 90;0never), for the disks holdingpaths(default your home folder); - waking from sleep (
sleep: falseto stop): a look that comes much later than planned means the machine slept; - with
lock: true, the screen locking and unlocking (macOS, Linux with systemd-logind, Windows).
It reads pmset on macOS, /sys/class/power_supply on Linux and Win32_Battery through
PowerShell on Windows. Details: event (on-battery, on-power, battery-low, disk-full,
woke, locked, unlocked), with battery and onPower; path, used (percent) and free
(GB) for a disk; slept (minutes) and since for waking.
Safety
The command runs in your shell with your rights, and the webhook and syslog listen only on this
machine unless you set host. With sedge's
sandbox on, the agent's own
commands are confined; the command signal's command is yours, and runs as you wrote it.
Channels and signals · MIT
