Chinaunix首页 | 论坛 | 博客
  • 博客访问: 617103
  • 博文数量: 73
  • 博客积分: 1813
  • 博客等级: 上尉
  • 技术积分: 1213
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-27 19:59
文章分类
文章存档

2013年(1)

2012年(12)

2011年(28)

2010年(31)

2009年(1)

我的朋友

分类: LINUX

2010-11-15 15:40:32

一.在windows-NT机器上安装NSClient
1.版本:NSClient++-0.3.8-Win32
2.安装:安装时与普通软件安装一样,双击运行。安装过程中要添加nagios服务器IP地址(配置文件中allow_hosts=),还要一个设置密码的选项,可以不填。如果设置密码,在服务端监控时,要加一个-p参数。然后造势要安装的模块,NT,NRPE...一共5个,全选上就行了。最后安装成功。
3.配置:配置文件在C:\Program Files\NSClient++下,有个NSC.ini
...
allowed_hosts=192.168.2.150,127.0.0.1
...
port=12489
...
主要是两个选项,端口默认为12489
4.此时查看端口情况:
C:\Documents and Settings\Administrator>netstat -an
Active Connections
  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:21             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:25             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:443            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:1025           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3389           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:4899           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:12489          0.0.0.0:0              LISTENING
......
可以看在12489端口处于监听状态。
 
5.控制NSClient的启动,关闭,与重启:
如果修改了配置文件,NSClient要进行重启,在运行中输入services.msc打开服务管理器,找到NSClient服务器可
控制。
 
一.设置服务器端
1.服务器端check_nt默认是安装好的,在安装nagios-plugins时已经安装好了。
2.测试使用:
 /usr/local/nagios/libexec/check_nt -H 192.168.2.80 -p 12489 -v CLIENTVERSION
NSClient++ 0.3.8.75 2010-05-27   查看windows机器上安装的nsclient的版本。
[root@localhost etc]# /usr/local/nagios/libexec/check_nt -H 192.168.2.80 -p 12489 -v USEDDISKSPACE 
-l c -w 80 -c 90
c:\ - total: 29.29 Gb - used: 3.08 Gb (11%) - free 26.21 Gb (89%) | 'c:\ Used
Space'=3.08Gb;23.43;26.36;0.00;29.29 查看C盘空间,l后面跟c,如果是d盘,则为d
[root@localhost etc]# /usr/local/nagios/libexec/check_nt -H 192.168.2.80 -p 12489 -v UPTIME
System Uptime - 9 day(s) 21 hour(s) 50 minute(s)
[root@localhost etc]# /usr/local/nagios/libexec/check_nt -H 192.168.2.80 -p 12489 -v CPULOAD -l
5,80,90
CPU Load 50% (5 min average) |   '5 min avg Load'=50%;80;90;0;100  查看CPU负载,5分钟内,超过80%报
warning,超过90%报critical
[root@localhost etc]# /usr/local/nagios/libexec/check_nt -H 192.168.2.80 -p 12489 -v MEMUSE -l
5,80,90
Memory usage: total:2440.57 Mb - used: 477.65 Mb (20%) - free: 1962.92 Mb (80%) | 'Memory
usage'=477.65Mb;0.00;0.00;0.00;2440.57

3.写入nagios的配置文件
[root@localhost etc]# cat hosts.cfg
#其他主机的省略了
define host {
host_name               windows  
alias                   windows
address                 192.168.2.80    
contact_groups          sagroup         
check_command           check-host-alive 
max_check_attempts      5                
notification_interval   10              
notification_period     24x7             
notification_options    d,u,r        
}
[root@localhost etc]# cat hostgroups.cfg
define hostgroup {
hostgroup_name  sa-servers
alias           sa servers
members         nagios-server,windows
}

[root@localhost etc]# cat services.cfg
#####windows########
 
define service {
host_name               windows
service_description     C:\
check_period            24x7
max_check_attempts      1
normal_check_interval   1
retry_check_interval    2
contact_groups          sagroup
notification_interval   10
notification_period     24x7
notification_options    w,u,c,r
check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
 
下面是其他的监控命令:
1)监控windows服务器运行的时间
check_command           check_nt!UPTIME
2)监控Windows服务器的CPU负载,如果5分钟超过80%则是warning,如果5分钟超过90%则是critical
check_command           check_nt!CPULOAD!-l 5,80,90
3)监控Windows服务器的内存使用情况,如果超过了80%则是warning,如果超过90%则是critical.
check_command           check_nt!MEMUSE!-w 80 -c 90
4)监控Windows服务器C:\盘的使用情况,如果超过80%已经使用则是warning,超过90%则是critical
check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c 90
注:-l后面接的参数用来指定盘符
5)监控Windows服务器D:\盘的使用情况,如果超过80%已经使用则是warning,超过90%则是critical
check_command           check_nt!USEDDISKSPACE!-l d -w 80 -c 90
6)监控Windows服务器的W3SVC服务的状态,如果服务停止了,则是critical
check_command           check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
7)监控Windows服务器的Explorer.exe进程的状态,如果进程停止了,则是critical
check_command           check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
阅读(1298) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~