2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Extract tarballs committed to git as plugins.

This commit is contained in:
Diego Elio Pettenò 2012-08-06 22:16:31 -07:00
parent 2dad4c6f70
commit 038c3ce96b
15 changed files with 352 additions and 0 deletions

62
plugins/beboxsync/beboxstats Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/perl -w
use strict;
my ($Args) = @ARGV;
my $expecter = "/home/alex/bin/beboxstats.expect";
if ($Args) {
# work out line to grab
if ($Args eq 'autoconf') {
# Check the expect script that polls the router exists
unless ( -e $expecter ) {
print "no (Can't find expect script. Check value of \$expecter: $expecter)\n";
} else {
print "yes\n";
}
} elsif ($Args eq 'config') { # print out plugin parameters
printf("
graph_title bebox line stats
graph_vlabel deciBels
graph_category other
graph_info This graph shows the various line parameters
attenuationdownstream.label Downstream Attenuation
attenuationupstream.label Upstream Attenuation
margindownstream.label Downstream Noise Margin
marginupstream.label Upstream Noise Margin
outputpowerdownstream.label Downstream Output Power
outputpowerupstream.label Upstream Output Power
margindownstream.type GAUGE
outputpowerupstream.type GAUGE
attenuationdownstream.type GAUGE
marginupstream.type GAUGE
outputpowerdownstream.type GAUGE
attenuationupstream.type GAUGE
");
# .label is the Key on the graph
} else {
printf("Usage: $0
No arguments: print line stats
autoconf: print 'yes'
config: print config info for Munin\n");
}
} else {
# if no arguments, just fetch the data and print it out
my @insplitted = split(' ', `$expecter | grep dB`);
print "margindownstream.value $insplitted[3]\n";
print "marginupstream.value $insplitted[4]\n";
print "attenuationdownstream.value $insplitted[8]\n";
print "attenuationupstream.value $insplitted[9]\n";
print "outputpowerdownstream.value $insplitted[13]\n";
print "outputpowerupstream.value $insplitted[14]\n";
}

View File

@ -0,0 +1,25 @@
#!/usr/bin/expect -f
# script to log on to a BeBox router [ST Speedtouch 780] and gather line stats
# set timeout for response from router to 30 seconds
set timeout 30
set router "host.or.ip.of.router"
set port "23"
set username "Administrator"
set password "routerpassword"
# telnet to $router on $port
spawn telnet $router $port
expect "Username :"
send "$username\r"
expect "Password :"
send "$password\r"
expect "}=>"
send "adsl info\r"
expect "}=>"
send "exit\r"

50
plugins/beboxsync/beboxsync Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/perl -w
# (C) Alex Dekker <me@ale.cx>
# License is GPL
use strict;
my ($Args) = @ARGV;
my $expecter = "/home/alex/bin/beboxstats.expect";
if ($Args) {
# work out line to grab
if ($Args eq 'autoconf') {
# Check the expect script that polls the router exists
unless ( -e $expecter ) {
print "no (Can't find expect script. Check value of \$expecter: $expecter)\n";
} else {
print "yes\n";
}
} elsif ($Args eq 'config') { # print out plugin parameters
printf("
graph_title bebox sync stats
graph_vlabel ATM kbps
graph_category other
graph_info This graph shows line sync speed
syncdownstream.label Downstream Sync Speed
syncupstream.label Upstream Sync Speed
syncdownstream.type GAUGE
syncupstream.type GAUGE
");
# .label is the Key on the graph
} else {
printf("Usage: $0
No arguments: print line stats
autoconf: print 'yes'
config: print config info for Munin\n");
}
} else {
# if no arguments, just fetch the data and print it out
my @insplitted = split(' ', `$expecter | grep stream`);
print "syncdownstream.value $insplitted[11]\n";
print "syncupstream.value $insplitted[15]\n";
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,16 @@
#!/bin/bash
user=''
pass=''
if [ "$1" = "config" ]; then
echo "graph_title Transmission seed ratios"
echo "graph_vlabel Seed ratio %"
echo "graph_category Transmission"
echo "graph_info This plugin shows your transmission ratios per torrent"
transmission-remote -n $user:$pass -l | gawk -f /usr/share/munin/plugins/tr_ratios_labels
exit 0
fi
transmission-remote -n $user:$pass -l | gawk -f /usr/share/munin/plugins/tr_ratios_data

View File

@ -0,0 +1,10 @@
BEGIN { FIELDWIDTHS = "7 4 13 10 7 9 7 13 40" }
NR > 1 {
split($1,torrentid," ")
if(torrentid[1] != "Sum:") {
split($7,ratio," ")
ratio[1] = ratio[1] * 100
print "ID" torrentid[1] ".value " ratio[1]
}
}

View File

@ -0,0 +1,8 @@
BEGIN { FIELDWIDTHS = "7 4 13 10 7 9 7 13 40" }
NR > 1 {
split($1,torrentid," ")
if(torrentid[1] != "Sum:") {
print "ID" torrentid[1] ".label " $9
}
}

36
plugins/zope/zodb/README Normal file
View File

@ -0,0 +1,36 @@
These are 2 rather crude munin plugins to get at data about zopes ZODB.
They have proved very usefull, together with the process_memory
plugin, in tweaking the zodb cache-size for performance.
There is no config, auto or otherwise, you have to edit the scripts to change anything.
Should not be to hard however :)
To install you have to copy the two scripts in the "scripts_python"
folder into zope. Probably easiest just to paste them into an
appropriately named new script in the ZMI.
Click on the proxy tab, and give them the "Manager" role.
You can test them like this:
wget --delete-after -q -O - localhost:8080/<your path>/munin_db_activity.py
wget --delete-after -q -O - localhost:8080/<your path>/munin_cache_parameters.py
Edit zope_db_activity and zope_cache_parameters scripts to reflect
<your path> and your instance(s) ports.
Then move them into your munin plugins lib, and create a symlink under etc according to the
usual munin custom:
mv zope_* /opt/munin/lib/plugins/
ln -s /opt/munin/lib/plugins/zope_* /etc/opt/munin/plugins/
Test them with:
/opt/munin/sbin/munin-run zope_db_activity
/opt/munin/sbin/munin-run zope_cache_parameters
Restart your munin-node and the graphs should appear shortly.
If you make any improvements (which should be easy), please update
the munin exhange entry, or mail me at gaute(at)pht(dot)no

View File

@ -0,0 +1,27 @@
## Script (Python) "munin_cache_parameters.py"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
"""
Fetches data about the ZODB for the munin plugin "zope_cache_parameters".
Needs the Manager proxy role to work.
Only answers requests from localhost directly to zopes port.
"""
req = context.REQUEST
if req['HTTP_X_FORWARDED_FOR'] or req['REMOTE_ADDR'] != '127.0.0.1':
return "This script can only be called frm localhost"
maindb = context.restrictedTraverse('/Control_Panel/Database/main')
print maindb.database_size(), # Total number of objects in the database
print maindb.cache_length(), # Total number of objects in memory from all caches
print len(maindb.cache_detail_length()) * maindb.cache_size() # Target number of objects in memory sum total
return printed

View File

@ -0,0 +1,34 @@
## Script (Python) "munin_db_activity.py"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
"""
Fetches data about the ZODB for the munin plugin "zope_db_activity".
Needs the Manager proxy role to work.
Only answers requests from localhost directly to zopes port.
"""
req = context.REQUEST
if req['HTTP_X_FORWARDED_FOR'] or req['REMOTE_ADDR'] != '127.0.0.1':
return "This script can only be called frm localhost"
sec = 60*5 # 5 min is munins update frequency
now = float(DateTime())
then = now-sec
request = dict(chart_start=then,
chart_end=now)
maindb = context.restrictedTraverse('/Control_Panel/Database/main')
cd = maindb.getActivityChartData(200, request)
print cd['total_load_count'],cd['total_store_count'],cd['total_connections']
return printed

View File

@ -0,0 +1,43 @@
#!/usr/bin/python
from sys import argv
import httplib
conns = []
# this should really go in plugins.conf
conns.append(httplib.HTTPConnection("localhost",8080))
conns.append(httplib.HTTPConnection("localhost",8070))
url = "/munin_cache_parameters.py"
if len(argv) > 1 and argv[1] == 'config':
# there is probably a better way to display this cached vs targed graph
# as a percentage of target possibly..
print """graph_title Zope cache parameters
graph_category Zope
graph_info A grap of the main data on the "Cache Parameters" tab of the main DB in the zope control panel.""".replace("\n ","\n")
for i in range(0,len(conns)):
print """obs_in_db%(i)s.label Z%(i)s Obs in DB
obs_cached%(i)s.label Z%(i)s obs in all caches
obs_target%(i)s.label Z%(i)s cached obs target""".replace("\n ","\n") % dict(i=i)
else:
for i in range(0,len(conns)):
conns[i].request("GET", url)
r1 = conns[i].getresponse()
#print r1.status, r1.reason
#200 OK
data = r1.read().strip()
conns[i].close()
(obs_in_db, obs_cached, obs_target) = data.split()
id = dict(i=i)
print 'obs_in_db%(i)s.value' % id, obs_in_db
print 'obs_cached%(i)s.value'% id, obs_cached
print 'obs_target%(i)s.value'% id, obs_target

View File

@ -0,0 +1,41 @@
#!/usr/bin/python
from sys import argv
import httplib
conns = []
# this should really go in plugins.conf
conns.append(httplib.HTTPConnection("localhost",8080))
conns.append(httplib.HTTPConnection("localhost",8070))
url = "/munin_db_activity.py"
if len(argv) > 1 and argv[1] == 'config':
print """graph_title Zope Database Activity
graph_vlabel Count / 5 min.
graph_category Zope
graph_info The number of Reads, Stores, and Connections that happens in the ZODB backend. The data comes from the same source as that in the "Recent Database Activity" tab in the zope control panel.""".replace("\n ","\n")
for i in range(0,len(conns)):
print """load_count%(i)s.label Z%(i)s Loads
store_count%(i)s.label Z%(i)s Stores
connections%(i)s.label Z%(i)s Connections""".replace("\n ","\n") % dict(i=i)
else:
for i in range(0,len(conns)):
conns[i].request("GET", url)
r1 = conns[i].getresponse()
#print r1.status, r1.reason
#200 OK
data = r1.read().strip()
conns[i].close()
(total_load_count, total_store_count, total_connections) = data.split()
id = dict(i=i)
print 'load_count%(i)s.value' % id, total_load_count
print 'store_count%(i)s.value'% id, total_store_count
print 'connections%(i)s.value'% id, total_connections

Binary file not shown.