`
qjoycn
  • 浏览: 1217445 次
文章分类
社区版块
存档分类
最新评论

How To Monitor Remote Windows Machine Using Nagios on Linux

 
阅读更多

Inthisarticle,l’llexplainhowtomonitorremotewindowsmachineandthevariousservicerunningonthewindowsserverusingnagiosmonitoringserver.Followingthreesectionsarecoveredinthisarticle.

I.Overview
II.4stepstoinstallnagiosonremotewindowshost

1InstallNSClient++ontheremotewindowsserver

2ModifytheNSClient++Service

3ModifytheNSC.ini

4StarttheNSClient++Service

III.6configurationstepsonnagiosmonitoringserver

5Verifycheck_ntcommandandwindows-servertemplate

6Uncommentwindows.cfgin/usr/local/nagios/etc/nagios.cfg

7Modify/usr/local/nagios/etc/objects/windows.cfg

8Definewindowsservicesthatshouldbemonitored.

9EnablePasswordProtection

10VerifyConfigurationandRestartNagios.

I.Overview

.
FollowingthreestepswillhappenonaveryhighlevelwhenNagios(installedonthenagios-server)monitorsaservice(fore.g.diskspaceusage)ontheremoteWindowshost.

11Nagioswillexecutecheck_ntcommandonnagios-serverandrequestittomonitordiskusageonremotewindowshost.

12Thecheck_ntonthenagios-serverwillcontacttheNSClient++serviceonremotewindowshostandrequestittoexecutetheUSEDDISKSPACEontheremotehost.

13TheresultsoftheUSEDDISKSPACEcommandwillbereturnedbackbyNSClient++daemontothecheck_ntonnagios-server.


Followingflowsummarizestheaboveexplanation:

NagiosServer(check_nt)—–>Remotehost(NSClient++)—–>USEDDISKSPACE
NagiosServer(check_nt)<—–Remotehost(NSClient++)<—–USEDDISKSPACE(returnsdiskspaceusage)

II.4stepstosetupnagiosonremotewindowshost

.

1.InstallNSClient++ontheremotewindowsserver

DownloadNSCP0.3.1(NSClient++-Win32-0.3.1.msi)fromNSClient++Project.NSClient++isanopensourcewindowsservicethatallowsperformancemetricstobegatheredbyNagiosforwindowsservices.GothroughthefollowingfiveNSClient++installationstepstogettheinstallationcompleted.

(1)NSClient++WelcomeScreen

(2)LicenseAgreementScreen

(3)SelectInstallationoptionandlocation.Usethedefaultoptionandclicknext.



(4)ReadytoInstallScreen.ClickonInstalltogetitstarted.

(5)InstallationcompletedScreen.

2.ModifytheNSClient++Service

GotoControlPanel->AdministrativeTools->Services.Doubleclickonthe“NSClientpp(Nagios)0.3.1.142008-03-12w32″serviceandselectthecheck-boxthatsays“Allowservicetointeractwithdesktop”asshownbelow.

3.ModifytheNSC.ini

(1)ModifyNSC.inianduncomment*.dll:EdittheC:/ProgramFiles/NSClient++/NSC.inifileanduncommenteverythingunder[modules]exceptRemoteConfiguration.dllandCheckWMI.dll

[modules]

;#NSCLIENT++MODULES

;#AlistwithDLLstoloadatstartup.

;YouwillneedtoenablesomeoftheseforNSClient++towork.

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

;**

;*NOTICE!!!-YOUHAVETOEDITTHIS*

;**

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

FileLogger.dll

CheckSystem.dll

CheckDisk.dll

NSClientListener.dll

NRPEListener.dll

SysTray.dll

CheckEventLog.dll

CheckHelpers.dll

;CheckWMI.dll

;

;RemoteConfigurationISANEXTREMEARLYIDEASODONTUSEFORPRODUCTIONENVIROMNEMTS!

;RemoteConfiguration.dll

;NSCAAgentisanewbetamoduleusewithcare!

NSCAAgent.dll

;LUAscriptmoduleusedtowriteyourown"checkdeamon"(sortof)earlybeta.

LUAScript.dll

;Scripttocheckexternalscriptsand/orinternalaliases,earlybeta.

CheckExternalScripts.dll

;CheckotherhoststhroughNRPEextremebetaandprobablyabitdangerous!

NRPEClient.dll


(2)ModifyNSC.inianduncommentallowed_hosts.EdittheC:/ProgramFiles/NSClient++/NSC.inifileandUncommentallowed_hostundersettingsandaddtheip-addressofthenagios-server.

;#ALLOWEDHOSTADDRESSES

;Thisisacomma-delimitedlistofIPaddressofhoststhatareallowedtotalktothealldaemons.

;Ifleavethisblankanyonecanaccessthedeamonremotly(NSClientstillrequiresavalidpassword).

;Thesyntaxishostorip/maskso192.168.0.0/24willallowanyoneonthatsubnetaccess

allowed_hosts=192.168.1.2/255.255.255.0

Note:allowed_hostislocatedunder[Settings],[NSClient]and[NRPE]section.Makesuretochangeallowed_hostunder[Settings]forthispurpose.

(3)ModifyNSC.inianduncommentport.EdittheC:/ProgramFiles/NSClient++/NSC.inifileanduncommenttheport#under[NSClient]section

;#NSCLIENTPORTNUMBER

;ThisistheporttheNSClientListener.dllwilllistento.

port=12489


(4)ModifyNSC.iniandspecifypassword.YoucanalsospecifyapasswordthenagiosserverneedstousetoremotelyaccesstheNSClient++agent.

[Settings]

;#OBFUSCATEDPASSWORD

;Thisisthesameasthepasswordoptionbuthereyoucanstorethepasswordinanobfuscatedmanner.

;*NOTICE*obfuscationis*NOT*thesameasencryption,someonewithaccesstothisfilecanstillfigureoutthe

;password.Itsjustabithardertodoitatfirstglance.

;obfuscated_password=Jw0KAUUdXlAAUwASDAAB

;

;#PASSWORD

;Thisisthepassword(-s)thatisrequiredtoaccessNSClientremotely.Ifyouleavethisblankeveryonewillbeabletoaccessthedaemonremotly.

password=My2Secure$Password

4.StarttheNSClient++Service

StarttheNSClient++serviceeitherfromtheControlPanel->Administrativetools->Services->Select“NSClientpp(Nagios)0.3.1.142008-03-12w32″andclickonstart(or)Clickon“Start->AllPrograms->NSClient++->StartNSClient++(Win32).PleasenotethatthiswillstarttheNSClient++asawindowsservice.

LaterifyoumodifyanythingintheNSC.inifile,youshouldrestartthe“NSClientpp(Nagios)0.3.1.142008-03-12w32″fromthewindowsservice.

III.6configurationstepsonnagiosmonitoringserver

.

1.Verifycheck_ntcommandandwindows-servertemplate

Verifythatthecheck_ntisenabledunder/usr/local/nagios/etc/objects/commands.cfg

#'check_nt'commanddefinition

definecommand{

command_namecheck_nt

command_line$USER1$/check_nt-H$HOSTADDRESS$-p12489-v$ARG1$$ARG2$

}


Verifythatthewindows-servertemplateisenabledunder/usr/local/nagios/etc/objects/templates.cfg

#Windowshostdefinitiontemplate-ThisisNOTarealhost,justatemplate!

definehost{

namewindows-server;Thenameofthishosttemplate

usegeneric-host;Inheritdefaultvaluesfromthegeneric-hosttemplate

check_period24x7;Bydefault,Windowsserversaremonitoredroundtheclock

check_interval5;Activelychecktheserverevery5minutes

retry_interval1;Schedulehostcheckretriesat1minuteintervals

max_check_attempts10;Checkeachserver10times(max)

check_commandcheck-host-alive;Defaultcommandtocheckifserversare"alive"

notification_period24x7;Sendnotificationoutatanytime-dayornight

notification_interval30;Resendnotificationsevery30minutes

notification_optionsd,r;Onlysendnotificationsforspecifichoststates

contact_groupsadmins;Notificationsgetsenttotheadminsbydefault

hostgroupswindows-servers;HostgroupsthatWindowsserversshouldbeamemberof

register0;DONTREGISTERTHIS-ITSJUSTATEMPLATE

}

2.Uncommentwindows.cfgin/usr/local/nagios/etc/nagios.cfg

#DefinitionsformonitoringaWindowsmachine

cfg_file=/usr/local/nagios/etc/objects/windows.cfg

3.Modify/usr/local/nagios/etc/objects/windows.cfg

Bydefaultasamplehostdefinitionforawindowsserverisgivenunderwindows.cfg,modifythistoreflecttheappropriatewindowsserverthatneedstobemonitoredthroughnagios.

#DefineahostfortheWindowsmachinewe'llbemonitoring

#Changethehost_name,alias,andaddresstofityoursituation

definehost{

usewindows-server;Inheritdefaultvaluesfromatemplate

host_nameremote-windows-host;Thenamewe'regivingtothishost

aliasRemoteWindowsHost;Alongernameassociatedwiththehost

address192.168.1.4;IPaddressoftheremotewindowshost

}

4.Definewindowsservicesthatshouldbemonitored.

Followingarethedefaultwindowsservicesthatarealreadyenabledinthesamplewindows.cfg.Makesuretoupdatethehost_nameontheseservicestoreflectthehost_namedefinedintheabovestep.

defineservice{

usegeneric-service

host_nameremote-windows-host

service_descriptionNSClient++Version

check_commandcheck_nt!CLIENTVERSION

}

defineservice{

usegeneric-service

host_nameremote-windows-host

service_descriptionUptime

check_commandcheck_nt!UPTIME

}

defineservice{

usegeneric-service

host_nameremote-windows-host

service_descriptionCPULoad

check_commandcheck_nt!CPULOAD!-l5,80,90

}

defineservice{

usegeneric-service

host_nameremote-windows-host

service_descriptionMemoryUsage

check_commandcheck_nt!MEMUSE!-w80-c90

}

defineservice{

usegeneric-service

host_nameremote-windows-host

service_descriptionC:/DriveSpace

check_commandcheck_nt!USEDDISKSPACE!-lc-w80-c90

}

defineservice{

usegeneric-service

host_nameremote-windows-host

service_descriptionW3SVC

check_commandcheck_nt!SERVICESTATE!-dSHOWALL-lW3SVC

}

defineservice{

usegeneric-service

host_nameremote-windows-host

service_descriptionExplorer

check_commandcheck_nt!PROCSTATE!-dSHOWALL-lExplorer.exe

}

5.EnablePasswordProtection

IfyouspecifiedapasswordintheNSC.inifileoftheNSClient++configurationfileontheWindowsmachine,you’llneedtomodifythecheck_ntcommanddefinitiontoincludethepassword.Modifythe/usr/local/nagios/etc/commands.cfgfileandaddpasswordasshownbelow.

definecommand{

command_namecheck_nt

command_line$USER1$/check_nt-H$HOSTADDRESS$-p12489-sMy2Secure$Password-v$ARG1$$ARG2$

}

6.VerifyConfigurationandRestartNagios.

Verifythenagiosconfigurationfilesasshownbelow.

[nagios-server]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg

TotalWarnings:0

TotalErrors:0

Thingslookokay-Noseriousproblemsweredetectedduringthepre-flightcheck


Restartnagiosasshownbelow.

[nagios-server]#/etc/rc.d/init.d/nagiosstop

Stoppingnagios:.done.

[nagios-server]#/etc/rc.d/init.d/nagiosstart

Startingnagios:done.


VerifythestatusofthevariousservicesrunningontheremotewindowshostfromtheNagioswebUI(http://nagios-server/nagios)asshownbelow.

<!--EndFragment-->
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics