82 lines
3.0 KiB
Markdown
82 lines
3.0 KiB
Markdown
# Cheap System Monitor
|
|
|
|
A small Linux system monitor for Ubuntu and Raspberry Pi OS (including the
|
|
Raspberry Pi 5). It stores metrics in a fixed-size RRD database and produces
|
|
PNG graphs for the last 3 hours, 1 day, 2 weeks, and 1 year.
|
|
|
|
It collects:
|
|
|
|
- processor load averages (1, 5, and 15 minutes)
|
|
- CPU user, system, and nice usage
|
|
- total network receive/transmit throughput
|
|
- disk usage for `/` and up to two additional mountpoints
|
|
- memory usage
|
|
- system uptime in days
|
|
|
|
## Install
|
|
|
|
Python 3 is already included in supported distributions. Install RRDTool,
|
|
clone/copy this directory, and run the installer:
|
|
|
|
```sh
|
|
sudo apt update
|
|
sudo apt install rrdtool
|
|
sudo ./install.sh
|
|
```
|
|
|
|
The executable application files are installed under
|
|
`/opt/cheap_system_monitor`. Configuration remains in
|
|
`/opt/cheap_system_monitor/monitor.conf`, and the RRD database remains under
|
|
`/var/lib/cheap-system-monitor` so code, configuration, and mutable data stay
|
|
separate.
|
|
|
|
Edit `/opt/cheap_system_monitor/monitor.conf` to choose network interfaces,
|
|
mountpoints, and the graph directory. For example, use
|
|
`mountpoints = /, /boot/firmware, /mnt/data` to monitor two additional disks;
|
|
every configured path must be mounted and accessible.
|
|
Restarting is unnecessary after configuration changes—the next timer runs use
|
|
the new values. If the RRD has already been created, do not change the order of
|
|
mountpoints unless you intentionally want the historical graph labels to refer
|
|
to different disks.
|
|
|
|
The generated PNG files and four responsive, auto-refreshing dashboard pages
|
|
are placed in `/var/www/html/system-monitor` by default. `index.html` shows
|
|
the last 3 hours and links to the 1-day, 2-week, and 1-year pages.
|
|
With a web server installed, such as nginx or Apache, they can be served
|
|
directly; otherwise they can simply be opened or copied as PNG files.
|
|
|
|
## Check operation
|
|
|
|
```sh
|
|
systemctl list-timers 'cheap-system-monitor*'
|
|
journalctl -u cheap-system-monitor.service -n 20
|
|
rrdtool info /var/lib/cheap-system-monitor/system.rrd
|
|
```
|
|
|
|
Run either job manually with:
|
|
|
|
```sh
|
|
sudo systemctl start cheap-system-monitor.service
|
|
sudo systemctl start cheap-system-monitor-graphs.service
|
|
```
|
|
|
|
The first meaningful network rate appears after two collection samples. A new
|
|
installation naturally needs time to accumulate history; RRD archives are
|
|
consolidated to five-minute samples for two weeks and hourly samples for a year.
|
|
|
|
The RRD schema is fixed when the database is created. When upgrading from a
|
|
version without uptime monitoring, move or remove the existing `system.rrd`
|
|
before the next collection if preserving its old history is not required. The
|
|
collector will then create a new database containing the uptime data source.
|
|
|
|
## Run from the source tree
|
|
|
|
For development or a non-system installation, copy the example configuration,
|
|
change its paths to writable locations, then use:
|
|
|
|
```sh
|
|
cp cheap-system-monitor.conf.example cheap-system-monitor.conf
|
|
python3 system_monitor.py --config cheap-system-monitor.conf
|
|
python3 generate_graphs.py --config cheap-system-monitor.conf
|
|
```
|