Module: check_mk
Branch: master
Commit: 004791e564d909bd05d4ba18ab4c7577b9d11708
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=004791e564d909…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Dec 15 11:51:01 2016 +0100
4141 FIX Fixed possible exception in web cron: argument of type 'NoneType' is not iterable (g_host_attribute)
Change-Id: Ieb9b9e9b8219983097aa3316ce7e116e97e3524e
---
.werks/4141 | 9 +++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 16 ++++++++--------
web/htdocs/watolib.py | 30 ++++++++++++++++++++----------
4 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/.werks/4141 b/.werks/4141
new file mode 100644
index 0000000..56188ec
--- /dev/null
+++ b/.werks/4141
@@ -0,0 +1,9 @@
+Title: Fixed possible exception in web cron: argument of type 'NoneType' is not iterable (g_host_attribute)
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.4.0i3
+Date: 1481799024
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 79fe8bb..62ba1e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -129,6 +129,7 @@
* 4133 FIX: Do not suppress site specific global issues during WATO activation
* 4134 FIX: Unified ineffective rulesets view with other ruleset list views
* 3999 FIX: Added core restart note to bulk host rename page
+ * 4141 FIX: Fixed possible exception in web cron: argument of type 'NoneType' is not iterable (g_host_attribute)
* 4150 FIX: Avoid exception in host search when searching for empty texts
Notifications:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 5cbadf4..65a374a 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -14447,7 +14447,7 @@ def save_changed_custom_attrs(all_attrs, what):
def declare_custom_host_attrs():
# First remove all previously registered custom host attributes
- for attr_name in g_host_attribute.keys():
+ for attr_name in all_host_attribute_names():
if attr_name not in builtin_host_attribute_names and not\
attr_name.startswith("tag_"):
undeclare_host_attribute(attr_name)
@@ -16350,14 +16350,13 @@ loaded_with_language = False
def load_plugins(force):
global builtin_host_attribute_names
- # Do not cache the custom attributes. They can be created by the user
- # during runtime, means they need to be loaded during each page request.
- # But delete the old definitions before to also apply removals of attributes
- if builtin_host_attribute_names:
- declare_custom_host_attrs()
-
global loaded_with_language
if loaded_with_language == current_language and not force:
+ # Do not cache the custom attributes. They can be created by the user
+ # during runtime, means they need to be loaded during each page request.
+ # But delete the old definitions before to also apply removals of attributes
+ if builtin_host_attribute_names:
+ declare_custom_host_attrs()
return
# Reset global vars
@@ -16365,6 +16364,7 @@ def load_plugins(force):
extra_buttons = []
modules = []
+ initialize_host_attribute_structures()
undeclare_all_host_attributes()
load_notification_table()
initialize_global_configvars()
@@ -16620,7 +16620,7 @@ def load_plugins(force):
declare_host_tag_attributes(force = True)
- builtin_host_attribute_names = g_host_attribute.keys()
+ builtin_host_attribute_names = all_host_attribute_names()
declare_custom_host_attrs()
# This must be set after plugin loading to make broken plugins raise
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index a41460c..f47438a 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -65,9 +65,11 @@ replication_paths = []
backup_paths = []
backup_domains = {}
automation_commands = {}
+g_rulespecs = None
def initialize_before_loading_plugins():
- g_rulespecs.clear()
+ if g_rulespecs:
+ g_rulespecs.clear()
# Directories and files to synchronize during replication
global replication_paths
@@ -2918,16 +2920,20 @@ class ContactGroupsAttribute(Attribute):
return True
-# Global datastructure holding all attributes (in a defined order)
-# as pairs of (attr, topic). Topic is the title under which the
-# attribute is being displayed. All builtin attributes use the
-# topic None. As long as only one topic is used, no topics will
-# be displayed. They are useful if you have a great number of
-# custom attributes.
-g_host_attributes = []
+def initialize_host_attribute_structures():
+ global g_host_attributes, g_host_attribute
+
+ # Global datastructure holding all attributes (in a defined order)
+ # as pairs of (attr, topic). Topic is the title under which the
+ # attribute is being displayed. All builtin attributes use the
+ # topic None. As long as only one topic is used, no topics will
+ # be displayed. They are useful if you have a great number of
+ # custom attributes.
+ g_host_attributes = []
+
+ # Dictionary for quick access
+ g_host_attribute = {}
-# Dictionary for quick access
-g_host_attribute = {}
# Declare attributes with this method
def declare_host_attribute(a, show_in_table = True, show_in_folder = True, show_in_host_search = True,
@@ -2971,6 +2977,10 @@ def all_host_attributes():
return g_host_attributes
+def all_host_attribute_names():
+ return g_host_attribute.keys()
+
+
def host_attribute(name):
return g_host_attribute[name]
Module: check_mk
Branch: master
Commit: 3aa7f5a88b3541fb36fd807f040a4a24f724e778
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3aa7f5a88b3541…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Dec 16 15:57:07 2016 +0100
4104 veeam_tapejobs: New check to monitor Veeam tape jobs
Change-Id: I854c999570ac2772eea8cc0893dbe7e7ba5bc9ac
---
.werks/4104 | 9 ++++
ChangeLog | 1 +
agents/windows/plugins/veeam_backup_status.ps1_ | 13 +++++
checkman/veeam_tapejobs | 19 ++++++++
checks/veeam_tapejobs | 65 +++++++++++++++++++++++++
5 files changed, 107 insertions(+)
diff --git a/.werks/4104 b/.werks/4104
new file mode 100644
index 0000000..cc3317e
--- /dev/null
+++ b/.werks/4104
@@ -0,0 +1,9 @@
+Title: veeam_tapejobs: New check to monitor Veeam tape jobs
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i3
+Date: 1481900204
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 68736f9..7734834 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,7 @@
* 4110 netscaler_vserver: now lower levels for health are configurable
* 4098 ups_cps_battery, ups_cps_battery.temp, ups_cps_inphase, ups_cps_outphase: Several checks to monitor CPS UPS devices
* 4118 check_bi_aggr: changed check and WATO rule to support Kerberos auth...
+ * 4104 veeam_tapejobs: New check to monitor Veeam tape jobs
* 3987 FIX: Check_MK Agent Access: Windows agent reported incorrect only from value
* 3952 FIX: diskstat: fixed bug if multipath devices having an alias...
* 3939 FIX: f5_bigip_conns: readded performance data and graphs...
diff --git a/agents/windows/plugins/veeam_backup_status.ps1_ b/agents/windows/plugins/veeam_backup_status.ps1_
index 7fd893b..88df1f5 100644
--- a/agents/windows/plugins/veeam_backup_status.ps1_
+++ b/agents/windows/plugins/veeam_backup_status.ps1_
@@ -22,6 +22,19 @@ Add-PSSnapin VeeamPSSnapIn -ErrorAction SilentlyContinue
try
{
+$tapeJobs = Get-VBRTapeJob
+write-host "<<<veeam_tapejobs>>>"
+write-host "JobName JobID LastResult LastState"
+foreach ($tapeJob in $tapeJobs)
+ {
+ $jobName = $tapeJob.Name
+ $jobID = $tapeJob.Id
+ $lastResult = $tapeJob.LastResult
+ $lastState = $tapeJob.LastState
+ write-host "$jobName $jobID $lastResult $lastState"
+ }
+
+
$myJobsText = "<<<veeam_jobs:sep(9)>>>`n"
$myTaskText = ""
diff --git a/checkman/veeam_tapejobs b/checkman/veeam_tapejobs
new file mode 100644
index 0000000..9fafec6
--- /dev/null
+++ b/checkman/veeam_tapejobs
@@ -0,0 +1,19 @@
+title: Veeam Tape Jobs
+agents: windows
+catalog: os/storage
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the status of the tape jobs run by the Veeam
+ backup tool. In order to carry out the check, the Veeam agent plugin
+ needs to be installed on the backup server. See special instructions in the
+ comment section of the Veeam agent plugin powershell scripts on how to install
+ the scripts.
+
+ This check is {OK} if the last tape job ran successfully and {CRIT} otherwise.
+
+inventory:
+ One check will be created for each tape job run by the Veeam tool.
+
+item:
+ The name of the tape job.
diff --git a/checks/veeam_tapejobs b/checks/veeam_tapejobs
new file mode 100644
index 0000000..0e45e71
--- /dev/null
+++ b/checks/veeam_tapejobs
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2016 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-
+# tails. 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.
+
+def parse_veeam_tapejobs(info):
+ parsed = {}
+ columns = map(lambda s: s.lower(), info[0])
+
+ for line in info[1:]:
+ name = " ".join( line[:-(len(columns)-1)] )
+ job_id, last_result, last_state = line[-(len(columns)-1):]
+ parsed[name] = {
+ "job_id" : job_id,
+ "last_result" : last_result,
+ "last_state" : last_state,
+ }
+
+ return parsed
+
+
+def inventory_veeam_tapejobs(parsed):
+ for job in parsed:
+ yield job, None
+
+
+def check_veeam_tapejobs(item, _no_params, parsed):
+ last_result = parsed[item]["last_result"]
+ last_state = parsed[item]["last_state"]
+
+ if last_result == "Success":
+ yield 0, "Last backup successful"
+ else:
+ yield 2, "Last backup result: " + last_result
+
+ yield 0, "Last state: " + last_state
+
+
+check_info["veeam_tapejobs"] = {
+ 'parse_function' : parse_veeam_tapejobs,
+ 'inventory_function' : inventory_veeam_tapejobs,
+ 'check_function' : check_veeam_tapejobs,
+ 'service_description' : 'VEEAM Tape Job %s',
+}