Projet

Général

Profil

Révision 038c3ce9

ID038c3ce96b719bc3573280f02db1ec17b41899e1
Parent 2dad4c6f
Enfant e5ce7492

Ajouté par Diego Elio Pettenò il y a plus de 13 ans

Extract tarballs committed to git as plugins.

Voir les différences:

plugins/beboxsync/beboxstats
1
#!/usr/bin/perl -w
2

  
3
use strict;
4

  
5
my ($Args) = @ARGV;
6

  
7
my $expecter = "/home/alex/bin/beboxstats.expect";
8

  
9
if ($Args) {
10

  
11
        # work out line to grab
12
        if ($Args eq 'autoconf') {
13
                # Check the expect script that polls the router exists
14
                unless ( -e $expecter ) {
15
                        print "no (Can't find expect script. Check value of \$expecter: $expecter)\n";
16
                } else {
17
                        print "yes\n";
18
                }
19

  
20
        } elsif ($Args eq 'config') { # print out plugin parameters
21
                printf("
22
graph_title bebox line stats
23
graph_vlabel deciBels
24
graph_category other
25
graph_info This graph shows the various line parameters
26
attenuationdownstream.label Downstream Attenuation
27
attenuationupstream.label Upstream Attenuation
28
margindownstream.label Downstream Noise Margin
29
marginupstream.label Upstream Noise Margin
30
outputpowerdownstream.label Downstream Output Power
31
outputpowerupstream.label Upstream Output Power
32
margindownstream.type GAUGE
33
outputpowerupstream.type GAUGE
34
attenuationdownstream.type GAUGE
35
marginupstream.type GAUGE
36
outputpowerdownstream.type GAUGE
37
attenuationupstream.type GAUGE
38
                ");
39
                # .label is the Key on the graph
40
        } else {
41
                printf("Usage: $0
42
                        No arguments: print line stats
43
                        autoconf: print 'yes'
44
                        config: print config info for Munin\n");
45
        }
46

  
47
} else {
48
        # if no arguments, just fetch the data and print it out
49

  
50
my @insplitted = split(' ', `$expecter | grep dB`);
51

  
52
print "margindownstream.value $insplitted[3]\n";
53
print "marginupstream.value $insplitted[4]\n";
54

  
55
print "attenuationdownstream.value $insplitted[8]\n";
56
print "attenuationupstream.value $insplitted[9]\n";
57

  
58
print "outputpowerdownstream.value $insplitted[13]\n";
59
print "outputpowerupstream.value $insplitted[14]\n";
60
}
61

  
62

  
plugins/beboxsync/beboxstats.expect
1
#!/usr/bin/expect -f
2

  
3
# script to log on to a BeBox router [ST Speedtouch 780] and gather line stats
4

  
5
# set timeout for response from router to 30 seconds
6
set timeout 30
7
set router "host.or.ip.of.router"
8
set port "23"
9
set username "Administrator"
10
set password "routerpassword"
11

  
12
# telnet to $router on $port
13
spawn telnet $router $port
14

  
15
expect "Username :"
16
send "$username\r"
17

  
18
expect "Password :"
19
send "$password\r"
20

  
21
expect "}=>"
22
send "adsl info\r"
23

  
24
expect "}=>"
25
send "exit\r"
plugins/beboxsync/beboxsync
1
#!/usr/bin/perl -w
2

  
3
# (C) Alex Dekker <me@ale.cx>
4
# License is GPL
5

  
6
use strict;
7

  
8
my ($Args) = @ARGV;
9

  
10
my $expecter = "/home/alex/bin/beboxstats.expect";
11

  
12
if ($Args) {
13

  
14
        # work out line to grab
15
        if ($Args eq 'autoconf') {
16
                # Check the expect script that polls the router exists
17
		unless ( -e $expecter ) {
18
			print "no (Can't find expect script. Check value of \$expecter: $expecter)\n";
19
		} else {
20
                	print "yes\n";
21
		}
22
        } elsif ($Args eq 'config') { # print out plugin parameters
23
                printf("
24
graph_title bebox sync stats
25
graph_vlabel ATM kbps
26
graph_category other
27
graph_info This graph shows line sync speed
28
syncdownstream.label Downstream Sync Speed
29
syncupstream.label Upstream Sync Speed
30
syncdownstream.type GAUGE
31
syncupstream.type GAUGE
32
                ");
33
                # .label is the Key on the graph
34
        } else {
35
                printf("Usage: $0
36
                        No arguments: print line stats
37
                        autoconf: print 'yes'
38
                        config: print config info for Munin\n");
39
        }
40

  
41
} else {
42
        # if no arguments, just fetch the data and print it out
43

  
44
my @insplitted = split(' ', `$expecter | grep stream`);
45

  
46
print "syncdownstream.value $insplitted[11]\n";
47
print "syncupstream.value $insplitted[15]\n";
48
}
49

  
50

  
plugins/other/transmission/tr_ratios
1
#!/bin/bash
2

  
3
user=''
4
pass=''
5

  
6
if [ "$1" = "config" ]; then
7
        echo "graph_title Transmission seed ratios"
8
	echo "graph_vlabel Seed ratio %"
9
	echo "graph_category Transmission"
10
	echo "graph_info This plugin shows your transmission ratios per torrent"
11
	transmission-remote -n $user:$pass -l | gawk -f /usr/share/munin/plugins/tr_ratios_labels
12
        exit 0
13
fi
14

  
15
transmission-remote -n $user:$pass -l | gawk -f /usr/share/munin/plugins/tr_ratios_data
16

  
plugins/other/transmission/tr_ratios_data
1
BEGIN { FIELDWIDTHS = "7 4 13 10 7 9 7 13 40" } 
2
NR > 1 {
3
	split($1,torrentid," ")
4
        if(torrentid[1] != "Sum:") {
5
		split($7,ratio," ")
6
		ratio[1] = ratio[1] * 100
7
                print "ID" torrentid[1] ".value " ratio[1]
8
        }
9
}
10

  
plugins/other/transmission/tr_ratios_labels
1
BEGIN { FIELDWIDTHS = "7 4 13 10 7 9 7 13 40" } 
2
NR > 1 {
3
	split($1,torrentid," ")
4
	if(torrentid[1] != "Sum:") {
5
		print "ID" torrentid[1] ".label " $9
6
	}
7
}
8

  
plugins/zope/zodb/README
1
These are 2 rather crude munin plugins to get at data about zopes ZODB.
2
They have proved very usefull, together with the process_memory
3
plugin, in tweaking the zodb cache-size for performance.
4

  
5
There is no config, auto or otherwise, you have to edit the scripts to change anything.
6
Should not be to hard however :)
7

  
8

  
9
To install you have to copy the two scripts in the "scripts_python"
10
folder into zope. Probably easiest just to paste them into an
11
appropriately named new script in the ZMI.
12

  
13
Click on the proxy tab, and give them the "Manager" role.
14

  
15
You can test them like this:
16
wget --delete-after -q -O - localhost:8080/<your path>/munin_db_activity.py
17
wget --delete-after -q -O - localhost:8080/<your path>/munin_cache_parameters.py
18

  
19
Edit zope_db_activity and zope_cache_parameters scripts to reflect
20
<your path> and your instance(s) ports. 
21

  
22
Then move them into your munin plugins lib, and create a symlink under etc according to the
23
usual munin custom:
24

  
25
mv zope_* /opt/munin/lib/plugins/
26

  
27
ln -s /opt/munin/lib/plugins/zope_*  /etc/opt/munin/plugins/
28

  
29
Test them with:
30
/opt/munin/sbin/munin-run zope_db_activity
31
/opt/munin/sbin/munin-run zope_cache_parameters
32

  
33
Restart your munin-node and the graphs should appear shortly.
34

  
35
If you make any improvements (which should be easy), please update
36
the munin exhange entry, or mail me at gaute(at)pht(dot)no
plugins/zope/zodb/scripts_python/munin_cache_parameters.py
1
## Script (Python) "munin_cache_parameters.py"
2
##bind container=container
3
##bind context=context
4
##bind namespace=
5
##bind script=script
6
##bind subpath=traverse_subpath
7
##parameters=
8
##title=
9
##
10
"""
11
Fetches data about the ZODB for the munin plugin "zope_cache_parameters".
12
Needs the Manager proxy role to work.
13
Only answers requests from localhost directly to zopes port.
14
"""
15

  
16
req = context.REQUEST
17

  
18
if req['HTTP_X_FORWARDED_FOR'] or req['REMOTE_ADDR'] != '127.0.0.1':
19
    return "This script can only be called frm localhost"
20

  
21
maindb = context.restrictedTraverse('/Control_Panel/Database/main')
22

  
23
print maindb.database_size(), # Total number of objects in the database
24
print maindb.cache_length(), # Total number of objects in memory from all caches
25
print len(maindb.cache_detail_length()) * maindb.cache_size() # Target number of objects in memory sum total
26

  
27
return printed
plugins/zope/zodb/scripts_python/munin_db_activity.py
1
## Script (Python) "munin_db_activity.py"
2
##bind container=container
3
##bind context=context
4
##bind namespace=
5
##bind script=script
6
##bind subpath=traverse_subpath
7
##parameters=
8
##title=
9
##
10
"""
11
Fetches data about the ZODB for the munin plugin "zope_db_activity".
12
Needs the Manager proxy role to work.
13
Only answers requests from localhost directly to zopes port.
14
"""
15

  
16
req = context.REQUEST
17

  
18
if req['HTTP_X_FORWARDED_FOR'] or req['REMOTE_ADDR'] != '127.0.0.1':
19
    return "This script can only be called frm localhost"
20

  
21
sec = 60*5 # 5 min is munins update frequency
22

  
23
now = float(DateTime())
24
then = now-sec
25

  
26
request = dict(chart_start=then,
27
               chart_end=now)
28

  
29
maindb = context.restrictedTraverse('/Control_Panel/Database/main')
30
cd =  maindb.getActivityChartData(200, request)
31

  
32
print cd['total_load_count'],cd['total_store_count'],cd['total_connections']
33

  
34
return printed
plugins/zope/zodb/zope_cache_parameters
1
#!/usr/bin/python
2

  
3
from sys import argv
4
import httplib
5
conns = []
6

  
7
# this should really go in plugins.conf
8
conns.append(httplib.HTTPConnection("localhost",8080))
9
conns.append(httplib.HTTPConnection("localhost",8070))
10

  
11

  
12
url = "/munin_cache_parameters.py"
13

  
14
if len(argv) > 1 and argv[1] == 'config':
15

  
16
    # there is probably a better way to display this cached vs targed graph
17
    # as a percentage of target possibly..
18

  
19
    print """graph_title Zope cache parameters
20
    graph_category Zope
21
    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")
22
    for i in range(0,len(conns)):
23
        print """obs_in_db%(i)s.label Z%(i)s Obs in DB
24
        obs_cached%(i)s.label Z%(i)s obs in all caches
25
        obs_target%(i)s.label Z%(i)s cached obs target""".replace("\n        ","\n") % dict(i=i)
26
else:
27
    for i in range(0,len(conns)):
28
        conns[i].request("GET", url)
29

  
30
        r1 = conns[i].getresponse()
31
        #print r1.status, r1.reason
32
        #200 OK
33
        data = r1.read().strip()
34
        conns[i].close()
35
        (obs_in_db, obs_cached, obs_target) = data.split()
36
        id = dict(i=i)
37
        print 'obs_in_db%(i)s.value' % id, obs_in_db
38
        print 'obs_cached%(i)s.value'% id, obs_cached
39
        print 'obs_target%(i)s.value'% id, obs_target
40
                    
41

  
42

  
43

  
plugins/zope/zodb/zope_db_activity
1
#!/usr/bin/python
2

  
3
from sys import argv
4
import httplib
5
conns = []
6

  
7
# this should really go in plugins.conf
8
conns.append(httplib.HTTPConnection("localhost",8080))
9
conns.append(httplib.HTTPConnection("localhost",8070))
10

  
11

  
12
url = "/munin_db_activity.py"
13

  
14
if len(argv) > 1 and argv[1] == 'config':
15

  
16
    print """graph_title Zope Database Activity
17
    graph_vlabel Count / 5 min.
18
    graph_category Zope
19
    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")
20
    for i in range(0,len(conns)):
21
        print """load_count%(i)s.label Z%(i)s Loads
22
        store_count%(i)s.label Z%(i)s Stores
23
        connections%(i)s.label Z%(i)s Connections""".replace("\n        ","\n") % dict(i=i)
24
else:
25
    for i in range(0,len(conns)):
26
        conns[i].request("GET", url)
27

  
28
        r1 = conns[i].getresponse()
29
        #print r1.status, r1.reason
30
        #200 OK
31
        data = r1.read().strip()
32
        conns[i].close()
33
        (total_load_count, total_store_count, total_connections) = data.split()
34
        id = dict(i=i)
35
        print 'load_count%(i)s.value' % id, total_load_count
36
        print 'store_count%(i)s.value'% id, total_store_count
37
        print 'connections%(i)s.value'% id, total_connections
38
                    
39

  
40

  
41

  

Formats disponibles : Unified diff