Metadata-Version: 2.4
Name: watchdog-host
Version: 1.0.2
Summary: Watchdog Host is a tool for automatically managing hosts.
Author-email: John <me@hakr.xyz>
License: MIT
Requires-Python: >=3.10
Requires-Dist: psutil>=7.2.1
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: requests>=2.32.5
Requires-Dist: typer>=0.21.0
Description-Content-Type: text/markdown

# Watchdog-Host

Watchdog-Host is a daemon designed to **monitor bandwidth usage on cloud hosts**, helping prevent unexpected charges caused by exceeding monthly traffic quotas.

## Features

- Monthly network traffic accounting for cloud instances
- Configurable via `config.yaml`, including:
  - Bandwidth quota limits
  - Usage percentage alert thresholds
- Multiple notification channels:
  - Email
  - WeCom (WeChat Work)
  - DingTalk
- Optional **automatic shutdown** when traffic usage exceeds the configured quota
- Runs as a systemd service, suitable for long-term unattended operation

## Usage Notes

- Historical network usage prior to the first run cannot be determined:
  - **Traffic statistics for the current month will be inaccurate on the first run**
  - Accurate statistics will be available starting from the next execution cycle
- Additional watchdog capabilities may be added in the future

## Requirements

- Must be executed as the **root user**
- Running via `sudo` is **not supported**
  - This is required due to systemd management and low-level network statistics access

## Installation

```shell
pip install watchdog-host
watchdog-host init
vim /etc/watchdog/config.yaml
systemctl enable --now <service>.service
systemctl status <service>.service
```

If your system version is Ubuntu 24.04 / Debian 12 or later, use this command.

```shell
apt update
apt install -y pipx
pipx ensurepath
pipx install watchdog-host
source ~/.bashrc

pip install watchdog-host
watchdog-host init
vim /etc/watchdog/config.yaml
systemctl enable --now <service>.service
systemctl status <service>.service
```

## Uninstallation

```shell
systemctl disable --now <service>.service
watchdog-host clean
pip uninstall -y watchdog-host

# Optional
rm -f /etc/watchdog/config.yaml
rm -f /etc/watchdog/*.json
```
