nagios监控ESXi硬件

普通的服务器硬件监控我们可以通过nagios+openmanage来实现,但是vsphere环境中的Esxi主机的硬件监控怎么实现呢?

这里有两种方案:

1.通过nagios插件check_esx来实现,这种方式需要安装vmware vsphere sdk for perl工具包

2.通过nagios插件check_esxi_hardware.py来实现,此插件使用python写的。

感人感觉第二种方式比较简单些,python在linux天生内置,还需要更多理由吗?

先看看官网介绍:

http://www.claudiokuenzler.com/nagios-plugins/check_esxi_hardware.php#.VWV5_JCUfTA

其中:

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

安装完成后,我们来查看下这个插件都有什么参数:

[[email protected] 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
[[email protected] 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.使用插件

[[email protected] 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 不采集电源信息,以下雷同。

4.给Esxi主机设置只读用户

(1)先登录Esxi主机,在“本地用户和组”标签中,空白处右键“添加”,即可添加用户。

(2)将nagios用户设置成“只读角色”。在“权限”标签中,空白处右键“添加权限”,然后按下图操作

ok,只读用户nagios就添加完毕。

5.测试

[[email protected] libexec]# ./check_esxi_hardware.py -H 10.10.10.1 -U nagios -P nagios -V dell
UNKNOWN: Authentication Error

又报错了,认证失败。在网上查到原因是Esxi版本不同差异导致,例如我的本地测试机和生产环境都是5.5,但是小版本不一样,也报错了。

解决方案:

ssh登陆Esxi主机,编辑如下

~ # cat /etc/security/access.conf
# This file is autogenerated and must not be edited.

+:dcui:ALL
+:root:ALL
+:vpxuser:ALL
+:vslauser:ALL
-:nagios:ALL
-:ALL:ALL

将“-:nagios:ALL”去掉,在第二行加上“+:nagios:sfcb”

这种方式适合在不经常添加用户的情况下使用,只改一次即可;但是经常加用户可能会导致access.conf变化,需要设置计划任务添加“+:nagios:sfcb”

再测试下:

[[email protected] libexec]# ./check_esxi_hardware.py -H 10.10.10.1 -U nagios -P nagios -V dell
OK - Server: Dell Inc. PowerEdge R610 s/n: XXXXXX System BIOS: XXXXXXXXXXX

ok,监控正常。

6.下面将将其加入到监控系统中吧。

(1)先在commands.cfg中添加命令。

vim /usr/local/nagios/etc/objects/commands.cfg
define command {
    command_name check_esxi_hardware
    command_line $USER1$/check_esxi_hardware.py -H $HOSTADDRESS$ -U $ARG1$ -P $ARG2$ -V $ARG3$ -I isolutions -p -t 20
}

(2)添加服务

define service{
    use                     local-service,srv-pnp
    host_name               test
    service_description     esxi_health
    check_command           check_esxi_hardware!nagios!nagios!dell
    service_groups          hardware_health
    notifications_enabled   1
    }   

nagioscheck

service nagios reload

(3)监控效果图

其中href中的链接就是我们在check_esxi_hardware.py中-I参数生成,方便我们直接查找解决方案。

时间: 2024-08-27 20:04:14

nagios监控ESXi硬件的相关文章

Nagios监控HP硬件状态

Nagios监控HP硬件状态 一,监控思想 可以使用两种模式,check_nrpe方式和SNMP方式,这里我们采用SNMP代理方式. 两种方式都依赖HP的ProLiant Support Pack(PSP)软件包,有两种方式安装PSP包,一种tar包,一种RPM包,经过实践tar包很难安装,所以最终采用rpm包方式. 二,实施步骤 1,到 http://downloads.linux.hp.com/SDR/getting_started.html 下载 add_repo.sh 脚本,并上传到HP

nagios借助check_hpasm插件监控惠普服务器硬件信息(未成)

nagios借助check_hpasm插件监控惠普服务器硬件信息: http://labs.consol.de/wp-content/uploads/2011/10/check_hpasm-4.3.tar.gz 被监控端: $ sudo tar zxfv check_hpasm-4.3.tar.gz $ cd check_hpasm $ ./configure --enable-hpacucli --enable-perfdata --enable-extendedinfo $ sudo mak

nagios(icinga)借助check_hp插件监控惠普服务器硬件信息

http://cpan.metacpan.org/authors/id/D/DT/DTOWN/Net-SNMP-v6.0.1.tar.gz http://exchange.nagios.org/directory/Plugins/Hardware/Server-Hardware/HP-(Compaq)/check_hp/details 被监控端: $ sudo apt-get install snmpd $ sudo vi /etc/snmp/snmpd.conf  (在Access Contr

nagios监控安装esxi的服务器(宿主机)

首先,该博文大部分内容来自网络,少部分是自己监控过程中遇到的问题.如果有侵权,请联系告知!!! 现在互联网公司,有能力的都是自己研发监控系统,要么就是zabbix或者小米的监控,还都二次开发等等,可能使用nagios的不是那么多.哈哈,做个记录,仅供参考!!! <准备部署使用open-Falcon(小米开源)> 以下内容大部分来自网络: 普通的Dell服务器硬件监控我们可以通过nagios+openmanage来实现,但是vsphere环境中的Esxi主机的硬件监控怎么实现呢? 这里有两种方案

Nagios 监控系统架设全攻略

Nagios 全名为(Nagios Ain’t Goona Insist on Saintood),最初项目名字是 NetSaint.它是一款免费的开源 IT 基础设施监控系统,其功能强大,灵活性强,能有效监控 Windows .Linux.VMware 和 Unix 主机状态,交换机.路由器等网络设置等.一旦主机或服务状态出现异常时,会发出邮件或短信报警第一时间通知 IT 运营人员,在状态恢复后发出正常的邮件或短信通知.Nagios 结构简单,可维护性强,越来越受中小企业青睐,以及运维和管理人

Nagios 监控系统架设全攻略(一)

最近一段时间在研究Nagios监控系统,然后网上搜索查看很多的资料,借鉴与各位大虾的经验,整理记录一下自己安装记录. Nagios 全名为(Nagios Ain’t Goona Insist on Saintood),最初项目名字是 NetSaint.它是一款免费的开源 IT 基础设施监控系统,其功能强大,灵活性强,能有效监控 Windows .Linux.VMware 和 Unix 主机状态,交换机.路由器等网络设置等.一旦主机或服务状态出现异常时,会发出邮件或短信报警第一时间通知 IT 运营

nagios监控实用教程

nagios监控实用教程 Nagios作为开源网络监视工具,它不但可以有效的监控内存.流量.数据库使用情况.它还可以Windows.Linux主机状态.本专题收录了有关Nagios监控相关文章,供大家参考学习. 标签:nagios nagios监控 监控工具 阅读量:26196收藏量:8 文章标题 阅读评论 作者 nagios网卡流量监控 trffic.sh 51/0 anyue0072017-04-26 nagios搭建(二):nagios监控windows主机 1203/0 fantefei

icinga2使用check_snmp_idrac.py监控DELL硬件状态

icinga2使用check_snmp_idrac.py监控DELL硬件状态: git clone https://github.com/pynag/pynag.git cd pynag python setup.py build python setup.py install yum install net-snmp-devel net-snmp-python https://github.com/rsmuc/health_monitoring_plugins 下载health_monitor

Nagios监控Windows的网卡流量

Nagios监控Windows的网卡流量 使用/usr/local/nagios/libexec/中的check_traffic.sh,不但可以监控Linux的网卡流量,也可以监控Windows服务器的流量. 1 Check_traffic.sh用法用法 [[email protected] libexec]#/usr/local/nagios/libexec/check_traffic.sh -h Usage: ./check_traffic.sh [ -v ] [ -6 ] [ -r ] -