Add SNMP profile mapping and fix asset cleanup

This commit is contained in:
Keith Smith
2026-05-26 16:34:10 -06:00
parent fe7157fdad
commit e59733d331
15 changed files with 676 additions and 35 deletions
+17 -1
View File
@@ -397,8 +397,10 @@ export function AssetsPage({ token, assets, monitors, onChanged }: AssetsPagePro
<div className="space-y-3">
<div className="grid gap-3 rounded-md border border-line bg-[#0d131c] p-3 text-sm sm:grid-cols-3">
<SummaryItem label="Device" value={discoveryResult.device_name || discoveryResult.host} />
<SummaryItem label="Interfaces" value={String(discoveryResult.interfaces.length)} />
<SummaryItem label="Profile" value={discoveryResult.profile_name} />
<SummaryItem label="Selected" value={String(selectedItems.length)} />
<SummaryItem label="Interfaces" value={String(discoveryResult.interfaces.length)} />
<SummaryItem label="Capabilities" value={formatCapabilities(discoveryResult.capabilities)} />
</div>
<div className="max-h-[360px] overflow-y-auto rounded-md border border-line bg-[#0d131c]">
{groupedItems.map(({ group, items }) => (
@@ -556,3 +558,17 @@ function friendlyAssetType(value: string) {
function friendlyItemType(value: string) {
return value.replaceAll("_", " ");
}
function formatCapabilities(capabilities: Record<string, boolean>) {
const labels: Record<string, string> = {
interfaces: "interfaces",
cpu: "CPU",
memory: "memory",
storage: "storage",
sensors: "sensors",
};
const active = Object.entries(labels)
.filter(([key]) => capabilities[key])
.map(([, label]) => label);
return active.length ? active.join(", ") : "System only";
}
+16
View File
@@ -146,7 +146,9 @@ export function DiscoveryPage({ token }: DiscoveryPageProps) {
<div className="grid gap-4 p-4 md:grid-cols-3">
<SummaryItem label="Name" value={result.device_name || result.host} />
<SummaryItem label="Host" value={result.host} />
<SummaryItem label="Profile" value={result.profile_name} />
<SummaryItem label="Uptime" value={formatDuration(result.uptime_seconds)} />
<SummaryItem label="Capabilities" value={formatCapabilities(result.capabilities)} />
<div className="md:col-span-3">
<div className="text-xs uppercase text-slate-500">Description</div>
<div className="mt-1 text-sm text-slate-300">{result.description || "No description reported"}</div>
@@ -265,3 +267,17 @@ function formatSpeed(value?: number | null) {
function friendlyItemType(value: string) {
return value.replaceAll("_", " ");
}
function formatCapabilities(capabilities: Record<string, boolean>) {
const labels: Record<string, string> = {
interfaces: "interfaces",
cpu: "CPU",
memory: "memory",
storage: "storage",
sensors: "sensors",
};
const active = Object.entries(labels)
.filter(([key]) => capabilities[key])
.map(([, label]) => label);
return active.length ? active.join(", ") : "System only";
}
+3
View File
@@ -173,6 +173,9 @@ export interface SnmpDiscoveryItem {
export interface SnmpDiscoveryResult {
host: string;
credential_profile_id: number;
profile_key: string;
profile_name: string;
capabilities: Record<string, boolean>;
device_name?: string | null;
description?: string | null;
uptime_seconds?: number | null;