Translations of this page:

check_disk

Dieses PlugIn zeigt den benutzten Plattenplatz in Prozent, KB, MB, GB und TB an (default: MB). Die Parameter für WARNING und CRITICAL sind variabel.

Konfiguration für localhost

Für einen Check auf dem Nagios Server selber muss folgende Konfiguration an der commands.cfg und an der services.cfg vorgenommen werden. (Letztere Konfigurationsdatei ist nicht aus den Standard-Templates. In diesem Beispiel sind alle Services in einer Datei.)

nagios/etc/objects/commands.cfg

# 'check_local_disk' command definition
define command{
        command_name    check_local_disk
        command_line    $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
        }

nagios/etc/objects/services.cfg

# Service definition
define service{
        use                             general-service            ; Name of service template to use
        host_name                       localhost
        service_description             HDD.root
        check_command                   check_local_disk!20%!10%!/dev/hda2
        }

Anstatt in der Service Definition den Pfad /dev/hda2 anzugeben, kann man auch den Mount-Point verwenden.
Bsp: check_local_disk!20%!10%!/

Ergebnis

Das Ergebnis über das Webinterface könnte wie folgt aussehen:

check_disk0010.jpg

Ein Test über die Konsole gibt folgendes zurück:

./check_disk -w 20% -c 10% -p /dev/sda2
DISK OK - free space: / 9277 MB (61% inode=95%);| /=5744MB;12671;14255;0;15839

Checks per NRPE

Für die Konfiguration eines NRPE-Clients muss man etwas anders vorgehen. Dieser Weg setzt voraus, dass auf dem zu überwachenden Rechner die Nagios-PlugIns und NRPE installiert sind.

nagios/etc/objects/commands.cfg

# 'check_nrpe' command defintion
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

Hinweis: In der command_line “-n“ anhängen, wenn SSL nicht verwendet werden soll/brauch.

nagios/etc/objects/services.cfg

# Service definition
define service{
        use                             generic-service            ; Name of service template to use
        host_name                       host1,host2
        service_description             HDD.root
        check_command                   check_nrpe!check_disk_root
        }

nagios/etc/include/nrpe.cfg

Diese Konfigurationsdatei muss auf dem zu überwachenden Rechner in ein Verzeichnis kopiert werden, von wo aus von NRPE verwendet werden kann. Ich benutze das Verzeichnis /usr/local/nagios/include und habe in der Datei /usr/local/nagios/etc/nrpe.cfg angegeben das dieses Verzeichnis „includiert“ wird (include_dir).

command[check_disk_root]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda2

Ergebnis

Die Ausgaben über die Konsole und über das Webinterface sehen so ziemlich gleich aus, wie beim normalen Check.

check_disk0020.jpg

Hilfe

Es gibt noch viele weitere Konfigurations-Parameter, die hier nicht ganannt worden sind, aber die man sich über die Hilfe des PlugIns ausgeben lassen kann.

cd nagios/libexec
./check_disk --help
check_disk v1.4.15 (nagios-plugins 1.4.15)
Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>
Copyright (c) 1999-2008 Nagios Plugin Development Team
        <nagiosplug-devel@lists.sourceforge.net>

This plugin checks the amount of used disk space on a mounted file system
and generates an alert if free space is less than one of the threshold values


Usage:
 check_disk -w limit -c limit [-W limit] [-K limit] {-p path | -x device}
[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]
[-t timeout] [-u unit] [-v] [-X type]

Options:
 -h, --help
    Print detailed help screen
 -V, --version
    Print version information
 -w, --warning=INTEGER
    Exit with WARNING status if less than INTEGER units of disk are free
 -w, --warning=PERCENT%
    Exit with WARNING status if less than PERCENT of disk space is free
 -c, --critical=INTEGER
    Exit with CRITICAL status if less than INTEGER units of disk are free
 -c, --critical=PERCENT%
    Exit with CRITCAL status if less than PERCENT of disk space is free
 -W, --iwarning=PERCENT%
    Exit with WARNING status if less than PERCENT of inode space is free
 -K, --icritical=PERCENT%
    Exit with CRITICAL status if less than PERCENT of inode space is free
 -p, --path=PATH, --partition=PARTITION
    Path or partition (may be repeated)
 -x, --exclude_device=PATH <STRING>
    Ignore device (only works if -p unspecified)
 -C, --clear
    Clear thresholds
 -E, --exact-match
    For paths or partitions specified with -p, only check for exact paths
 -e, --errors-only
    Display only devices/mountpoints with errors
 -g, --group=NAME
    Group paths. Thresholds apply to (free-)space of all partitions together
 -k, --kilobytes
    Same as '--units kB'
 -l, --local
    Only check local filesystems
 -L, --stat-remote-fs
    Only check local filesystems against thresholds. Yet call stat on remote filesystems
    to test if they are accessible (e.g. to detect Stale NFS Handles)
 -M, --mountpoint
    Display the mountpoint instead of the partition
 -m, --megabytes
    Same as '--units MB'
 -A, --all
    Explicitly select all paths. This is equivalent to -R '.*'
 -R, --eregi-path=PATH, --eregi-partition=PARTITION
    Case insensitive regular expression for path/partition (may be repeated)
 -r, --ereg-path=PATH, --ereg-partition=PARTITION
    Regular expression for path or partition (may be repeated)
 -I, --ignore-eregi-path=PATH, --ignore-eregi-partition=PARTITION
    Regular expression to ignore selected path/partition (case insensitive) (may be repeated)
 -i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION
    Regular expression to ignore selected path or partition (may be repeated)
 -t, --timeout=INTEGER
    Seconds before connection times out (default: 10)
 -u, --units=STRING
    Choose bytes, kB, MB, GB, TB (default: MB)
 -v, --verbose
    Show details for command-line debugging (Nagios may truncate output)
 -X, --exclude-type=TYPE
    Ignore all filesystems of indicated type (may be repeated)

Examples:
 check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /
    Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB
 check_disk -w 100 -c 50 -C -w 1000 -c 500 -g sidDATA -r '^/oracle/SID/data.*$'
    Checks all filesystems not matching -r at 100M and 50M. The fs matching the -r regex
    are grouped which means the freespace thresholds are applied to all disks together
 check_disk -w 100 -c 50 -C -w 1000 -c 500 -p /foo -C -w 5% -c 3% -p /bar
    Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use 100M/50M

Send email to nagios-users@lists.sourceforge.net if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to nagiosplug-devel@lists.sourceforge.net
nagios/plugins/check_disk.txt · Zuletzt geändert: 2011/08/16 09:58 von eyrax
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0