Zoeken op website

Hoe Windows Host toe te voegen aan Nagios Monitoring Server


In dit artikel wordt beschreven hoe u 'privé'-services van Windows-machines kunt controleren, zoals CPU-belasting, Schijfgebruik, Geheugengebruik, Services, etc. Hiervoor moesten we een NSClient++ add-on installeren op de Windows machine. De add-on fungeert als proxy tussen de Windows machine en Nagios en controleert de daadwerkelijke services door te communiceren met de check_nt plug-in. De plug-in check_nt is al geïnstalleerd op de Nagios Monitoring Server, als u onze Nagios installatiehandleiding hebt gevolgd.

We gaan ervan uit dat u de Nagios-server al hebt geïnstalleerd en geconfigureerd volgens onze volgende handleidingen.

  1. Hoe Nagios 4.0.1 op RHEL/CentOS 6.x/5.x en Fedora 18/19/17 te installeren
  2. Voeg Linux-host toe aan Nagios Monitoring Server

Om Windows-machines te monitoren, moet u verschillende stappen volgen:

  1. Installeer NSClient++ add-on op de Windows-machine.
  2. Configureer Nagios Server voor het monitoren van Windows Machine.
  3. Voeg nieuwe host- en servicedefinities toe voor Windows-machinemonitoring.
  4. Start de Nagios-service opnieuw.

Om deze handleiding eenvoudiger en eenvoudiger te maken, zijn een aantal configuraties al voor u uitgevoerd tijdens de Nagios installatie.

  1. Er is al een check_nt commandodefinitie toegevoegd aan het command.cfg bestand. Dit definitiecommando wordt gebruikt door de check_nt plug-in om Windows-services te controleren.
  2. Een host-sjabloon voor Windows-server die al is gemaakt in het bestand templates.cfg. Met deze sjabloon kunt u nieuwe Windows-hostdefinities toevoegen.

De bovenstaande twee bestanden “command.cfg” en “templates.cfg” zijn te vinden op /usr/local/nagios/etc/objects/ map. U kunt uw eigen definities wijzigen en toevoegen die aan uw vereisten voldoen. Maar ik raad u aan de instructies te volgen die in dit artikel worden beschreven, zodat u uw Windows-host in minder dan 20 minuten succesvol kunt monitoren.

Stap 1: NSClient++ Agent installeren op een Windows-machine

Gebruik de onderstaande instructies om NSClient++ Agent op de Remote Windows Host te installeren. Download eerst de nieuwste stabiele versie NSClient++ 0.3.1 add-onbronbestanden, die u kunt vinden via onderstaande link.

  1. http://sourceforge.net/projects/nscplus/

Zodra u de laatste stabiele versie heeft gedownload, pakt u de NSClient++ bestanden uit in een nieuwe C:\NSClient++ map.

Open nu een MS-DOS opdrachtprompt vanuit het Startscherm –> Uitvoeren –> typ 'cmd' en druk op enter en ga naar de map C:\NSClient++.

C:\NSClient++

Registreer vervolgens de service NSClient++ op het systeem met de volgende opdracht.

nsclient++ /install

Installeer ten slotte het NSClient++ systray met de volgende opdracht.

nsclient++ SysTray

Open Windows Services Manager en klik met de rechtermuisknop op NSClient, ga naar Eigenschappen en vervolgens op het tabblad 'Aanmelden' en klik op het selectievakje met de tekst 'Sta toe dat de service communiceert met het bureaublad'. Als dit nog niet is toegestaan, vink dan het vakje aan om dit toe te staan.

Open het NSC.INI bestand in de map C:\NSClient++ en verwijder de commentaartekens voor alle modules die zijn gedefinieerd in de sectie “modules”, behalve voor CheckWMI.dll en RemoteConfiguration.dll.

[modules]
;# NSCLIENT++ MODULES
;# A list with DLLs to load at startup.
;  You will need to enable some of these for NSClient++ to work.
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
; *                                                               *
; * N O T I C E ! ! ! - Y O U   H A V E   T O   E D I T   T H I S *
; *                                                               *
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
;CheckWMI.dll
;
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!
;RemoteConfiguration.dll
; NSCA Agent is a new beta module use with care!
;NSCAAgent.dll
; LUA script module used to write your own "check deamon" (sort of) early beta.
;LUAScript.dll
; Script to check external scripts and/or internal aliases, early beta.
;CheckExternalScripts.dll
; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)
;NRPEClient.dll

Verwijder de opmerkingen bij “allowed_hosts” in het gedeelte “Instellingen” en definieer het IP-adres van uw Nagios Monitoring Server of laat het leeg zodat eventuele hosts verbinding kunnen maken.

[Settings]
;# ALLOWED HOST ADDRESSES
;  This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons.
;  If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password).
;  The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access
allowed_hosts=172.16.27.41

Verwijder de opmerkingen bij ‘poort’ in het gedeelte ‘NSClient’ en stel de standaardpoort ‘12489‘ in. Zorg ervoor dat u de ‘12489’-poort op Windows Firewall opent.

