NetBox 統合
視覚化機能
NetBox データの視覚化オプション
NetBox から取得したデータを様々な方法で視覚化できます。
帯域幅の可視化
インターフェースの speed フィールドから帯域幅を自動検出し、線の太さで表現します。
| NetBox speed (kbps) | Shumoku bandwidth | 視覚化 |
|---|---|---|
| 1,000,000 | 1G | 1本線 |
| 10,000,000 | 10G | 2本線 |
| 25,000,000 | 25G | 3本線 |
| 40,000,000 | 40G | 4本線 |
| 100,000,000+ | 100G | 5本線 |
VLAN の可視化
インターフェースの tagged_vlans と untagged_vlan から VLAN 情報を収集し、リンクに設定します。
- 両端インターフェースの VLAN を統合
- VLAN ID に基づいた色分け
- トランクリンクの識別
ケーブルタイプによる色分け
colorByCableType: true(CLI: デフォルト有効、--no-colors で無効)で、ケーブル種別に応じた色と線種を適用します。
| ケーブルタイプ | 色 | 線種 |
|---|---|---|
| SMF (シングルモード) | 黄色 | 実線 |
| MMF-OM3 | 緑 | 実線 |
| MMF-OM4 | シアン | 実線 |
| Cat6 | 青 | 実線 |
| Cat6a | 紫 | 実線 |
| DAC (パッシブ) | オレンジ | 破線 |
| DAC (アクティブ) | 赤 | 破線 |
| AOC | ピンク | 破線 |
デバイスステータスの可視化
colorByStatus: true(CLI: --color-by-status)で、デバイスの状態に応じたスタイルを適用します。
| ステータス | スタイル |
|---|---|
| active | デフォルト |
| planned | 破線ボーダー、グレー、半透明 |
| staged | 黄色背景 |
| failed | 赤背景 |
| offline | グレー、半透明 |
| inventory | 青背景、破線 |
| decommissioning | オレンジ背景、破線 |
グループ化オプション
groupBy オプション(CLI: --group-by, -g)でデバイスのグループ化方法を指定します。
| 値 | 説明 |
|---|---|
tag | NetBox タグでグループ化(デフォルト) |
site | サイトでグループ化 |
location | ロケーションでグループ化 |
prefix | IP プレフィックス(/16)でグループ化 |
none | グループ化しない |
凡例(Legend)
legend オプション(CLI: --legend)でダイアグラムに凡例を表示できます。
CLI での使用
npx netbox-to-shumoku --legend -o network.svgライブラリでの使用
// シンプルに有効化
const graph = convertToNetworkGraph(devices, interfaces, cables, {
legend: true
})
// カスタマイズ
const graph = convertToNetworkGraph(devices, interfaces, cables, {
legend: {
enabled: true,
position: 'top-right', // 表示位置
showDeviceTypes: true, // デバイスタイプを表示
showBandwidth: true, // 帯域幅を表示
showCableTypes: true, // ケーブルタイプを表示
showVlans: false, // VLAN を表示
}
})凡例オプション
| 設定 | 説明 | デフォルト |
|---|---|---|
enabled | 凡例を表示 | true |
position | 表示位置 | top-right |
showDeviceTypes | デバイスタイプアイコンを表示 | true |
showBandwidth | 帯域幅インジケーターを表示 | true |
showCableTypes | ケーブルタイプの色を表示 | true |
showVlans | VLAN の色を表示 | false |
position の選択肢:
top-lefttop-rightbottom-leftbottom-right
階層型出力
複数拠点のネットワークを階層型 YAML に変換できます。
import { convertToHierarchicalYaml } from '@shumoku/netbox'
const result = convertToHierarchicalYaml(
deviceResp,
interfaceResp,
cableResp,
{
hierarchical: true,
hierarchyDepth: 'location', // 'site' | 'location' | 'rack'
fileBasePath: './',
theme: 'light',
}
)
// 結果
console.log(result.main) // main.yaml の内容
console.log(result.files) // Map<locationId, yamlContent>
console.log(result.crossLinks) // 拠点間リンク一覧階層の深さ
| hierarchyDepth | 説明 |
|---|---|
site | サイト単位でファイル分割 |
location | ロケーション単位(デフォルト) |
rack | ラック単位(最も細かい) |
出力例
# main.yaml
name: "Network Overview"
subgraphs:
- id: tokyo-dc
label: "Tokyo DC"
file: "./tokyo-dc.yaml"
- id: osaka-dc
label: "Osaka DC"
file: "./osaka-dc.yaml"
links:
# 拠点間リンクはデバイスを直接参照
- from:
node: tokyo-router
port: wan1
to:
node: osaka-router
port: wan1
bandwidth: 10G