Nagios监控ESXi硬件
普通的Dell服务器硬件监控我们可以通过nagios+openmanage来实现,但是vsphere环境中的Esxi主机的硬件监控怎么实现呢?
这里有两种方案:
1.通过nagios插件check_esx来实现,这种方式需要安装vmware vsphere sdk for perl工具包
2.通过nagios插件check_esxi_hardware.py来实现,此插件使用python写的。
感人感觉第二种方式比较简单些,python在linux天生内置,还需要更多理由吗?
先看看官网介绍。
其中:
Requirements
- Python must be installed
- The Python extension pywbem must be installed
Windows users click here for a step-by-step guide how to install Python and PyWBEM on a Windows server.
- If there is a firewall between your monitoring and ESXi server, open ports 443 and 5989
以上是实现监控的先决条件:
1.python必须安装
2.python的扩展包pywbem必须安装
3.你的Esxi主机的443,5989端口必须对nagios监控端开放
好了,下面就赶紧实施吧!
1.安装check_essi_hardware.py
cd /usr/local/nagios/libexec
wget http://www.claudiokuenzler.com/nagios-plugins/check_esxi_hardware.py
chown nagios.nagios check_esxi_hardware.py
chmod 755 check_esxi_hardware.py
安装完成后,我们来查看下这个插件都有什么参数:
[root@nagios libexec]# ./check_esxi_hardware.py
Traceback (most recent call last):
File "./check_esxi_hardware.py", line 222, in <module>
import pywbem
ImportError: No module named pywbem
[root@nagios libexec]# ./check_esxi_hardware.py -h
Traceback (most recent call last):
File "./check_esxi_hardware.py", line 222, in <module>
import pywbem
ImportError: No module named pywbem
哦,原来pywbem模块没有安装,那就赶紧装下吧。
2.安装python的第三方模块
cd /usr/local/src
wget http://downloads.sourceforge.net/project/pywbem/pywbem/pywbem-0.7/pywbem-0.7.0.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fpywbem%2Ffiles%2Fpywbem%2F&ts=1299742557&use_mirror=voxel
tar -zxvf pywbem-0.7.0.tar.gz
cd pywbem-0.7.0
python setup.py build
python setup.py install --record files.txt
ok,pywbem安装完毕。
注意:(1).不要使用pywbem-0.8.0版本,这个版本有bug导致我们的插件无法使用
(2).python setup.py install --record files.txt 记录安装目录的目的就是为了方便卸载插件,cat files.txt | xargs rm -rf
3.使用插件
[root@nagios libexec]# ./check_esxi_hardware.py
no parameters specified
Usage: check_esxi_hardware.py https://hostname user password system [verbose]
example: check_esxi_hardware.py https://my-shiny-new-vmware-server root fakepassword dell
or, using new style options:
usage: check_esxi_hardware.py -H hostname -U username -P password [-V system -v -p -I XX]
example: check_esxi_hardware.py -H my-shiny-new-vmware-server -U root -P fakepassword -V auto -I uk
or, verbosely:
usage: check_esxi_hardware.py --host=hostname --user=username --pass=password [--vendor=system --verbose --perfdata --html=XX]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
Mandatory parameters:
-H HOST, --host=HOST
report on HOST
-U USER, --user=USER
user to connect as
-P PASS, --pass=PASS
password, if password matches file:<path>, first line
of given file will be used as password
Optional parameters:
-V VENDOR, --vendor=VENDOR
Vendor code: auto, dell, hp, ibm, intel, or unknown
(default)
-v, --verbose print status messages to stdout (default is to be
quiet)
-p, --perfdata collect performance data for pnp4nagios (default is
not to)
-I XX, --html=XX generate html links for country XX (default is not to)
-t TIMEOUT, --timeout=TIMEOUT
timeout in seconds - no effect on Windows (default =
no timeout)
-i IGNORE, --ignore=IGNORE
comma-separated list of elements to ignore
--no-power don't collect power performance data
--no-volts don't collect voltage performance data
--no-current don't collect current performance data
--no-temp don't collect temperature performance data
--no-fan don't collect fan performance data
从上面可以看出,此插件需要用户名,密码连接Esxi主机才能使用。当然为保证安全,只需要在Esxi主机上建立只读的用户名和密码即可。
其中-U 用户名 -P 密码 -V服务器类型,有dell,hp等,根据实际情况-v打印状态信息-p结合画图工具画图
-I 输出链接到dell或其他官网,方面找解决方案-t超时时间-i忽略某项监控内容
--no-power 不采集电源信息,以下雷同。
--------------------------------------分割线 --------------------------------------
--------------------------------------分割线 --------------------------------------