A lightweight system monitoring agent for Linux and Windows that provides system metrics via a secure HTTP API. This agent is designed to work with Glance dashboard for real-time system monitoring.
- System Information: CPU load, memory usage, disk usage, and host details
- Security: Bearer token authentication, local IP restriction and rate limited
- Configurable: Customizable ignored mountpoints, flexible configuration, and selective feature monitoring
- Feature Toggles: Enable or disable specific monitoring features (CPU, memory, disk, temperature, swap, host info)
- Linux/Windows operating system
- Go 1.24+ for building from source
- When running within docker OS information is incorrect. On linux systems this can be resolved by adding a volume passing in the host os-release info
/etc/os-release:/etc/os-release:ro - On Windows or within docker CPU temperature readings often do not work.
git clone <repository-url>
cd glance-agent
go build -o glance-agentThe application supports multiple configuration methods with the following precedence order:
- Command line flags (highest priority)
- Environment variables
- .env file (lowest priority)
export SECRET_TOKEN="your-secure-token-here"# Server port (default: 9012)
export PORT="9012"
# Additional mountpoints to ignore (comma-separated)
export IGNORE_MOUNTPOINTS="/mnt/backup,/media,/opt/custom"
# Additional IPs whitelist (comma-separated)
export WHITELIST_IPS="100.64.0.0/10,fd7a:115c:a1e0::/48"
# Limit access to whats defined on the whitelist alone
export WHITELIST_ONLY="false"
# Override default ignored mountpoints completely
export OVERRIDE_IGNORED_MOUNTPOINTS="/snap,/boot/efi,/custom"
# Feature toggles (default: all features enabled)
export DISABLE_CPU_LOAD="false"
export DISABLE_TEMPERATURE="false"
export DISABLE_MEMORY="false"
export DISABLE_SWAP="false"
export DISABLE_DISK="false"
export DISABLE_HOST="false"The application automatically loads a .env file from the same directory as the binary. Create a .env file:
# .env file format
SECRET_TOKEN=your-secret-token-here
PORT=9012
IGNORE_MOUNTPOINTS=/mnt/backup,/media,/opt/custom
OVERRIDE_IGNORED_MOUNTPOINTS=/snap,/boot/efi
# Disable specific features (optional)
DISABLE_TEMPERATURE=true
DISABLE_SWAP=true./glance-agent -helpAvailable flags:
-token: Bearer token for API authentication (required)-port: Server port number (default: 9012)-ignore-mounts: Comma-separated list of additional mountpoints to ignore-override-mounts: Comma-separated list to override default ignored mountpoints-disable-cpu: Disable CPU load monitoring-disable-temp: Disable temperature monitoring-disable-memory: Disable memory monitoring-disable-swap: Disable swap monitoring-disable-disk: Disable disk monitoring-disable-host: Disable host information-whitelist-only: Disables the default IP local connection whitelist-help: Show help message
# Using .env file (recommended)
echo "SECRET_TOKEN=my-secure-token" > .env
./glance-agent
# Using environment variables
SECRET_TOKEN="my-secure-token" ./glance-agent
# Using command line flags
./glance-agent -token my-secure-token -port 8080
# Disable specific features
./glance-agent -token my-secure-token -disable-temp -disable-swap
# Combining methods (CLI flags override env vars and .env file)
./glance-agent -token cli-token -ignore-mounts "/custom/mount" -disable-disk# Monitor only CPU and memory (disable everything else)
./glance-agent -token my-token -disable-temp -disable-swap -disable-disk -disable-host
# Environment variable approach
export SECRET_TOKEN="my-token"
export DISABLE_TEMPERATURE="true"
export DISABLE_SWAP="true"
export DISABLE_DISK="true"
export DISABLE_HOST="true"
./glance-agent
# Minimal monitoring (only host info)
./glance-agent -token my-token -disable-cpu -disable-temp -disable-memory -disable-swap -disable-diskcurl -H "Authorization: Bearer your-secret-token" \
http://localhost:9012/api/sysinfo/allResponse Example:
{
"host_info_is_available": true,
"boot_time": 1640995200,
"hostname": "myserver",
"platform": "Ubuntu 22.04",
"cpu": {
"load_1": 1.2,
"load_15": 0.8,
"load_1_percent": 60,
"load_15_percent": 40,
"temperature": 45
},
"memory": {
"memory_is_available": true,
"total_mb": 8192,
"used_mb": 4096,
"used_percent": 50,
"swap_is_available": true,
"swap_total_mb": 2048,
"swap_used_mb": 0,
"swap_used_percent": 0
},
"mountpoints": [
{
"path": "/",
"name": "/",
"total_mb": 51200,
"used_mb": 25600,
"used_percent": 50
}
]
}| Feature | CLI Flag | Environment Variable | Description |
|---|---|---|---|
| CPU Load | --disable-cpu |
DISABLE_CPU_LOAD |
Disables the CPU load averages and percentages |
| Temperature | --disable-temp |
DISABLE_TEMPERATURE |
Disables the CPU temperature monitoring |
| Memory | --disable-memory |
DISABLE_MEMORY |
Disables the RAM usage statistics |
| Swap | --disable-swap |
DISABLE_SWAP |
Disables the Swap usage statistics |
| Disk | --disable-disk |
DISABLE_DISK |
Disables the Disk usage for all mountpoints |
| Host Info | --disable-host |
DISABLE_HOST |
Disables the Hostname, platform, boot time |
The following mountpoints are ignored by default:
/snap,/boot/efi,/dev,/proc,/sys,/run/tmp,/var/tmp,/dev/shm,/run/lock/sys/fs/cgroup,/boot/grub,/var/lib/docker
The sample .env file contains:
/usr/lib/os-release,/etc/resolv.conf/etc/hostname,/etc/hosts
On Windows A:/ and B:/ are ignored by default
proc,sysfs,devtmpfs,tmpfs,cgroup,cgroup2pstore,bpf,debugfs,tracefs,securityfshugetlbfs,mqueue,fusectl,configfs
none
# Via environment variable
export IGNORE_MOUNTPOINTS="/mnt/backup,/media,/opt/custom"
# Via .env file
echo "IGNORE_MOUNTPOINTS=/mnt/backup,/media,/opt/custom" >> .env
# Via command line flag
./glance-agent -token mytoken -ignore-mounts "/mnt/backup,/media,/opt/custom"# Via environment variable
export OVERRIDE_IGNORED_MOUNTPOINTS="/snap,/boot/efi"
# Via .env file
echo "OVERRIDE_IGNORED_MOUNTPOINTS=/snap,/boot/efi" >> .env
# Via command line flag
./glance-agent -token mytoken -override-mounts "/snap,/boot/efi"# Start the server with .env file
echo "SECRET_TOKEN=test-token" > .env
./glance-agent
# Or start with command line
./glance-agent -token test-token
# Test in another terminal
curl -H "Authorization: Bearer test-token" \
http://localhost:9012/api/sysinfo/all | jq '.'# Test with only CPU monitoring enabled
./glance-agent -token test-token -disable-temp -disable-memory -disable-swap -disable-disk -disable-host
# Verify response contains only CPU data
curl -H "Authorization: Bearer test-token" \
http://localhost:9012/api/sysinfo/all | jq '.cpu'Various packages are built for each release if possible it's recommended to install the provided package.
This package will install the agent and a service. Simple add a configuration file to /etc/glance-agent/config.env and start the service
# systemctl enable --now glance-agent.service
Make sure that the config file is readable by the glance user.
Create /etc/systemd/system/glance-agent.service:
[Unit]
Description=Glance System Monitoring Agent
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=glance
Group=glance
Environment=SECRET_TOKEN=your-production-token
Environment=PORT=9012
ExecStart=/opt/glance-agent/glance-agent
Restart=on-failure
RestartSec=5
# Hardening
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
[Install]
WantedBy=multi-user.targetsudo useradd --system --no-create-home --shell /bin/false glancesudo mkdir -p /opt/glance-agent
sudo cp ./glance-agent.x86_64 /opt/glance-agent/glance-agent
sudo chown root:root /opt/glance-agent/glance-agent
sudo chmod +x /opt/glance-agent/glance-agentsudo systemctl daemon-reload
sudo systemctl enable glance-agent
sudo systemctl start glance-agentWarning
While the application is designed to be as secure as reasonable it is recommended you restrict what clients can access the api using your system's firewall
This software is licenced with the GPL v3 License.
Copyright (C) Ava Glass <SuperNinja_4965>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Some exclusions apply to scripts which may be licenses with the MIT license - these files are marked in their header.