Posts mit dem Label Icinga werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Icinga werden angezeigt. Alle Posts anzeigen

Dienstag, 7. Oktober 2014

Ubuntu 12.04: Probleme bei der Nutzung von check_vmware_api.pl / check_vmware_esx

Wenn es um die Überwachung von ESX-Servern geht, haben sich zwei Plugins bei mir bewährt.

Auf die Installation des Plugins gehe ich jetzt nicht weiter ein, sondern mehr auf meine Fallstricke/Optimierungen

1. Nutzung der Umgebungsvariablen http_proxy / https_proxy


Falls die Umgebungsvariablen http(s)_proxy gesetzt sind, wird der Abruf der Daten über den Proxyserver erfolgen (falls keine Ausnahmen deklariert wurden), umgehen kann man dieses, indem man die Skripte um folgende Zeilen erweitert:

Erweiterung der Plugins um folgende Zeilen (z.B. auf Höhe der Variablen-Deklaration)

  # reset proxy
  $ENV{http_proxy} = "";
  $ENV{https_proxy} = "";

Streng genommen würde https_proxy reichen, da die Requests über SSL erfolgen.

2. Timeouts beim Abruf mit Ubuntu 12.04



Da scheinbar das vSphere SDK nicht mit den aktuellen libwww-perl Modulen zurecht kommen, muss eine ältere Version installiert werden:


cpan[1]> i /libwww-perl/
Going to read '/root/.cpan/Metadata'
  Database was generated on Mon, 06 Oct 2014 13:17:02 GMT
Distribution    GAAS/libwww-perl-5.837.tar.gz
Distribution    MSCHILLI/libwww-perl-6.08.tar.gz
Author          LWWWP ("The libwww-perl mailing list" <libwww@perl.org>)
3 items found

cpan[2]> install GAAS/libwww-perl-5.837.tar.gz

Anschließend klappt der Abruf der Daten.

3. Ablegen der Session Files in ein TMPFS


Um die Performance zu steigern empfiehlt es sich eine RAM-Disk als Plugin Cache anzulegen, dazu erstellt man folgenden Eintrag in der /etc/fstab

# nagios plugins
tmpfs           /var/cache/nagios_plugin     tmpfs   nodev,nosuid,noexec,nodiratime,size=512M        0 0

Der Parameter "size" muss natürlich angepasst werden, möglich sind dort die Kombinationen 
  • % - z.B. 10% des zur Verfügung stehenden RAMs
  • k,m,g - Angabe in Kilobyte,Megabyte oder Gigabyte

Achtung: wenn die RAM-Disk zu groß angelegt wird, kann es zu Problemen mit dem System kommen, daher vorher mit "free -m" überprüfen.

Anschließend wird der mount point erstellt und die Zugriffsrechte für den Nagios/Icinga User gesetzt:

$ mkdir /var/cache/nagios_plugin
$ chown nagios:nagios $_

Kleine Randnotiz: innerhalb der bash enthält die Variable "$_" das letzte Argument des zuletzt ausgeführten Befehls.

Nun soll die RAM-Disk gemountet werden:
$ mount /var/cache/nagios_plugn

Im Plugin muss nun noch die Variable plugin_cache angepasst werden:
$ sed -i 's/plugin_cache=.*/plugin_cache="\/var\/cache\/nagios_plugin\/";/g' /usr/lib/nagios/plugins/check_vmware_esx

Dabei muss noch der Pfad des Plugins entsprechend angepasst werden.

Donnerstag, 28. August 2014

Nagios: NetApp Plugin check_netapp_sdk.pl

Written in Perl, using NetApp Manageability SDK


Functions
  • check-volume
  • check-lun
  • check-snapmirror
  • check-aggr
  • check-cluster
  • check-shelf
  • check-license

Dependencies:
- NetApp 7-Mode
- Nagios::Plugins (Perl)
- NetApp Manageability SDK (Perl)
- At line 24 adjust your lib path:
use lib "/usr/lib/perl5/site_perl/5.8.8/NetApp";
- Warning/Critical defaults to 85/95%


