Module: check_mk
Branch: master
Commit: f3d1a82acfb348843e60aadc715e0eeb2af5d3b9
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f3d1a82acfb348…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon May 18 15:33:03 2015 +0200
mk_oracle.aix: fix cache age computation, output cache meta information
---
agents/plugins/mk_oracle.aix | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/agents/plugins/mk_oracle.aix b/agents/plugins/mk_oracle.aix
index cd2389d..fb1a1f6 100755
--- a/agents/plugins/mk_oracle.aix
+++ b/agents/plugins/mk_oracle.aix
@@ -948,8 +948,8 @@ export -f sqlplus_internal
export -f do_async_checks
export -f set_oraenv
-function file_age() {
- /usr/bin/perl -e 'if (! -f $ARGV[0]){die "0000000"};$mtime=(stat($ARGV[0]))[9];print ($^T-$mtime);' "$1"
+function file_mtime() {
+ /usr/bin/perl -e 'if (! -f $ARGV[0]){die "0000000"};$mtime=(stat($ARGV[0]))[9];print ($mtime);' "$1"
}
function run_cached_local () {
@@ -967,7 +967,7 @@ function run_cached_local () {
# nothing if the age (access time) of $CACHEFILE.new is twice the MAXAGE
local NOW=$(date +%s)
if [ -e "$CACHEFILE.new" ] ; then
- CF_ATIME=$(file_age "$CACHEFILE.new")
+ CF_ATIME=$(file_mtime "$CACHEFILE.new")
if [ $((NOW - CF_ATIME)) -ge $((MAXAGE * 2)) ] ; then
# Kill the process still accessing that file in case
# it is still running. This avoids overlapping processes!
@@ -979,11 +979,11 @@ function run_cached_local () {
# Check if cache file exists and is recent enough
if [ -s "$CACHEFILE" ] ; then
- MTIME=$(file_age "$CACHEFILE")
+ MTIME=$(file_mtime "$CACHEFILE")
if [ $((NOW - MTIME)) -le $MAXAGE ] ; then local USE_CACHEFILE=1 ; fi
# Output the file in any case, even if it is
# outdated. The new file will not yet be available
- cat "$CACHEFILE"
+ sed "/^<<</s/>>>$/:cached($MTIME,$MAXAGE)>>>/" "$CACHEFILE"
fi
# Cache file outdated and new job not yet running? Start it
Module: check_mk
Branch: master
Commit: ac3ae91d9c47f972ab691347545966ae4e669b4a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ac3ae91d9c47f9…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon May 18 10:01:08 2015 +0200
#2229 Do not fail on non-existing Livestatus columns any longer, output None or null instead
When you ask for a column that does not exist in your Livestatus version, now this is not
considered as a fatal error any longer but just being logged as a warning. Instead
an empty string (CSV), <tt>None</tt> (Python) or <tt>null</tt> (JSON) is being returned.
This makes it easier for GUIs to maintain compatibility with existing Livestatus version
when new features are implemented that make use of new Livestatus columns.
---
.werks/2229 | 13 +++++++++++++
ChangeLog | 1 +
livestatus/src/Column.h | 1 +
livestatus/src/Makefile.am | 2 +-
livestatus/src/NullColumn.cc | 31 +++++++++++++++++++++++++++++++
livestatus/src/NullColumn.h | 41 +++++++++++++++++++++++++++++++++++++++++
livestatus/src/Query.cc | 34 +++++++++++++++++++++-------------
livestatus/src/Query.h | 1 +
8 files changed, 110 insertions(+), 14 deletions(-)
diff --git a/.werks/2229 b/.werks/2229
new file mode 100644
index 0000000..9546287
--- /dev/null
+++ b/.werks/2229
@@ -0,0 +1,13 @@
+Title: Do not fail on non-existing Livestatus columns any longer, output None or null instead
+Level: 1
+Component: livestatus
+Compatible: compat
+Version: 1.2.7i1
+Date: 1431935942
+Class: feature
+
+When you ask for a column that does not exist in your Livestatus version, now this is not
+considered as a fatal error any longer but just being logged as a warning. Instead
+an empty string (CSV), <tt>None</tt> (Python) or <tt>null</tt> (JSON) is being returned.
+This makes it easier for GUIs to maintain compatibility with existing Livestatus version
+when new features are implemented that make use of new Livestatus columns.
diff --git a/ChangeLog b/ChangeLog
index 598dc78..0ff2f45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -549,6 +549,7 @@
* 2151 FIX: Fixed wrong time in events when forwarding logwatch to EC between timezones...
Livestatus:
+ * 2229 Do not fail on non-existing Livestatus columns any longer, output None or null instead...
* 2208 FIX: Add missing Livestatus column service_period...
HW/SW-Inventory:
diff --git a/livestatus/src/Column.h b/livestatus/src/Column.h
index 036cd98..1045dd8 100644
--- a/livestatus/src/Column.h
+++ b/livestatus/src/Column.h
@@ -38,6 +38,7 @@ using namespace std;
#define COLTYPE_TIME 4
#define COLTYPE_DICT 5
#define COLTYPE_BLOB 6
+#define COLTYPE_NULL 7
class Filter;
class Query;
diff --git a/livestatus/src/Makefile.am b/livestatus/src/Makefile.am
index 151a34c..660769b 100644
--- a/livestatus/src/Makefile.am
+++ b/livestatus/src/Makefile.am
@@ -31,7 +31,7 @@ pkglib_LIBRARIES = livestatus.so
livestatus_so_SOURCES = \
AndingFilter.cc ClientQueue.cc Column.cc ColumnsColumn.cc CustomVarsExplicitColumn.cc \
ContactsColumn.cc CustomVarsColumn.cc CustomVarsFilter.cc DoubleColumn.cc \
- DoubleColumnFilter.cc DowntimeOrComment.cc DownCommColumn.cc EmptyColumn.cc \
+ DoubleColumnFilter.cc DowntimeOrComment.cc DownCommColumn.cc EmptyColumn.cc NullColumn.cc \
Filter.cc GlobalCountersColumn.cc HostContactsColumn.cc HostgroupsColumn.cc \
HostlistColumn.cc HostlistColumnFilter.cc HostlistStateColumn.cc MetricsColumn.cc \
HostSpecialIntColumn.cc ServiceSpecialIntColumn.cc InputBuffer.cc IntColumn.cc IntColumnFilter.cc \
diff --git a/livestatus/src/NullColumn.cc b/livestatus/src/NullColumn.cc
new file mode 100644
index 0000000..a439e2b
--- /dev/null
+++ b/livestatus/src/NullColumn.cc
@@ -0,0 +1,31 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2014 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 "NullColumn.h"
+#include "Query.h"
+
+void NullColumn::output(void *data __attribute__ ((__unused__)), Query *query)
+{
+ query->outputNull();
+}
diff --git a/livestatus/src/NullColumn.h b/livestatus/src/NullColumn.h
new file mode 100644
index 0000000..6e7add1
--- /dev/null
+++ b/livestatus/src/NullColumn.h
@@ -0,0 +1,41 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2014 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 NullColumn_h
+#define NullColumn_h
+
+#include "config.h"
+
+#include "Column.h"
+
+class NullColumn : public Column
+{
+public:
+ NullColumn(string name, string description) :
+ Column(name, description, -1) {}
+ int type() { return COLTYPE_NULL; }
+ void output(void *data, Query *);
+};
+
+#endif // NullColumn_h
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index 77fde0c..8bb3b93 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -36,7 +36,7 @@
#include "Query.h"
#include "Filter.h"
#include "Column.h"
-#include "EmptyColumn.h"
+#include "NullColumn.h"
#include "OutputBuffer.h"
#include "InputBuffer.h"
#include "StatsColumn.h"
@@ -199,7 +199,7 @@ Query::~Query()
Column *Query::createDummyColumn(const char *name)
{
- Column *col = new EmptyColumn(name, "Dummy column");
+ Column *col = new NullColumn(name, "Non existing column");
_dummy_columns.push_back(col);
return col;
}
@@ -543,8 +543,12 @@ void Query::parseColumnsLine(char *line)
if (column)
_columns.push_back(column);
else {
- _output->setError(RESPONSE_CODE_INVALID_HEADER,
- "Table '%s' has no column '%s'", _table->name(), column_name);
+ logger(LOG_WARNING, "Replacing non-existing column '%s' with null column", column_name);
+ // Do not fail any longer. We might want to make this configurable.
+ // But not failing has the advantage that an updated GUI, that expects new columns,
+ // will be able to keep compatibility with older Livestatus versions.
+ // _output->setError(RESPONSE_CODE_INVALID_HEADER,
+ // "Table '%s' has no column '%s'", _table->name(), column_name);
Column *col = createDummyColumn(column_name);
_columns.push_back(col);
}
@@ -1052,15 +1056,8 @@ void Query::outputCounter(counter_t value)
void Query::outputDouble(double value)
{
- if (isnan(value)) {
- if (_output_format == OUTPUT_FORMAT_CSV) {
- // output empty cell
- }
- else if (_output_format == OUTPUT_FORMAT_PYTHON)
- _output->addBuffer("None", 4);
- else
- _output->addBuffer("null", 4); // JSON
- }
+ if (isnan(value))
+ outputNull();
else {
char buf[64];
int l = snprintf(buf, sizeof(buf), "%.10e", value);
@@ -1068,6 +1065,17 @@ void Query::outputDouble(double value)
}
}
+void Query::outputNull()
+{
+ if (_output_format == OUTPUT_FORMAT_CSV) {
+ // output empty cell
+ }
+ else if (_output_format == OUTPUT_FORMAT_PYTHON)
+ _output->addBuffer("None", 4);
+ else
+ _output->addBuffer("null", 4); // JSON
+}
+
void Query::outputAsciiEscape(char value)
{
char buf[8];
diff --git a/livestatus/src/Query.h b/livestatus/src/Query.h
index 752a859..a15bd6b 100644
--- a/livestatus/src/Query.h
+++ b/livestatus/src/Query.h
@@ -115,6 +115,7 @@ public:
void outputUnsignedLong(unsigned long);
void outputCounter(counter_t);
void outputDouble(double);
+ void outputNull();
void outputAsciiEscape(char value);
void outputUnicodeEscape(unsigned value);
void outputString(const char *, int size=-1);
Module: check_mk
Branch: master
Commit: 97808d280054fa3ff26ec4264758d9971ab9253b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=97808d280054fa…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 15 15:09:55 2015 +0200
Fixed handling of duplicate oids in case of using SNMPv3 contextes
---
modules/snmp.py | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/modules/snmp.py b/modules/snmp.py
index c312e63..79ccbc8 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -154,6 +154,7 @@ def get_snmp_table(hostname, ip, check_type, oid_info):
if opt_use_snmp_walk or is_usewalk_host(hostname):
rowinfo = get_stored_snmpwalk(hostname, fetchoid)
else:
+ added_oids = set([])
rowinfo = []
if is_snmpv3_host(hostname):
snmp_contexts = snmpv3_contexts_of(hostname, check_type)
@@ -162,18 +163,25 @@ def get_snmp_table(hostname, ip, check_type, oid_info):
for context_name in snmp_contexts:
if has_inline_snmp and use_inline_snmp:
- rowinfo += inline_snmpwalk_on_suboid(hostname, check_type, fetchoid, oid,
+ rows = inline_snmpwalk_on_suboid(hostname, check_type, fetchoid, oid,
context_name=context_name)
else:
- rowinfo += snmpwalk_on_suboid(hostname, ip, fetchoid, context_name=context_name)
-
- # I've seen a broken device (Mikrotik Router), that broke after an
- # update to RouterOS v6.22. It would return 9 time the same OID when
- # .1.3.6.1.2.1.1.1.0 was being walked. We try to detect these situations
- # by removing any duplicate OID information
- if len(rowinfo) > 1 and rowinfo[0][0] == rowinfo[1][0]:
- vverbose("Detected broken SNMP agent. Ignoring duplicate OID %s.\n" % rowinfo[0][0])
- rowinfo = rowinfo[:1]
+ rows = snmpwalk_on_suboid(hostname, ip, fetchoid, context_name=context_name)
+
+ # I've seen a broken device (Mikrotik Router), that broke after an
+ # update to RouterOS v6.22. It would return 9 time the same OID when
+ # .1.3.6.1.2.1.1.1.0 was being walked. We try to detect these situations
+ # by removing any duplicate OID information
+ if len(rows) > 1 and rows[0][0] == rows[1][0]:
+ vverbose("Detected broken SNMP agent. Ignoring duplicate OID %s.\n" % rows[0][0])
+ rows = rows[:1]
+
+ for row_oid, val in rows:
+ if row_oid in added_oids:
+ vverbose("Duplicate OID found: %s (%s)\n" % (row_oid, val))
+ else:
+ rowinfo.append((row_oid, val))
+ added_oids.add(row_oid)
columns.append((fetchoid, rowinfo))
number_rows = len(rowinfo)
@@ -409,7 +417,6 @@ def get_stored_snmpwalk(hostname, oid):
rowinfo = collect_until(current, -1)
rowinfo.reverse()
rowinfo += collect_until(current + 1, 1)
- # import pprint ; pprint.pprint(rowinfo)
if dot_star:
return [ rowinfo[0] ]
cisco_srst_phones, cisco_srst_call_legs edited
Message-ID: <5555e03f.sveqm7vGoZdcSHBq%si(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: c213ab2a35eee77fb8bd4b9ceed0e41d13fdb691
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c213ab2a35eee7…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri May 15 14:01:47 2015 +0200
Manpages of checks cisco_srst_state, cisco_srst_phones, cisco_srst_call_legs edited
---
checkman/cisco_srst_call_legs | 8 ++++----
checkman/cisco_srst_phones | 3 ++-
checkman/cisco_srst_state | 16 +++++-----------
3 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/checkman/cisco_srst_call_legs b/checkman/cisco_srst_call_legs
index 4e888e9..dfa662f 100644
--- a/checkman/cisco_srst_call_legs
+++ b/checkman/cisco_srst_call_legs
@@ -4,13 +4,13 @@ catalog: hw/network/cisco
license: GPL
distribution: check_mk
description:
- This check monitors the amount of participants of a telephony conference using
- an Cisco SRST router.
+ This check monitors the total number of SIP call legs routed through the Cisco
+ device since going active. This Cisco device supports the Cisco Unified SRST feature.
The status is always OK.
perfdata:
- One variable: the amount of the participants of a current
- telephony conference.
+ One variable: the total number of SIP call legs routed through the device since
+ going active.
inventory:
One service is created for each device.
diff --git a/checkman/cisco_srst_phones b/checkman/cisco_srst_phones
index 477da5b..af7e867 100644
--- a/checkman/cisco_srst_phones
+++ b/checkman/cisco_srst_phones
@@ -4,7 +4,8 @@ catalog: hw/network/cisco
license: GPL
distribution: check_mk
description:
- This check monitors the registered phones of an Cisco SRST router.
+ This check monitors the registered phones of a Cisco device which supports
+ the Cisco Unified SRST feature.
The status is always OK.
perfdata:
diff --git a/checkman/cisco_srst_state b/checkman/cisco_srst_state
index c97a55b..e1de5a0 100644
--- a/checkman/cisco_srst_state
+++ b/checkman/cisco_srst_state
@@ -4,18 +4,12 @@ catalog: hw/network/cisco
license: GPL
distribution: check_mk
description:
- This check monitors the status of the SRST mode of a Cisco SRST router:
+ This check monitors the status of the Cisco Unified SRST feature
+ of a Cisco device which supports that feature.
+ There are two possible states: active (OK) or inactive (WARN).
- - active (OK)
- - inactive (WARN)
-
- Moreover the check displays the time since the SRST mode switched
- to active mode. The time format looks like
-
- Wed May 13 15:33:28 2015 (0d 00:47:00)
-
- which means that the conference started 47 minutes ago on wednesday,
- the 13th of May, 2015, at 15:33:28.
+ Moreover the check displays the time (in minutes) since the SRST feature
+ switched to active mode.
inventory:
One service is created for each device.
Module: check_mk
Branch: master
Commit: e5fa46f091b65c3cbea23a195aa54feebab20552
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e5fa46f091b65c…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri May 15 13:21:07 2015 +0200
Manpages of checks cisco_srst_phones and cisco_srst_call_legs edited
---
checkman/cisco_srst_call_legs | 2 +-
checkman/cisco_srst_phones | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/checkman/cisco_srst_call_legs b/checkman/cisco_srst_call_legs
index 1c9a3eb..4e888e9 100644
--- a/checkman/cisco_srst_call_legs
+++ b/checkman/cisco_srst_call_legs
@@ -10,7 +10,7 @@ description:
perfdata:
One variable: the amount of the participants of a current
- telephony conference (int >= 0).
+ telephony conference.
inventory:
One service is created for each device.
diff --git a/checkman/cisco_srst_phones b/checkman/cisco_srst_phones
index 8bc76fb..477da5b 100644
--- a/checkman/cisco_srst_phones
+++ b/checkman/cisco_srst_phones
@@ -8,7 +8,7 @@ description:
The status is always OK.
perfdata:
- One variable: the amount of registered phones (int >= 0).
+ One variable: the amount of registered phones.
inventory:
One service is created for each device.