Sign inSign up

nghia2801dt/monitoring-server

By nghia2801dt

•Updated 2 months ago

Lightweight Docker monitoring agent that collects host metrics

Image
Developer tools
1

2.9K

nghia2801dt/monitoring-server repository overview

⁠Docker Monitor Client

Lightweight monitoring agent that runs on a Docker host and periodically collects:

  • Host CPU/RAM/Disk/Network metrics
  • Docker container stats (running containers)
  • Top processes (CPU & memory)

It can ship data to either:

  • MySQL (store full payload in a table), or
  • HTTP API (POST JSON to your backend)

Priority rule: if MySQL env vars are present and valid, the agent writes to MySQL; otherwise it falls back to API mode. It does not send to both at the same time.

For a concise usage guide, see docs/USAGE.md.

⁠Quick start (API mode)

Create docker-compose.yml on the server:

services:
  sys-monitor:
    image: nghia2801dt/monitoring-server:latest
    network_mode: "host"
    pid: "host"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    environment:
      - API_URL=https://your-api.example.com/api/send
      - AUTH_TOKEN=your_token_here
      - INTERVAL_SECONDS=10
      - TZ=Asia/Ho_Chi_Minh
    restart: always

Run:

docker compose up -d

Update:

docker compose pull && docker compose up -d

⁠Quick start (MySQL mode)

services:
  sys-monitor:
    image: nghia2801dt/monitoring-server:latest
    network_mode: "host"
    pid: "host"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    environment:
      - DB_HOST=your-mysql-host
      - DB_PORT=3306
      - MYSQL_DATABASE=your_db_name
      - MYSQL_USER=your_db_user
      - MYSQL_PASSWORD=your_db_password
      # Optional: override table name (default: monitor_metrics)
      # - DB_TABLE=monitor_metrics
      - INTERVAL_SECONDS=10
      - TZ=Asia/Ho_Chi_Minh
    restart: always

Run:

docker compose pull && docker compose up -d

⁠Payload format

The JSON payload stored in MySQL payload (and sent to API mode) has this structure:

{
  "server": {
    "name": "Server",
    "ip": "12345678",
    "uptime_seconds": 434400,
    "load_1m": 1.69,
    "timestamp": "2026-04-21T03:31:24Z"
  },
  "hardware": {
    "cpu_cores": 4,
    "cpu_percent": 34.10256410528888,
    "ram": {
      "total_gb": 3.8286666870117188,
      "used_gb": 0.9409599304199219,
      "free_gb": 2.52056884765625,
      "percent": 24.57670012414538
    },
    "swap": {
      "used_gb": 0,
      "percent": 0
    }
  },
  "storage": [
    {
      "total_gb": 39.285579681396484,
      "used_gb": 3.6568374633789062,
      "percent": 9.71784514023603
    }
  ],
  "disk_speed": {
    "read_bytes_per_sec": 0,
    "write_bytes_per_sec": 0
  },
  "docker": {
    "containers_total": 3,
    "containers_running": 3,
    "containers": [
      {
        "name": "monitor-sys-monitor-1",
        "state": "running",
        "cpu_percent": 0.0035526315789473684,
        "ram_mb": 11.7109375
      }
    ]
  },
  "network": {
    "tcp_connections": 6256,
    "udp_connections": 20,
    "speed": {
      "upload_bytes_per_sec": 16282868,
      "download_bytes_per_sec": 18151593
    },
    "traffic": {
      "total_gb": 5149.827770592645,
      "sent_gb": 2537.7627201527357,
      "received_gb": 2612.065050439909
    }
  },
  "top_processes": {
    "top_cpu": [
      {
        "pid": 42833,
        "name": "docker",
        "cpu_percent": 5.566378500965565,
        "mem_percent": 13.291028,
        "mem_mb": 521.08203125
      }
    ],
    "top_mem": [
      {
        "pid": 42833,
        "name": "docker",
        "cpu_percent": 5.566378500965565,
        "mem_percent": 13.291028,
        "mem_mb": 521.08203125
      }
    ]
  }
}

Tag summary

Content type

Image

Digest

sha256:5f3e1d702…

Size

36.6 MB

Last updated

2 months ago

docker pull nghia2801dt/monitoring-server