root / plugins / mail / mailman_subscribers @ 430d68ff
Historique | Voir | Annoter | Télécharger (2,63 ko)
| 1 | 39714938 | Rodolphe Quiedeville | #!/usr/bin/perl |
|---|---|---|---|
| 2 | # |
||
| 3 | # Copyright (C) 2006-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> |
||
| 4 | # |
||
| 5 | # This program is free software; you can redistribute it and/or |
||
| 6 | # modify it under the terms of the GNU General Public License |
||
| 7 | # as published by the Free Software Foundation; version 2 dated June, |
||
| 8 | # 1991. |
||
| 9 | # |
||
| 10 | # This program is distributed in the hope that it will be useful, |
||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | # GNU General Public License for more details. |
||
| 14 | # |
||
| 15 | # You should have received a copy of the GNU General Public License |
||
| 16 | # along with this program; if not, write to the Free Software |
||
| 17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
| 18 | # |
||
| 19 | # $Log$ |
||
| 20 | # Revision 1.0 2007/01/17 15:57:19 rodo |
||
| 21 | # Add total and correct family |
||
| 22 | # |
||
| 23 | # Revision 1.0 2006/04/30 22:44:19 rodo |
||
| 24 | # Created by Rodolphe Quiedeville |
||
| 25 | # |
||
| 26 | # Need to be run as root, add the following lines ... |
||
| 27 | # |
||
| 28 | # [mailman_subscribers] |
||
| 29 | # user root |
||
| 30 | # |
||
| 31 | # to /etc/munin/plugin-conf.d/munin-node |
||
| 32 | # |
||
| 33 | # Magic markers (optinal - used by munin-config and some installation |
||
| 34 | # scripts): |
||
| 35 | # |
||
| 36 | #%# family=manual |
||
| 37 | #%# capabilities=autoconf |
||
| 38 | |||
| 39 | use strict; |
||
| 40 | ec2baa46 | Jakob Unterwurzacher | my ($list,$desc,%lists,$label); |
| 41 | 39714938 | Rodolphe Quiedeville | |
| 42 | my $list_lists = "/usr/sbin/list_lists"; |
||
| 43 | (-x $list_lists) || die "Can't exec $list_lists\n"; |
||
| 44 | |||
| 45 | my $list_members = "/usr/sbin/list_members"; |
||
| 46 | (-x $list_members) || die "Can't exec $list_members\n"; |
||
| 47 | |||
| 48 | open(LL, "$list_lists|") or exit 4; |
||
| 49 | while (<LL>) |
||
| 50 | {
|
||
| 51 | b8e09a39 | Jakob Unterwurzacher | ($list, $desc) = (/^\s+(.*?)\s-\s(.*)$/); |
| 52 | 39714938 | Rodolphe Quiedeville | $lists{$list} = $desc if ($list);
|
| 53 | } |
||
| 54 | close(LL); |
||
| 55 | |||
| 56 | if ($ARGV[0] and $ARGV[0] eq "config" ){
|
||
| 57 | print "graph_title Mailman subscribers\n"; |
||
| 58 | print "graph_args --base 1000 -l 0\n"; |
||
| 59 | print "graph_scale yes\n"; |
||
| 60 | print "graph_vlabel subscribers\n"; |
||
| 61 | print "graph_category mailman\n"; |
||
| 62 | print "graph_total Total\n"; |
||
| 63 | print 'graph_info Plugin available at <a href="http://rodolphe.quiedeville.org/hack/munin/mailman/">http://rodolphe.quiedeville.org/hack/munin/mailman/</a>'."\n"; |
||
| 64 | |||
| 65 | my $num =0; |
||
| 66 | while (($list,$desc) = each(%lists)) {
|
||
| 67 | ec2baa46 | Jakob Unterwurzacher | $label=$list; |
| 68 | $list=clean_name($list); |
||
| 69 | print("$list.label $label\n");
|
||
| 70 | 39714938 | Rodolphe Quiedeville | print("$list.info $desc\n");
|
| 71 | ($num > 0) ? print("$list.draw STACK\n") : print("$list.draw AREA\n");
|
||
| 72 | $num++; |
||
| 73 | } |
||
| 74 | exit 0; |
||
| 75 | } |
||
| 76 | |||
| 77 | while (($list,$desc) = each(%lists)) {
|
||
| 78 | my $num = 0; |
||
| 79 | open(LM, "$list_members $list|") or exit 4; |
||
| 80 | while (<LM>) |
||
| 81 | {
|
||
| 82 | $num++; |
||
| 83 | } |
||
| 84 | close(LL); |
||
| 85 | |||
| 86 | ec2baa46 | Jakob Unterwurzacher | $list=clean_name($list); |
| 87 | 39714938 | Rodolphe Quiedeville | print("$list.value $num\n");
|
| 88 | } |
||
| 89 | ec2baa46 | Jakob Unterwurzacher | |
| 90 | sub clean_name |
||
| 91 | {
|
||
| 92 | # http://munin-monitoring.org/wiki/notes_on_datasource_names |
||
| 93 | my $list = shift(@_); |
||
| 94 | $list=~s/^[^A-Za-z_]/_/; |
||
| 95 | $list=~s/[^A-Za-z0-9_]/_/g; |
||
| 96 | return $list; |
||
| 97 | } |
