nagios监控(二)之监控windows server服务器

摘要
本文介绍了如何使用nagios通过nsclient监控windows主机。
此次实验环境基于上篇文章,监控端在Linux环境下,Windows服务器使用的时windows server 2012。

1. 安装NSClient++
访问http://nsclient.org/nscp/下载NSClient++,这里我使用的是NSCP-0.4.3.143-x64的msi安装包。下载之后直接安装,过程中会提示输入Nagios监控服务器地址和密码。地址填写正确,密码不用设置。Nagios监控服务器事先在监控Linux服务器时候已经搭建好,需要的小伙伴看这里

2.配置NSClient++
在 NSClient++ 的安装目录打开 nsclient.ini,将监控服务器的IP地址加到 allowed hosts 指令后面。
这里写图片描述
然后检查下12489端口是否正常监听
netstat -an | more

因为安装时候需要的模块已经勾选了,所以配置文件中不用再作设置。否则可以通过去掉每个模块前的;来启用该模块。

到这里即完成了Windows Server 2012上的配置。接下来我们设置Nagios监控服务器。

3.Nagios监控服务器设置
vi /usr/local/nagios/etc/nagios.cfg
搜索找到:
Definitions for monitoring a Windows machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
将第二行的#去掉打开Nagios监控的Windows模块,然后保存。
这里写图片描述

接着编辑
找到并设置监控的服务器:
设置被监控主机名和被监控的Windows服务器地址。
此地址为Linux服务端的ip地址

vi /usr/local/nagios/etc/objects/windows.cfg
define host{
use windows-server ; Inherit default values from a template
host_name winserver ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 192.168.0.2 ; IP address of the host
}

这里写图片描述

接下来搜索各种监控的服务并设置:

#监控NSClient版本。
Create a service for monitoring the version of NSCLient++ that is installed
Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}

#监控服务器在线时间。
Create a service for monitoring the uptime of the server
Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description Uptime
check_command check_nt!UPTIME
}


#监控服务器CPU负载。
Create a service for monitoring CPU load
Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description CPU Load
check_command check_nt!CPULOAD!-l 20,30,50
}


#监控服务器的内存占用。
 Create a service for monitoring memory usage
 Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}


#监控系统C盘的磁盘占用。
Create a service for monitoring C:\ disk usage
Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}

进入目录 /usr/local/nagios/libexec/
在nagios监控端验证是否可以监控到windows主机,用命令./check_nt -H 192.168.13.132 -p 12489 -v UPTIME可以检测到Windows服务器已经启动的时长,也表示可以从Windows服务器拿到数据了。
这里写图片描述

现在就可以登录到nagios的web界面,查看你的监控信息了
这里写图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值