Files
pipelines/app/tool/health_probe_fixture.dart
T

96 lines
2.4 KiB
Dart

import 'package:pipelines_app/core/api_gateway.dart';
/// In-memory server_stats reply for browser captures before the server command
/// is available. It deliberately uses the production envelope shape.
class HealthProbeGateway implements ApiGateway {
@override
Stream<JsonMap> get frames => const Stream.empty();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
if (type != 'server_stats') return {'error': 'Unknown command: $type'};
return {'server_stats': healthProbeSnapshot()};
}
}
JsonMap healthProbeSnapshot() => {
'sampled_at': DateTime.now().toUtc().toIso8601String(),
'host': {
'hostname': 'capture-host',
'os': 'linux',
'platform': 'Ubuntu',
'platform_version': '24.04',
'uptime_seconds': 86400,
'load1': 1.2,
'load5': 1.0,
'load15': 0.8,
},
'cpu': {
'model': 'Capture CPU',
'logical_cores': 8,
'physical_cores': 4,
'usage_percent': 42.5,
'load1': 1.2,
'load5': 1.0,
'load15': 0.8,
'per_core_percent': [20, 35, 42, 55, 61, 30, 48, 39],
},
'memory': {
'total_bytes': 17179869184,
'used_bytes': 7516192768,
'available_bytes': 9663676416,
'used_percent': 43.7,
'swap_total_bytes': 4294967296,
'swap_used_bytes': 536870912,
},
'storage': [
{
'mount': '/data',
'device': '/dev/sdb',
'fs_type': 'ext4',
'total_bytes': 2199023255552,
'used_bytes': 1759218604441,
'free_bytes': 439804651111,
'used_percent': 80,
},
{
'mount': '/',
'device': '/dev/sda',
'fs_type': 'ext4',
'total_bytes': 107374182400,
'used_bytes': 53687091200,
'free_bytes': 53687091200,
'used_percent': 50,
},
],
'data': {
'dir': '/var/lib/pipelines',
'db_bytes': 1073741824,
'artifacts_bytes': 12884901888,
'total_bytes': 13958643712,
},
'process': {
'pid': 42,
'started_at': '2026-11-06T12:00:00Z',
'rss_bytes': 268435456,
'cpu_percent': 4.5,
'goroutines': 84,
'heap_bytes': 134217728,
'threads': 12,
'go_version': 'go1.24.1',
'build': 'capture',
},
'gpu': {
'available': true,
'devices': [
{
'name': 'NVIDIA RTX 4070',
'vendor': 'NVIDIA',
'utilization_percent': 36,
'memory_total_bytes': 12884901888,
'memory_used_bytes': 3221225472,
'temperature_c': 54,
},
],
},
};