check-volume [-n VOLUME_NAME] - List volumes use -n to specify volume
-> size in percent (-w/-c)
check-lun [-n LUN_NAME] - List LUNs, use -n to specify lun
-> size in percent (-w/-c)
-> misalignment results to warning
-> offline state and is mapped results to critical
check-snapmirror [-n SNAPMIRROR_NAME] - List snapmirrors, use -n to specify snapmirror
-> lag_time in seconds (-w/-c)
-> transfer error -> CRITICAL
check-aggr [-n AGGREGATE_NAME] - List aggregates, use -n to specify lun
-> size in percent (-w/-c)
-> mount state: warning on creating, mounting, unmounting, quiescing; ok on online consistent quiesced; critical for the rest!
-> mirror state: warning on 'CP count check in progress'; ok on mirrored, unmirrored; critical for the rest!
-> raid state: warning on resyncing, copying, growing, reconstruct; ok on normal, mirrored; critical for the rest
-> inconsistency results on critical
check-cluster - checks for cluster state
-> warning/critical on other state than connected
-> warning on inactive hwassist (if available)
-> interconnect state
check-shelf
-> critical on failed power-supply
-> critical on failed voltage sensor
-> critical on failed temp sensor
-> temperature (values provided by netapp, is needed due to different sensor locations)
-> shelf state : warning on informational, non_critical; ok on normal; critical for the rest!
check-license - checks license
-> expiry date (excludes demo, auto_enabled and non expiry lics)

Sample Output:


$ check_netapp_sdk.pl -H snapmirror1 -U $USER1$ -P $USER2$ -S -C check-snapmirror -w 43200 -c 86400
CRITICAL - 1 failed snapmirror found: C->netapp1->snapmirror1: nfs_ds2_snapmirror: Lag-time: 10.2 days Error: - | netapp1_snapmirror1_nfs_ds2_snapmirror_xfer_size=36609B;; netapp1_snapmirror1_nfs_ds2_snapmirror_lag_time=885023s;43200;86400

$ check_netapp_sdk.pl -H netapp1 -U $USER1$ -P $USER2$ -S -C check-cluster
OK - Cluster is fine! Partner netapp2 is connected

$ check_netapp_sdk.pl -H netapp1 -U $USER1$ -P $USER2$ -S -C check-lun -n /vol/lun_1_vol/lun_1
WARNING - 1 suspicious luns found: W->lun_1: 85.66% | lun_1_size_used=44911216B;44564480;47185920;;52428800 lun_1_size_pct=85.66%;85;9

$ check_netapp_sdk.pl -H netapp1 -U $USER1$ -P $USER2$ -S -C check-volume -n lun_1_vol
WARNING - 1 suspicious volumes found: W->lun_1_vol: 88.56% | lun_1_vol_size_used=52653680B;50537015;53509781;;59455312 lun_1_vol_size_pct=88.56%;85;9

$ check_netapp_sdk.pl -H netapp1 -U $USER1$ -P $USER2$ -S -C check-aggr
OK - 0 suspicious aggregate found | aggr_unmirrored_size_used=3161408134.68B;3274284218;3466889172;;3852099080 aggr_unmirrored_size_pct=82.07%;85;90 aggr0_size_used=10676546580.44B;11114697879;11768503637;;13076115152 aggr0_size_pct=81.65%;85;90

$ check_netapp_sdk.pl -H netapp1 -U $USER1$ -P $USER2$ -S -C check-license
OK - 0/48 expired licenses found

$ check_netapp_sdk.pl -H netapp1 -U $USER1$ -P $USER2$ -S -C check-version
OK - System-Name: netapp1 System-ID: 123456789 Model: FAS3240 Serial: 123456789 Version: NetApp Release 8.1.2P4 7-Mode: Fri Apr 26 19:57:25 PDT 2013
 
 
 

Freitag, 1. August 2014

My github for monitoring plugins

Instead of using a local subversion, i moved my selfwritten monitoring plugins to github.

