设为首页 收藏本站
查看: 1900|回复: 0

nagios监控ESXi硬件

[复制链接]

尚未签到

发表于 2015-11-23 04:01:37 | 显示全部楼层 |阅读模式
  普通的Dell服务器硬件监控我们可以通过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
  
  安装完成后,我们来查看下这个插件都有什么参数:
  

[iyunv@nagios libexec]# ./check_esxi_hardware.py
Traceback (most recent call last):
File &quot;./check_esxi_hardware.py&quot;, line 222, in <module>
import pywbem
ImportError: No module named pywbem
[iyunv@nagios libexec]# ./check_esxi_hardware.py -h
Traceback (most recent call last):
File &quot;./check_esxi_hardware.py&quot;, 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.txtok,pywbem安装完毕。  
  注意:(1).不要使用pywbem-0.8.0版本,这个版本有bug导致我们的插件无法使用
      (2).python setup.py install --record files.txt 记录安装目录的目的就是为了方便卸载插件,cat files.txt | xargs rm -rf
  3.使用插件
  

[iyunv@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 不采集电源信息,以下雷同。
  4.给Esxi主机设置只读用户
  (1)先登录Esxi主机,在“本地用户和组”标签中,空白处右键“添加”,即可添加用户。
DSC0000.jpg


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


  ok,只读用户nagios就添加完毕。
  5.测试
  

[iyunv@nagios 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”去掉,在第二行加上“&#43;:nagios:sfcb”
  这种方式适合在不经常添加用户的情况下使用,只改一次即可;但是经常加用户可能会导致access.conf变化,需要设置计划任务添加“&#43;:nagios:sfcb”
  再测试下:
  

[iyunv@nagios 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: XXXXXXXXXXXok,监控正常。  
  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)监控效果图
DSC0002.jpg


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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-142308-1-1.html 上篇帖子: 在CentOS6.3上搭建nagios+cacti+ntop+pnp 下篇帖子: The requested URL /nagios/cgi-bin/statusmap.cgi was not found on this server
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表