1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

- have some dirs

This commit is contained in:
Steve Schnepp 2012-02-13 18:24:46 +01:00
parent 0b089ea777
commit 08346aac58
687 changed files with 0 additions and 0 deletions

111
plugins/solr/solr Executable file
View file

@ -0,0 +1,111 @@
#!/usr/bin/python
import sys, os
import urllib2
try:
from xml.etree import cElementTree as ET
except ImportError:
try:
import cElementTree as ET
except ImportError:
sys.exit(1)
SOLR_PORT=8389
SOLR_HOST="localhost"
# Parameters:
#
# config (required)
# autoconf (optional - used by munin-config)
#
# Magic markers (Used by munin-config and some installation scripts.
# Optional):
# author: Tarjei Huse (tarjei - at - kraken.no)
#
#%# family=auto
#%# capabilities=autoconf
def parseArgs():
"Parses the name of the file "
parts = sys.argv[0].split("_")
params = {
'cores' : [core1],
'valueName' : "avgTimePerRequest"
}
if len(parts) == 1:
return params
params['valueName'] = parts[1]
if len(parts) < 3:
return params
params['cores'] = parts[2:]
return params
def printGraphdef(name, label, info, _min, _max, _type):
print "%s.label %s" % (name, label)
# print "%s.info %s" % (name, info)
print "%s.max %d" % (name, _max)
print "%s.min %d" % (name, _min)
print "%s.type %s" % (name, _type)
def fetchUrl(core):
if ("URL" in os.environ):
URL=os.environ['URL']
else:
URL="http://%s:%d/%s/admin/stats.jsp"
response = urllib2.urlopen(URL % (SOLR_HOST, SOLR_PORT, core))
return parse(response)
def parse(response):
root = ET.parse(response)
queues = root.findall("/solr-info/QUERYHANDLER/entry")
return queues
def fetchFile():
f = open("/tmp/stats.jsp.html")
return parse(f)
def getEntry(entries, entryName):
for entry in entries:
name = entry.findtext("name").strip()
if (name != entryName):
continue
return entry.find("stats")
def getValue(entry, valueName):
for stat in entry:
if stat.get('name') == valueName:
return stat.text
#print "Could not find %s for entry" % valueName
return 0
if len(sys.argv) > 1:
if sys.argv[1]== "autoconf":
# check connection
sys.exit(0)
elif sys.argv[1] == "config":
params = parseArgs()
print 'graph_title Solr %s' % params['valueName']
print 'graph_args -l 0 '
print 'graph_vlabel Size %s' % params['valueName']
print 'graph_category Solr'
print 'graph_info Info for cores: %s' % ( ",".join(params['cores']))
for core in params['cores']:
#print core, params['valueName']
print "%s-%s.label %s-%s" % (core, params['valueName'], params['valueName'], core)
print "%s-%s.type GAUGE" % (core, params['valueName'])
print "%s-%s.min 0" % (core, params['valueName'])
sys.exit(0)
params = parseArgs()
for core in params['cores']:
#print core, params['valueName']
queues = fetchUrl(core)
searcher = getEntry(queues, "org.apache.solr.handler.StandardRequestHandler")
value = getValue(searcher, params['valueName']).strip()
print "%s-%s.value %s" % (core, params['valueName'], value)
sys.exit(0)

59
plugins/solr/solr-stats Executable file
View file

@ -0,0 +1,59 @@
#!/usr/bin/php
<?php
/**
* SolR Plugin
* author : nicolas.moussikian@shopbot-inc.com
*
* This plugin allows to graph any data present in the stats report on a multi core SolR instance
* AKA : http://127.0.0.1:8080/solr/[name of the core]/admin/stats.jsp
* Verify the server where the munin-node instance is can access that URL
*
* You need to have a PHP 5.2.6+ CLI installed too
*
* Once the plugin is available you can simlink it with the following naming convention :
* solr-[name of the core]-[name of the stats section - ex.: CORE]-[name of the entry in the xml - ex.: searcher]-[name of the stat to graph - ex.: numDocs]
*/
$action = empty($argv[1]) ? '' : $argv[1];
$tabParams = explode('-', $argv[0]);
$core = $tabParams[1];
$category = $tabParams[2];
$item = $tabParams[3];
$property = $tabParams[4];
if('config' === $action)
{
echo 'graph_category SolR ' . $core . "\n";
echo 'graph_title ' . $item . ' ' . $property . "\n";
echo 'graph_vlabel ' . $property . "\n";
echo $core . $item . $property . 'solr.label ' . $property . "\n";
}
else
{
$file = 'http://127.0.0.1:8080/solr/' . $core . '/admin/stats.jsp';
$doc = new DOMDocument('1.0', 'utf-8');
$doc->load($file);
$xpath = new DOMXpath($doc);
$elements = $xpath->query('/solr/solr-info/' . $category . '/entry');
foreach($elements as $element)
{
if($item == trim($element->getElementsByTagName('name')->item(0)->textContent))
{
$stats = $element->getElementsByTagName('stat');
foreach($stats as $stat)
{
if($property == trim($stat->getAttribute('name')))
{
echo $core . $item . $property . 'solr.value ' . floatval(trim($stat->textContent)) . "\n";
}
}
}
}
}

181
plugins/solr/solrmulticore Executable file
View file

