Some checks failed
Build APK / build-apk (push) Failing after 11m29s
SvelteKit + Capacitor 6 Netzwerk-Diagnose-App: - Tool-Plattform (IP-Scan, Port, Ping, WLAN, DHCP, SNMP, Traceroute, Stresstest, iperf) - Offline-First SQLite-Cache + idempotenter Dolibarr-Sync - Natives Kotlin-Plugin NetDiagScanner (ARP, Ping, Ports, WLAN, DHCP, SNMP, Traceroute) - Backbutton-Single-Instance-Modul, Auto-Updater, Toast-System - Auftrags-/Kunden-Übersicht nach Baustellen-App-Muster - CI: [apk]-Tag → Forgejo Runner → Package Registry netdiag-apk Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
/**
|
|
* Tool: Dauer-/Stresstest — Langzeitmessung von Verlust und Latenz.
|
|
*
|
|
* Läuft nativ als Foreground-Service, damit Android den Lauf nicht beendet.
|
|
* Die Dauer wird als Parameter vorgegeben; run() wartet auf das Ergebnis.
|
|
*/
|
|
|
|
import { scanner } from '../../scanner';
|
|
import type { MeasureStatus, Tool } from '../types';
|
|
|
|
export const stressTestTool: Tool = {
|
|
id: 'stresstest',
|
|
category: 'netzwerk',
|
|
name: 'Dauer-/Stresstest',
|
|
icon: 'gauge',
|
|
description: 'Langzeitmessung: Paketverlust und Latenz über einen Zeitraum.',
|
|
scope: 'protocol',
|
|
params: [
|
|
{ key: 'host', label: 'Ziel', type: 'text', default: '192.168.1.1' },
|
|
{
|
|
key: 'duration',
|
|
label: 'Dauer',
|
|
type: 'select',
|
|
default: '300',
|
|
options: [
|
|
{ value: '60', label: '1 Minute' },
|
|
{ value: '300', label: '5 Minuten' },
|
|
{ value: '900', label: '15 Minuten' },
|
|
{ value: '3600', label: '1 Stunde' },
|
|
],
|
|
},
|
|
],
|
|
async run(ctx) {
|
|
const host = String(ctx.params.host || '192.168.1.1');
|
|
const durationSec = Number(ctx.params.duration || 300);
|
|
|
|
const { runId } = await scanner.startStressTest({ host, durationSec });
|
|
// Auf das Ende des Laufs warten (Foreground-Service misst weiter)
|
|
await new Promise((r) => setTimeout(r, durationSec * 1000));
|
|
const res = await scanner.stopStressTest({ runId });
|
|
|
|
let status: MeasureStatus = 0;
|
|
if (res.lossPct > 0 || res.maxMs > 100) status = 1;
|
|
if (res.lossPct >= 5 || res.maxMs > 500) status = 2;
|
|
|
|
return {
|
|
label: `${host}: ${res.lossPct}% Verlust über ${Math.round(durationSec / 60)} min`,
|
|
result: {
|
|
host,
|
|
dauerSekunden: durationSec,
|
|
messpunkte: res.samples,
|
|
verlustProzent: res.lossPct,
|
|
avgMs: res.avgMs,
|
|
maxMs: res.maxMs,
|
|
},
|
|
measureStatus: status,
|
|
};
|
|
},
|
|
};
|