A simple tool to reset traffic statistics (upload/download) for the s-ui panel. It features both a monthly scheduled task and an HTTP API for manual triggers.
- Automated Monthly Reset: Automatically clears traffic for all clients on the 1st of every month at 00:00 (Asia/Shanghai).
- Manual Reset API: Provides an HTTP endpoint to trigger the reset manually at any time.
- Pure Go Implementation: Uses
modernc.org/sqlite, so no CGO is required for compilation. - Easy Deployment: Includes a systemd installation script for Linux servers.
Run the following command on your Linux server to automatically download the latest version and install it as a systemd service:
curl -fsSL https://raw.githubusercontent.com/itning/reset-s-ui-traffic/master/deploy.sh | sudo bash -s installIf you prefer to build from source or have already downloaded the binary:
Ensure you have Go installed.
# Clone the repository
git clone https://github.com/itning/reset-s-ui-traffic.git
cd reset-s-ui-traffic
# Build for your platform (e.g., Linux AMD64)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o reset-traffic main.go- Upload your compiled binary and
install.shto your server. - Run the installation script:
sudo chmod +x install.sh
sudo ./install.shFollow the menu prompts to install the service. The script will create a systemd service named reset-traffic.
The service listens on 127.0.0.1:52893 by default. You can manually trigger a reset by sending a request to the following endpoint:
Endpoint: GET http://127.0.0.1:52893/api/traffic/reset
Response Example:
{
"status": "success",
"message": "Traffic reset successfully",
"rows_affected": 10
}The cron job runs automatically inside the binary. By default, it is set to:
0 0 1 * * (At 00:00 on day-of-month 1).
You can customize the behavior using environment variables in the systemd service file or before running the binary:
| Variable | Description | Default |
|---|---|---|
SUI_DB_PATH |
Path to the s-ui.db file |
/usr/local/s-ui/db/s-ui.db |
PORT |
Listening port for the HTTP API | 52893 |