温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Cacti+Nagios(七):Nagios监控windows(基于check_nt)

发布时间:2020-05-30 19:08:21 来源:网络 阅读:23820 作者:月晴星飞 栏目:移动开发

1、工作原理

  Cacti+Nagios(七):Nagios监控windows(基于check_nt)

  Cacti+Nagios(七):Nagios监控windows(基于check_nt)

    Nagios服务器使用check_nt工具与客户端程序通讯,客户端程序NSCP使用命令来获取本地客户端的信息并返回给check_nt。

    check_nt只是NSCP其中一项服务,Nagios还可以通过check命令(如check_http检查WEB服务)、check_nrpe、NSCA、WMI来监控windows客户端


2、下载客户端程序

  下载地址:  http://nsclient.org/nscp/downloads

  64位系统下载:NSCP-0.4.1.105-x64.msi

  32位系统下载:NSCP-0.4.1.105-Win32.msi


3、安装NSCP(也叫NSClient++)

    设置Nagios服务器IP地址、客户端访问密码(后面Nagios设置check_nt命令时要用到)和启用各种监控服务。

  Cacti+Nagios(七):Nagios监控windows(基于check_nt)

  配置文件C:\Program Files\NSClient++\nsclient.ini中可以修改Allowed hosts和Password。


4、检查服务、端口状态

  Cacti+Nagios(七):Nagios监控windows(基于check_nt)

  启动服务后netstat -an查看使用的端口,check_nt使用12489、check_nrpe使用5666

  Cacti+Nagios(七):Nagios监控windows(基于check_nt)


5、测试监控命令

(1)获取帮助信息:

[root@nagios ~]# cd /usr/local/nagios/libexec
[root@nagios libexec]# ./check_nt -h

(2)监控运行时间:

[root@nagios libexec]# ./check_nt -H 10.188.1.172 -v UPTIME -p 12489 -s 123456
System Uptime - 0 day(s) 3 hour(s) 16 minute(s) |uptime=196

   -p指定端口,-s指定客户端安装时设置的密码,UPTIME是监控工具。

(3)监控CPU负载 -w警告-c紧急 -l监测参数(过去5分钟平均值,80%警告,90%紧急):

[root@nagios libexec]# ./check_nt -H 10.188.1.172 -v CPULOAD -w 80 -c 90 -l 5,80,90 -p 12489 -s 123456
CPU Load 9% (5 min average) |   '5 min avg Load'=9%;80;90;0;100

(4)监控C盘使用率(-l C指定盘符):

[root@nagios libexec]# ./check_nt -H 10.188.1.172 -v USEDDISKSPACE -w 80 -c 90 -l C -p 12489 -s 123456
C:\ - total: 35.00 Gb - used: 31.68 Gb (91%) - free 3.32 Gb (9%) | 'C:\ Used Space'=31.68Gb;28.00;31.50;0.00;35.00

6、配置Nagios监控

(1)修改check_nt命令

[root@nagios libexec]# cd /usr/local/nagios/etc/objects/
[root@nagios objects]# vi command.cfg
# 'check_nt' command definition
define command{
        command_name    check_nt
        command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s 123456 -v $ARG1$ $ARG2$
        }

(2)创建windows监控主机配置文件夹

[root@nagios libexec]# mkdir winserver

(3)创建windows监控主机配置文件

    配置文件参考/usr/local/nagios/etc/objects/windows.cfg,可以直接复制过来修改,不过太乱了,自己定义吧:

[root@nagios objects]# cd winserver
[root@nagios winserver]# vi winhost_172.cfg
#定义监控主机,设置主机名(不可重复)、别名、IP地址。
define host{
        use             windows-server
        host_name       winhost_172
        alias           ywzhou_pc
        address         10.188.1.172
        }
#定义主机组,在winserver文件下只需要一个文件定义了主机组,其他文件就不要再定义了。
define hostgroup{
        hostgroup_name  windows-servers
        alias           Windows Servers
        }
#第一部分:定义基于check_nt命令的监控服务。
#一个配置文件中的service_description不能重复
#监控NSClient++客户端软件版本
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     NSClient++ Version
        check_command           check_nt!CLIENTVERSION
        }
#监控在线时长
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     Uptime
        check_command           check_nt!UPTIME
        }
#监控CPU负载,超过80%报警,超过90%严重
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     CPU Load
        check_command           check_nt!CPULOAD!-l 5,80,90
        }
#监控内存使用情况,超过80%报警,超过90%严重
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     Memory Usage
        check_command           check_nt!MEMUSE!-w 80 -c 90
        }
#监控C盘使用情况,可以复制该组服务来监控其他磁盘
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     C:\ Drive Space
        check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c 90
        }
#监控系统服务状态(是否启动),默认的W3SVC是IIS的服务,可以复制该组服务来监控其他系统服务
#可以在任务管理器中的服务项查看哪些服务器比较重要就监控起来,比如IIS、SQLServer等。
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     W3SVC
        check_command           check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
        }
#监控程序状态(是否运行),默认的Explorer.exe是桌面进程的程序,可以复制该组服务来监控其他系统服务
#可以在任务管理器中的进程项查看哪些服务器比较重要就监控起来。
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     Explorer
        check_command           check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
        }

#第二部分:定义基于check plugins的监控服务。
#安装NSCP时启用了Enable common check plugins功能
#check plugins是位于/usr/local/nagios/libexec下的Nagios自带的监控插件
#监控ftp服务
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     FTP
        check_command           check_ftp
        }
#监控http服务
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     HTTP
        check_command           check_http
        }
#监控ssh服务
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     SSH
        check_command           check_ssh
        }
#监控dhcp服务
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     DHCP
        check_command           check_dhcp
        }
#监控pop3服务
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     POP
        check_command           check_pop
        }
#监控imap服务
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     IMAP
        check_command           check_imap
        }
#监控smtp服务
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     SMTP
        check_command           check_smtp
        }
#监控tcp端口,常用于监控多个网站使用不同端口时,监控端口状态
define service{
        use                     generic-service
        host_name               winhost_172
        service_description     TCP
        check_command           check_tcp!80
        }

    下面列出所有插件,其中有很多暂时没空去研究,欢迎共同探讨。

Cacti+Nagios(七):Nagios监控windows(基于check_nt)


(4)载入监控配置并重启nagios

[root@nagios winserver]# vi /usr/local/nagios/etc/nagios.cfg
cfg_dir=/usr/local/nagios/etc/objects/winserver
[root@nagios winserver]# service nagios restart



7、Nagios页面操作

(1)查看Hosts主机页面:


Cacti+Nagios(七):Nagios监控windows(基于check_nt)


(2)查看Down主机,有两台PING不通(关机了)

Cacti+Nagios(七):Nagios监控windows(基于check_nt)

 

(3)查看主机hv02的信息,可以设置各种开关

Cacti+Nagios(七):Nagios监控windows(基于check_nt)


(4)查看主机hv02的所有监控服务

Cacti+Nagios(七):Nagios监控windows(基于check_nt)

(5)查看所有报警的监控服务

Cacti+Nagios(七):Nagios监控windows(基于check_nt)


(6)查看所有监控服务,观察正常状态的状态值status informationCacti+Nagios(七):Nagios监控windows(基于check_nt)

Cacti+Nagios(七):Nagios监控windows(基于check_nt)

(7)在Cacti中通过NPC插件查看Nagios信息

Cacti+Nagios(七):Nagios监控windows(基于check_nt)

Cacti+Nagios(七):Nagios监控windows(基于check_nt)

Cacti+Nagios(七):Nagios监控windows(基于check_nt)



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI