オープンソースのコンピュータシステムおよびネットワーク監視のためのNagiosからVMware ESXiを監視する設定をしてみました
Nagios
http://www.nagios.org/
Nagiosインストール(過去記事)
http://www.rootlinks.net/2012/10/29/install-nagios/
VMware ESXiの監視にはいくつか方法がありますが、今回はCheck VMware APIを使用しました
Check VMware API
http://www.op5.org/community/plugin-inventory/op5-projects/check-esx-plugin
参考サイト
Monitoring VMware ESXi and vSphere with Nagios
http://www.feub.net/2010/12/monitoring-vmware-esxi-and-vsphere-with-nagios/
- VMWare Perl SDKインストール
- VMware API projectのダウンロード
- check_vmware_api.plをコピー
- check_vmware_api.plの実行
Check VMware APIを動作させるためにはVMWare Perl SDKが必要になります
今回はVMware-vSphere-SDK-for-Perl-4.0.0-161974.i386.tar.gzをダウンロードしてインストールを行いました
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
[root@host1 src]# tar xvfz VMware-vSphere-SDK-for-Perl-4.0.0-161974.i386.tar.gz vmware-vsphere-cli-distrib/ vmware-vsphere-cli-distrib/apps/ vmware-vsphere-cli-distrib/apps/AppUtil/ (snip) vmware-vsphere-cli-distrib/installer/ vmware-vsphere-cli-distrib/installer/services.sh vmware-vsphere-cli-distrib/FILES [root@host1 src]# cd vmware-vsphere-cli-distrib/ [root@host1 vmware-vsphere-cli-distrib]# ./vmware-install.pl Creating a new vSphere CLI installer database using the tar4 format. Installing vSphere CLI. Installing version 161974 of vSphere CLI You must read and accept the vSphere CLI End User License Agreement to continue. Press enter to display it. VMware(r) End User License Agreement VMware, Inc. ("VMware") provides the vSphere Command-Line Interface (vSphere (snip) Do you accept? (yes/no) yes Thank you. The following Perl modules were found on the system but may be too old to work with vSphere CLI: Crypt::SSLeay Compress::Zlib XML::SAX In which directory do you want to install the executable files? [/usr/bin] Please wait while copying vSphere CLI files... The installation of vSphere CLI 4.0.0 build-161974 for Linux completed successfully. You can decide to remove this software from your system at any time by invoking the following command: "/usr/bin/vmware-uninstall-vSphere-CLI.pl". This installer has successfully installed both vSphere CLI and the vSphere SDK for Perl. Enjoy, --the VMware team |
最初は最新のVMware-vSphere-Perl-SDK-5.0.0-422456.i386.tar.gzをインストールしたのですがMissing perl module VMware::VIRuntimeのエラーがでて、メッセージにあるようにVMware-vSphere-SDK-for-Perl-4.0.0-161974の32bit版をインストールし直しました
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 [root@host1 src]# ./check_vmware_api.plVMWARE_API UNKNOWN - Missing perl module VMware::VIRuntime. Download and install 'VMware Infrastructure (VI) Perl Toolkit', available at http://www.vmware.com/download/sdk/Download the latest version of Perl Toolkit from VMware support page.In this example we use VMware-vSphere-SDK-for-Perl-4.0.0-161974.x86_64.tar.gz,but the instructions should apply to newer versions as well.Upload the file to your op5 Monitor server's /root dir and execute:cd /roottar xvzf VMware-vSphere-SDK-for-Perl-4.0.0-161974.x86_64.tar.gzcd vmware-vsphere-cli-distrib/./vmware-install.plFollow the on screen instructions, described below:"Creating a new vSphere CLI installer database using the tar4 format.Installing vSphere CLI.Installing version 161974 of vSphere CLIYou must read and accept the vSphere CLI End User License Agreement tocontinue.Press enter to display it."<ENTER>"Read through the License Agreement""Do you accept? (yes/no) yes"The following Perl modules were found on the system but may be too old to workwith VIPerl:Crypt::SSLeayCompress::Zlib""In which directory do you want to install the executable files? [/usr/bin]"<ENTER>"Please wait while copying vSphere CLI files...The installation of vSphere CLI 4.0.0 build-161974 for Linux completedsuccessfully. You can decide to remove this software from your system at anytime by invoking the following command:"/usr/bin/vmware-uninstall-vSphere-CLI.pl".This installer has successfully installed both vSphere CLI and the vSphere SDKfor Perl.Enjoy,--the VMware team"Note: "Crypt::SSLeay" and "Compress::Zlib" are not needed for check_vmware_api to work.
VMware API projectからスクリプトをダウンロードします
参考サイトでは”check_esx”となっていますが名前が変わって”check_vmware_api.pl”になっています
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
[root@host1 ~]# git clone git://git.op5.org/nagios/op5plugins.git Cloning into 'op5plugins'... remote: Counting objects: 3262, done. remote: Compressing objects: 100% (1884/1884), done. remote: Total 3262 (delta 1984), reused 2050 (delta 1297) Receiving objects: 100% (3262/3262), 1.02 MiB | 263 KiB/s, done. Resolving deltas: 100% (1984/1984), done. [root@host1 ~]# cd op5plugins/ [root@host1 op5plugins]# ls LICENSE check_modbus Makefile check_movex.php README check_movex_as400.pl adam check_mssql.pl check_biztalk.pl check_op5backup.sh check_biztalk_cluster_host_instance.sh check_op5backup2.pl check_biztalk_msdtc.sh check_oracle.pl check_buildbot.py check_pattern.pl check_cmc.pl check_portstatus check_cpu_iowait_aix.pl check_route.sh check_dummyd.c check_sitescanner.pl check_dummyv2.pl check_smsd.c check_file.pl check_unix check_icmp.c check_vmware_api.pl check_internet.sh check_xenapi.pl check_ipmi.php check_yum_update.pl check_libvirt.pl multiurl check_load_by_w.pl op5build check_logserver.pl packetfront check_ls_log.php plugins-op5.spec.in check_ls_log_2_1.php rand check_maxdb.pl snmpif check_megaraid.c xen |
check_vmware_api.plをNagiosのコマンドフォルダにコピー(あるいは移動)させます
私の場合はソースからインストールして特にインストールフォルダの変更は行っていないので”/usr/local/nagios/libexec”になります。また、実行権限の無い場合は追加して下さい
1 2 3 4 |
[root@host1 ~]# cp op5plugins/check_vmware_api.pl /usr/local/nagios/libexec/ [root@host1 ~]# ls -l /usr/local/nagios/libexec/check_vmware_api.pl -rwxr-xr-x 1 nagios nagios 167291 8月 19 21:41 libexec/check_vmware_api.pl |
取り敢えずcheck_vmware_api.plを実行してみます
Can’t locate Nagios/Plugin/Functions.pmとエラーが出てしまいました
1 2 3 |
[root@host1 ~]# /usr/local/nagios/libexec/check_vmware_api.pl Can't locate Nagios/Plugin/Functions.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 . . /usr/local/nagios/perl/lib,/usr/local/nagios/perl/lib/i386-linux-thread-multi) at /usr/local/nagios/op5plugins/check_vmware_api.pl line 36. BEGIN failed--compilation aborted at /usr/local/nagios/op5plugins/check_vmware_api.pl line 36. |
あるいは場合によってはCan’t locate Params/Validate.pmとエラーが表示されるかもしれません
1 2 3 4 5 |
[root@host1 ~]# /usr/local/nagios/libexec/check_vmware_api.pl Can't locate Params/Validate.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at Nagios/Plugin/Functions.pm line 11. BEGIN failed--compilation aborted at Nagios/Plugin/Functions.pm line 11. Compilation failed in require at ./check_vmware_api.pl line 31. BEGIN failed--compilation aborted at ./check_vmware_api.pl line 31. |
まだNagios::Plugin perl moduleが必要でした。次回これをインストールします
How do I use the Nagios::Plugin perl module?
http://nagiosplugins.org/faq/development/nagios-plugin-perl