[packages/nagios-plugin-check_elvis_status: 2/2] initial version
glen
glen at pld-linux.org
Fri Feb 15 13:06:02 CET 2013
commit 1a02d719e4585c3647c260825d8c2a662c77469e
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Fri Feb 15 13:58:35 2013 +0200
initial version
check_elvis_status | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++
check_elvis_status.cfg | 20 +++++++++++
2 files changed, 111 insertions(+)
---
diff --git a/check_elvis_status b/check_elvis_status
new file mode 100755
index 0000000..41647f2
--- /dev/null
+++ b/check_elvis_status
@@ -0,0 +1,91 @@
+#!/usr/bin/php
+<?php
+/* vim: set encoding=utf-8: */
+/*
+ * Nagios plugin to check Elvis DAM server-status json
+ * Copyright (C) 2012 Elan Ruusamäe <glen at delfi.ee>
+ *
+ * This program 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, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @(#) $Id$
+ */
+
+define('PROGNAME', basename(array_shift($argv)));
+define('LABEL', strtoupper(str_replace('check_', '', PROGNAME)));
+
+// loads from same dir as program
+require_once 'utils.php';
+
+function usage() {
+ global $default_opt;
+ $opt = $default_opt;
+ echo "Usage: ", PROGNAME, " [OPTION]...
+
+Check Elvis DAM server-status data
+Example: ", PROGNAME ,"
+
+Plugin action specific options:
+ -u URL to Elvis DAM /server-status. Sample: http://USERNAME:PASSWORD@HOSTNAME/dam/controller/admin/server-status
+ -m Message what you are querying
+ -e Expression what to retrieve from json data. this must be valid PHP Expression
+ -w The warning range. default '{$opt['w']}'
+ -c The critical range. default '{$opt['c']}'
+";
+ exit(STATE_UNKNOWN);
+}
+
+$default_opt = array(
+ 'u' => '',
+ 'm' => '',
+ 'e' => null,
+ 'w' => 0,
+ 'c' => 0,
+);
+$opt = array_merge($default_opt, getopt("u:e:m:w:c:"));
+
+if (empty($opt['u']) || !isset($opt['e'])) {
+ usage();
+}
+
+$data = file_get_contents($opt['u']);
+if ($data === false) {
+ echo "ERROR: Can't fetch '{$opt['u']}'\n";
+ exit(STATE_CRITICAL);
+}
+
+$json = json_decode($data);
+if ($json === null) {
+ echo "ERROR: Can't parse json\n";
+ exit(STATE_CRITICAL);
+}
+
+$eval = 'return $json' . $opt['e'] .';';
+$res = eval($eval);
+
+if ($res === null) {
+ echo LABEL, ": ERROR: {$opt['m']}: Unexpected null\n";
+ exit(STATE_UNKNOWN);
+} elseif ($res === false) {
+ echo LABEL, ": ERROR: {$opt['m']}: parse error: {$opt['e']}\n";
+ exit(STATE_UNKNOWN);
+} elseif ($res > $opt['c']) {
+ echo LABEL, ": CRITICAL: {$opt['m']}: $res\n";
+ exit(STATE_CRITICAL);
+} elseif ($res > $opt['w']) {
+ echo LABEL, ": WARNING: {$opt['m']}: $res\n";
+ exit(STATE_WARNING);
+} else {
+ echo LABEL, ": OK: {$opt['m']}: $res\n";
+ exit(STATE_OK);
+}
diff --git a/check_elvis_status.cfg b/check_elvis_status.cfg
new file mode 100644
index 0000000..344bd19
--- /dev/null
+++ b/check_elvis_status.cfg
@@ -0,0 +1,20 @@
+# Usage:
+# check_elvis_status
+define command {
+ command_name check_elvis_status
+ command_line /usr/lib/nagios/plugins/check_elvis_status $ARG1$
+}
+
+define service {
+ use generic-service
+ name elvis_status
+ service_description elvis_status
+ register 0
+
+ normal_check_interval 5
+ retry_check_interval 1
+
+ notification_interval 10
+
+ check_command check_elvis_status
+}
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/nagios-plugin-check_elvis_status.git/commitdiff/1a02d719e4585c3647c260825d8c2a662c77469e
More information about the pld-cvs-commit
mailing list