luoson1 发表于 2015-9-8 09:02:56

Nagios监控Windows服务器(SNMP方式)

Nagios使用SNMP方式监控Windows服务器
此种方式通过snmp协议来获取Windows主机的相关系统信息。因此Windows端必须配置SNMP服务,Nagios端要安装net-snmp包
1、安装配置
  Windows 端,配置SNMP Service,按照以下方式配置,
1.1)安装snmp
  下载snmp for xp http://pan.baidu.com/share/link?shareid=1697071351&uk=2737059485

需要安装光盘,不需要重启
1.2)配置SNMP服务


1.3) 配置snmp团体名称和允许的主机列表

2、开通防火墙的snmp协议端口udp 161
3、检查161端口Listen情况
  netstat –an
  看到“ UDP0.0.0.0:161 *:*”,即表示已在windows主机成功安装。
4、Nagios服务端安装nagios-snmp-plugins
       http://nagios.manubulon.com/index_info.html
SNMP login

      For more information, you can have a look at information on snmp login
      If you are using snmp v1 :
      $USER7$=-C <community>
      If you are using snmp v2c :
      $USER7$=-C <community> -2
      or you can use $USER9$ if you need both v1 and v2c.
      Examples of snmp v3 login :
      AuthNoPriv (md5) :
      $USER8$=-l <login> -x <pass>
      AuthPriv (md5,aes) :             $USER8$=-l <login> -x <pass> -X <pass> -L md5,aes

  本文中使用的是V-1.1.1版本
4.1 下载各模块http://pan.baidu.com/s/1qWJk5La,依赖模块下载亦可到官方网站http://www.cpan.org/
  Crypt::DES
  Digest::MD5
  Digest::SHA1
  Digest::HMAC
  Net::SNMP
下载后对于每个模块依次按照下面的方式安装
  tar zxf .tar.gz 表示模块名,具体请按上面提到的模块替换
  cd 表示模块名,具体请按上面提到的模块替换
  perl Makefile.pl
  make install
注意:Net::SNMP模块必须在最后安装。至此Net::SNMP手动安装完毕
执行nagios-snmp-plugins安装脚本
  ./install.sh
根据提示选择相应路径,执行之后会将插件命令安装到/usr/local/nagios/libexec下
4.2 添加配置文件,检查命令
注:
check_snmp_load,check_snmp_proc,check_snmp_stor中
snmp v1 :
-C $ARG1$=-C <community>
snmp v2c :
-C $ARG1$=-C <community> -2

vi /usr/local/nagios/etc/objects/commands.cfg

define command {
    command_name    check_snmp_load
    command_line    $USER1$/check_snmp_load.pl -H $HOSTADDRESS$ -C $ARG1$ -T $ARG2$ -w $ARG3$ -c $ARG4$ $ARG5$
    }
define command {
    command_name    check_snmp_proc
    command_line    $USER1$/check_snmp_process.pl -H $HOSTADDRESS$ -C $ARG1$ -n $ARG2$ -w $ARG3$ -c $ARG4$ $ARG5$
    }
define command {
    command_name    check_snmp_stor
    command_line    $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ -C $ARG1$ -m $ARG2$ -w $ARG3$ -c $ARG4$ $ARG5$
    }
define command {
    command_name    check_snmp
    command_line    $USER1$/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o $ARG2$
    }
4.3 windows系统监控应用
define host{
  use        windows-server
  host_name    10.0.1.99
  alias        My Windows Server
  address                10.0.1.99
  }
define hostgroup{
  hostgroup_name   windows
  alias                     Windows Servers
  }
#C:\磁盘空间###############
define service{
  use          generic-service
  host_name               10.0.1.99
  service_description      C盘空间利用率
  check_command          check_snmp_stor!public -2!C!40!80
  }
#物理内存#############
define service{
  use                        generic-service
  host_name                10.0.1.99
  service_description   物理内存
  check_command      check_snmp_stor!public -2!Physical Memory!40!80
  }
#虚拟内存(ram+swap)######
define service{
  use                        generic-service
  host_name               10.0.1.99
  service_description      虚拟内存
  check_command          check_snmp_stor!public -2!Virtual!10!20
  }
#进程QQ.exe#############
define service{
  use          generic-service
  host_name      10.0.1.99
  service_description   QQ
  check_command   check_snmp_proc!public -2!"QQ.exe"!0!0
;critical if not, no warnings
      }
#CPU负载#########
define service{
  use          generic-service
  host_name               10.0.1.99
  service_description      CPU_Load
  check_command          check_snmp_load!public -2!stand!30!80
  }            
#网卡流量##############
监控网卡流量,详见http://www.cnblogs.com/wowchky/archive/2013/06/01/3111839.html
define service{
  use          generic-service
  host_name      10.0.1.99
  service_description      eth1
  check_command          check_traf!1!50,100!900,1000 -C public
  }
#系统运行时间############
define service{
  use                        generic-service
  host_name             10.0.1.99
  service_description      系统运行时间
  check_command          check_snmp!public!sysUpTime.0
  }
页: [1]
查看完整版本: Nagios监控Windows服务器(SNMP方式)