[packages/nagios-plugin-check_elvis_status] up to 0.2, use tarball distribution

glen glen at pld-linux.org
Tue May 20 10:42:37 CEST 2014


commit 96ab45c40b20cfda9612eecd50e52712667f5639
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Tue May 20 11:42:07 2014 +0300

    up to 0.2, use tarball distribution

 README.md                             |  53 -------------
 check_elvis_status.cfg                |  20 -----
 check_elvis_status.php                | 138 ----------------------------------
 nagios-plugin-check_elvis_status.spec |  17 ++---
 4 files changed, 6 insertions(+), 222 deletions(-)
---
diff --git a/nagios-plugin-check_elvis_status.spec b/nagios-plugin-check_elvis_status.spec
index 2f29471..a15558b 100644
--- a/nagios-plugin-check_elvis_status.spec
+++ b/nagios-plugin-check_elvis_status.spec
@@ -3,12 +3,12 @@
 %include	/usr/lib/rpm/macros.php
 Summary:	Nagios plugin to check Elvis DAM status
 Name:		nagios-plugin-%{plugin}
-Version:	0.1
-Release:	2
+Version:	0.2
+Release:	1
 License:	GPL v2
 Group:		Networking
-Source0:	%{plugin}.php
-Source1:	%{plugin}.cfg
+Source0:	https://github.com/glensc/nagios-plugin-check_elvis_status/archive/v%{version}/%{plugin}-%{version}.tar.gz
+# Source0-md5:	a0ecef927a2fc9c7c3982c626757586f
 URL:		https://github.com/glensc/nagios-plugin-check_elvis_status
 Requires:	nagios-common
 Requires:	nagios-plugins-libs
@@ -17,9 +17,6 @@ Requires:	php(json)
 BuildArch:	noarch
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
-# for perl plugins:
-%define		_noautoreq	perl(utils)
-
 %define		_sysconfdir	/etc/nagios/plugins
 %define		plugindir	%{_prefix}/lib/nagios/plugins
 
@@ -28,14 +25,12 @@ Nagios plugin to check Elvis DAM status via admin /server-status json
 data.
 
 %prep
-%setup -qcT
-cp -p %{SOURCE0} %{plugin}
-cp -p %{SOURCE1} .
+%setup -q
 
 %install
 rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{plugindir}}
-install -p %{plugin} $RPM_BUILD_ROOT%{plugindir}/%{plugin}
+install -p %{plugin}.php $RPM_BUILD_ROOT%{plugindir}/%{plugin}
 cp -p %{plugin}.cfg $RPM_BUILD_ROOT%{_sysconfdir}/%{plugin}.cfg
 
 %clean
