Skip to content

Mini-HowTo: Green Cell® UPS USV mit Nagios überwachen

Der Status einer günstigen unterbrechungsfreien Stromversorgung (USV), in dem Fall eine (Green Cell® UPS USV Unterbrechungsfreie Stromversorgung 600VA (360W)) soll mittels Nagios abgefragt werden. Das UPS Modell ist mit dem Network UPS Tools (NUT) Treiber blazer_usb kompatibel. Die USV versorgt einen Clientrechner client.lan, Nagios ist auf einem Server server.lan installiert. Unter debian bzw. seinen Ablegern lässt sich die nötige Software auf dem Clientrechner wie gehabt installieren:
sudo apt install nut

Irgendwelche Abhängigkeiten sollten natürlich aufgelöst werden. Danach editieren wir die Datei /etc/nut/ups.conf und fügen am Ende folgende Definition für die GreenCell UPS ein:
[GreenCell]
        driver = "blazer_usb"
        port = "auto"
        desc = "GreenCell USV 600VA"
Die Datei /etc/nut/nut.conf editiert man dann entsprechend dem Verwendungszweck (Standalone/Netzserver/-client)
# Network UPS Tools: example nut.conf
#
##############################################################################
# General section
##############################################################################
# The MODE determines which part of the NUT is to be started, and which
# configuration files must be modified.
#
# This file try to standardize the various files being found in the field, like
# /etc/default/nut on Debian based systems, /etc/sysconfig/ups on RedHat based
# systems, ... Distribution's init script should source this file to see which
# component(s) has to be started.
#
# The values of MODE can be:
# - none: NUT is not configured, or use the Integrated Power Management, or use
#   some external system to startup NUT components. So nothing is to be started.
# - standalone: This mode address a local only configuration, with 1 UPS 
#   protecting the local system. This implies to start the 3 NUT layers (driver,
#   upsd and upsmon) and the matching configuration files. This mode can also
#   address UPS redundancy.
# - netserver: same as for the standalone configuration, but also need
#   some more network access controls (firewall, tcp-wrappers) and possibly a
#   specific LISTEN directive in upsd.conf.
#   Since this MODE is opened to the network, a special care should be applied
#   to security concerns.
# - netclient: this mode only requires upsmon.
#
# IMPORTANT NOTE:
#  This file is intended to be sourced by shell scripts.
#  You MUST NOT use spaces around the equal sign!

MODE=standalone

Auf dem Server wird Nagios am besten aus den Quellen installiert, viele Plugins und auch das Programmpaket selber liegt meistens in recht hm... veralteten Versionen vor. Ich verweise hier mal auf ein recht aktuelles HowTo. ^^

Sobald Nagios läuft, stricken wir uns einen Befehl zum Ansprechen der UPS zusammen und editieren dazu die Datei /usr/local/nagios/etc/objects/commands.cfg
# UPS Check
#
#
define command {

    command_name check_ups
    command_line    $USER1$/check_ups -H $HOSTADDRESS$ -u GreenCell
}

