如何配置Nagios来监控Windows Server

60次阅读
没有评论

共计 3409 个字符,预计需要花费 9 分钟才能阅读完成。

这篇文章给大家分享的是有关如何配置 Nagios 来监控 Windows Server 的内容。丸趣 TV 小编觉得挺实用的,因此分享给大家做个参考,一起跟随丸趣 TV 小编过来看看吧。

Nagios 是多功能的网络监控系统,可以帮助你轻松监控数据中心的各个设备。它对 Linux 系统支持一定的开箱即用性,但对于通过使用 NSClient++,你也可以利用 Nagios 监控 Windows Server。

在 Nagios 的环境中监控 Windows 有几种不同的模式。本文讨论的比较简单的方法是使用 check_nt 命令,这条命令在 Nagios 的 commands.cfg 文件中已经被定义了。在以后的文章中,你还会学到怎样配置 Nagios Remote Plugin Executor(NRPE)。

首先,监控你的 Windows 环境的 *** 步是到 http://sourceforge.net/projects/nscplus 下载并安装 NSClient++。在下载之前先确定你需要哪种版本的软件。默认下载的是支持 64 位的版本。如果你需要在 32 位 Windows 下运行 NSClient++,就需要从下载页的 Files section 下载 32-bit MSI。

下载了 NSClient++ 之后,打开 Windows 服务界面,配置 NSClient++ 服务以便让它自动开始。同样的你还要确保服务日志与本地系统账户一同存在,而且可以从桌面自动运行。*** 一步就是检查 Windows 防火墙。NSClient++ 在 12489 端口运行,确保你防火墙里这一端口是开着的。

配置 Nagios 服务器

配置好 Windows 的部分之后,你还得配置 Nagios 服务器。首先,确保 check_nt 命令在 /etc/nagios/objects/commands.cfg 都被定义了。还有一点改变,应用默认配置不使用密码了,所以在命令行末尾,加 -s nagios(参见例 1),以便让 check_nt 命令使用默认的密码“nagios”。

#  check_nt  command definition
define command{
 command_name check_nt
 command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ -s nagios
 }

例 1:在命令行末尾加 -s nagios,来让 check_nt 命令使用默认密码。

然后,在 /etc/nagios/objects/templates.cfg,你需要模板来定义 Windows 主机应该怎样配置(例 2 会告诉你这个定义在默认状态下是怎么样的):

define host{
 name windows-server ;(本主机模板的名字) use generic-host

(继承通用主机模板的默认值)

check_period 24x7 ;(默认将日夜不间断监控 Windows servers) check_interval 5 ;(每五分钟主动检查服务器) retry_interval 1 ;(每隔一分钟,重试日程主机检查。) max_check_attempts 10 ; (每个服务器检查十遍(最多)) check_command check-host-alive ;(检查服务器是否运转的默认命令。) notification_period 24x7 ;(在任何时段发送报告。) notification_interval 30 ;(每隔 30 分钟重复发送报告。) notification_options d,r ;(只为特定主机状况发送报告。) contact_groups admins ;(默认把报告发送给 admins。) hostgroups windows-servers ;(主机把 Windows servers 分组为成员。) register 0 ;(不要注册这个,这只是个模板) }

例 2:# Windows 主机定义模板 mdash; mdash; 不是真的主机,只是模板!

核实模板存在之后,你需要通知 Nagios 还得监视 Windows。通过取消注解 cfg_file 行(例 3 会讲到)的方法,让 Nagios 看 windows.cfg 文件:

# Definitions for monitoring a Windows machine
cfg_file=/etc/nagios/objects/windows.cfg

例 3:取消对 cfg_file 行的注解。

这样做之后,你可以定义 Windows 主机被监视。这一步在每个要被监视的 windows 主机都要做。你需要一个在 windows.cfg 文件中的定义主机项(见例 4):

define host{
 use windows-server ;(从模板继承默认值。) host_name winserver ;(我们给这台主机起的名字。) alias My Windows Server ;(更长的名字来联系这个主机。) address 192.168.1.54 ; IP address of the host (主机的 IP 地址) }

例 4:定义主机部分

现在,为 Windows 配置 Nagios 的 *** 一步就是定义你想要监控的设备。这也从 windows.cfg 文件发生。你可以在下文(例 5)中找到这些设备的其中两个的例子。

#########################################################################
#########################################################################
# SERVICE DEFINITIONS
#########################################################################
#########################################################################
# Create a service for monitoring the version of NSCLient++ that is installed (创建一个设备来监视已安装 NSCLient++ 的版本)# Change the host_name to match the name of the host you defined above (改变 host_name 以符合之前已经定义的主机名称)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 (改变 host_name 以符合之前已经定义的主机名称)define service{
 use generic-service
 host_name winserver
 service_description Uptime
 check_command check_nt!UPTIME
 }

例 5:定义 Nagios 要监控的设备

阅读 windows.cfg 文件剩余的内容,找出哪些设备检查是可用的,确保所有需要的设备能用。一旦你做完这些,就可以保存你的改变并重启 Nagios 服务器,使用 Nagios 主机上的 service nagios restart。这就可以激活改变,然后,你就能从 Nagios 界面监控 Windows 主机上的设备了。

感谢各位的阅读!关于“如何配置 Nagios 来监控 Windows Server”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-25发表,共计3409字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)