new calculation approach with unique sessions, new API endpoint to get list of active sessions, fix for UNDEF user, UI and Back to support certificate management still under development

This commit is contained in:
Антон
2026-01-12 11:44:50 +03:00
parent 839dd4994f
commit 6df0f5e180
10 changed files with 1175 additions and 59 deletions

View File

@@ -162,6 +162,75 @@ Ensure `mod_rewrite`, `mod_proxy`, and `mod_proxy_http` are enabled.
---
## 🧹 Database Management
### Resetting Statistics
To completely reset all traffic statistics and start fresh:
1. **Stop Services**:
```bash
# Systemd
sudo systemctl stop ovpmon-gatherer ovpmon-api
# OpenRC (Alpine)
rc-service ovpmon-gatherer stop
rc-service ovpmon-api stop
```
2. **Remove Database**:
Navigate to the application directory (e.g., `/opt/ovpmon/APP`) and delete or rename the database file:
```bash
rm openvpn_monitor.db
```
3. **Restart Services**:
The system will automatically recreate the database with a fresh schema.
```bash
# Systemd
sudo systemctl start ovpmon-gatherer ovpmon-api
# OpenRC (Alpine)
rc-service ovpmon-gatherer start
rc-service ovpmon-api start
```
### Advanced: Reset Stats (Keep Client List)
To reset counters but keep the known list of clients, run this SQL command:
```bash
sqlite3 openvpn_monitor.db "
DELETE FROM usage_history;
DELETE FROM stats_5min;
DELETE FROM stats_15min;
DELETE FROM stats_hourly;
DELETE FROM stats_6h;
DELETE FROM stats_daily;
DELETE FROM active_sessions;
UPDATE clients SET
total_bytes_received = 0,
total_bytes_sent = 0,
last_bytes_received = 0,
last_bytes_sent = 0,
status = 'Disconnected';
VACUUM;"
```
### Remove a Specific User
To completely remove a user (e.g., `UNDEF`) and their history:
```bash
sqlite3 openvpn_monitor.db "
DELETE FROM usage_history WHERE client_id IN (SELECT id FROM clients WHERE common_name = 'UNDEF');
DELETE FROM stats_5min WHERE client_id IN (SELECT id FROM clients WHERE common_name = 'UNDEF');
DELETE FROM stats_15min WHERE client_id IN (SELECT id FROM clients WHERE common_name = 'UNDEF');
DELETE FROM stats_hourly WHERE client_id IN (SELECT id FROM clients WHERE common_name = 'UNDEF');
DELETE FROM stats_6h WHERE client_id IN (SELECT id FROM clients WHERE common_name = 'UNDEF');
DELETE FROM stats_daily WHERE client_id IN (SELECT id FROM clients WHERE common_name = 'UNDEF');
DELETE FROM active_sessions WHERE client_id IN (SELECT id FROM clients WHERE common_name = 'UNDEF');
DELETE FROM clients WHERE common_name = 'UNDEF';
VACUUM;"
```
---
## 📚 API Reference
**Base URL:** `http://<server-ip>:5001/api/v1`