ShumokuShumoku
NetBox 統合

視覚化機能

NetBox データの視覚化オプション

NetBox から取得したデータを様々な方法で視覚化できます。

帯域幅の可視化

インターフェースの speed フィールドから帯域幅を自動検出し、線の太さで表現します。

NetBox speed (kbps)Shumoku bandwidth視覚化
1,000,0001G1本線
10,000,00010G2本線
25,000,00025G3本線
40,000,00040G4本線
100,000,000+100G5本線

VLAN の可視化

インターフェースの tagged_vlansuntagged_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)でデバイスのグループ化方法を指定します。

説明
tagNetBox タグでグループ化(デフォルト)
siteサイトでグループ化
locationロケーションでグループ化
prefixIP プレフィックス(/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
showVlansVLAN の色を表示false

position の選択肢:

  • top-left
  • top-right
  • bottom-left
  • bottom-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

目次