Diese API-Wrapper-Klasse ProxmoxMonitorAPI ermöglicht die einfache Nutzung des Networking
Monitoringsystems per PHP.
Die Klasse kommuniziert mit dem Server unter https://monitor.trynxt.com/monitor und erfordert keine
direkte Datenbankverbindung.
$api = new ProxmoxMonitorAPI();
Beschreibung: Legt einen Zugang für den Monitor an. Nur einmal pro Server nötig.
Parameter:
$host: URL zum Proxmox-Server (z. B. https://1.2.3.4:8006)$token: API-Token z. B. root@pam!abc=xyz$node: Node-Name (z. B. pve01)$authKey: Dein Auth Key (z. B. trafficmonitorauthkey)$api->createAuthentication("https://1.2.3.4:8006", "root@pam!token=xyz", "pve01", "trafficmonitorauthkey");
{
"status": "auth_created",
"uuid": "abc-123-xyz",
"auth_key": "trafficmonitorauthkey",
"auth_token": "geheimerZugriffstoken"
}
Beschreibung: Entfernt eine Authentifizierung samt aller zugehörigen Monitore.
Parameter:
$uuid: Die UUID des Zugangs$authToken: Der Auth-Token des Zugangs$authKey: Dein Auth Key (z. B. trafficmonitorauthkey)$api->deleteAuthentication("abc-123", "geheimerZugriffstoken", "trafficmonitorauthkey");
{
"status": "authentication_deleted",
"uuid": "abc-123"
}
Beschreibung: Erstellt ein neues Monitoring für eine VM.
Parameter:
$uuid: von createAuthentication erhalten$authToken: ebenfalls von dort$vmid: ID der zu überwachenden VM$days: Gültigkeit in Tagen (Wann der Reset durchgeführt wird(Traffic wird auf 0
zurückgesetzt.))
$api->createMonitor("abc-123", "auth_token", 100, 30);
{
"status": "monitor_created"
}
Beschreibung: Gibt aktuelle Traffic- und Zeitinformationen zurück.
$uuid, $authToken$api->getMonitor("abc-123", "auth_token");
{
"uuid": "abc-123",
"vmid": 100",
"total_netin_bytes": 23421421,
"total_netout_bytes": 10921903,
"create_date": "2025-04-10 22:00:00",
"expire_at": "2025-05-10 22:00:00"
}
Beschreibung: Verlängert die Laufzeit eines Monitors.
$uuid, $authToken, $days$api->updateMonitor("abc-123", "auth_token", 60);
{
"status": "updated",
"new_days": 60
}
Beschreibung: Entfernt einen Monitor vollständig.
$uuid, $authToken, $vmid$api->deleteMonitor("abc-123", "auth_token", 100);
{
"status": "monitor_deleted",
"uuid": "abc-123",
"vmid": 100
}
Beschreibung: Setzt den Traffic einer bestimmten VM zurück (NetIn & NetOut = 0) und aktualisiert das Start- und Ablaufdatum neu.
Parameter:
$uuid: Die UUID des Monitor-Zugangs$authToken: Der Authentifizierungs-Token$vmid: Die ID der zu reset-tenden VM$api->resetVM("abc-123", "auth_token", 100);
{
"status": "vm_reset",
"uuid": "abc-123",
"vmid": 100
}
Beschreibung: Gibt eine Liste aller Monitore zurück, die zu einer bestimmten Authentifizierung gehören.
Parameter:
$uuid: Die UUID des Monitor-Zugangs$authToken: Der Authentifizierungs-Token$api->getAllMonitors("abc-123", "auth_token");
{
"monitors": [
{
"uuid": "abc-123",
"vmid": 100,
"total_netin_bytes": 23421421,
"total_netout_bytes": 10921903,
"create_date": "2025-04-10 22:00:00",
"expire_at": "2025-05-10 22:00:00",
"days": 30
},
{
"uuid": "abc-123",
"vmid": 101,
"total_netin_bytes": 842134,
"total_netout_bytes": 294822,
"create_date": "2025-04-15 11:00:00",
"expire_at": "2025-05-15 11:00:00",
"days": 30
}
]
}
Beschreibung: Gibt alle authentifizierten Proxmox-Nodes (Zugänge) zurück, die einem bestimmten Benutzer gehören.
Parameter:
$email: Deine registrierte E-Mail-Adresse$password: Dein Account-Passwort$authToken: Dein Auth-Key$api->getAllAuthentications("deine_email", "dein_passwort", "testkey");
{
"authentications": [
{
"uuid": "e5b9137d-3dbe-476f-b15a-28a835f1541a",
"auth_key": "testkey",
"auth_token": "a1b2c3d4",
"host": "https://1.2.3.4:8006",
"token": "root@pam!token=xyz",
"node": "pve01"
},
{
"uuid": "9f223a14-2c8b-410d-8db0-93d8b2a9b1f4",
"auth_key": "testkey",
"auth_token": "e4r5t6y7",
"host": "https://1.2.3.5:8006",
"token": "root@pam!token=abc",
"node": "pve02"
}
]
}
Hinweis: Alle Funktionen benötigen gültige Zugangsdaten (uuid + auth_token), um Missbrauch zu verhindern.