Module: check_mk
Branch: master
Commit: a04bee7734dbed6888cb6bf6d2a5d3d78af44ef9
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a04bee7734dbed…
Author: Goetz Golla <gg(a)mathias-kettner.de>
Date: Wed Jun 4 10:30:28 2014 +0200
apc_symmetra: check now also monitors the battery replacement status
---
.werks/615 | 8 ++++++++
ChangeLog | 1 +
checkman/apc_symmetra | 31 +++++++++++++++++++------------
checks/apc_symmetra | 39 ++++++++++++++++++++++++++++-----------
4 files changed, 56 insertions(+), 23 deletions(-)
diff --git a/.werks/615 b/.werks/615
new file mode 100644
index 0000000..86cc707
--- /dev/null
+++ b/.werks/615
@@ -0,0 +1,8 @@
+Title: apc_symmetra: check now also monitors the battery replacement status
+Level: 1
+Component: checks
+Version: 1.2.5i3
+Date: 1401870579
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 8e4e1b2..4fc1d94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -64,6 +64,7 @@
* 0926 windows agent: local / plugin scripts now get the REMOTE_HOST as environment variable
* 0163 kaspersky_av_quarantine,kaspersky_av_tasks,kaspersky_av_updates: New checks for kaspersky anti virus on linux
* 0164 symantec_av_progstate,symantec_av_quarantine, symantec_av_updates: New checks for Symantec Anti Virus on Linux
+ * 0615 apc_symmetra: check now also monitors the battery replacement status
* 0777 FIX: special agent emcvnx: did not work with security file authentication...
* 0786 FIX: zfsget: fixed compatibility with older Solaris agents...
* 0809 FIX: brocade_fcport: Fixed recently introduced problem with port speed detection
diff --git a/checkman/apc_symmetra b/checkman/apc_symmetra
index a04a997..a05c1d6 100644
--- a/checkman/apc_symmetra
+++ b/checkman/apc_symmetra
@@ -4,20 +4,27 @@ catalog: hw/power/apc
license: GPL
distribution: check_mk
description:
- This check monitors eight aspects of an APC Symmetra UPS: {(1)} the battery status,
- {(2)} the output status, {(3)} the battery capacity, {(4)} the battery
- temperature, {(5)} the battery current, {(6)} the output voltage and
- {(7)} the output current, {(8)} the remaing run time. The output current and
- remaining run time are not checked against a level but are just displayed, {(9)} the current
- load in percent.
+
+ This check monitors ten aspects of an APC Symmetra UPS: {(1)} the
+ battery status, {(2)} the battery replacement status including the number
+ of batteries to be replaced, {(3)} the output status, {(4)} the battery
+ capacity, {(5)} the battery temperature, {(6)} the battery current, {(7)}
+ the output voltage, {(8)} the output current, {(9)} the remaing run time,
+ and {(10)} the current load in percent.
+
+ The output current and remaining run time are not checked against a level,
+ but just displayed. {(2)} is only displayed if a problem is found, the level
+ is {WARN} if one battery needs to be replaced and {CRIT} if more than one
+ battery needs to be replaced. {(1)} is not displayed if the state is normal
+ but a problem in {(2)} was found.
The check output includes the calibration status of the UPS. During a
- calibration the check result in section {(2)} is OK even though the UPS is running
- on battery.
- The check reads the date of the last calibration and optionally applies an alternative
- level for the battery capacity on the day of the calibration. This is because the battery
- capacity is reduced after calibration and may cause an unwanted critical condition
- with the standard level. In addition a time span after the day of the calibration
+ calibration the check result in section {(2)} is OK even though the UPS is
+ running on battery. The check reads the date of the last calibration and
+ optionally applies an alternative level for the battery capacity on the
+ day of the calibration. This is because the battery capacity is reduced
+ after calibration and may cause an unwanted critical condition with the
+ standard level. In addition a time span after the day of the calibration
can be configured during which the post-calibration phase still persists.
examples:
diff --git a/checks/apc_symmetra b/checks/apc_symmetra
index f7a32d3..dda0fcd 100644
--- a/checks/apc_symmetra
+++ b/checks/apc_symmetra
@@ -29,6 +29,8 @@
# PowerNet-MIB::upsBasicOutputStatus.0 .1.3.6.1.4.1.318.1.1.1.4.1.1.0
# PowerNet-MIB::upsAdvBatteryCapacity.0 .1.3.6.1.4.1.318.1.1.1.2.2.1.0
# PowerNet-MIB::upsAdvBatteryTemperature.0 .1.3.6.1.4.1.318.1.1.1.2.2.2.0
+# PowerNet-MIB::upsAdvBatteryReplaceIndicator.0 .1.3.6.1.4.1.318.1.1.1.2.2.4.0
+# PowerNet-MIB::upsAdvBatteryNumOfBadBattPacks.0 .1.3.6.1.4.1.318.1.1.1.2.2.6.0
# PowerNet-MIB::upsAdvBatteryCurrent.0 .1.3.6.1.4.1.318.1.1.1.2.2.9.0
# PowerNet-MIB::upsAdvOutputVoltage.0 .1.3.6.1.4.1.318.1.1.1.4.2.1.0
# PowerNet-MIB::upsAdvOutputCurrent.0 .1.3.6.1.4.1.318.1.1.1.4.2.4.0
@@ -78,9 +80,10 @@ factory_settings["apc_default_levels"] = {
def check_apc(item, params, info):
BasicBatteryStatus, BasicOutputStatus, AdvBatteryCapacity, \
- AdvBatteryTemperature, AdvBatteryCurrent, AdvInputVoltage, AdvOutputVoltage, \
+ AdvBatteryTemperature, AdvBatteryReplaceIndicator, AdvBatteryNumOfBadBattPacks, \
+ AdvBatteryCurrent, AdvInputVoltage, AdvOutputVoltage, \
AdvOutputCurrent, AdvBatteryRunTimeRemaining, AdvTestCalibrationResults, AdvOutputLoad \
- = [ saveint(x) for x in info[0][:11] ]
+ = [ saveint(x) for x in info[0][:13] ]
LastDiagnosticsDate = info[0][-1]
RunTimeRemaining = AdvBatteryRunTimeRemaining / 100
@@ -110,11 +113,23 @@ def check_apc(item, params, info):
if BasicBatteryStatus != 2:
state = 2
infotxt += "(!!)"
+ single_states.append( (state, infotxt, None) )
else:
state = 0
- single_states.append( (state, infotxt, None) )
- # 2. Check basic output status
+ # 2. Check battery replacement status
+ if AdvBatteryReplaceIndicator == 2:
+ if AdvBatteryNumOfBadBattPacks == 1:
+ infotxt = "one battery needs replacement(!)"
+ state = 1
+ else:
+ infotxt = "%i batteries need replacement(!!)" % AdvBatteryNumOfBadBattPacks
+ state = 2
+ single_states.append( (state, infotxt, None) )
+ elif state == 0: # if normal only print when replacement status is also OK, to save on service output text
+ single_states.append( (state, infotxt, None) )
+
+ # 3. Check basic output status
status_text = { 1:"unknown", 2:"online", 3:"on battery", 4:"on smart boost", 5:"timed sleeping",
6:"software bypass", 7:"off", 8:"rebooting", 9:"switched bypass",
10:"hardware failure bypass", 11:"sleeping until power return",
@@ -129,7 +144,7 @@ def check_apc(item, params, info):
state = 0
single_states.append( (state, infotxt, None) )
- # 3. Check battery capacity
+ # 4. Check battery capacity
state = 0
infotxt = "capacity %d%% (crit at " % AdvBatteryCapacity
@@ -146,7 +161,7 @@ def check_apc(item, params, info):
single_states.append( (state, infotxt, ("capacity", AdvBatteryCapacity, "", crit_capacity, 0, 100)) )
- # 4. Check System temperature
+ # 5. Check System temperature
# The Name AdvBatteryTemperature is a wrong naming in the vendor mib.
infotxt = "sys. temp. %dC" % AdvBatteryTemperature
if AdvBatteryTemperature >= crit_sys_temp:
@@ -156,7 +171,7 @@ def check_apc(item, params, info):
state = 0
single_states.append( (state, infotxt, ("systemp", AdvBatteryTemperature, "", crit_sys_temp) ) )
- # 5. Check battery current
+ # 6. Check battery current
infotxt = "bat. curr. %dA" % AdvBatteryCurrent
if AdvBatteryCurrent >= crit_batt_curr:
state = 2
@@ -168,7 +183,7 @@ def check_apc(item, params, info):
# 6a. Simply show input voltage (no performance data)
single_states.append( (0, "input voltage %dV" % AdvInputVoltage, None) )
- # 6. Check output voltage
+ # 7. Check output voltage
infotxt = "output voltage %dV" % AdvOutputVoltage
if AdvOutputVoltage <= crit_voltage:
state = 2
@@ -177,17 +192,17 @@ def check_apc(item, params, info):
state = 0
single_states.append( (state, infotxt, ("voltage", AdvOutputVoltage, "", crit_voltage, 0) ) )
- # 7. Simply add output current as perfdata
+ # 8. Simply add output current as perfdata
single_states.append( (0, "output current %dA" % AdvOutputCurrent, ("current", AdvOutputCurrent)) )
- # 8. run time remaining
+ # 9. run time remaining
# RunTimeRemaining formatiert == "26:00.00"
hrs = int(RunTimeRemaining) / 3600
mins, secs = divmod(int(RunTimeRemaining) % 3600, 60)
single_states.append( (0, "run time remaining: %02d:%02d:%02d" % (hrs, mins, secs),
("runtime", RunTimeRemaining/60)) )
- # 9. Adv Output load (load in percent)
+ # 10. Adv Output load (load in percent)
load_state = 0
loadwarn, loadcrit = None, None
label = ""
@@ -227,6 +242,8 @@ check_info['apc_symmetra'] = {
"4.1.1.0", # BasicOutputStatus,
"2.2.1.0", # AdvBatteryCapacity,
"2.2.2.0", # AdvBatteryTemperature,
+ "2.2.4.0", # AdvBatteryReplaceIndicator,
+ "2.2.6.0", # AdvBatteryNumOfBadBattPacks,
"2.2.9.0", # AdvBatteryCurrent,
"3.2.1.0", # AdvInputVoltage,
"4.2.1.0", # AdvOutputVoltage,
Module: check_mk
Branch: master
Commit: c7785bb91864f27eaf52134e741a963bf4a2dc61
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c7785bb91864f2…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jun 3 10:51:58 2014 +0200
Added missing Livestatus file
---
livestatus/src/HostServiceState.cc | 68 +++++++++++++++++++++++++
livestatus/src/HostServiceState.h | 97 ++++++++++++++++++++++++++++++++++++
2 files changed, 165 insertions(+)
diff --git a/livestatus/src/HostServiceState.cc b/livestatus/src/HostServiceState.cc
new file mode 100644
index 0000000..eff4561
--- /dev/null
+++ b/livestatus/src/HostServiceState.cc
@@ -0,0 +1,68 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+// +------------------------------------------------------------------+
+//
+// This file is part of Check_MK.
+// The official homepage is at http://mathias-kettner.de/check_mk.
+//
+// check_mk is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation in version 2. check_mk is distributed
+// in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+// out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+// PARTICULAR PURPOSE. See the GNU General Public License for more de-
+// ails. You should have received a copy of the GNU General Public
+// License along with GNU Make; see the file COPYING. If not, write
+// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+// Boston, MA 02110-1301 USA.
+
+#include "HostServiceState.h"
+
+HostServiceState::~HostServiceState()
+{
+ if (_log_output != 0)
+ free(_log_output);
+}
+
+void HostServiceState::computePerStateDurations()
+{
+ _duration_state_UNMONITORED = 0;
+ _duration_part_UNMONITORED = 0;
+ _duration_state_OK = 0;
+ _duration_part_OK = 0;
+ _duration_state_WARNING = 0;
+ _duration_part_WARNING = 0;
+ _duration_state_CRITICAL = 0;
+ _duration_part_CRITICAL = 0;
+ _duration_state_UNKNOWN = 0;
+ _duration_part_UNKNOWN = 0;
+
+ switch (_state) {
+ case -1:
+ _duration_state_UNMONITORED = _duration;
+ _duration_part_UNMONITORED = _duration_part;
+ break;
+ case 0:
+ _duration_state_OK = _duration;
+ _duration_part_OK = _duration_part;
+ break;
+ case 1:
+ _duration_state_WARNING = _duration;
+ _duration_part_WARNING = _duration_part;
+ break;
+ case 2:
+ _duration_state_CRITICAL = _duration;
+ _duration_part_CRITICAL = _duration_part;
+ break;
+ case 3:
+ _duration_state_UNKNOWN = _duration;
+ _duration_part_UNKNOWN = _duration_part;
+ break;
+ }
+}
diff --git a/livestatus/src/HostServiceState.h b/livestatus/src/HostServiceState.h
new file mode 100644
index 0000000..8dec7e5
--- /dev/null
+++ b/livestatus/src/HostServiceState.h
@@ -0,0 +1,97 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+// +------------------------------------------------------------------+
+//
+// This file is part of Check_MK.
+// The official homepage is at http://mathias-kettner.de/check_mk.
+//
+// check_mk is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation in version 2. check_mk is distributed
+// in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+// out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+// PARTICULAR PURPOSE. See the GNU General Public License for more de-
+// ails. You should have received a copy of the GNU General Public
+// License along with GNU Make; see the file COPYING. If not, write
+// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+// Boston, MA 02110-1301 USA.
+
+#ifndef HostServiceState_h
+#define HostServiceState_h
+
+#include <time.h>
+#include <string.h>
+#include <nagios.h>
+#include <vector>
+using namespace std;
+
+struct HostServiceState;
+typedef vector<HostServiceState*> HostServices;
+
+typedef void* HostServiceKey;
+
+struct HostServiceState {
+ bool _is_host;
+ time_t _time;
+ int _lineno;
+ time_t _from;
+ time_t _until;
+
+ time_t _duration;
+ double _duration_part;
+
+ // Do not change order within this block!
+ // These durations will be bzero'd
+ time_t _duration_state_UNMONITORED;
+ double _duration_part_UNMONITORED;
+ time_t _duration_state_OK;
+ double _duration_part_OK;
+ time_t _duration_state_WARNING;
+ double _duration_part_WARNING;
+ time_t _duration_state_CRITICAL;
+ double _duration_part_CRITICAL;
+ time_t _duration_state_UNKNOWN;
+ double _duration_part_UNKNOWN;
+
+ // State information
+ int _host_down; // used if service
+ int _state; // -1/0/1/2/3
+ int _in_notification_period;
+ int _in_service_period;
+ int _in_downtime;
+ int _in_host_downtime;
+ int _is_flapping;
+
+ // Service information
+ HostServices _services;
+
+ // Absent state handling
+ bool _may_no_longer_exist;
+ bool _has_vanished;
+ time_t _last_known_time;
+
+
+ const char *_debug_info;
+ // Pointer to dynamically allocated strings (strdup) that live here.
+ // These pointers are 0, if there is no output (e.g. downtime)
+ char *_log_output;
+ char *_notification_period; // may be "": -> no period known, we assume "always"
+ char *_service_period; // may be "": -> no period known, we assume "always"
+ host *_host;
+ service *_service;
+ const char *_host_name; // Fallback if host no longer exists
+ const char *_service_description; // Fallback if service no longer exists
+
+ HostServiceState() { bzero(this, sizeof(HostServiceState)); }
+ ~HostServiceState();
+ void computePerStateDurations();
+ void debug_me(const char *loginfo, ...);
+};
+
+#endif // HostServiceState_h