[NSClient]
;# NSCLIENT PORT NUMBER
;  This is the port the NSClientListener.dll will listen to.
port=12489

Start ten slotte de NSClient++ service met het volgende commando.

nsclient++ /start

Als het correct is geïnstalleerd en geconfigureerd, zou u een nieuw pictogram in het systeemvak moeten zien in een gele cirkel met een zwarte 'M' erin.

Stap 2: Nagios Server configureren en Windows-hosts toevoegen

Log nu in op Nagios Server en voeg enkele objectdefinities toe aan Nagios configuratiebestanden om de nieuwe Windows machine te monitoren. Open het windows.cfg-bestand om het te bewerken met de Vi-editor.

[root@tecmint]# vi /usr/local/nagios/etc/objects/windows.cfg

Een voorbeeld van een Windows-hostdefinitie die al is gedefinieerd voor de Windows-machine. U kunt eenvoudig de hostdefinitie, zoals de velden host_name, alias en adres wijzigen in de juiste velden waarden van uw Windows-machine.

###############################################################################
###############################################################################
#
HOST DEFINITIONS
#
###############################################################################
###############################################################################

Define a host for the Windows machine we'll be monitoring
Change the host_name, alias, and address to fit your situation

define host{
        use             windows-server  ; Inherit default values from a template
        host_name       winserver       ; The name we're giving to this host
        alias           My Windows Server       ; A longer name associated with the host
        address         172.31.41.53    ; IP address of the host
        }

De volgende services zijn al toegevoegd en ingeschakeld in het bestand windows.cfg. Als u nog meer servicedefinities wilt toevoegen die moeten worden gemonitord, kunt u deze definities eenvoudig aan hetzelfde configuratiebestand toevoegen. Zorg ervoor dat u de host_name wijzigt voor alle services waarbij host_name is gedefinieerd in de bovenstaande stap.

define service{
	use			generic-service
	host_name		winserver
	service_description	NSClient++ Version
	check_command		check_nt!CLIENTVERSION
	}

Add the following service definition to monitor the uptime of the Windows server.

define service{
	use			generic-service
	host_name		winserver
	service_description	Uptime
	check_command		check_nt!UPTIME
	}

Add the following service definition to monitor the CPU utilization on the Windows server and generate a CRITICAL alert if the 5-minute CPU load is 90% or more or a WARNING alert if the 5-minute load is 80% or greater.

define service{
	use			generic-service
	host_name		winserver
	service_description	CPU Load
	check_command		check_nt!CPULOAD!-l 5,80,90
	}

Add the following service definition to monitor memory usage on the Windows server and generate a CRITICAL alert if memory usage is 90% or more or a WARNING alert if memory usage is 80% or greater.

define service{
	use			generic-service
	host_name		winserver
	service_description	Memory Usage
	check_command		check_nt!MEMUSE!-w 80 -c 90
	}

Add the following service definition to monitor usage of the C:\ drive on the Windows server and generate a CRITICAL alert if disk usage is 90% or more or a WARNING alert if disk usage is 80% or greater.

define service{
	use			generic-service
	host_name		winserver
	service_description	C:\ Drive Space
	check_command		check_nt!USEDDISKSPACE!-l c -w 80 -c 90
	}

Add the following service definition to monitor the W3SVC service state on the Windows machine and generate a CRITICAL alert if the service is stopped.

define service{
	use			generic-service
	host_name		winserver
	service_description	W3SVC
	check_command		check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
	}

Add the following service definition to monitor the Explorer.exe process on the Windows machine and generate a CRITICAL alert if the process is not running.

define service{
	use			generic-service
	host_name		winserver
	service_description	Explorer
	check_command		check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
	}

Verwijder ten slotte de commentaartekens voor het bestand windows.cfg in /usr/local/nagios/etc/nagios.cfg.

[root@tecmint]# vi /usr/local/nagios/etc/nagios.cfg
Definitions for monitoring a Windows machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg

Controleer ten slotte de Nagios-configuratiebestanden op eventuele fouten.

[root@tecmint]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

Als het verificatieproces foutmeldingen genereert, repareert u deze fouten totdat het verificatieproces zonder foutmeldingen is voltooid. Zodra u deze fouten heeft verholpen, start u de Nagios-service opnieuw.

[root@tecmint]# service nagios restart

Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.

Dat is het. Ga nu naar de Nagios Monitoring-webinterface op “http://Uw-server-IP-adres/nagios” of “http://FQDN/nagios” en geef de gebruikersnaam “nagiosadmin ” en wachtwoord. Controleer of de Remote Windows Host is toegevoegd en wordt gecontroleerd.

Dat is het! voorlopig laat ik je in mijn komende artikel zien hoe je Printer en Switches toevoegt aan Nagios Monitoring Server. Als u problemen ondervindt bij het toevoegen van Windows host aan Nagios. Geef alstublieft commentaar op uw vragen via de commentaarsectie. Blijf tot die tijd linux-console.net in de gaten houden voor meer van dit soort waardevolle artikelen.


Alle rechten voorbehouden. © Linux-Console.net • 2019-2024