Internet Monitor Agent for Linux
================================

The Agent measures the quality of your internet connection in the background
(latency, packet loss, outages, DNS and HTTPS checks, optional speed tests) and
keeps the history in a local database. It has no user interface of its own; it
is meant for an always-on machine such as a Raspberry Pi, a NAS, or a server.

The program is a single static file that runs on any Linux distribution
(x86_64 or aarch64). It needs no root rights.

To see its measurements, use the Internet Monitor desktop app: on a Linux
desktop, install the .deb package from https://im.robour.hu instead of this
one (it contains the Agent too, and sets up the ping permission and the
automatic start); from a Windows computer, pair with this Agent (see "Reaching
the Agent from another computer" below). Opening the Agent's address in a web
browser shows only a short note: it is a programming interface, not a web page.


Install
-------

    mkdir -p ~/.local/bin
    cp im-agent ~/.local/bin/
    ~/.local/bin/im-agent install       # a systemd user service, started at login
    systemctl --user start internet-monitor-agent.service

To keep it running when nobody is logged in (a server or a Raspberry Pi):

    sudo loginctl enable-linger $USER

Check it:

    ~/.local/bin/im-agent status
    journalctl --user -u internet-monitor-agent.service


Ping (ICMP) permission
----------------------

Most distributions allow every user to send pings. If the Agent's log says
"ICMP (ping) probes cannot run", allow it in one of two ways:

    sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"
    (and put the same setting in /etc/sysctl.d/ to keep it after a restart)

or give the program the capability (repeat after every update of the file):

    sudo setcap cap_net_raw+ep ~/.local/bin/im-agent

If you installed the service with version 0.2.2 or earlier, run
`~/.local/bin/im-agent install` again after updating: the old service file
did not let the program use this capability.


Configuration and data
----------------------

Without a configuration file the defaults are used. To change them, copy
agent.example.toml, edit it, and pass it to the commands:
im-agent install /path/to/agent.toml

The data (database, logs) is in ~/.local/share/internet-monitor
(or $XDG_DATA_HOME/internet-monitor).

    im-agent backup FILE      a consistent copy of the database
    im-agent stop             stop the running Agent
    im-agent uninstall        remove the service (the data is kept)
    im-agent help             all commands


Reaching the Agent from another computer
----------------------------------------

Off by default. To show this Agent's data in the desktop app on your PC, put
these lines in the configuration file and restart the Agent:

    remote_access = true
    remote_listen = "0.0.0.0:8765"

Then run "im-agent pair" here, and in the desktop app choose "Add a remote
Agent..." (the Agent menu next to the status) and enter the address and the
code it shows. The connection is encrypted, and only paired computers get in.
"im-agent clients" lists them; "im-agent unpair NAME" revokes one. Allow port
8765 in the firewall for your home network if one is active. Never forward this
port to the internet; from outside your home, use a VPN.


License
-------

Internet Monitor is free to use but proprietary: see LICENSE.txt. The
open-source components it contains are listed in THIRD_PARTY_NOTICES.txt.
