icinga2借助check_wmi_plus.pl监控Windows服务器-阿里云开发者社区

开发者社区> 开发与运维> 正文
登录阅读全文

icinga2借助check_wmi_plus.pl监控Windows服务器

简介:

icinga2借助check_wmi_plus.pl监控Windows服务器



Windows端:


1、确保services里的Windows Management Instrumentation服务是start的(一般均为start)

2、将账号加入本地的Distributed COM Users、Perfromance Log Users、Performance Monitor Users组

3、固定WMI端口为TCP 24158步骤(默认是不固定的),TCP 135(RPC端口)也要开:


以管理员身份运行cmd——net stop winmgmt /y——winmgmt /standalonehost——net start winmgmt——net stop winmgmt——net start winmgmt


Windows 2003不能固定WMI的端口,Windows 2008及以上才可以,默认为1024-65535之间随机




icinga2 服务器端:


check_wmi_plus.pl下载网址:


http://www.edcint.co.nz/checkwmiplus/?q=downloads


将下载下来的check_wmi_plus.v1.60.tar.gz解压,将里面的check_wmi_plus.pl拷到/usr/lib64/nagios/plugins/下,etc目录下的check_wmi_plus拷到服务器的/etc/下


# cp /etc/check_wmi_plus/check_wmi_plus.conf.sample /etc/check_wmi_plus/check_wmi_plus.conf

# vi /etc/check_wmi_plus/check_wmi_plus.conf


$base_dir='/etc/check_wmi_plus';


$ignore_my_outdated_perl_module_versions=1;


:wq





安装perl模块支持:


# cpan Number::Format

# cpan Config::IniFiles

# cpan YAML

# cpan DateTime



wmic下载网址(需要调用wmic命令):


http://rpm.pbone.net/index.php3/stat/4/idpl/21769667/dir/opensuse/com/wmic-1.3.13-8.1.x86_64.rpm.html


# rpm -i wmic-1.3.13-8.1.x86_64.rpm




直接带用户名、密码方式:


# /usr/lib64/nagios/plugins/check_wmi_plus.pl -H 10.0.0.3 -u zhi.yang@ming.com -p xxxxx -m checkcpu -w 80 -c 90




在文件里写好账号、密码方式:


# vi /etc/check_wmi_plus/wmi.auth


username=zhi.yang

password=xxxx

domain=ming.com

:wq


# /usr/lib64/nagios/plugins/check_wmi_plus.pl -H 10.0.0.3 -A /etc/check_wmi_plus/wmi.auth -m checkcpu -w 80 -c 90






抓取Windows CPU:

# /usr/lib64/nagios/plugins/check_wmi_plus.pl -H 10.0.0.3 -A /etc/check_wmi_plus/wmi.auth -m checkcpu -w 80 -c 90


抓取Windows diskIO:

# /usr/lib64/nagios/plugins/check_wmi_plus.pl -H 10.0.0.3 -A /etc/check_wmi_plus/wmi.auth -m checkio -s logical -a D:



抓取Windows D盘使用情况:

# /usr/lib64/nagios/plugins/check_wmi_plus.pl -H 10.0.0.3 -A /etc/check_wmi_plus/wmi.auth -m checkdrivesize -w 80 -c 90 -a D:



抓取Windows内存使用情况:

# /usr/lib64/nagios/plugins/check_wmi_plus.pl -H 10.0.0.3 -A /etc/check_wmi_plus/wmi.auth -m checkmem -w 80 -c 90



抓取Windows网络情况(发送和接收,Local Area Connection指本地连接1):

# /usr/lib64/nagios/plugins/check_wmi_plus.pl -H 10.0.0.3 -A /etc/check_wmi_plus/wmi.auth -m checknetwork -a 'Local Area Connection'


抓取Windows 用户连接数:

# /usr/lib64/nagios/plugins/check_wmi_plus.pl -H 10.0.0.3 -A /etc/check_wmi_plus/wmi.auth -m checkts -s sessions


抓取Windows 2003系统用户连接数:

# /usr/lib64/nagios/plugins/check_wmi_plus.pl -H 10.0.0.3 -A /etc/check_wmi_plus/wmi.auth -m checkts -s sessions2003




集成到icinga2:



# vi /etc/icinga2/conf.d/templates.conf


object CheckCommand "win-users" {

  import "plugin-check-command"

  command = [ PluginDir + "/check_wmi_plus.pl" ]

  arguments = {

  "-H" = "$address$"

  "-A" = "$wmiauthdir$"

  "-m" = "$mode$"

  "-s" = "$sessions$"

}

}

:wq


# vi /etc/icinga2/conf.d/services.conf


apply Service "win_users" {

  import "generic-service"

  check_command = "win-users"

  vars.wmiauthdir="/etc/check_wmi_plus/wmi.auth"

  vars.mode="checkts"

  vars.sessions="sessions"

  vars.perf = true

  assign where host.vars.os == "RDBJ"

:wq


# service icinga2 restart



集成到grafana略(生成graph即可)

本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/1915428如需转载请自行联系原作者

yangzhimingg

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

其他文章
最新文章
相关文章