From 39705d6221627904f458f185151f5eff5f09b684 Mon Sep 17 00:00:00 2001 From: iborodikhin Date: Tue, 24 Jul 2012 12:37:34 +0600 Subject: [PATCH 1/4] Added plugin which shows number of documents in Sphinx index. --- plugins/sphinx/sphindex_ | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 plugins/sphinx/sphindex_ diff --git a/plugins/sphinx/sphindex_ b/plugins/sphinx/sphindex_ new file mode 100755 index 00000000..a2b60441 --- /dev/null +++ b/plugins/sphinx/sphindex_ @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# vim: set fileencoding=utf-8 +# +# Munin plugin to show number of documents in Sphinx index +# +# Copyright Igor Borodikhin +# +# License : GPLv3 +# +# parsed environment variables: +# server: hostname or ip-address of Sphinx server +# port: port number of Sphinx server +# +#%# capabilities=autoconf +#%# family=contrib + +import os, sys, sphinxsearch +progName = sys.argv[0] +indexName = progName[progName.find("_")+1:] + +if len(sys.argv) == 2 and sys.argv[1] == "autoconf": + print "yes" +elif len(sys.argv) == 2 and sys.argv[1] == "config": + print "graph_title Sphinx index %s stats"%indexName + print "graph_vlabel docs count" + print "graph_category search" + + print "documents_count.label Documents count in index" + print "graph_args --base 1000 -l 0" +else: + if "server" in os.environ and os.environ["server"] != None: + server = os.environ["server"] + else: + server = "localhost" + + if "port" in os.environ and os.environ["port"] != None: + try: + port = int(os.environ["port"]) + except ValueError: + port = 9312 + else: + port = 9312 + + client = sphinxsearch.SphinxClient() + client.SetServer(server, port) + result = client.Query("", indexName) + docCount = result["total_found"] + + print "documents_count.value %d"%docCount From 08690fe634aa4c4503e7148c9018c5e5a46e9c51 Mon Sep 17 00:00:00 2001 From: iborodikhin Date: Tue, 24 Jul 2012 14:20:45 +0600 Subject: [PATCH 2/4] Including readme file --- plugins/sphinx/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 plugins/sphinx/README.md diff --git a/plugins/sphinx/README.md b/plugins/sphinx/README.md new file mode 100644 index 00000000..ba2d8fdd --- /dev/null +++ b/plugins/sphinx/README.md @@ -0,0 +1,17 @@ +This plugin shows graphs of numbers of documents in Sphinxsearch indexes. + +## Requirements +This plugin requires pythons sphinxsearch module which can be installed via easy_install. + +## Installation +Copy file to directory /usr/share/munin/pligins/ and create symbolic links for each index you wish to monitor. +For example, if you've got indexex called index1 and index2 create these symlinks: + ln -s /usr/share/munin/plugins/sphindex_ /etc/munin/plugins/sphindex_index1 + ln -s /usr/share/munin/plugins/sphindex_ /etc/munin/plugins/sphindex_index2 + +If you run munin-node at different box than Sphinxsearch you can specify hostname and port options in munin-node.conf: + [sphindex_*] + env.server 10.216.0.141 + env.port 9312 + + From c307f85c1518288860bc62a27a7481a10768f5f5 Mon Sep 17 00:00:00 2001 From: iborodikhin Date: Tue, 24 Jul 2012 15:37:28 +0600 Subject: [PATCH 3/4] Updating README.md to correct syntax --- plugins/sphinx/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/sphinx/README.md b/plugins/sphinx/README.md index ba2d8fdd..7bfec6ea 100644 --- a/plugins/sphinx/README.md +++ b/plugins/sphinx/README.md @@ -6,10 +6,12 @@ This plugin requires pythons sphinxsearch module which can be installed via easy ## Installation Copy file to directory /usr/share/munin/pligins/ and create symbolic links for each index you wish to monitor. For example, if you've got indexex called index1 and index2 create these symlinks: + ln -s /usr/share/munin/plugins/sphindex_ /etc/munin/plugins/sphindex_index1 ln -s /usr/share/munin/plugins/sphindex_ /etc/munin/plugins/sphindex_index2 If you run munin-node at different box than Sphinxsearch you can specify hostname and port options in munin-node.conf: + [sphindex_*] env.server 10.216.0.141 env.port 9312 From 862e559c26d75a08c196dc03cd6e43c4e98a67c6 Mon Sep 17 00:00:00 2001 From: iborodikhin Date: Tue, 24 Jul 2012 21:25:59 +0600 Subject: [PATCH 4/4] Moving usage documentation from README.md to plugin file header --- plugins/sphinx/README.md | 19 ------------------- plugins/sphinx/sphindex_ | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 19 deletions(-) delete mode 100644 plugins/sphinx/README.md diff --git a/plugins/sphinx/README.md b/plugins/sphinx/README.md deleted file mode 100644 index 7bfec6ea..00000000 --- a/plugins/sphinx/README.md +++ /dev/null @@ -1,19 +0,0 @@ -This plugin shows graphs of numbers of documents in Sphinxsearch indexes. - -## Requirements -This plugin requires pythons sphinxsearch module which can be installed via easy_install. - -## Installation -Copy file to directory /usr/share/munin/pligins/ and create symbolic links for each index you wish to monitor. -For example, if you've got indexex called index1 and index2 create these symlinks: - - ln -s /usr/share/munin/plugins/sphindex_ /etc/munin/plugins/sphindex_index1 - ln -s /usr/share/munin/plugins/sphindex_ /etc/munin/plugins/sphindex_index2 - -If you run munin-node at different box than Sphinxsearch you can specify hostname and port options in munin-node.conf: - - [sphindex_*] - env.server 10.216.0.141 - env.port 9312 - - diff --git a/plugins/sphinx/sphindex_ b/plugins/sphinx/sphindex_ index a2b60441..34ed21c3 100755 --- a/plugins/sphinx/sphindex_ +++ b/plugins/sphinx/sphindex_ @@ -12,6 +12,24 @@ # server: hostname or ip-address of Sphinx server # port: port number of Sphinx server # +# This plugin shows graphs of numbers of documents in Sphinxsearch indexes. +# +# ## Requirements +# This plugin requires pythons sphinxsearch module which can be installed via easy_install. +# +# ## Installation +# Copy file to directory /usr/share/munin/pligins/ and create symbolic links for each index you wish to monitor. +# For example, if you've got indexes called index1 and index2 create these symlinks: +# +# ln -s /usr/share/munin/plugins/sphindex_ /etc/munin/plugins/sphindex_index1 +# ln -s /usr/share/munin/plugins/sphindex_ /etc/munin/plugins/sphindex_index2 +# +# If you run munin-node at different box than Sphinxsearch you can specify hostname and port options in munin-node.conf: +# +# [sphindex_*] +# env.server 10.216.0.141 +# env.port 9312 +# #%# capabilities=autoconf #%# family=contrib