Wie man unschwer erkennen kann, bezieht sich der Befehl in der vorletzten Zeile auf das in der Datei /etc/nut/ups.conf definierte Gerät. Dieser Befehl kann nun in beliebigen Serverkonfigurationen, die Nagios überwacht, angewendet werden. Wir richten nun aber erst einmal die Nagios Konfiguration des Clients ein, der durch die USV versorgt wird und editieren dazu eine neue Datei, in dem Fall nennen wir sie einfach /usr/local/nagios/etc/servers/client.lan.cfg
(...)
define service {
use                     local-service
host_name               client.lan
service_description     GreenCell UPS
check_command           check_ups!-H client.lan -u GreenCell

Ab diesem Zeitpunkt sollte der Status der UPS abgefragt werden können. Welche Werte genau abgefragt werden können ist natürlich von der jeweiligen UPS abhängig und welche Werte von Belang sind. Wie bei den meisten anderen Nagios Plugins können auch bei check_ups die möglichen Parameter durch einen Aufruf auf den Kommandozeile abgefragt werden. Hier man ein wenig Copy & Paste:
nagiosuser@server.lan:/usr/local/nagios/libexec# ./check_ups -h
check_ups v2.3.3 (nagios-plugins 2.3.3)
Copyright (c) 2000 Tom Shields
Copyright (c) 2004 Alain Richard <alain.richard@equation.fr>
Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>
Copyright (c) 2000-2014 Nagios Plugin Development Team
    <devel@nagios-plugins.org>

This plugin tests the UPS service on the specified host. Network UPS Tools
from www.networkupstools.org must be running for this plugin to work.

Usage:
check_ups -H host -u ups [-p port] [-v variable] [-w warn_value] [-c crit_value] [-e] [-to to_sec] [-T]

Options:
 -h, --help
    Print detailed help screen
 -V, --version
    Print version information
 --extra-opts=[section][@file]
    Read options from an ini file. See
    https://www.nagios-plugins.org/doc/extra-opts.html
    for usage and examples.
 -H, --hostname=ADDRESS
    Host name, IP Address, or unix socket (must be an absolute path)
 -p, --port=INTEGER
    Port number (default: 3493)
 -u, --ups=STRING
    Name of UPS
 -T, --temperature
    Output of temperatures in Celsius
 -e, --extended-units
    Allow nonstandard units in performance data (used for voltage and temperatures)
 -v, --variable=STRING
    Valid values for STRING are LINE, TEMP, BATTLEFT, BATTPCT or LOADPCT
 -w, --warning=DOUBLE
    Response time to result in warning status (seconds)
 -c, --critical=DOUBLE
    Response time to result in critical status (seconds)
 -t, --timeout=INTEGER:
    Seconds before connection times out (default: 10)
    Optional ":" can be a state integer (0,1,2,3) or a state STRING

This plugin attempts to determine the status of a UPS (Uninterruptible Power
Supply) on a local or remote host. If the UPS is online or calibrating, the
plugin will return an OK state. If the battery is on it will return a WARNING
state. If the UPS is off or has a low battery the plugin will return a CRITICAL
state.

Notes:
 You may also specify a variable to check (such as temperature, utility voltage,
 battery load, etc.) as well as warning and critical thresholds for the value
 of that variable.  If the remote host has multiple UPS that are being monitored
 you will have to use the --ups option to specify which UPS to check.

 This plugin requires that the UPSD daemon distributed with Russell Kroll's
 Network UPS Tools be installed on the remote host. If you do not have the
 package installed on your system, you can download it from
 http://www.networkupstools.org

Send email to help@nagios-plugins.org if you have questions regarding use
of this software. To submit patches or suggest improvements, send email to
devel@nagios-plugins.org

Eine am Server abgesetzte Anfrage ergibt in unserem Fall:
nagiosuser@server.lan:/usr/local/nagios/libexec# ./check_ups -H prusapi.lan -u GreenCell
UPS OK - Status=Online Utility=230,0V Batt=100,0% Load=4,0% |voltage=230,000000;;;0,000000 battery=100,000000%;;;0,000000;100,000000 load=4,000000%;;;0,000000;100,000000

Nagios verwertet diesen Schnipsel so:



Einige Links in diesem Beitrag sind Vorschläge / Einkaufsquellen und sog. Affiliatelinks. Wenn Du etwas über diesen Link kaufst, erhalten wir eine kleine Provision. Der Preis für Dich bleibt derselbe. Vielen Dank für Deine Unterstützung.

Some of the links are suggestions for parts to replicate the thing and affiliate. If you buy something, I get a small commission. The price you pay is the same. Thank you very much.

Trackbacks

Keine Trackbacks

Kommentare

Ansicht der Kommentare: Linear | Verschachtelt

Matthias am :

Gibt es auch Erfahrungen mit dem Steuern der USV?
Ich habe den Eindruck, dass der Treiber blazer_usb nur lesend auf die USV zugreifen kann.
Es gelingt mir jedenfalls nicht, die USV über den Befehl upscmd -u xxx -p yyy ups@localhost load.off abzuschalten.

Thomas Trueten am :

Hallo Matthias,
ist wohl so, jedenfalls klappt das Ausschalten nicht mit dem Befehl. Auf jeden Fall Danke für den Hinweis, ist mir bisher gar nicht aufgefallen, da das Teil bei mir 24/7 läuft und bisher bei 2 Stromausfällen problemlos funktionierte.
Viele Grüße,
Thomas

Kommentar schreiben

Die angegebene E-Mail-Adresse wird nicht dargestellt, sondern nur für eventuelle Benachrichtigungen verwendet.
Um einen Kommentar hinterlassen zu können, erhalten Sie nach dem Kommentieren eine E-Mail mit Aktivierungslink an ihre angegebene Adresse.

Um maschinelle und automatische Übertragung von Spamkommentaren zu verhindern, bitte die Zeichenfolge im dargestellten Bild in der Eingabemaske eintragen. Nur wenn die Zeichenfolge richtig eingegeben wurde, kann der Kommentar angenommen werden. Bitte beachten Sie, dass Ihr Browser Cookies unterstützen muss, um dieses Verfahren anzuwenden.
CAPTCHA

Umschließende Sterne heben ein Wort hervor (*wort*), per _wort_ kann ein Wort unterstrichen werden.
BBCode-Formatierung erlaubt
Formular-Optionen

Kommentare werden erst nach redaktioneller Prüfung freigeschaltet!

cronjob