@ -0,0 +1,181 @@
#!/usr/bin/python
#
# Copyright (C) Rodolphe Franceschi
#
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# This plugin monitors a SOLR server configured for multicore by automaticaly
# getting core names from SOLR default page.
#
# Tested on SOLR 1.4.0
#
# Parameters:
# config (required)
# autoconf (optional - used by munin-config)
#
# For the full list of options, refer to PLUGINOPTIONSLIST variable
#
# Example of symlink creation on Debian Lenny
# ln -s /usr/share/munin/plugins/solrmulticore_ /etc/munin/plugins/solrmulticore_avgRequestsPerSecond
#
# Magic markers (Used by munin-config and some installation scripts.
# Optional):
#%# family=auto
#%# capabilities=autoconf
import sys, os
import urllib2
import HTMLParser, urllib
try:
from xml.etree import cElementTree as ET
except ImportError:
try:
import cElementTree as ET
except ImportError:
sys.exit(1)
## GLOBALS
SOLR_PORT = 8983
SOLR_HOST = "localhost"
PLUGINOPTIONSLIST = {
"avgRequestsPerSecond" : { 'xmlpath': '/solr-info/QUERYHANDLER/entry', 'xmlparententryname': 'org.apache.solr.handler.StandardRequestHandler', 'label': 'Average requests per second' },
"avgTimePerRequest" : { 'xmlpath': '/solr-info/QUERYHANDLER/entry', 'xmlparententryname': 'org.apache.solr.handler.StandardRequestHandler', 'label': 'Average time per request' },
"errors" : { 'xmlpath': '/solr-info/QUERYHANDLER/entry', 'xmlparententryname': 'org.apache.solr.handler.StandardRequestHandler', 'label': 'Number of errors' },
"timeouts" : { 'xmlpath': '/solr-info/QUERYHANDLER/entry', 'xmlparententryname': 'org.apache.solr.handler.StandardRequestHandler', 'label': 'Number of timeouts' },
"requests" : { 'xmlpath': '/solr-info/QUERYHANDLER/entry', 'xmlparententryname': 'org.apache.solr.handler.StandardRequestHandler', 'label': 'Total number of requests' },
"numDocs" : { 'xmlpath': '/solr-info/CORE/entry', 'xmlparententryname': 'searcher', 'label': 'Number of documents' },
# "" : { 'xmlpath': '/solr-info/QUERYHANDLER/entry', 'xmlparententryname': 'org.apache.solr.handler.StandardRequestHandler' },
}
# Automatic extraction of core names from SOLR default page if empty array
SOLR_CORES = []
# If you do not want automatic gathering, feel free to put your array manually
#SOLR_CORES = [ "core0", "core1" ]
## FUNCTIONS
def getSolrCoreNameList():
url = "http://%s:%s/solr/" % (SOLR_HOST, SOLR_PORT)
class linkParser(HTMLParser.HTMLParser):
def __init__(self):
HTMLParser.HTMLParser.__init__(self)
self.links = []
def handle_starttag(self, tag, attrs):
if tag=='a':
self.links.append(dict(attrs)['href'])
htmlSource = urllib.urlopen(url).read(200000)
p = linkParser()
p.feed(htmlSource)
# Remove link to . (First one !)
p.links.pop(0)
dealcores = [ ]
for link in p.links:
dealcores.append ( link.split("/")[0] )
return dealcores
def parseArgs():
"Parses the name of the file "
parts = sys.argv[0].split("_")
params = { }
params['valueName'] = parts[1]
# Automatic / Manual Mode for core names
if (len(SOLR_CORES) == 0):
params['cores'] = getSolrCoreNameList()
else:
params['cores'] = SOLR_CORES
params['cores'].sort()
return params
# For multicore / Solr 1.3, URL is like that
def fetchUrl(core, xmlPath):
URL="http://%s:%d/solr/%s/admin/stats.jsp"
URLFULL = URL % (SOLR_HOST, SOLR_PORT, core)
response = urllib2.urlopen(URLFULL)
return parseXmlResponse(response, xmlPath)
def parseXmlResponse(response, xmlPath):
root = ET.parse(response)
queues = root.findall(xmlPath)
return queues
#def fetchFile():
# f = open("/tmp/stats.jsp.html")
# return parseXmlResponse(f)
def getEntry(entries, entryName):
for entry in entries:
name = entry.findtext("name").strip()
if (name != entryName):
continue
return entry.find("stats")
def getValue(entry, valueName):
for stat in entry:
if stat.get('name') == valueName:
return stat.text
#print "Could not find %s for entry" % valueName
return 0
## MAIN
if len(sys.argv) > 1:
if sys.argv[1]== "autoconf":
# check connection
sys.exit(0)
elif sys.argv[1] == "config":
params = parseArgs()
# Extracting Generic graph datas
print 'graph_title %s' % ( PLUGINOPTIONSLIST[params['valueName']]['label'] )
print "graph_args --base 1000";
print 'graph_vlabel Size %s' % params['valueName']
print 'graph_category Solr'
print 'graph_info Info for cores: %s' % ( ",".join(params['cores']) )
# Iterations for core datas
for core in params['cores']:
#print core, params['valueName']
print "%s.label %s" % (core, core)
print "%s.type GAUGE" % (core)
print "%s.min 0" % (core)
sys.exit(0)
params = parseArgs()
for core in params['cores']:
#print core, params['valueName']
queues = fetchUrl(core, PLUGINOPTIONSLIST[params['valueName']]['xmlpath'])
searcher = getEntry(queues, PLUGINOPTIONSLIST[params['valueName']]['xmlparententryname'])
value = getValue(searcher, params['valueName']).strip()
print "%s.value %s" % (core, value)
sys.exit(0)