mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Add SNMP scanner that polls a gateway's ARP table
Introduce a sixth scanner that periodically queries an SNMP agent
(typically the router/firewall) for its ARP/neighbour cache via
SNMPv2c and feeds discovered devices into the shared devices, events
and notifications pipeline. Unlike the ARP scanner it generates no
traffic on the local segment and can surface devices across all
subnets the agent routes.
Scope is intentionally minimal: SNMPv2c only, a single target, and the
ipNetToMediaTable (ARP) only. SNMPv3 and switch MAC/forwarding-table
polling are left as follow-ups in TODO.md.
- backend: csnmp dependency; SnmpScanner config (opt-in, off unless a
[snmp_scanner] section is present); DeviceEventScanner::Snmp;
scanners/snmp/{finder,scanner,status}; main.rs wiring; status API
endpoint wired into OpenAPI
- frontend: SNMP scanner status model, card, API method, status screen
and summary card rows, and device-event label
- docs/config: sample TOML, README options, NixOS module option, and
setup notes for enabling SNMP on pfSense/OPNsense
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
20c51faaea
commit
2987f66363
@@ -0,0 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../model/snmp_scanner_status.dart';
|
||||
import '../theme/app_colors.dart';
|
||||
import '../utils/duration_formatter.dart';
|
||||
import '../utils/oott_api.dart';
|
||||
import 'scanner_status_card.dart';
|
||||
|
||||
class SnmpScannerCard extends StatelessWidget {
|
||||
const SnmpScannerCard({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScannerStatusCard<SnmpScannerStatus>(
|
||||
title: 'SNMP Scanner',
|
||||
fetch: ({cancelToken}) =>
|
||||
BackendAPI.instance.getSnmpScannerStatus(cancelToken: cancelToken),
|
||||
resolver: _resolve,
|
||||
);
|
||||
}
|
||||
|
||||
static ScannerStatus _resolve(
|
||||
BuildContext context,
|
||||
SnmpScannerStatus status,
|
||||
double elapsed,
|
||||
) {
|
||||
final successColor = Theme.of(
|
||||
context,
|
||||
).extension<AppColorExtension>()!.success;
|
||||
final neutralColor = Theme.of(context).colorScheme.outline;
|
||||
if (status.isRunning) {
|
||||
final sub = status.runningForSeconds != null
|
||||
? ['Running for ${formatSeconds(status.runningForSeconds! + elapsed)}']
|
||||
: <String>[];
|
||||
return (color: successColor, label: 'Running', sublabels: sub);
|
||||
}
|
||||
if (status.nextRunInSeconds != null) {
|
||||
final remaining = (status.nextRunInSeconds! - elapsed).clamp(
|
||||
0.0,
|
||||
double.infinity,
|
||||
);
|
||||
return (
|
||||
color: neutralColor,
|
||||
label: 'Waiting for next run',
|
||||
sublabels: ['Next run in ${formatSeconds(remaining)}'],
|
||||
);
|
||||
}
|
||||
return (color: neutralColor, label: 'Not started', sublabels: []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user