上节内容实现了使用NRPE+Nagios-plugin插件对远程Linux服务器及相关服务的监控,这节将主要介绍如何使用Nagios实现对远程windows主机的监控配置。
一、被监控端安装NSClient++
下载NSClinet++:https://nchc.dl.sourceforge.net/project/nscplus/nscplus/NSClient%2B%2B%200.4.1/NSCP-0.4.1.73-x64.msi
被监控的windows主机下载并安装相关NSClinet++软件,按照提示进行安装即可。
并放开NSClinet++的端口12489以及添加共享文件和打印机的预定义策略否则则显示主机状态为down,而服务为OK的局面;
二、Nagios监控端配置
[[email protected] objects]# /usr/local/nagios/libexec/check_nt -H 192.168.31.20 -p 12489 -V UPTIME check_nt v2.2.1 (nagios-plugins 2.2.1) [[email protected] ~]# vim /usr/local/nagios/etc/nagios.cfg cfg_file=/usr/local/nagios/etc/objects/windows.cfg ;添加window监控模板[[email protected] objects]# vim 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.31.20 ; IP address of the host (被监控的windows主机地址) } [[email protected] objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg [[email protected] objects]# service nagios restart
web端监控验证
三、配置nagios的邮件告警
nagios邮件告警可以直接使用系统自带的sendmail工具进行设置,具体操作如下
[[email protected] objects]# yum -y install sendmail [[email protected] objects]# service sendmail restart [[email protected] objects]# chkconfig sendmail on [[email protected] objects]# vim /usr/local/nagios/etc/objects/contacts.cfg
define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-cont act template (defined above) alias Nagios Admin ; Full name of user email 52*****[email protected] ; <<***** 设置自己的邮箱地址即可 S ****** }
检查配置文件如果没有错误则重启nagios服务即可,可通过停止已经监控的某个服务查看能够否收到邮件,收件箱如果没有的话可以查看下是否在垃圾箱恢复即可,邮件内容大致如下。
***** Nagios ***** Notification Type: PROBLEM Host: winserver State: DOWN Address: 192.168.31.20 Info: (Host Check Timed Out) Date/Time: Mon Nov 6 23:57:42 CST 2017
到此介绍完了nagios服务对windows系统和邮件告警的发送配置
时间: 2024-09-30 06:53:19