Chinaunix首页 | 论坛 | 博客
  • 博客访问: 181982
  • 博文数量: 16
  • 博客积分: 170
  • 博客等级: 入伍新兵
  • 技术积分: 753
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-11 10:57
文章分类

全部博文(16)

文章存档

2017年(3)

2016年(2)

2015年(3)

2014年(1)

2013年(2)

2012年(5)

我的朋友

分类: 网络与安全

2012-06-27 15:26:27

WMI是Window管理协议,详细可百度.
 
这里直接讲nagios如何通过nagios来监控windows.
 
核心内容:
    check_wmi_plus插件通过WMI的客户端命令/bin/wmic来采集windows数据并分析,然后返回给nagios来处理。
 
第一部分:安装/bin/wmic
----------------------------------------------------------------
----------------------------------------------------------------
安装过程
#wget http://dev.zenoss.org/svn/trunk/inst/externallibs/wmi-1.3.14.tar.bz2
#tar jxvf wmi-1.3.14.tar.bz2
#cd wmi-1.3.14/Samba/source
#./autogen.sh
./autogen.sh: running script/mkversion.sh
./script/mkversion.sh: 'version.h' created for Samba("4.0.0tp4-SVN-build-UNKNOWN")              //可以看出wmi-1.3.14.tar.bz2源自于Samba-4.0.0tp4版本。
./autogen.sh: running autoheader -I. -Ilib/replace
./autogen.sh: running autoconf -I. -Ilib/replace
Now run ./configure and then make.
#./configure
#make
...
Linking bin/wmis
Linking bin/wmic
Linking bin/oLschema2ldif
Linking bin/ldbmodify
Linking bin/net
Linking bin/net
make: *** No rule to make target `wmi/wmiq.o', needed by `bin/wmiq'.  Stop.
在编译过程中,会出现如上错误,但不用理会。
因为在当前目录的bin子目录中已产生“wmic”和“wmis”两个命令,所以不用“make install”,直接复制即可。
#ll bin | grep wmi
-rwxr-xr-x 1 root  root  6944522 06-22 00:30 wmic
-rwxr-xr-x 1 root  root  6943756 06-22 00:30 wmis
#cp bin/wmic /bin/
#cp bin/wmis /bin/
#cp bin/winexe /bin/
命令帮助
#/bin/wmic -?
#/bin/wmis -?
测试:
#/bin/wmicwmic -U domain/username%password //192.168.0.1 "select * from Win32_ComputerSystem"
 
 
第二部分:安装check_wmi_plus插件
----------------------------------------------------------------
----------------------------------------------------------------
安装前提:需如下perl模块,且Perl需v5.10.0以上版本
  Config::IniFiles
  Getopt::Long
  DateTime
  Number::Format
  Data::Dumper
  Scalar::Util
  Storable
 
step1:安装
#wget
#tar zxvf check_wmi_plus.v1.52.tar.gz
#mv check_wmi_plus.conf.sample /usr/local/nagios/libexec/check_wmi_plus.conf      //提示:/usr/local/nagios/libexec是nagios的插件目录
#mv check_wmi_plus.pl /usr/local/nagios/libexec/check_wmi_plus.pl
#mv check_wmi_plus.d /usr/local/nagios/libexec/
#chown -R nagios:nagios /usr/local/nagios/libexec/
step2:配置
1.在check_wmi_plus.pl文件中
  my $conf_file='/opt/nagios/bin/plugins/check_wmi_plus.conf';  ==> my $conf_file='/usr/local/nagios/libexec/check_wmi_plus.conf';
  use lib "/usr/lib/nagios/plugins";                            ==> use lib "/usr/lib/nagios/libexec";
2.在check_wmi_plus.conf文件中
  use lib "/usr/lib/nagios/plugins";         ===>  use lib "/usr/lib/nagios/libexec";
  $base_dir="$conf_file_dir";                ===>  系统会自动默认为nagios的插件目录,如:“/usr/lib/nagios/libexec”
  $wmic_command="/bin/wmic"                  ===>  需事先安装wmic
  $tmp_dir='/tmp';                           ===>  $tmp_dir='/usr/local/nagios/var/tmp';该目录必须事先存在,且有nagios访问权限。
 
step3:测试
#/usr/local/nagios/libexec/check_wmi_plus.pl -d -d | head -n 14
 
 
第配部分:安装check_wmi_plus插件
----------------------------------------------------------------
----------------------------------------------------------------
详细请查看:
   
define service{
        use                     generic-service
        host_name               win2003
        service_description     Disk Space - All
        active_checks_enabled   1
        check_interval          2
        check_command           check_win_disk!.!80!90!-o 1 -3 1
        retry_interval          1
        max_check_attempts      1
        notifications_enabled   0
        notification_interval   1
        notification_period     24x7
        notification_options    w,u,c,r
}
阅读(5837) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~