Module: check_mk
Branch: master
Commit: dc3cd6973868e8b1f0948ef3818bb5420a399bec
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dc3cd6973868e8…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Jan 23 13:18:30 2014 +0100
Added files from unitrends backup
---
.werks/125 | 4 +-
agents/plugins/unitrends_backup.php | 64 +++++++++++++++++++++++++++++
checkman/unitrends_backup | 17 ++++++++
checks/unitrends_backup | 76 +++++++++++++++++++++++++++++++++++
4 files changed, 159 insertions(+), 2 deletions(-)
diff --git a/.werks/125 b/.werks/125
index fffd5d6..4b74c0f 100644
--- a/.werks/125
+++ b/.werks/125
@@ -1,4 +1,4 @@
-Title: Unitrends Backup
+Title: unitrends_backup:Unitrends Backup
Level: 1
Component: checks
Version: 1.2.5i1
@@ -6,5 +6,5 @@ Date: 1390467872
Class: feature
Unitrends is a enterprise class backup solution.
-This check kann monitor the Backup schedules from unitrends.
+This check can monitor the Backup schedules from unitrends.
diff --git a/agents/plugins/unitrends_backup.php b/agents/plugins/unitrends_backup.php
new file mode 100755
index 0000000..72ff7ab
--- /dev/null
+++ b/agents/plugins/unitrends_backup.php
@@ -0,0 +1,64 @@
+#!/usr/bin/php
+<?php
+print "<<<unitrends_backup:sep(124)>>>\n";
+$conn = "port=5432 dbname=bpdb user=postgres";
+$db = pg_connect($conn);
+
+$query = "SELECT
+ schedule_id, a.type AS app_type
+ FROM
+ bp.schedules AS s
+ JOIN
+ bp.application_lookup AS a USING(app_id)
+ WHERE
+ enabled=true AND email_report=true
+ ORDER BY s.name";
+$res = pg_query($db, $query);
+
+$start = time() - (24 * 3600);
+$in = array("start_time" => $start);
+bp_bypass_cookie(3, 'schedule_report');
+
+while ($obj = pg_fetch_object($res)) {
+ if ($obj->app_type == "Archive")
+ continue;
+
+ $in["schedule_id"] = (int)$obj->schedule_id;
+ $ret = bp_get_schedule_history($in);
+ if (empty($ret[0]["backups"]))
+ continue;
+
+ print "HEADER|".
+ $ret[0]["schedule_name"]."|" .
+ $ret[0]["application_name"]."|".
+ $ret[0]["schedule_description"]."|".
+ $ret[0]["failures"]."\n";
+
+ foreach($ret[0]["backups"] as $trash => $backup) {
+ foreach($backup as $row) {
+
+ $name = $row["primary_name"];
+ switch($ret[0]["app_type"]){
+ case "SQL Server":
+ $name .= "/".$row["secondary_name"];
+ break;
+
+ case "VMware":
+ $name .= ", VM ".$row["secondary_name"];
+ break;
+ }
+
+ $backup_type = $row["type"];
+
+ if (!isset($name))
+ $name = $backup_tyoe;
+
+ $backup_no = (isset($row["backup_id"])) ?
$row["backup_id"] : "N/A" ;
+
+ print
"$name|$backup_no|$backup_type|".$row['description']."\n";
+ }
+ }
+}
+pg_free_result($res);
+bp_destroy_cookie();
+?>
diff --git a/checkman/unitrends_backup b/checkman/unitrends_backup
new file mode 100644
index 0000000..d8787c7
--- /dev/null
+++ b/checkman/unitrends_backup
@@ -0,0 +1,17 @@
+title: Unitrends Backup Schedule
+agents: linux
+catalog: app/unitrends
+license: GPL
+distribution: check_mk
+description:
+ Unitrends is a enterprise class backup solution.
+ This plugin needs the unitrends_backup plugin installed on the unitrends server
+ in order to work. The plugin will deliver a complete list of all schedules including
+ a sublist of a jobs in this schdule from the last 24 hours.
+
+ As long all of the jobs are succsessful the check returns a {OK} state. In each other
+ case the check will return {CRITICAL}. In anycase it's possible to see the complete
+ log in the long plugin output field from the core.
+
+inventory:
+ One Service for each Schedule will be created
diff --git a/checks/unitrends_backup b/checks/unitrends_backup
new file mode 100644
index 0000000..1a61f53
--- /dev/null
+++ b/checks/unitrends_backup
@@ -0,0 +1,76 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | 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.
+
+# Header: Schedule Name, Application Name, Schedule Description, Failures
+#<<<unitrends_backup:sep(124)>>>
+#HEADER|DMZ-SR01|Hyper-V 2012|DMZ-HV01|0
+#rodc2|18761|Incremental|Successful
+#rodc2|18761|Incremental|Successful
+#owncloud-test|18762|Incremental|Successful
+
+
+def inventory_unitrends_backup(info):
+ inventory = []
+ for line in info:
+ if line[0] == "HEADER":
+ inventory.append( (line[1], None) )
+ return inventory
+
+def check_unitrends_backup(item, _no_params, info):
+ found = False
+ details = []
+ for line in info:
+ if line[0] == "HEADER" and found:
+ # We are finish collection detail informatoinen
+ break
+
+ if found == True:
+ # Collection Backup deatils
+ app_type, bid, backup_type, status = line
+ details.append("Application Type: %s (%s), %s: %s" % \
+ ( app_type, bid, backup_type, status))
+ continue
+
+ if line[0] == "HEADER" and line[1] == item:
+ found = True
+ head, sched_name, app_name, sched_desc, failures = line
+ message = "%s Errors in last 24/h for Application %s (%s) " % \
+ ( failures, app_name, sched_desc )
+
+ if found == True:
+ message += "\n" + "\n".join(details)
+ if failures == '0':
+ return 0, message
+ else:
+ return 2, message
+ return 3, "Schedule not found in Agent Output"
+
+check_info["unitrends_backup"] = {
+ "check_function" : check_unitrends_backup,
+ "inventory_function" : inventory_unitrends_backup,
+ "service_description" : "Schedule %s",
+}
+