packages: nagios-plugin-check_sphinx/check_sphinx.cfg (NEW), nagios-plugin-...

glen glen at pld-linux.org
Mon Jun 14 21:42:30 CEST 2010


Author: glen                         Date: Mon Jun 14 19:42:30 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- new

---- Files affected:
packages/nagios-plugin-check_sphinx:
   check_sphinx.cfg (NONE -> 1.1)  (NEW), check_sphinx.php (NONE -> 1.1)  (NEW), nagios-plugin-check_sphinx.spec (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/nagios-plugin-check_sphinx/check_sphinx.cfg
diff -u /dev/null packages/nagios-plugin-check_sphinx/check_sphinx.cfg:1.1
--- /dev/null	Mon Jun 14 21:42:30 2010
+++ packages/nagios-plugin-check_sphinx/check_sphinx.cfg	Mon Jun 14 21:42:25 2010
@@ -0,0 +1,6 @@
+# Usage:
+# check_sphinx
+define command {
+	command_name    check_sphinx
+	command_line    /usr/lib/nagios/plugins/check_sphinx -H $HOSTADDRESS$ $ARG1$
+}

================================================================
Index: packages/nagios-plugin-check_sphinx/check_sphinx.php
diff -u /dev/null packages/nagios-plugin-check_sphinx/check_sphinx.php:1.1
--- /dev/null	Mon Jun 14 21:42:31 2010
+++ packages/nagios-plugin-check_sphinx/check_sphinx.php	Mon Jun 14 21:42:25 2010
@@ -0,0 +1,81 @@
+#!/usr/bin/php
+<?php
+/* vim: set encoding=utf-8: */
+/*
+ *  Nagios plugin to check Sphinx search engine status.
+ *  Copyright (C) 2010  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('PROGRAM', basename(array_shift($argv)));
+
+// loads from same dir as program
+require_once 'utils.php';
+
+// No pecl class, try php version
+if (!class_exists('SphinxClient')) {
+	// loads from php include_path
+	require_once 'sphinxapi.php';
+}
+
+function usage() {
+	echo PROGRAM,
+" [-H HOSTNAME] [-p PORT] [-s SEARCHSTRING] [-i INDEXNAME] [-t TIMEOUT]
+";
+	exit(STATE_UNKNOWN);
+}
+
+$default_opt = array(
+	'H' => 'localhost',
+	'p' => 9312,
+	'i' => '*',
+	't' => 10,
+	'd' => null,
+);
+$opt = array_merge($default_opt, getopt("H:p:s:i:t:d"));
+
+if (empty($opt['H']) || empty($opt['s'])) {
+	usage();
+}
+
+$sphinx = new SphinxClient();
+$sphinx->SetServer($opt['H'], $opt['p']);
+#$sphinx->setMatchMode(SPH_MATCH_ANY);
+$sphinx->SetConnectTimeout($opt['t']);
+$sphinx->setMaxQueryTime($opt['t']);
+$res = $sphinx->Query($opt['s'], $opt['i']);
+
+if ($msg = $sphinx->GetLastWarning()) {
+	echo "WARINNG: ", $msg, "\n";
+	exit(STATE_WARNING);
+}
+if ($msg = $sphinx->GetLastError()) {
+	echo "ERROR: ", $msg, "\n";
+	exit(STATE_CRITICAL);
+}
+
+if (isset($opt['d'])) {
+	print_r($res);
+}
+
+if ($res['total']) {
+	printf("OK: Found %d documents in %.3f secs\n", $res['total'], $res['time']);
+	exit(STATE_OK);
+} else {
+	printf("WARNING: Found %d documents in %.3f secs\n", $res['total'], $res['time']);
+	exit(STATE_WARNING);
+}

================================================================
Index: packages/nagios-plugin-check_sphinx/nagios-plugin-check_sphinx.spec
diff -u /dev/null packages/nagios-plugin-check_sphinx/nagios-plugin-check_sphinx.spec:1.1
--- /dev/null	Mon Jun 14 21:42:31 2010
+++ packages/nagios-plugin-check_sphinx/nagios-plugin-check_sphinx.spec	Mon Jun 14 21:42:25 2010
@@ -0,0 +1,46 @@
+# $Revision$, $Date$
+%define		plugin	check_sphinx
+Summary:	Nagios plugin to check Sphinx search engine status
+Name:		nagios-plugin-%{plugin}
+Version:	0.1
+Release:	0.1
+License:	GPL v2+
+Group:		Networking
+Source0:	%{plugin}.php
+Source1:	%{plugin}.cfg
+Requires:	nagios-common
+Requires:	nagios-plugins-libs
+BuildArch:	noarch
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%define		_sysconfdir	/etc/nagios/plugins
+%define		plugindir	%{_prefix}/lib/nagios/plugins
+
+%description
+Nagios plugin to check Sphinx search engine status.
+
+%prep
+%setup -qcT
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{plugindir}}
+install -p %{SOURCE0} $RPM_BUILD_ROOT%{plugindir}/%{plugin}
+cp -a %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/%{plugin}.cfg
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{plugin}.cfg
+%attr(755,root,root) %{plugindir}/%{plugin}
+
+%define date	%(echo `LC_ALL="C" date +"%a %b %d %Y"`)
+%changelog
+* %{date} PLD Team <feedback at pld-linux.org>
+All persons listed below can be reached at <cvs_login>@pld-linux.org
+
+$Log$
+Revision 1.1  2010/06/14 19:42:25  glen
+- new
================================================================


More information about the pld-cvs-commit mailing list