It's accessible through this link: https://github.com/riskersen/Monitoring


Feel free to contribute :-)

Donnerstag, 19. Juni 2014

Monitoring: Sophos SafeGuard Enterprise

Was ist Sophos SafeGuard Enterprise?

Sophos SafeGuard Enterprise ist eine Software-Lösung für Endpoint-Security, mit der man im wesentlichen eine managed Verschlüsselungslösung für Clients aufbauen kann.

Wesentliche Komponenten sind:
  • Zertifizierte Verschlüsselungstechnologien (FIPS, Common Criteria)
  • Hohe Verschlüsselungsstärke (AES 256 Bit)
  • Festplattenverschlüsselung
  • Verschlüsselung von Wechselmedien
  • Verschlüsselter Datenaustausch, ohne dass der Empfänger selber das Produkt installiert haben muss
  • Verschlüsselung für CloudStorage (Dropbox und co) mit Zugriffsmöglichkeiten auf mobile devices
  • Verschlüsselung für Netzwerk-Freigaben
  • Unterstützung von BitLocker, FileVault etc
  • Token-basierte Authentifizierung
  • OU-basierte Zuweisung von Richtlinien
  • Client-Unterstützung: Windows  XP - 8.1, MAC OSX 10.5 - 10.9
  • Datenbank-Unterstützung: SQL Server 2005 - 2012 SP1 (jeweils auch Express)
  • Management-Server: Windows Server 2003 - 2012 R2
  • Management-Konsole: Windows Server 2003 - 2012 R2, XP - 8.1
Die Installation des Clients kann bequem mittels einer Software-Verteilung erfolgen, die Kommunikation mit dem Server erfolgt dann bidirektional (z.B. Richtlinien abrufen, Zustand hochladen), über HTTP optional mit SSL-Verschlüsselung.




Die Überwachung von Sophos SafeGuard Enterprise gestaltet sich als relativ einfach, da Sophos bereits eine Web-Schnittstelle für die wichtigsten Komponenten bereitstellt:
  • WebService (wie bereits oben beschrieben, eine sehr kritische Komponente)
  • DBAuth: Zugriff auf die Datenbank
Da der Abruf der Informationen aus Sicherheitsgründen nur über Localhost gestattet ist und der Server/Management Center nur auf einem Windows Server installiert werden kann, konnte ich, ohne Interpreter-Installation auf dem Server, leider keine meiner bevorzugten Sprachen nutzen.
Daher habe ich das Plugin VBS geschrieben und bin dabei auf einen unschönen Bug in der Web-Schnittstelle gestoßen.

Die Informationen der Schnittstelle werden als XML abgerufen, allerdings werden die spitzen Klammern als HTML Steuerzeichen ausgegeben und können somit nicht direkt verarbeitet werden:

Falsches XML:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">&lt;Dataroot&gt;&lt;WebService&gt;OK&lt;/WebService&gt;
&lt;DBAuth&gt;OK&lt;/DBAuth&gt;
&lt;Info&gt;
&lt;Database&gt;SafeGuard&lt;/Database&gt;
   &lt;Server&gt;SGE1\SQLEXPRESS&lt;/Server&gt;
   &lt;Version&gt;11.00.3000&lt;/Version&gt;
   &lt;Name&gt;DBFactorySql on process: w3wp
Process ID: 33264&lt;/Name&gt;
   &lt;Owner&gt;[dbo]&lt;/Owner&gt;
   &lt;ConnectionInfo&gt;SQL Server credentials are used for authentication.&lt;/ConnectionInfo&gt;
&lt;/Info&gt;
&lt;/Dataroot&gt;</string>

Valides XML:
<?xml version="1.0"?>
<string xmlns="http://tempuri.org/"><Dataroot><WebService>OK</WebService>
<DBAuth>OK</DBAuth>
<Info>
<Database>SafeGuard</Database>
   <Server>SGE1\SQLEXPRESS</Server>
   <Version>11.00.3000</Version>
   <Name>DBFactorySql on process: w3wp
 Process ID: 49588</Name>
   <Owner>[dbo]</Owner>
   <ConnectionInfo>SQL Server credentials are used for authentication.</ConnectionInfo>
