设为首页 收藏本站
查看: 1147|回复: 0

Nagios监控Windows服务器(NSClient++安装与应用)

[复制链接]

尚未签到

发表于 2015-9-8 09:31:29 | 显示全部楼层 |阅读模式
  NSClient++安装
下载NSClient++插件
点击下面链接下载http://files.nsclient.org/x-0.3.x/NSClient%2B%2B-0.3.9-Win32.msi
安装插件与配置
安装过程十分简单,直接点击下一步,下一步即可。安装过程注意如下图的设置即可
DSC0000.jpg
  
配置NSClient
编辑NSClient安装目录下的NSC.ini文件,修改后,重启NSClient即可,如下图所示
DSC0001.jpg
DSC0002.jpg
DSC0003.jpg
DSC0004.jpg
模块作用说明,如下表
Module    Description    Commands
CheckSystem.dll    Handles many system checks    CPU, MEMORY, COUNTER etc
CheckDisk.dll    Handles Disk related checks    USEDDISKSPACE
FileLogger.dll    Logs errors to a file so you can see what is going on    N/A
NSClientListener.dll    Listens and responds to incoming requests from nagios    N/A
NSClient应用监控
NSClient++与Nagios服务器通信,主要使用Nagios服务器的check_nt插件。原理图如下
DSC0005.jpg
check_nt插件的使用说明
[iyunv@localhost libexec]# ./check_nt -h
check_nt v1.4.15 (nagios-plugins 1.4.15)
Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)
Copyright (c) 2000-2007 Nagios Plugin Development Team
        <nagiosplug-devel@lists.sourceforge.net>
This plugin collects data from the NSClient service running on a
Windows NT/2000/XP/2003 server.
Usage:
check_nt -H host -v variable [-p port] [-w warning] [-c critical]
[-l params] [-d SHOWALL] [-u] [-t timeout]
Options:
-h, --help
    Print detailed help screen
-V, --version
    Print version information
Options:
-H, --hostname=HOST
   Name of the host to check
-p, --port=INTEGER
   Optional port number (default: 1248)
-s, --secret=<password>
   Password needed for the request
-w, --warning=INTEGER
   Threshold which will result in a warning status
-c, --critical=INTEGER
   Threshold which will result in a critical status
-t, --timeout=INTEGER
   Seconds before connection attempt times out (default:  -l, --params=<parameters>
   Parameters passed to specified check (see below) -d, --display={SHOWALL}
   Display options (currently only SHOWALL works) -u, --unknown-timeout
   Return UNKNOWN on timeouts10)
-h, --help
   Print this help screen
-V, --version
   Print version information
-v, --variable=STRING
   Variable to check
Valid variables are:
CLIENTVERSION = Get the NSClient version
  If -l <version> is specified, will return warning if versions differ.
CPULOAD =
  Average CPU load on last x minutes.
  Request a -l parameter with the following syntax:
  -l <minutes range>,<warning threshold>,<critical threshold>.
  <minute range> should be less than 24*60.
  Thresholds are percentage and up to 10 requests can be done in one shot.
  ie: -l 60,90,95,120,90,95
UPTIME =
  Get the uptime of the machine.
  No specific parameters. No warning or critical threshold
USEDDISKSPACE =
  Size and percentage of disk use.
  Request a -l parameter containing the drive letter only.
  Warning and critical thresholds can be specified with -w and -c.
MEMUSE =
  Memory use.
  Warning and critical thresholds can be specified with -w and -c.
SERVICESTATE =
  Check the state of one or several services.
  Request a -l parameters with the following syntax:
  -l <service1>,<service2>,<service3>,...
  You can specify -d SHOWALL in case you want to see working services
  in the returned string.
PROCSTATE =
  Check if one or several process are running.
  Same syntax as SERVICESTATE.
COUNTER =
  Check any performance counter of Windows NT/2000.
        Request a -l parameters with the following syntax:
        -l "\\<performance object>\\counter","<description>
        The <description> parameter is optional and is given to a printf
  output command which requires a float parameter.
  If <description> does not include "%%", it is used as a label.
  Some examples:
  "Paging file usage is %%.2f %%%%"
  "%%.f %%%% paging file used."
