From 038c3ce96b719bc3573280f02db1ec17b41899e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Mon, 6 Aug 2012 22:16:31 -0700 Subject: [PATCH] Extract tarballs committed to git as plugins. --- plugins/beboxsync/beboxstats | 62 ++++++++++++++++++ plugins/beboxsync/beboxstats.expect | 25 +++++++ plugins/beboxsync/beboxsync | 50 ++++++++++++++ plugins/other/beboxsync | Bin 1188 -> 0 bytes plugins/other/tr_ratios | Bin 589 -> 0 bytes plugins/other/transmission/tr_ratios | 16 +++++ plugins/other/transmission/tr_ratios_data | 10 +++ plugins/other/transmission/tr_ratios_labels | 8 +++ plugins/zfs/zfs-statistics-for-freebsd | Bin 1561 -> 0 bytes plugins/zope/zodb/README | 36 ++++++++++ .../scripts_python/munin_cache_parameters.py | 27 ++++++++ .../zodb/scripts_python/munin_db_activity.py | 34 ++++++++++ plugins/zope/zodb/zope_cache_parameters | 43 ++++++++++++ plugins/zope/zodb/zope_db_activity | 41 ++++++++++++ plugins/zope/zope_zodb | Bin 2322 -> 0 bytes 15 files changed, 352 insertions(+) create mode 100755 plugins/beboxsync/beboxstats create mode 100755 plugins/beboxsync/beboxstats.expect create mode 100755 plugins/beboxsync/beboxsync delete mode 100755 plugins/other/beboxsync delete mode 100755 plugins/other/tr_ratios create mode 100755 plugins/other/transmission/tr_ratios create mode 100644 plugins/other/transmission/tr_ratios_data create mode 100644 plugins/other/transmission/tr_ratios_labels delete mode 100755 plugins/zfs/zfs-statistics-for-freebsd create mode 100644 plugins/zope/zodb/README create mode 100644 plugins/zope/zodb/scripts_python/munin_cache_parameters.py create mode 100644 plugins/zope/zodb/scripts_python/munin_db_activity.py create mode 100755 plugins/zope/zodb/zope_cache_parameters create mode 100755 plugins/zope/zodb/zope_db_activity delete mode 100755 plugins/zope/zope_zodb diff --git a/plugins/beboxsync/beboxstats b/plugins/beboxsync/beboxstats new file mode 100755 index 00000000..184b8315 --- /dev/null +++ b/plugins/beboxsync/beboxstats @@ -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"; +} + + diff --git a/plugins/beboxsync/beboxstats.expect b/plugins/beboxsync/beboxstats.expect new file mode 100755 index 00000000..aedd3d89 --- /dev/null +++ b/plugins/beboxsync/beboxstats.expect @@ -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" diff --git a/plugins/beboxsync/beboxsync b/plugins/beboxsync/beboxsync new file mode 100755 index 00000000..be992845 --- /dev/null +++ b/plugins/beboxsync/beboxsync @@ -0,0 +1,50 @@ +#!/usr/bin/perl -w + +# (C) Alex Dekker +# 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"; +} + + diff --git a/plugins/other/beboxsync b/plugins/other/beboxsync deleted file mode 100755 index aa34bfba225c4134a0a8a1491586010a42250698..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1188 zcmV;V1Y7$biwFP?EZ0c@1MOFBZ`(Ey&R6SK+++hzfX4Al9Cz7T#A%0oSknbdvM)`s z(h_BJmPw7I;sjg&`;L@kOO~7z!;-C-4hAfV&)t#t#=8lfh&!c;Ry$8dU8K=)X#RVn zVK@J8XfPZNcY3|v(eS80><VONi4_HFrV>B92Q#st2gXEJ z(qt7>odo3~4+~a;{%{;fsR>IV=OAJYA>$OZfT<*t)%uDH==H~7CPzPZb=wZ5CPn*L?5rU?A>s*)Ta2)KtuG%qx$cus^(u?+lnfh)R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V4$-JCw zQ4G6iPUkhu+z3bia4xu#W#ni7-5 z2&lzSDO_=0DI5W{2)@CX-+qDG2<%KNTZdc;dy>Vu=bkpu* 1 { + split($1,torrentid," ") + if(torrentid[1] != "Sum:") { + split($7,ratio," ") + ratio[1] = ratio[1] * 100 + print "ID" torrentid[1] ".value " ratio[1] + } +} + diff --git a/plugins/other/transmission/tr_ratios_labels b/plugins/other/transmission/tr_ratios_labels new file mode 100644 index 00000000..273ab3d3 --- /dev/null +++ b/plugins/other/transmission/tr_ratios_labels @@ -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 + } +} + diff --git a/plugins/zfs/zfs-statistics-for-freebsd b/plugins/zfs/zfs-statistics-for-freebsd deleted file mode 100755 index 8bb497591cc081345bdd6db7320f1d373768756b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1561 zcmV+!2Il!6iwFRfBJE571MOOEZ`(Ey_6BT2{AJ&^uQw%`Utrmi{MI;V3paI_0QFYH zF3=@T1zM(UqOzn(R2!$uKiNOn-`NiuDOr9=;y6vzBnJ4vg2b0Q9*;-f9q6;Zrz6+U z4P*?lJ|xuByW>g8Bpyw~07X%%Xg~w)B}8q4WFW}iFt#I0Z}k9Vj6wUDFUAIDHMFqEts}}%wU~n^mE)H z?7y_D?7%Z9^zg@m<(npG&wf=Gi8-(_v|)_Bg}PHhL5XUx>ETNhl4VQFN%|ytfiNP1 zG<%jxJX20)%6-O}ab-WY1mU_a>OZVo(0({*YTzPgs8d3j%8y>PpnkXqd)$y=pP4nc zmaz1inRV(C9dZXAfNX+tx$UEgy4Zy6%Pj_?cwoC@KH%k6V)bok4~YjsnQcD%Q)nk# zwqTRNa3Wh+G6UI?%a^(ie*^mT0a7m-za9JzpW(2@wIabTyb8WLmIUWe*sJgDH(>vu z-GUc?LRflz&}tXpv*Qwro~Ib2PBLIsc;BJ<>^5ui{BF8%+@WxiE#xFAvl~=EC!NoB zGBs9Ji|T6mNe}1|&oR;1VkZC_e@oegLC6O3C#;Ju<+c>oEf|$GOZiZl(i|NZnzxLI z1&VZ@+DIlhCguF9*34?0!%Y?(ZCQkw=)u%rP)Z{^2porJCf21v|kE z?0J~+W;M1?9iOg+@+YdlQqe)(_M}Hp&{-kRTD93Ss8aqTGJVXpm3E#=KD3t-_*%#p z^7_?2zK1B%>Da+{9%DuPr)cG36#uDeS>f?txl$4F-@V|wpMFSun@BW~0e`gMUF64k zU1Ebh8hgg<;pKlhLA&v;eV8?d%URaj?Zd?L@Bf=n{KK9fFLe24R{yhMkMhWIOq_4y zQ`)c$yGN`6Ykb>&B|q6!izQ91?mQ{QJ#ztuuf6v zP`!};sXMijBGNyR{;ga3$E~ADc(A`D_mgGcaj+|!WW*#<*&b)fpv>M6kPmWUM}e^1 z%K2^tz8ho745PHfYVxzywna(ZqM6*_r6r|Z); zohh5?n)OLd31O~x`nWD1A^A){VQT`AJ$?@-S++#SioBEObhvO zt=7uo#!q/munin_db_activity.py +wget --delete-after -q -O - localhost:8080//munin_cache_parameters.py + +Edit zope_db_activity and zope_cache_parameters scripts to reflect + 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 \ No newline at end of file diff --git a/plugins/zope/zodb/scripts_python/munin_cache_parameters.py b/plugins/zope/zodb/scripts_python/munin_cache_parameters.py new file mode 100644 index 00000000..70dff165 --- /dev/null +++ b/plugins/zope/zodb/scripts_python/munin_cache_parameters.py @@ -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 diff --git a/plugins/zope/zodb/scripts_python/munin_db_activity.py b/plugins/zope/zodb/scripts_python/munin_db_activity.py new file mode 100644 index 00000000..824fce48 --- /dev/null +++ b/plugins/zope/zodb/scripts_python/munin_db_activity.py @@ -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 diff --git a/plugins/zope/zodb/zope_cache_parameters b/plugins/zope/zodb/zope_cache_parameters new file mode 100755 index 00000000..cfdf3813 --- /dev/null +++ b/plugins/zope/zodb/zope_cache_parameters @@ -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 + + + + diff --git a/plugins/zope/zodb/zope_db_activity b/plugins/zope/zodb/zope_db_activity new file mode 100755 index 00000000..64175fb9 --- /dev/null +++ b/plugins/zope/zodb/zope_db_activity @@ -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 + + + + diff --git a/plugins/zope/zope_zodb b/plugins/zope/zope_zodb deleted file mode 100755 index f2e1a0d90b7721a3173ee6207360b8aae5483bf6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2322 zcmV+t3GMbDiwFRo%40?V1MOLDbKAHP_GkWzJ$Y^Noo=sl+&zH)m+R7&a-~@Ya4=)J<{#mEtovzle;{@nZ{0B$J2hjNvo!O^9c>G6mt~juaLk}{h=RAWj z%OehpT*Ly>B%j4XftE1i8kmNNX$EW}a}6|i6uiGUdmVVFXAN_<zI7)n<6%oQWBF zLag;1jR)Slxy+LYwQ86csX5Ccn9CK%p}~pop=pWz#rcyYJL*H3u8n%VlBEe67=Ef1 z@8cBhNKx~qGKo-MEKraf8o=93PS_+_17|AcO2aQWM@etWl;)&mVcD7RSc-m3vzTd) z0)j2j^MbDms~e;5-~5D*I!)s62Bg@y{{wcCP0(2)f?2#QG@DMoVS>$gR)b6?67m|-*wu5LN{Uj zaGrhNHWO?dO~x$L@iNxyAYK1=y38~grz}G^pr9g!-Z{nEWVwndGiLK~U#2=GGCoas zsJ)6MBWPYt;Bf{vln<%QvOA19H&Iq|U@w~;-4&w#1WvZy&=QvV_T9~bz4 zG#Ctei2uh&FCG3r3mtyb&Q;c?^=T2w^QM_xU_w%~fN*VLaWGqY#q(V26!V9NK#O^7 z2v^shcW7{6v$QayB?v_`g2qk43ka93OhC(4M2$jG@aNI!?I|{3o{gnw)XF4ZYf_f? z{Z9}ZkeKJ?S%N*RJq!*t&x@y!aM7S4`tUt;O|GH0tL`-nhfuc_MIBQuAkk2ZY9rmC zG{bD738z+UO}RRXRhrNvImKATVhHgBwc?Y>VTCTHP#BAu5R(kTEy$_m(g-L@#i%?8 ztX)KSp`li*8S$}>b%Lml3)UKdN){z{%N1fq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