</Info>
</Dataroot></string>


Durch diesen Bug musste ich im Plugin ein Tempfile erstellen (%windir%/temp) und in diesem, das XML gerade biegen.

Dabei kommt dann folgendes raus:
' Author: Oliver Skibbe
' Date: 2014-06-18
' Required Variables
Const PROGNAME = "check_sge"
Const VERSION = "1.0.0"

' Nagios helper functions
nsclientDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
Include nsclientDir & "\lib\NagiosPlugins.vbs"

' Create the NagiosPlugin object
Set np = New NagiosPlugin
Set WshShell = WScript.CreateObject("WScript.Shell")
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
Set objFSO = CreateObject("Scripting.FileSystemObject") 

' fetch xml, per default "CheckConnection" is only available via localhost
Set oXMLHTTP = CreateObject("Msxml2.ServerXMLHTTP.3.0")
oXMLHTTP.SetOption 2, oXMLHTTP.GetOption(2) - SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
oXMLHTTP.Open "POST", "https://localhost/SGNSRV/Trans.asmx/CheckConnection", False
oXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXMLHTTP.Send ""

' Ugly, but we have to build a Tempfile, cause SafeGuard Enterprise does not provide a valid xml file
' Sophos Support: might be fixed in 6.20
' temporary file, 
strWinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
TEMPFILE = strWinDir & "\Temp\nagios_sge.xml"

' load fetched xml file
Set myFile = objFSO.CreateTextFile(TEMPFILE, True)
bodyStr = oXMLHTTP.responseXML.xml
' this is the magic, replace broken html stuff with real ">" & "<"
bodyXML = Replace(bodyStr, "<", "<")
bodyXML = Replace(bodyXML, ">", ">")
' save file
myFile.write(bodyXML)

' Website is responding and returns OK
If oXMLHTTP.Status = 200 Then 
 ' Parse XML
 xmlDoc.load(TEMPFILE)
 
 If isObject(xmlDoc) Then
  ' prepare output
  For Each x In xmlDoc.documentElement.selectNodes("//string/Dataroot")
   WebService = x.selectSingleNode("WebService").Text
   DBAuth = x.selectSingleNode("DBAuth").Text
   Info = "Database: " & x.selectSingleNode("Info/Database").Text
   Info = Info & vbcrlf & "DBServer: " & x.selectSingleNode("Info/Server").Text
   Info = Info & vbcrlf & "DBVersion: " & x.selectSingleNode("Info/Version").Text
   Info = Info & vbcrlf & "DBOwner: " & x.selectSingleNode("Info/Owner").Text
   Info = Info & vbcrlf & "DBConnectionInfo: " & x.selectSingleNode("Info/ConnectionInfo").Text
  Next
  
  If WebService = "OK" And DBAuth = "OK" Then
   return_code = OK
   return_msg = "Everything's fine!"
  Else
   return_code = CRITICAL
   return_msg = "Something happened!"
  End If ' end if webserver and dbauth
  ' prepare return msg
  return_msg = return_msg & " WebService: " & WebService & " DBAuth: " & DBAuth & vbcrlf & Info    
 Else
  ' XML not loaded
  return_code = CRITICAL
  return_msg = "XML could not be read"
 End If ' end if xml load
Else 
' Webservice reporting something other than 200 (OK)
 MsgBox("Error: " & oXMLHTTP.Status)
 return_code = CRITICAL
 return_msg = "Webservice answered something strange, http status: " & oXMLHTTP.Status
End If ' end if Webservice status 200 (OK)

' exit
np.nagios_exit return_msg, return_code

' helper for including nagios lib
Sub Include( cNameScript )
    Set oFS = CreateObject("Scripting.FileSystemObject")  
    Set oFile = oFS.OpenTextFile( cNameScript )
    ExecuteGlobal oFile.ReadAll()
    oFile.Close
End Sub
' EOF