INSTANCES =
  Check any performance counter object of Windows NT/2000.
  Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>
  <counter object> is a Windows Perfmon Counter object (eg. Process),
  if it is two words, it should be enclosed in quotes
  The returned results will be a comma-separated list of instances on
   the selected computer for that object.
  The purpose of this is to be run from command line to determine what instances
   are available for monitoring without having to log onto the Windows server
    to run Perfmon directly.
  It can also be used in scripts that automatically create Nagios service
   configuration files.
  Some examples:
  check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process
检查Nagios目录下的libexec子目录,一定要存在check_nt
(例如:/usr/local/nagios/libexec/check_nt)
查看Nagios服务器下定义check_nt命令
[iyunv@localhost etc]# vim commands.cfg
define command {
command_name   check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
register          1
}
Windows系统监控应用
首先定义一个需要监控的主机,本例为监控Winxp226,命令如下:
define host {
        host_name                       winxp226
        alias                             My Windows Server
        address                          10.0.192.226
        use                              windows-server,host-pnp
        register                           1
}
监控 windows 主机的 CPU 负载
define service {
        host_name                       winxp226
        service_description                cpuload
        use                              generic-service
        check_command                  check_nt!CPULOAD!-l 5,70,80,10,80,90
        register                           1
}
注:#CPU如果到达80%则报警,到达90%则警笛
监控 windows 主机的内存使用状况
define service {
        host_name                       winxp226
        service_description                Memory Usage
        use                              generic-service
        check_command                  check_nt!MEMUSE!-w 80 -c 90
        register                           1
}
注:内存使用到达80%则warn,到达90%则Critical
监控 windows 主机的开机运作时间
define service {
        host_name                       winxp226
        service_description                Uptime
        use                              generic-service
        check_command                  check_nt!UPTIME
        register                          1
}
检查windows主机是否已经安装了NSClient++,及它的版本号
define service {
        host_name                       winxp226
        service_description                NSClient++ Version
        use                              generic-service
        check_command                  check_nt!CLIENTVERSION
        register                           1
}
监控 windows 主机的 C:\ 的空间使用量
define service {
        host_name                     winxp226
        service_description              C:\ Drive Space
        use                            generic-service
        check_command                check_nt!USEDDISKSPACE!-l c! -w 80 -c 90
        register                         1
}
监控 windows主机的W3SVC设置的动作状况
define service{
     host_name           winxp226     use                 generic-service     service_description    W3SVC     check_command      check_nt!SERVICESTATE!-d SHOWALL -l W3SVC }
监控 windows 主机的 Explorer.exe 进程运作状况,如程序终止,则会发 Critical
define service {
      host_name              winxp226
      service_description       Explorer
      use                     generic-service
      check_command         check_nt!PROCSTATE! -d SHOWALL -l explorer.exe
      register                  1
}
监控 windows 主机的SNMP服务的运作状况,如服务终止,则会发CRITICAL
define service{use                      generic-servicehost_name               winxp226service_description       SNMPcheck_command         check_nt!SERVICESTATE!-d SHOWALL -l "SNMP Service" }
9)监控Windows主机的MySQL服务运行情况,如服务终止,则会发出CRITICAL
     define service {
        host_name               winxp226
        service_description       MySQL55
        use                      generic-service
        check_command         check_nt!SERVICESTATE! -d SHOWALL -l MySQL55
        register                  1
      }
注意:此服务名称应与Windows服务名称相同,如服务中间有空格时请将其放入双引号内,否则将会报无效的参数。如下图
DSC0006.jpg
检查nagios.cfg文件是否有误,然后重启nagios
[iyunv@localhost services]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[iyunv@localhost services]# service nagios restart
监控效果图
DSC0007.jpg

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-110914-1-1.html 上篇帖子: Nagios状态长时间处于Pending的解决方法 下篇帖子: nagios二次开发(三)---nagiosql架构简介
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表