SNMP discovery updates continued
This commit is contained in:
@@ -91,6 +91,7 @@ export function AssetsPage({ token, assets, monitors, onChanged }: AssetsPagePro
|
||||
const discovered = await api.discoverSnmpDevice(token, {
|
||||
host: setupAddress,
|
||||
credential_profile_id: profileId,
|
||||
asset_type: selectedAsset?.asset_type ?? assetType,
|
||||
});
|
||||
setDiscoveryResult(discovered);
|
||||
} catch (err) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CheckSquare, Network, RefreshCw, Router, Search, Square } from "lucide-
|
||||
|
||||
import { api } from "../api/client";
|
||||
import { Button } from "../components/Button";
|
||||
import type { SnmpCredentialProfile, SnmpDiscoveryItem, SnmpDiscoveryResult } from "../types/api";
|
||||
import type { SnmpCredentialProfile, SnmpDiscoveredInterface, SnmpDiscoveryItem, SnmpDiscoveryResult } from "../types/api";
|
||||
|
||||
interface DiscoveryPageProps {
|
||||
token: string;
|
||||
@@ -169,8 +169,8 @@ export function DiscoveryPage({ token }: DiscoveryPageProps) {
|
||||
result.interfaces.map((item) => (
|
||||
<div key={item.index} className="grid gap-2 p-4 md:grid-cols-[1fr_120px_120px_120px] md:items-center">
|
||||
<div>
|
||||
<div className="font-medium">{item.name}</div>
|
||||
<div className="text-sm text-slate-400">{item.description || "No description"}</div>
|
||||
<div className="font-medium">{item.label}</div>
|
||||
<div className="text-sm text-slate-400">{interfaceContext(item)}</div>
|
||||
</div>
|
||||
<Status value={item.admin_status || "unknown"} />
|
||||
<Status value={item.oper_status || "unknown"} />
|
||||
@@ -268,6 +268,11 @@ function friendlyItemType(value: string) {
|
||||
return value.replaceAll("_", " ");
|
||||
}
|
||||
|
||||
function interfaceContext(item: SnmpDiscoveredInterface) {
|
||||
const details = [item.name, item.description].filter((value, index, values) => value && values.indexOf(value) === index);
|
||||
return details.length ? details.join(" - ") : "No description";
|
||||
}
|
||||
|
||||
function formatCapabilities(capabilities: Record<string, boolean>) {
|
||||
const labels: Record<string, string> = {
|
||||
interfaces: "interfaces",
|
||||
|
||||
@@ -151,11 +151,13 @@ export interface SnmpCredentialProfileUpdate {
|
||||
export interface SnmpDiscoveryRequest {
|
||||
host: string;
|
||||
credential_profile_id: number;
|
||||
asset_type?: string | null;
|
||||
}
|
||||
|
||||
export interface SnmpDiscoveredInterface {
|
||||
index: number;
|
||||
name: string;
|
||||
label: string;
|
||||
description?: string | null;
|
||||
admin_status?: string | null;
|
||||
oper_status?: string | null;
|
||||
|
||||
Reference in New Issue
Block a user