Das Plugin wird kritisch, wenn entweder:
  • DBAuth und/oder WebService nicht "OK" sind
  • HTTP Status != 200
  • Fehler bei der XML Verarbeitung aufgetreten sind

Download: Nagios Exchange


Bei Fragen bitte einfach melden.

Freitag, 22. November 2013

Nagios: Überwachung eines ESX Clusters und Visualisierung

Wer einen ESX-Cluster im Hause hat, möchte sicherlich auch informiert werden, wenn dort etwas schief geht.

Dazu setze ich das Plugin check_esx3.pl von OP5 ein, dieses liefert, via Webschnittstelle, den Status für ein Datacenter, einzelne ESXi-Hosts oder virtuelle Maschinen.

Als Abhängigkeiten hat es folgende Perl Klassen: Nagios::Plugins, File::Basename und VMware::VIRuntime (muss separat über das Perl SDK von VMWare installiert werden: https://my.vmware.com/de/web/vmware/details?productId=285&downloadGroup=VSP510-SDKPERL-510 )

Überblick:

Usage: check_esx3.pl -D <data_center> | -H <host_name> [ -N <vm_name> ]

    -u <user> -p <pass> | -f <authfile>

    -l <command> [ -s <subcommand> ]

    [ -x <black_list> ] [ -o <additional_options> ]

    [ -t <timeout> ] [ -w <warn_range> ] [ -c <crit_range> ]

    [ -V ] [ -h ]



 -?, --usage

   Print usage information

 -h, --help

   Print detailed help screen

 -V, --version

   Print version information

 --extra-opts=[section][@file]

   Read options from an ini file. See http://nagiosplugins.org/extra-opts

   for usage and examples.

 -H, --host=<hostname>

   ESX or ESXi hostname.

 -C, --cluster=<clustername>

   ESX or ESXi clustername.

 -D, --datacenter=<DCname>

   Datacenter hostname.

 -N, --name=<vmname>

   Virtual machine name.

 -u, --username=<username>

   Username to connect with.

 -p, --password=<password>

   Password to use with the username.

 -f, --authfile=<path>

   Authentication file with login and password. File syntax :

   username=<login>

   password=<password>

 -w, --warning=THRESHOLD

   Warning threshold. See

   http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT

   for the threshold format.

 -c, --critical=THRESHOLD

   Critical threshold. See

   http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT

   for the threshold format.

 -l, --command=COMMAND

   Specify command type (CPU, MEM, NET, IO, VMFS, RUNTIME, ...)

 -s, --subcommand=SUBCOMMAND

   Specify subcommand

 -S, --sessionfile=SESSIONFILE

   Specify a filename to store sessions for faster authentication

 -x, --exclude=<black_list>

   Specify black list

 -o, --options=<additional_options>

   Specify additional command options

 -t, --timeout=INTEGER

   Seconds before plugin times out (default: 30)

 -v, --verbose

   Show details for command-line debugging (can repeat up to 3 times)

Supported commands(^ means blank or not specified parameter) :

    Common options for VM, Host and DC :

        * cpu - shows cpu info

            + usage - CPU usage in percentage

            + usagemhz - CPU usage in MHz

            ^ all cpu info

        * mem - shows mem info

            + usage - mem usage in percentage

            + usagemb - mem usage in MB

            + swap - swap mem usage in MB

            + overhead - additional mem used by VM Server in MB

            + overall - overall mem used by VM Server in MB

            + memctl - mem used by VM memory control driver(vmmemctl) that controls ballooning

            ^ all mem info

        * net - shows net info

            + usage - overall network usage in KBps(Kilobytes per Second)

            + receive - receive in KBps(Kilobytes per Second)

            + send - send in KBps(Kilobytes per Second)

            ^ all net info

        * io - shows disk io info

            + read - read latency in ms (totalReadLatency.average)

            + write - write latency in ms (totalWriteLatency.average)

            ^ all disk io info

        * runtime - shows runtime info

            + status - overall host status (gray/green/red/yellow)

            + issues - all issues for the host

            ^ all runtime info

    VM specific :

        * cpu - shows cpu info

            + wait - CPU wait time in ms

            + ready - CPU ready time in ms

        * mem - shows mem info

            + swapin - swapin mem usage in MB

            + swapout - swapout mem usage in MB

            + active - active mem usage in MB

        * io - shows disk I/O info

            + usage - overall disk usage in MB/s

        * runtime - shows runtime info

            + con - connection state

            + cpu - allocated CPU in MHz

            + mem - allocated mem in MB

            + state - virtual machine state (UP, DOWN, SUSPENDED)

            + consoleconnections - console connections to VM

            + guest - guest OS status, needs VMware Tools

            + tools - VMWare Tools status

    Host specific :

        * net - shows net info

            + nic - makes sure all active NICs are plugged in

        * io - shows disk io info

            + aborted - aborted commands count

            + resets - bus resets count

            + kernel - kernel latency in ms

            + device - device latency in ms

            + queue - queue latency in ms

        * vmfs - shows Datastore info

            + (name) - free space info for datastore with name (name)

            ^ all datastore info

        * runtime - shows runtime info

            + con - connection state

            + health - checks cpu/storage/memory/sensor status

            + maintenance - shows whether host is in maintenance mode

            + list(vm) - list of VMWare machines and their statuses

        * service - shows Host service info

            + (names) - check the state of one or several services specified by (names), syntax for (names):<service1>,<service2>,...,<serviceN>

            ^ show all services

        * storage - shows Host storage info

            + adapter - list bus adapters

            + lun - list SCSI logical units

            + path - list logical unit paths

    DC specific :

        * io - shows disk io info

            + aborted - aborted commands count

            + resets - bus resets count

            + kernel - kernel latency in ms

            + device - device latency in ms

            + queue - queue latency in ms

        * vmfs - shows Datastore info

            + (name) - free space info for datastore with name (name)

            ^ all datastore info

        * runtime - shows runtime info

            + list(vm) - list of VMWare machines and their statuses

            + listhost - list of VMWare esx host servers and their statuses

            + tools - VMWare Tools status

        * recommendations - shows recommendations for cluster

            + (name) - recommendations for cluster with name (name)

            ^ all clusters recommendations


Wie man sehen kann, lassen sich dort sehr viele Dinge überwachen, meiner Meinung nach sind Sachen wie die Auslastung (CPU, RAM, VMFS, IO, Netzwerk) und der Zustand von wichtigen VMs interessante Faktoren, die auf Probleme (Ausfälle, geringe Leistungskapazitäten, ...) hindeuten können.

Dazu hier eine typische commands.cfg:
 
define command {
        command_name    check_esxi_vm_list
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -H $_HOSTESX_HOSTNAME$.DOMAIN.TLD -f $ARG2$ -l runtime -s list
}

define command {
        command_name    check_esxi_status
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -H $_HOSTESX_HOSTNAME$.DOMAIN.TLD -f $ARG2$ -l runtime -s status
}

define command {
        command_name    check_esxi_io
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -H $_HOSTESX_HOSTNAME$.DOMAIN.TLD -f $ARG2$ -l io
}

define command {
        command_name    check_esxi_vmfs
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -H $_HOSTESX_HOSTNAME$.DOMAIN.TLD -f $ARG2$ -l vmfs -w 10%: -c 5%:
}

define command {
        command_name    check_esxi_cpu
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -H $_HOSTESX_HOSTNAME$.DOMAIN.TLD -f $ARG2$ -l cpu -w 80 -c 90
}

define command {
        command_name    check_esxi_mem
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -H $_HOSTESX_HOSTNAME$.DOMAIN.TLD -f $ARG2$ -l mem -w 80 -c 90
}

define command {
        command_name    check_esxi_net
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -H $_HOSTESX_HOSTNAME$.DOMAIN.TLD -f $ARG2$ -l net
}

define command {
        command_name    check_esxi_vm_running
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -H $_HOSTESX_HOSTNAME$.DOMAIN.TLD -f $ARG2$ -l runtime
}

define command {
        command_name    check_esxi_dc_running_hosts
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -f $ARG2$ -l runtime -s listhost -c 8
}
define command {
        command_name    check_esxi_dc_vmfs
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -f $ARG2$ -l vmfs -w 10%: -c 5%:
}

define command {
        command_name    check_esxi_dc
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -f $ARG2$ -l runtime
}
define command {
        command_name    check_esxi_dc_net
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -f $ARG2$ -l net
}

define command {
        command_name    check_esxi_dc_io
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -f $ARG2$ -l io
}
define command {
        command_name    check_esxi_dc_cpu
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -f $ARG2$ -l cpu
}

define command {
        command_name    check_esxi_dc_mem
        command_line    $USER1$/check_esx3.pl -D $ARG1$ -f $ARG2$ -l mem
}

In der commands.cfg verwende ich Custom Hostvariablen, da Hosts im Nagios normalerweise über die IP angelegt werden (keine DNS Abhängigkeit..) und die IPs dann natürlich nicht im Virtual Center matchen würden, diese Host Variablen kann man ganz einfach anlegen:
        _ESX_HOSTNAME                   esx2

Argument 1 muss die IP oder den Hostname des Virtual Centers enthalten, welcher die Abfragen für ein DataCenter bündeln kann.
Argument 2 wäre ein Authentifizierungsfile im Format, dabei ist Domain nur nötig, wenn man AD Authentifizierung nutzt:
username=foobar@domain.tld 

password=barfoo


Wenn die commands.cfg nun eingebunden ist, bietet es sich an eine Hostgruppe für die Veerbung der Service Checks einzurichten (Redundanzen vermeiden!) und dieser dann die ESXi Knoten zuweisen.


Nachdem nun die Service Checks eingerichtet wurden, kann die Überwachung beginnen.

Nun fehlt aber noch das i-Tüpfelchen: die Visualisierung der Auslastung über alle Hosts!

Dazu bediene ich mich dem großartigen PNP4Nagios (Achtung, bitte Version >= 0.6.x nutzen!), die Installation ist, durch die sehr gute Dokumentation, relativ einfach und schnell vollzogen.
Zum Start gibt es bereits ein Template, welches von OP5 im PNP4Nagios mitgeliefert wird.

Dieses unterstützt allerdings keine Multigraphen über mehrere Hosts, daher habe ich dafür eines selbst geschrieben, welches dann so aussieht:



Der grüne Balken ist ein Ticker und zeigt dort direkt Grün, Gelb, Rot an, wenn einer der Hosts ein Problem hat, also die Thresholds überschritten wurden.

Das Template bekommt ihr hier und muss in den templates.special Ordner (z.B: /usr/share/pnp4nagios/templates.special) abgelegt und geringfügig angepasst werden:

Hostnames unterstützen RegEx (z.B. 'esx' => esx1,esx2,...,esxN) oder arrays, falls die Namen kein gleiches Muster haben (array("host1","clusternode2","clusterhost1").
Die ServiceNames (in meinem Fall: ESXi_XXX) müssen genau passen, damit das Special Template funktionieren kann.

Bei Unsicherheiten kann man aber auch einfach die Zeilen "throw new Kohana_exception(print_r($data,TRUE));" auskommentieren und das Template über /pnp4nagios/special anschließend aufrufen, damit werden alle verfügbaren Daten ausgegeben.

$services = $this->tplGetServices("HOST_NAMES",  "SERVICE_NAME")
In Zeile: 12 (CPU), 37 (RAM), 60 (Network)


Wenn nun das Template in dem entsprechenden Ordner abgelegt ist, wird beim Aufruf des PNP4Nagios ein neuer "S" Button auf der rechten Seiten erscheinen, wenn man den auswählt, sollte das neue Template aufgelistet bzw. schon geöffnet sein.

Falls nicht, bitte die Pfade, Berechtigungen und Endung (.php!) überprüfen.


Et voila, die Überwachung der ESXi-Hosts / DataCenter ist eingerichtet und wird in Farbe und bunt angezeigt.