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

Nagios利用NSClient++监控Windows主机

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-9-28 09:22:25 | 显示全部楼层 |阅读模式
一、简介

NSClient++官网:http://www.nsclient.org/
1、利用NSClient++监控的资源

CPU负载

内存占有率
Disk利用率

服务状态

运行的进程等


2、NSClient++监控的工作原理
NSClient++是用来监控Windows主机时安装在Windows主机上的组件。被监控机上安装NSClient,,当监控主机将监控请求发给NSClient后,NSClient直接完成监控,所有的监控是由NSClient完成的.不需要额外的插件。这也说明了NSClient不灵活,没有可扩展性.它只能完成自己本身包含的监控操作,不能由一些插件来扩展.好在NSClient已经做的不错了,基本上可以完全满足我们的监控需要。
wKiom1QmsE6D3w78AACXqNusVkc181.jpg


二、安装NSClient++
1、下载NSClient++
下载地址:http://sourceforge.net/projects/nscplus/files/nscplus/

2、安装NSClient++
wKiom1QmswLChu7BAAF5ugAoQLo820.jpg
wKioL1QmsyqyCXr-AAHsG6bmgZw306.jpg
wKiom1QmswOwzMYBAAGsdr9E0Pc403.jpg
wKioL1QmsyqTfejsAAGRfdnH-xU473.jpg
Allowed hosts:(this is the IP of the nagios (or other)server)

允许的主机地址:Nagios服务器端的IP地址

NSClient password(only userd via check_nt)
NSClient的密码:填写Nagios跟NSClient++进程通信的密码,可以不设置

Modules to load:
安装并加载相应的模块:NSClient++自带的有check_plugins插件,check_nt,check_nrpe,NSCA,WMI
在这里我们全部选择,以后会有用到的。
wKiom1QmswOTN7ZdAAF8CMhGqWs779.jpg
wKioL1Qmsyvjmrj1AADuL2UQatY830.jpg
点击【Finsh】,表示安装NSClient++完成
wKioL1QmsyujK89FAAGCBr_MNf0266.jpg

3、查看NSClient++服务是否已经启用
wKioL1QnXTmgMzAWAAQEAtOdHlA759.jpg
wKioL1QmteTAZNRsAAFeBB6Vn6c938.jpg

4、查看NSClient++的配置文件
默认是安装在C:Program FilesNSClient++ 目录下,NSC.ini即为NSClient服务的配置文件,一般我们无需修改,但是当我们监控端的IP地址改变时,或者密码忘记,即可以在这里修改了。
安装时加载的模块
wKioL1QnXLeisp6DAAOmUPyr8zQ318.jpg
设置允许连接的地址:为Nagios的IP地址
wKiom1QnXJDxt5BDAAZlbauD00Y308.jpg
NRPE的默认端口号
wKioL1QnXLnCQe-sAATIjXBJX2M538.jpg

三、NSClient应用监控
NSClient++与Nagios服务器通信,主要使用Nagios服务器的check_nt插件。原理图如下
wKiom1QnXc7Rghy-AAC9NsiJ0jA271.jpg

1、check_nt插件的使用说明
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
[iyunv@Nagios ~]# cd /usr/local/nagios/libexec/
[iyunv@Nagios libexec]# ./check_nt -h   #查看check_nt的语法
check_nt v2.0.3 (nagios-plugins 2.0.3)
Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)
Copyright (c) 2000-2014 Nagios Plugin Development Team
    <devel@nagios-plugins.org>

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
--extra-opts=[section][@file]
    Read options from an ini file. See
    https://www.nagios-plugins.org/doc/extra-opts.html
    for usage and examples.
Options:
-H, --hostname=HOST
   Name of the host to check
-p, --port=INTEGER
   Optional port number (default: 1248)  #默认端口号
-s, --secret=                 #指定的密码
   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 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  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 ,,.
   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.
  -l  
   = seconds, minutes, hours, or days. (default: minutes)
  Thresholds will use the unit specified above.
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 ,,,...
  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 "\\counter","
    The  parameter is optional and is given to a printf
  output command which requires a float parameter.
  If  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  -p  -v INSTANCES -l
   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   #check_nt的语法
  
Notes:
- The NSClient service should be running on the server to get any information
   (http://nsclient.ready2run.nl).
- Critical thresholds should be lower than warning thresholds
- Default port 1248 is sometimes in use by other services. The error
   output when this happens contains "Cannot map xxxxx to protocol number".
   One fix for this is to change the port to something else on check_nt
   and on the client service it's connecting to.

Send email to help@nagios-plugins.org if you have questions regarding use
of this software. To submit patches or suggest improvements, send email to
devel@nagios-plugins.org



2、check_nt命令的使用
check_nt参数解释
-w:警告比例
-c:紧急比例
-l:过去5分钟的平均值,80%的警告  90%紧急 wKiom1QmuKqBRFWJAAJvlnFCVQ4764.jpg

四、定义命令、主机、服务
1、定义命令

1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@Nagios ~]# vim /usr/local/nagios/etc/objects/commands.cfg
# 'check_win' command definition
define command{
        command_name    check_win
        command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
        }
注释:
$..$    表示系统内置的宏,也就是所谓的变量
$USER1$ 表示插件所在的目录  
-H      指定主机地址
$HOSTADDRESS$  应用到哪个主机,就用哪个主机的地址
$ARG1$  传递的参数,形参
-s      指定密码 默认为空




2、定义主机和服务
1
2
3
[iyunv@Nagios objects]# cp windows.cfg windows106.cfg
[iyunv@Nagios objects]# sed -i 's/winserver/Windows106/g' windows106.cfg
[iyunv@Nagios objects]# sed -i 's/192.168.1.2/192.168.0.106/' windows106.cfg



4、检测配置文件是否有语法错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
[iyunv@Nagios ~]# service nagios configtest

Nagios Core 4.0.7
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 06-03-2014
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
    Checked 8 services.
    Checked 1 hosts.
    Checked 1 host groups.
    Checked 0 service groups.
    Checked 1 contacts.
    Checked 1 contact groups.
    Checked 25 commands.
    Checked 5 time periods.
    Checked 0 host escalations.
    Checked 0 service escalations.
Checking for circular paths...
    Checked 1 hosts
    Checked 0 service dependencies
    Checked 0 host dependencies
    Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
Object precache file created:
/usr/local/nagios/var/objects.precache




5、重启nagios服务
1
2
3
4
[iyunv@Nagios objects]# service nagios restart
Running configuration check...
Stopping nagios: .done.
Starting nagios: done.




四、浏览器查看监控信息

1、登陆后点击【Hosts】,查看新监控的Windows主机信息

wKioL1Qmw93SnhVOAAOI_HKVwgw436.jpg

2、点击【Services】,查看Windows服务的状态信息
wKiom1Qmw7awxW6cAAfMmerFYOc506.jpg

3、等待几分钟后状态就正常了,如下图所示

wKiom1Qmys7Sl-qRAAVcoYMMwSw515.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-25437-1-1.html 上篇帖子: Nagios利用NRPE监控Linux主机 下篇帖子: nagios安装部署 Windows 监控 主机
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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