diff --git a/README.md b/README.md
deleted file mode 100644
index 72e246b..0000000
--- a/README.md
+++ /dev/null
@@ -1,53 +0,0 @@
-Nagios plugin: check_elvis_status
-=================================
-
-Check [Elvis DAM](http://www.elvisdam.com/) status via admin /server-status json data.
-
-This plugins allows you monitor number and boolean values from server-status json (specified with `-u` option).
-Numbers may be expressed with size qualifiers (TB, GB, MB).
-
-It expression is taken via `-e` option, the warning and critical tresholds are configurable with `-w` and `-c` 
-options respectively. Additionally `-i` option allows you inverse the comparision logic.
-
-Requires: php 5.2, [php-json](http://php.net/json) (if using php < 5.2, use [json pecl](http://pecl.php.net/package/json))
-
-Examples
-========
-  
-Check for API Operations count:
-
-    ./check_elvis_status -u elvis.json -e '->securityStatus->apiOperationsToday' -m 'API ops' -w 3000 -c 5000
-    ELVIS_STATUS: CRITICAL: API ops: 5329
-     
-    ./check_elvis_status -u elvis.json -e '->securityStatus->apiOperationsToday' -m 'API ops' -w 5000 -c 15000
-    ELVIS_STATUS: WARNING: API ops: 5329
-
-    ./check_elvis_status -u elvis.json -e '->securityStatus->apiOperationsToday' -m 'API ops' -w 6000 -c 15000
-    ELVIS_STATUS: OK: API ops: 5329
-
-
-Check processing queue monitoring if >300 warning, if >500 critical
-
-     ./check_elvis_status.php -u elvis.json -e '->mediaStatus->waitingProcessingRequests' -m 'waitingProcessingRequests' -w 300 -c 500
-    ELVIS_STATUS: OK: waitingProcessingRequests: 0
-
-Check if proccessing servers are seen by Elvis:
-
-    ./check_elvis_status.php -u elvis.json -e '->mediaStatus->operationalNodes' -m operationalNodes -v -i -c 3 
-    EVAL: return $json->mediaStatus->operationalNodes;
-    ELVIS_STATUS: OK: operationalNodes: 3
-
-Check if Processing Servers are Connected & status ready.  
-This one converts boolean value to integer to be able to make comparision :)
-
-    ./check_elvis_status.php -u elvis.json -e '->mediaStatus->mediaNodesStatus[0]->ready+0' -m 'ready' -c 1 -i
-    ELVIS_STATUS: OK: ready: 1
-    ./check_elvis_status.php -u elvis.json -e '->mediaStatus->mediaNodesStatus[0]->ready+0' -m 'ready' -c 1 -i
-    ELVIS_STATUS: CRITICAL: ready: 0
-    
-If you want the same check to give WARNING instead of CRITICAL, setup warning option instead:
-
-    ./check_elvis_status.php -u elvis.json -e '->mediaStatus->mediaNodesStatus[0]->ready+0' -m 'ready' -w 1 -i
-    ELVIS_STATUS: OK: ready: 1
-    ./check_elvis_status.php -u elvis.json -e '->mediaStatus->mediaNodesStatus[0]->ready+0' -m 'ready' -w 1 -i
-    ELVIS_STATUS: WARNING: ready: 0
diff --git a/check_elvis_status.cfg b/check_elvis_status.cfg
deleted file mode 100644
index 344bd19..0000000
--- a/check_elvis_status.cfg
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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
-}
diff --git a/check_elvis_status.php b/check_elvis_status.php
deleted file mode 100755
index b842238..0000000
--- a/check_elvis_status.php
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/usr/bin/php
-<?php
-/* vim: set encoding=utf-8: */
-/*
- * Nagios plugin to check Elvis DAM server-status json
- * Copyright (C) 2013 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/>.
- */
-
-define('PROGNAME', basename(array_shift($argv), '.php'));
-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
-  -i    Invert expression, critical and warning must be below the tresholds
-  -w    The warning range. default '{$opt['w']}'
-  -c    The critical range. default '{$opt['c']}'
-  -v    Enable verbose mode.
-";
-	exit(STATE_UNKNOWN);
-}
-
-/*
- * based on code from:
- * http://stackoverflow.com/questions/11807115/php-convert-kb-mb-gb-tb-etc-to-bytes
- */
-function byteConvert($input) {
-	if (!preg_match('/^(?P<number>[\d.,]+)\s*(?P<type>\w+B)$/i', $input, $m)) {
-		return $input;
-	}
-
-	// comma is decimal separator. replace it to computer language
-	$number = str_replace(',', '.', $m['number']);
-
-	switch (strtoupper($m['type'])) {
-	case "B":
-		$output = $number;
-		break;
-	case "KB":
-		$output = $number*1024;
-		break;
-	case "MB":
-		$output = $number*1024*1024;
-		break;
-	case "GB":
-		$output = $number*1024*1024*1024;
-		break;
-	case "TB":
-		$output = $number*1024*1024*1024;
-		break;
-	}
-	return $output;
-}
-
-$default_opt = array(
-	'u' => '',
-	'm' => '',
-	'e' => null,
-	'v' => null,
-	'w' => 0,
-	'c' => 0,
-);
-$opt = array_merge($default_opt, getopt("u:e:m:w:c:vi"));
-$invert = isset($opt['i']);
-$verbose = isset($opt['v']);
-$critical = byteConvert($opt['c']);
-$warning = byteConvert($opt['w']);
-
-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'] .';';
-if ($verbose) {
-	echo "EVAL: $eval\n";
-}
-$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);
-}
-
-$value = byteConvert($res);
-if ($verbose) {
-	echo "RES: $res; VALUE: $value; WARNING: $warning; CRITICAL: $critical\n";
-}
-
-if ((!$invert && $value > $critical) || ($invert && $value < $critical))  {
-	echo LABEL, ": CRITICAL: {$opt['m']}: $res\n";
-	exit(STATE_CRITICAL);
-} elseif ((!$invert && $value > $warning) || ($invert && $value < $warning)) {
-	echo LABEL, ": WARNING: {$opt['m']}: $res\n";
-	exit(STATE_WARNING);
-} else {
-	echo LABEL, ": OK: {$opt['m']}: $res\n";
-	exit(STATE_OK);
-}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/nagios-plugin-check_elvis_status.git/commitdiff/96ab45c40b20cfda9612eecd50e52712667f5639



More information about the pld-cvs-commit mailing list