Nagios需要在Windows上面配置一些信息,之前我直接在配置文件中添加Windows服务器信息,但是发现监控的东西都是一些不痛不痒的,后来按照文档上面说的,发现这回监控的不错,功能很强大。
下面是具体的步骤以及解决办法
首先安装服务器所必须的安装包:
apt-get install nagios-images nagios-nrpe-plugin nagios-nrpe-server nagios-plugins nagios-plugins-basic nagios-plugins-standard nagios3 nagios3-cgi nagios3-common nagios3-core
如果这些都安装好了就进行下一步
编辑 /etc/nagios-plugins/config/nt.cfg 修改里面的文件
把以下的文件
define command {
command_name check_nt
command_line /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -v '$ARG1$' }
修改为
define command {
command_name check_nt
command_line /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v $ARG1$ $ARG2$
}
再定义nrpe服务,将信任的 主机加到该文件里
vim /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1
In order to allow more hosts to report to the nagios nrpe daemon, change the value to let's say:
allowed_hosts=127.0.0.1,192.168.1.4,192.168.1.5,192.168.1.6
This config allows the three IPs 192.168.1.4-6 to be able to report for nrpe.
For the changes to nrpe server to take effect, it has to be restrarted.
debian:~# /etc/init.d/nagios-nrpe-server restart
然后再在Windows服务器安装nsclient++
之前我安装的时候输入了密码,所以会出现下面的问题
在为windows客户端做监控的过程中,Nagios报 "NSClient - ERROR: Invalid password"的错误,status为UNKOWN,这错误说的是NSClient的密码不可用。
原因如下:
A.在安装Windows客户端程序NSClient++-的时候设置了密码,在nagios 的配置文件没增加-s PASSWORD造成的。
B.在nagios 的配置文件确定不用-s PASSWORD的时候,不小心设置了密码,或者操作失误输入了密码。
解决办法:
1.对于A的情况,在nagios 的配置文件没增加-s PASSWORD,重启nagios 服务。
2.对于B的情况, 在windows客户端,打开C:\Program Files\NSClient++\NSC.ini文件,不password那行注释掉,然后重启动NSClient++ 服务。
切记,咱安装这个的时候最好不要输入密码,否则还要再在服务器端重新配置
在Windows中安装完这个软件后需要重新启动该服务
配置Ubuntu服务器端监控Windows的配置文件
按照官方文档说将这个目录下的文件
/usr/share/doc/nagios3-common/examples/template-object/windows.cfg
直接拷贝到 /etc/nagios3/conf.d 当作监控的脚本
下面的代码是Windows.cfg,根据你自己的需求更改一些配置
PS:前提要在你主机的hosts文件里面加入相关windows服务器的信息
将以上的代码填写到之前的配置文件中
下面是监控windows的配置文件详细信息
# A simple configuration file for monitoring the local host
# This can serve as an example for configuring other servers;
# Custom services specific to this host are added here, but services
# defined in nagios2-common_services.cfg may also apply.
#
define host{
use generic-host ; Name of host template to use
host_name ismonitor02
alias ismonitor02
address 172.16.71.12
}
# Define a service to check the disk space of the root partition
# on the local machine. Warning if < 20% free, critical if
# < 10% free space on partition.
define service{
use generic-service ; Name of service template to use
host_name ismonitor02
service_description Disk Space
check_command check_all_disks!20%!10%
}
# Define a service to check the number of currently logged in
# users on the local machine. Warning if > 20 users, critical
# if > 50 users.
define service{
use generic-service ; Name of service template to use
host_name ismonitor02
service_description Current Users
check_command check_users!20!50
}
# Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 processes.
define service{
use generic-service ; Name of service template to use
host_name ismonitor02
service_description Total Processes
check_command check_procs!250!400
}
# Define a service to check the load on the local machine.
define service{
use generic-service ; Name of service template to use
host_name ismonitor02
service_description Current Load
check_command check_load!5.0!4.0!3.0!10.0!6.0!4.0
}
###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################
# Define a hostgroup for Windows machines
# All hosts that use the windows-server template will automatically be a member of this group
#define hostgroup{
# hostgroup_name windows-servers ; The name of the hostgroup
# alias Windows Servers ; Long name of the group
# }
###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################
# 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 ismonitor02
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 ismonitor02
service_description Uptime
check_command check_nt!UPTIME
}
# 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 ismonitor02
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
# 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 ismonitor02
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
# 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 ismonitor02
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above
#define service{
# use generic-service
# host_name ismonitor02
# service_description W3SVC
# check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
# }
# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name ismonitor02
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}