Skip to content

sysadm-webalert/webalert-agent

Repository files navigation

WebAlert Agent

Quality Gate Status

Overview

The WebAlert Agent is a lightweight monitoring tool designed to collect system metrics. It provides essential insights to ensure optimal system reliability and website uptime.

Features

  • System Metrics Monitoring: Collects CPU usage, memory consumption, and disk utilization.
  • Configurable: Easily set up using a /etc/webalert-agent/config.json file.
  • Secure Communication: Sends data to your centralized instance API over HTTPS.
  • Systemd Integration: Runs as a service on Linux-based systems (Ubuntu/Debian).
  • Flexible Logging: Stores logs in /var/log/webalert-agent/ to easy debug.

Installation

Prerequisites

  • Linux-based system (Ubuntu/Debian)
  • Go ^1.23.2 (for building from source)

Using Prebuilt Package

  1. Download the latest .deb package from the Releases.
  2. Install the package:
    sudo dpkg -i webalert-agent-latest.deb
  3. Verify installation:
    systemctl status webalert-agent

Building from Source

  1. Init modules:
    go mod init webalert-agent
  2. Install dependencies:
    go get github.com/shirou/gopsutil/cpu
    go get github.com/shirou/gopsutil/mem
    go get github.com/shirou/gopsutil/disk
    go mod tidy
  3. Build the binary:
    go build -o ./usr/local/bin/webalert-agent main.go
  4. Copy the binary to /usr/local/bin:
    sudo cp webalert-agent /usr/local/bin/
  5. Set up the service:
    sudo cp webalert-agent.service /etc/systemd/system/
    sudo systemctl enable webalert-agent
    sudo systemctl start webalert-agent
  6. Create the directory for logging:
    mkdir /var/log/webalert-agent

Configuration

Create a config.json file in /etc/webalert-agent/ with the following structure, you can add one or multiple sites:

  1. One site example:
{
  "email": "your_user_app",
  "password": "your_password_app",
  "api_uri": "https://api.webalert.digital",
  "siteName": ["https://yoursite.com"]
}
  1. Two or more sites example:
{
  "email": "your_user_app",
  "password": "your_password_app",
  "api_uri": "https://api.webalert.digital",
  "siteName": ["https://yoursite.com","https://yoursecond.com"]
}

Usage

Start the Agent

sudo systemctl start webalert-agent

Stop the Agent

sudo systemctl stop webalert-agent

Status the Agent

sudo systemctl status webalert-agent

Restart the Agent

sudo systemctl restart webalert-agent

View Logs

sudo tail -f /var/log/webalert-agent/agent.log

Test Metrics Collection

Run the binary directly to view metrics:

webalert-agent -m cpu
webalert-agent -m memory
webalert-agent -m disk

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch.
  3. Commit your changes.
  4. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For issues or feature requests, please open an issue in the GitHub repository.


WebAlert Agent © 2024