1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

goのgovmomiでESXiのNIC情報を自動取得するZabbixのLLDツールを作ってみた

Posted at

Goの勉強で govmomi を使ってESXiの物理NIC情報を取得してZabbixのLLDで監視を自動登録するツールを作ってみました。

作った背景

Zabbixは標準でVMwareのESXiホストをLLDで自動登録することができるのですが、VMwareの監視アイテムをLLDで自動登録するキーは少なく手動で登録する必要がありました。
数が少ないと問題ないのですが、動的にホストが増減するようなシステムだと非効率のためGoのお勉強がてらまずはESXiホストの物理NIC情報を取得してLLD登録するツールをGoで作ってみました。

vmware_esxi_nic_lld

https://github.com/sky-joker/zabbix-go-monitoring-tools/tree/master/vmware_esxi_nic_lld

検証環境

項目 バージョン
OS RHEL7.5
Zabbix 3.4
govmomi 0.18.0

使い方

(1) ここの手順でビルドします。

(2) Zabbixサーバまたはプロキシにツールをアップロードします。

$ scp vmware_esxi_nic_lld root@zabbix34:
$ ssh root@zabbix34
# cd /usr/lib/zabbix/externalscripts
# mv ~/vmware_esxi_nic_lld .
# chmod +x vmware_esxi_nic_lld
# ./vmware_esxi_nic_lld -h
NAME:
   vmware_esxi_nic_lld - Get physical nic name of esxi

USAGE:
   vmware_esxi_nic_lld URL UserName Password Uuid Datacenter

COMMANDS:
     URL         URL for vCenter sdk(ex:https://vcenter/sdk)
     UserName    vCenter user
     Password    vCenter user password
     Uuid        ESXi uuid
     Datacenter  Datacenter name(optional)
     help, h     Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help

(3) テンプレート例をダウンロードしてZabbixへインポートします。

(4) ZabbixのLLDで自動ESXiホストを追加するのではなく手動登録する場合は ホスト名uuid を指定します。

スクリーンショット 2018-06-30 21.04.50.png

ESXiホストのuuidを確認するには以下のページを参照ください。

https://qiita.com/sky_jokerxx/items/e14455bfd51295d1d1e7#zabbixに監視登録をする

上記で紹介しているツールの使用例

$ ./mob-property-view.py -vc 192.168.0.253 --mob HostSystem -t esxi-07.local --property summary | grep uuid
Password:
      uuid = '00000000-0000-0000-0000-ac1f6b1e8888',

(5) マクロ は以下のように登録します。

スクリーンショット 2018-06-30 21.11.46.png

項目 説明
{$URL} vCenterのSDK URL
{$USERNAME} vCenterへログインするユーザー名
{$PASSWORD} vCenterへログインするユーザーのパスワード

これで、ESXiホストのNIC情報をLLDで取得し登録することができます :)

スクリーンショット 2018-06-30 21.23.22.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?