首页 > 服务器 > Win服务器 > 正文

怎么用Nagios监测Windows服务器?

2024-09-10 00:01:47
字体:
来源:转载
供稿:网友
  监控主机配置:redhatlinuxas4,nagios3
  被监控主机:WindowsServer2008R2Enterprise,nsclient++0.4.4.172
  Nagios是一款开源的免费网络监视工具,其功能强大,灵活性强。能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。nagios监控windows系统有三种实现方式:SNMP、NSClient++、NRPE。
  下面介绍使用NSClient++方式来监控Windows:
在windows下安装nsclient++,运行NSCP-0.4.0.172-x64.msi安装文件,一步一步往下走,其中需要设置nagios监控主机IP和NSClient密码(值当使用check_nt时使用)。
Allowed hosts:填写nagios监控主机IP。
NSClient Password:当使用命令check_nt时需要设置密码,根据自己情况设置。
Module to load:根据自己的需要选择相应的模块。
安装完毕以后,打开windows服务管理器,查看nsclient服务是否启动,然后在nagios监控主机上面进行相关的配置,主要涉及两个配置文件nagios.cfg和windows.cfg。
1、 因为nagios是模块化调用,先到配置文件打开windows相关模块,编辑nagios.cfg文件:
  [root@localhostetc]#ls
  cgi.cfghtpasswdnagios.cfgnrpe.cfgobjectsobjects.bakobjects.tarresource.cfg
  [root@localhostetc]#pwd
  /usr/local/nagios/etc
  [root@localhostetc]#vinagios.cfg
  将#cfg_file=/usr/local/nagios/etc/objects/windows.cfg该行前面的#注释去掉即可。
 
2、修改windows.cfg配置文件,需要修改define host和define service两部分:
  #DefineahostfortheWindowsmachinewe'llbemonitoring
  #Changethehost_name,alias,andaddresstofityoursituation
  definehost
  {usewindows-server;Inheritdefaultvaluesfromatemplate
  host_namevideo4-beijing;Thenamewe'regivingtothishost被监控主机的主机名
  aliasvideo4-beijing;Alongernameassociatedwiththehost
  contact_groupssa;
  address10.12.4.169;IPaddressofthehost被监控主机的IP}
  #CreateaserviceformonitoringCPUload
  #Changethehost_nametomatchthenameofthehostyoudefinedabove
  defineservice
  {usegeneric-service
  host_namevideo4-beijing
  service_descriptionCPULoad
  check_commandcheck_nt!CPULOAD!-l5,80,90
  contact_groupssa}
  #Createaserviceformonitoring
  #Changethehost_nametomatchthenameofthehostyoudefinedabove
  defineservice
  {usegeneric-service
  host_namevideo4-beijing
  service_descriptionMemoryUsage
  check_commandcheck_nt!MEMUSE!-w80-c90
  contact_groupssa}
  #CreateaserviceformonitoringC:/diskusage
  #Changethehost_nametomatchthenameofthehostyoudefinedabove
  defineservice
  {usegeneric-service
  host_namevideo4-beijing
  service_descriptionC:/DriveSpace
  check_commandcheck_nt!USEDDISKSPACE!-lc-w80-c90
  contact_groupssa}
 
3、修改完相关的配置文件以后,执行如下命令检查配置文件是否正确:
  [root@localhostobjects]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg
 
4、遇到的问题,在检查配置文件时错误信息如下:
  Checkingservices...
  Error:Contactgroup'admins'specifiedinservice'C:/DriveSpace'forhost'video4-beijing'isnotdefinedanywhere!
  Error:Contactgroup'admins'specifiedinservice'Explorer'forhost'video4-beijing'isnotdefinedanywhere!
  Error:Contactgroup'admins'specifiedinservice'MemoryUsage'forhost'video4-beijing'isnotdefinedanywhere!
  Checked14services.
  Checkinghosts...
  Error:Contactgroup'admins'specifiedinhost'video4-beijing'isnotdefinedanywhere!
  Checked7hosts.
  Checkinghostgroups...
  Checked2hostgroups.
  Checkingservicegroups...
  Checked0servicegroups.
  Checkingcontacts...
  Checked1contacts.
  Checkingcontactgroups...
  Checked1contactgroups.
  Checkingserviceescalations...
  Checked0serviceescalations.
  Checkingservicedependencies...
  Checked0servicedependencies.
  Checkinghostescalations...
  Checked0hostescalations.
  Checkinghostdependencies...
  Checked0hostdependencies.
  Checkingcommands...
  Checked25commands.
  Checkingtimeperiods...
  Checked5timeperiods.
  Checkingforcircularpathsbetweenhosts...
  Checkingforcircularhostandservicedependencies...
  Checkingglobaleventhandlers...
  Checkingobsessivecompulsiveprocessorcommands...
  Checkingmiscsettings...
  TotalWarnings:0
  TotalErrors:4
  ***>Oneormoreproblemswasencounteredwhilerunningthepre-flightcheck...
  Checkyourconfigurationfile(s)toensurethattheycontainvalid
  directivesanddatadefintions.Ifyouareupgradingfromaprevious
  versionofNagios,youshouldbeawarethatsomevariables/definitions
  mayhavebeenremovedormodifiedinthisversion.Makesuretoread
  theHTMLdocumentationregardingtheconfigfiles,aswellasthe
  'WhatsNew'sectiontofindoutwhathaschanged.
  以上问题的原因是因为一开始在windows.cfg文件中定义host和service时没有增加contact_groupssa这个字段,host和service默认所在的contact_group为admins,而我的nagios监控主机contacts.cfg文件中配置的contactgroup为sa。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表