mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Category Tree: Reduce number of categories
This commit is contained in:
parent
d5440def19
commit
3c98d06933
19 changed files with 25 additions and 25 deletions
|
@ -1,144 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# +----------------------------------------------------------------------+
|
||||
# | A Munin Graph Plugin for ASSP |
|
||||
# | [ assp-envelope-recipient-statistics ] |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Enrico Labedzki |
|
||||
# | Email: enzo@guel.info |
|
||||
# | Last Modified: 2010-02-22 |
|
||||
# | Licence: GPLv3 http://www.gnu.org/licenses/gpl-3.0.txt |
|
||||
# +----------------------------------------------------------------------+
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use LWP;
|
||||
use Mail::Sendmail;
|
||||
|
||||
# -------------------------- DEBUG VARS ---------------------------------
|
||||
my $DEBUG = 0; # for debugging purpose
|
||||
my $EMAILDEBUG = 0; # for email debugging
|
||||
my $pluginname = &basename( "$0" ); # get the basename of the plugin
|
||||
my @to = qw( webmaster@guel.info ); # the list of admins receivced messages on an error
|
||||
my $from = "$pluginname-at-host\@guel.info"; # the host where the plugin is installed
|
||||
my $muninnodename = "mail.guel.info"; # the real Node from where it comes
|
||||
my $smtp = "mail.guel.info"; # the smtp relay to send the mail
|
||||
|
||||
# ------------------------- GLOBAL VARS ---------------------------------
|
||||
my $version = "1.0"; # UA Version
|
||||
my $agentname = "$pluginname Munin Plugin V$version"; # UA String
|
||||
my $url = "http://localhost:55553/"; # (defaults to localhost)
|
||||
my $response = 0; # the server output
|
||||
my @content = (); # the content we're retrive from $response
|
||||
my %index = ( # for Version 2
|
||||
'from' => 40, # <-- index frame from ( a tweak for other ASSP Versions )
|
||||
'to' => 63 # <-- index frame to ( "" )
|
||||
);
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
my @muninlabel = (
|
||||
# Envelope Recipient Statistics --> index 40..63
|
||||
"Local Recipients Accepted",
|
||||
"Validated Recipients",
|
||||
"Unchecked Recipients",
|
||||
"Spam-Lover Recipients",
|
||||
"Remote Recipients Accepted",
|
||||
"Whitelisted Recipients",
|
||||
"Not Whitelisted Recipients",
|
||||
"Noprocessed Recipients",
|
||||
"Email Reports",
|
||||
"Spam Reports",
|
||||
"Ham Reports",
|
||||
"Whitelist Additions",
|
||||
"Whitelist Deletions",
|
||||
"Redlist Additions",
|
||||
"Redlist Deletions",
|
||||
"Local Recipients Rejected",
|
||||
"Nonexistent Recipients",
|
||||
"Delayed Recipients",
|
||||
"Delayed (Late) Recipients",
|
||||
"Delayed (Expired) Recipients",
|
||||
"Embargoed Recipients",
|
||||
"Spam Bucketed Recipients",
|
||||
"Remote Recipients Rejected",
|
||||
"Relay Attempts Rejected"
|
||||
);
|
||||
|
||||
# ============= SANITY CHECKS ================
|
||||
unless( defined(@ARGV) ){
|
||||
$ARGV[0] = "";
|
||||
}
|
||||
|
||||
# =============== THE GET ====================
|
||||
if( $ARGV[0] eq "" ){
|
||||
my $agent = LWP::UserAgent->new();
|
||||
$agent->agent("$agentname");
|
||||
$response = $agent->get( $url );
|
||||
&response_error() unless $response->is_success;
|
||||
@content = split( /\n/, $response->content );
|
||||
|
||||
my $line = "";
|
||||
my $count = $index{from};
|
||||
my $label;
|
||||
my( $key, $value, $last );
|
||||
while( 1 ){
|
||||
&finish() if( $count > $index{to} );
|
||||
$line = $content[$count];
|
||||
$count++;
|
||||
chomp( $line );
|
||||
next if $line eq ""; # no empty lines
|
||||
next if $line =~ /^\n$/; # no newlines
|
||||
next if $line =~ /^\r$/; # or else
|
||||
next if $line =~ /^\r\n$/; # http specific
|
||||
( $key, $value, $last) = split( /\|/, $line ); # split up to three values
|
||||
$key =~ s/^\s//g; $key =~ s/\s$//g; # no spaces at the end and the beginning
|
||||
$value =~ s/^\s//g; $value =~ s/\s$//g;
|
||||
$value =~ s/(\d*)\s*.*/$1/g; # remove more than one values from splited data
|
||||
$value =~ s/[a-zA-Z\(\)\%]//g; # and not alphanummeric glyphs
|
||||
$last =~ s/^\s//g; $last =~ s/\s$//g;
|
||||
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g; # generate a label
|
||||
$label =~ s/\-/\_/g; # the subs glyph to underline
|
||||
$label =~ s/[\(\)]//g; # no special glyphs feel free to add more
|
||||
print "$label.value $value\n"; # print the result to the label
|
||||
}
|
||||
}
|
||||
|
||||
# =============== FUNCTIONS ==================
|
||||
sub finish{
|
||||
exit 0;
|
||||
}
|
||||
sub response_error{
|
||||
if( $DEBUG ){
|
||||
foreach my $admin ( @to ){
|
||||
my %mail = ( smtp => "$smtp", To => "$admin", From => "$from", Subject => "Munin Plugin $pluginname", Message => "ERROR: $agentname at $muninnodename\n" );
|
||||
&sendmail(%mail) or die "ERROR: $Mail::Sendmail::error\n";
|
||||
|
||||
if( $EMAILDEBUG ){
|
||||
print "OK. Log says:\n$Mail::Sendmail::log\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
exit 1; # if no admin exists
|
||||
}
|
||||
|
||||
# ============== MUNIN GRAPHER COINFIG =======
|
||||
|
||||
if( $ARGV[0] eq "config" ){
|
||||
print "graph_title ASSP - Envelope Recipient Statistics\n";
|
||||
print "graph_vlabel Counter in k,m\n";
|
||||
print "graph_category ASSP\n";
|
||||
|
||||
my $label;
|
||||
foreach my $key ( @muninlabel ){
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g;
|
||||
$label =~ s/\-/\_/g;
|
||||
$label =~ s/[\(\)]//g;
|
||||
print "$label.label $key\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# +----------------------------------------------------------------------+
|
||||
# | A Munin Graph Plugin for ASSP |
|
||||
# | [ assp-general-runtime-information ] |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Enrico Labedzki |
|
||||
# | Email: enrico.labdzki@brodos.de |
|
||||
# | Last Modified: 2010-03-05 |
|
||||
# | Licence: GPLv3 http://www.gnu.org/licenses/gpl-3.0.txt |
|
||||
# +----------------------------------------------------------------------+
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use LWP;
|
||||
use Mail::Sendmail;
|
||||
|
||||
# -------------------------- DEBUG VARS ---------------------------------
|
||||
my $DEBUG = 0; # for debugging purpose
|
||||
my $EMAILDEBUG = 0; # for email debugging
|
||||
my $pluginname = &basename( "$0" ); # get the basename of the plugin
|
||||
my @to = qw( webmaster@guel.info ); # the list of admins receivced messages on an error
|
||||
my $from = "$pluginname-at-host\@guel.info"; # the host from where it comes
|
||||
my $muninnodename = "mail.guel.info"; # the Node from where it comes
|
||||
my $smtp = "mail.guel.info"; # the smtp relay to send the mail
|
||||
|
||||
# ------------------------- GLOBAL VARS ---------------------------------
|
||||
my $version = "1.0"; # UA Version
|
||||
my $agentname = "$pluginname Munin Plugin V$version"; # UA String
|
||||
my $url = "http://localhost:55553/"; # (defaults to localhost)
|
||||
my $response = 0; # the server output
|
||||
my @content = (); # the content we're retrive from $response
|
||||
my %index = ( # for Version 2
|
||||
'from' => 2, # <-- index frame from ( a tweak for other ASSP Versions )
|
||||
'to' => 4 # <-- index frame to ( "" )
|
||||
);
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
my @muninlabel = ( # General Runtime Information
|
||||
#"ASSP Proxy Uptime",
|
||||
#"Messages Processed",
|
||||
"Non-Local Mail Blocked",
|
||||
"CPU Usage",
|
||||
#"Concurrent SMTP Sessions"
|
||||
);
|
||||
|
||||
# ============= SANITY CHECKS ================
|
||||
unless( defined(@ARGV) ){
|
||||
$ARGV[0] = "";
|
||||
}
|
||||
|
||||
# =============== THE GET ====================
|
||||
if( $ARGV[0] eq "" ){
|
||||
my $agent = LWP::UserAgent->new();
|
||||
$agent->agent("$agentname");
|
||||
$response = $agent->get( $url );
|
||||
&response_error() unless $response->is_success;
|
||||
@content = split( /\n/, $response->content );
|
||||
|
||||
my $line = "";
|
||||
my $count = $index{from};
|
||||
my $label;
|
||||
my( $key, $value, $last );
|
||||
while( 1 ){
|
||||
&finish() if( $count == $index{to} ); # EXIT IF GENERAL SECTION FINISH
|
||||
$line = $content[$count];
|
||||
$count++;
|
||||
chomp( $line );
|
||||
next if $line eq ""; # no empty lines
|
||||
next if $line =~ /^\n$/; # no newlines
|
||||
next if $line =~ /^\r$/; # or else
|
||||
next if $line =~ /^\r\n$/; # http specific
|
||||
( $key, $value, $last) = split( /\|/, $line ); # split up to three values
|
||||
$key =~ s/^\s//g; $key =~ s/\s$//g; # no spaces at the end and the beginning
|
||||
$value =~ s/^\s//g; $value =~ s/\s$//g;
|
||||
$value =~ s/(\d*)\s*.*/$1/g; # remove more than one values from splited data
|
||||
$value =~ s/[a-zA-Z\(\)\%]//g; # and not alphanummeric glyphs
|
||||
$last =~ s/^\s//g; $last =~ s/\s$//g;
|
||||
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g; # generate a label
|
||||
$label =~ s/\-/\_/g; # the subs glyph to underline
|
||||
$label =~ s/[\(\)]//g; # no special glyphs feel free to add more
|
||||
print "$label.value $value\n"; # print the result to the label
|
||||
}
|
||||
}
|
||||
|
||||
# =============== FUNCTIONS ==================
|
||||
sub finish{
|
||||
exit 0;
|
||||
}
|
||||
sub response_error{
|
||||
if( $DEBUG ){
|
||||
foreach my $admin ( @to ){
|
||||
my %mail = ( smtp => "$smtp", To => "$admin", From => "$from", Subject => "Munin Plugin $pluginname", Message => "ERROR: $agentname at $muninnodename\n" );
|
||||
&sendmail(%mail) or die "ERROR: $Mail::Sendmail::error\n";
|
||||
|
||||
if( $EMAILDEBUG ){
|
||||
print "OK. Log says:\n$Mail::Sendmail::log\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
exit 1; # if no admin exists
|
||||
}
|
||||
|
||||
# ============== MUNIN GRAPHER COINFIG =======
|
||||
|
||||
if( $ARGV[0] eq "config" ){
|
||||
my $count = 0;
|
||||
my $label;
|
||||
foreach my $key ( @muninlabel ){
|
||||
if( $count == 0 ){ # General Runtime Information
|
||||
print "graph_title ASSP - General Runtime Information\n";
|
||||
print "graph_vlabel Counter in Percent\n";
|
||||
print "graph_category ASSP\n";
|
||||
}
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g;
|
||||
$label =~ s/\-/\_/g;
|
||||
$label =~ s/[\(\)]//g;
|
||||
print "$label.label $key\n";
|
||||
$count++;
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# +----------------------------------------------------------------------+
|
||||
# | A Munin Graph Plugin for ASSP |
|
||||
# | [ assp-message-statistics ] |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Enrico Labedzki |
|
||||
# | Email: enrico.labdzki@brodos.de |
|
||||
# | Last Modified: 2010-02-22 |
|
||||
# | Licence: GPLv3 http://www.gnu.org/licenses/gpl-3.0.txt |
|
||||
# +----------------------------------------------------------------------+
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use LWP;
|
||||
use Mail::Sendmail;
|
||||
|
||||
# -------------------------- DEBUG VARS ---------------------------------
|
||||
my $DEBUG = 0; # for debugging purpose
|
||||
my $EMAILDEBUG = 0; # for email debugging
|
||||
my $pluginname = &basename( "$0" ); # get the basename of the plugin
|
||||
my @to = qw( webmaster@bguel.info ); # the list of admins receivced messages on an
|
||||
my $from = "$pluginname-at-host\@guel.info"; # the host from where it comes
|
||||
my $muninnodename = "mail.guel.info"; # the Node from where it comes
|
||||
my $smtp = "mail.guel.info"; # the smtp relay to send the mail
|
||||
|
||||
# ------------------------- GLOBAL VARS ---------------------------------
|
||||
my $version = "1.0"; # UA Version
|
||||
my $agentname = "$pluginname Munin Plugin V$version"; # UA String
|
||||
my $url = "http://localhost:55553/"; # (defaults to localhost)
|
||||
my $response = 0; # the server output
|
||||
my @content = (); # the content we're retrive from $response
|
||||
my %index = ( # for Version 2
|
||||
'from' => 66, # <-- index frame from ( a tweak for other ASSP Versions )
|
||||
'to' => 100 # <-- index frame to ( "" )
|
||||
);
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
my @muninlabel = (
|
||||
# Message Statistics --> index 66..100
|
||||
"Bayesian Hams",
|
||||
"Whitelisted",
|
||||
"Local",
|
||||
"Noprocessing",
|
||||
"Spamlover Spams Passed",
|
||||
"Bayesian Spams",
|
||||
"Domains Blacklisted",
|
||||
"HELO Blacklisted",
|
||||
"HELO Invalid",
|
||||
"HELO Forged",
|
||||
"Missing MX",
|
||||
"Missing PTR",
|
||||
"Invalid PTR",
|
||||
"Spam Collected Messages",
|
||||
"Penalty Trap Messages",
|
||||
"Bad Attachments",
|
||||
"Viruses Detected",
|
||||
"Sender Regex",
|
||||
"Bomb Regex",
|
||||
"Penalty Box",
|
||||
"Message Scoring",
|
||||
"Invalid Local Sender",
|
||||
"Invalid Internal Mail",
|
||||
"Scripts",
|
||||
"SPF Failures",
|
||||
"RBL Failures",
|
||||
"URIBL Failures",
|
||||
"Max Errors Exceeded",
|
||||
"Delayed",
|
||||
"Empty Recipient",
|
||||
"Not SRS Signed Bounces",
|
||||
"MSGID Signature",
|
||||
"DKIM",
|
||||
"DKIM pre Check",
|
||||
"Pre Header"
|
||||
);
|
||||
|
||||
# ============= SANITY CHECKS ================
|
||||
unless( defined(@ARGV) ){
|
||||
$ARGV[0] = "";
|
||||
}
|
||||
|
||||
# =============== THE GET ====================
|
||||
if( $ARGV[0] eq "" ){
|
||||
my $agent = LWP::UserAgent->new();
|
||||
$agent->agent("$agentname");
|
||||
$response = $agent->get( $url );
|
||||
&response_error() unless $response->is_success;
|
||||
@content = split( /\n/, $response->content );
|
||||
|
||||
my $line = "";
|
||||
my $count = $index{from};
|
||||
my $label;
|
||||
my( $key, $value, $last );
|
||||
while( 1 ){
|
||||
&finish() if( $count > $index{to} );
|
||||
$line = $content[$count];
|
||||
$count++;
|
||||
chomp( $line );
|
||||
next if $line eq ""; # no empty lines
|
||||
next if $line =~ /^\n$/; # no newlines
|
||||
next if $line =~ /^\r$/; # or else
|
||||
next if $line =~ /^\r\n$/; # http specific
|
||||
( $key, $value, $last) = split( /\|/, $line ); # split up to three values
|
||||
$key =~ s/^\s//g; $key =~ s/\s$//g; # no spaces at the end and the beginning
|
||||
$value =~ s/^\s//g; $value =~ s/\s$//g;
|
||||
$value =~ s/(\d*)\s*.*/$1/g; # remove more than one values from splited data
|
||||
$value =~ s/[a-zA-Z\(\)\%]//g; # and not alphanummeric glyphs
|
||||
$last =~ s/^\s//g; $last =~ s/\s$//g;
|
||||
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g; # generate a label
|
||||
$label =~ s/\-/\_/g; # the subs glyph to underline
|
||||
$label =~ s/[\(\)]//g; # no special glyphs feel free to add more
|
||||
print "$label.value $value\n"; # print the result to the label
|
||||
}
|
||||
}
|
||||
|
||||
# =============== FUNCTIONS ==================
|
||||
sub finish{
|
||||
exit 0;
|
||||
}
|
||||
sub response_error{
|
||||
if( $DEBUG ){
|
||||
foreach my $admin ( @to ){
|
||||
my %mail = ( smtp => "$smtp", To => "$admin", From => "$from", Subject => "Munin Plugin $pluginname", Message => "ERROR: $agentname at $muninnodename\n" );
|
||||
&sendmail(%mail) or die "ERROR: $Mail::Sendmail::error\n";
|
||||
|
||||
if( $EMAILDEBUG ){
|
||||
print "OK. Log says:\n$Mail::Sendmail::log\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
exit 1; # if no admin exists
|
||||
}
|
||||
|
||||
# ============== MUNIN GRAPHER COINFIG =======
|
||||
|
||||
if( $ARGV[0] eq "config" ){
|
||||
print "graph_title ASSP - Message Statistics\n";
|
||||
print "graph_vlabel Counter in k,m\n";
|
||||
print "graph_category ASSP\n";
|
||||
|
||||
my $label;
|
||||
foreach my $key ( @muninlabel ){
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g;
|
||||
$label =~ s/\-/\_/g;
|
||||
$label =~ s/[\(\)]//g;
|
||||
print "$label.label $key\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# +----------------------------------------------------------------------+
|
||||
# | A Munin Graph Plugin for ASSP |
|
||||
# | [ assp-smtp-connection-statistics ] |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Enrico Labedzki |
|
||||
# | Email: enrico.labdzki@brodos.de |
|
||||
# | Last Modified: 2010-02-22 |
|
||||
# | Licence: GPLv3 http://www.gnu.org/licenses/gpl-3.0.txt |
|
||||
# +----------------------------------------------------------------------+
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use LWP;
|
||||
use Mail::Sendmail;
|
||||
|
||||
# -------------------------- DEBUG VARS ---------------------------------
|
||||
my $DEBUG = 0; # for debugging purpose
|
||||
my $EMAILDEBUG = 0; # for email debugging
|
||||
my $pluginname = &basename( "$0" ); # get the basename of the plugin
|
||||
my @to = qw( webmaster@guel.info ); # the list of admins receivced messages on an error
|
||||
my $from = "$pluginname-at-host\@guel.info"; # the host from where it comes
|
||||
my $muninnodename = "mail.guel.info"; # the Node from where it comes
|
||||
my $smtp = "mail.guel.info"; # the smtp relay to send the mail
|
||||
|
||||
# ------------------------- GLOBAL VARS ---------------------------------
|
||||
my $version = "1.0"; # UA Version
|
||||
my $agentname = "$pluginname Munin Plugin V$version"; # UA String
|
||||
my $url = "http://localhost:55553/"; # (defaults to localhost)
|
||||
my $response = 0; # the server output
|
||||
my @content = (); # the content we're retrive from $response
|
||||
my %index = ( # for Version 2
|
||||
'from' => 25, # <-- index frame from ( a tweak for other ASSP Versions )
|
||||
'to' => 38 # <-- index frame to ( "" )
|
||||
);
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
my @muninlabel = (
|
||||
# SMTP Connection Statistics --> index 25..38
|
||||
"Accepted Logged SMTP Connections",
|
||||
"SSL SMTP Connections",
|
||||
"TLS SMTP Connections",
|
||||
"Not Logged SMTP Connections",
|
||||
"SMTP Connection Limits",
|
||||
"Overall Limits",
|
||||
"By IP Limits",
|
||||
"By IP Frequency Limits",
|
||||
"By Domain IP Limits",
|
||||
"SMTP Connections Timeout",
|
||||
"SMTP SSL-Connections Timeout",
|
||||
"SMTP TLS-Connections Timeout",
|
||||
"Denied SMTP Connections",
|
||||
"SMTP damping"
|
||||
);
|
||||
|
||||
# ============= SANITY CHECKS ================
|
||||
unless( defined(@ARGV) ){
|
||||
$ARGV[0] = "";
|
||||
}
|
||||
|
||||
# =============== THE GET ====================
|
||||
if( $ARGV[0] eq "" ){
|
||||
my $agent = LWP::UserAgent->new();
|
||||
$agent->agent("$agentname");
|
||||
$response = $agent->get( $url );
|
||||
&response_error() unless $response->is_success;
|
||||
@content = split( /\n/, $response->content );
|
||||
|
||||
my $line = "";
|
||||
my $count = $index{from};
|
||||
my $label;
|
||||
my( $key, $value, $last );
|
||||
while( 1 ){
|
||||
&finish() if( $count > $index{to} );
|
||||
$line = $content[$count];
|
||||
$count++;
|
||||
chomp( $line );
|
||||
next if $line eq ""; # no empty lines
|
||||
next if $line =~ /^\n$/; # no newlines
|
||||
next if $line =~ /^\r$/; # or else
|
||||
next if $line =~ /^\r\n$/; # http specific
|
||||
( $key, $value, $last) = split( /\|/, $line ); # split up to three values
|
||||
$key =~ s/^\s//g; $key =~ s/\s$//g; # no spaces at the end and the beginning
|
||||
$value =~ s/^\s//g; $value =~ s/\s$//g;
|
||||
$value =~ s/(\d*)\s*.*/$1/g; # remove more than one values from splited data
|
||||
$value =~ s/[a-zA-Z\(\)\%]//g; # and not alphanummeric glyphs
|
||||
$last =~ s/^\s//g; $last =~ s/\s$//g;
|
||||
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g; # generate a label
|
||||
$label =~ s/\-/\_/g; # the subs glyph to underline
|
||||
$label =~ s/[\(\)]//g; # no special glyphs feel free to add more
|
||||
print "$label.value $value\n"; # print the result to the label
|
||||
}
|
||||
}
|
||||
|
||||
# =============== FUNCTIONS ==================
|
||||
sub finish{
|
||||
exit 0;
|
||||
}
|
||||
sub response_error{
|
||||
if( $DEBUG ){
|
||||
foreach my $admin ( @to ){
|
||||
my %mail = ( smtp => "$smtp", To => "$admin", From => "$from", Subject => "Munin Plugin $pluginname", Message => "ERROR: $agentname at $muninnodename\n" );
|
||||
&sendmail(%mail) or die "ERROR: $Mail::Sendmail::error\n";
|
||||
|
||||
if( $EMAILDEBUG ){
|
||||
print "OK. Log says:\n$Mail::Sendmail::log\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
exit 1; # if no admin exists
|
||||
}
|
||||
|
||||
# ============== MUNIN GRAPHER COINFIG =======
|
||||
|
||||
if( $ARGV[0] eq "config" ){
|
||||
print "graph_title ASSP - SMTP Connection Statistics\n";
|
||||
print "graph_vlabel Counter in k,m\n";
|
||||
print "graph_category ASSP\n";
|
||||
|
||||
my $label;
|
||||
foreach my $key ( @muninlabel ){
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g;
|
||||
$label =~ s/\-/\_/g;
|
||||
$label =~ s/[\(\)]//g;
|
||||
print "$label.label $key\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# +----------------------------------------------------------------------+
|
||||
# | A Munin Graph Plugin for ASSP |
|
||||
# | [ assp-smtp-handler-statistics ] |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Enrico Labedzki |
|
||||
# | Email: enrico.labdzki@brodos.de |
|
||||
# | Last Modified: 2010-02-22 |
|
||||
# | Licence: GPLv3 http://www.gnu.org/licenses/gpl-3.0.txt |
|
||||
# +----------------------------------------------------------------------+
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use LWP;
|
||||
use Mail::Sendmail;
|
||||
|
||||
# -------------------------- DEBUG VARS ---------------------------------
|
||||
my $DEBUG = 0; # for debugging purpose
|
||||
my $EMAILDEBUG = 0; # for email debugging
|
||||
my $pluginname = &basename( "$0" ); # get the basename of the plugin
|
||||
my @to = qw( webmaster@guel.info ); # the list of admins receivced messages on an error
|
||||
my $from = "$pluginname-at-host\@guel.info"; # the host from where it comes
|
||||
my $muninnodename = "mail.guel.info"; # the Node from where it comes
|
||||
my $smtp = "mail.guel.info"; # the smtp relay to send the mail
|
||||
|
||||
# ------------------------- GLOBAL VARS ---------------------------------
|
||||
my $version = "1.0"; # UA Version
|
||||
my $agentname = "$pluginname Munin Plugin V$version"; # UA String
|
||||
my $url = "http://localhost:55553/"; # (defaults to localhost)
|
||||
my $response = 0; # the server output
|
||||
my @content = (); # the content we're retrive from $response
|
||||
my %index = ( # for Version 2
|
||||
'from' => 4, # <-- index frame from ( a tweak for other ASSP Versions )
|
||||
'to' => 5 # <-- index frame to ( "" )
|
||||
);
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
my @muninlabel = ( # General Runtime Information
|
||||
#"ASSP Proxy Uptime",
|
||||
#"Messages Processed",
|
||||
#"Non-Local Mail Blocked",
|
||||
#"CPU Usage",
|
||||
"Concurrent SMTP Sessions"
|
||||
);
|
||||
|
||||
# ============= SANITY CHECKS ================
|
||||
unless( defined(@ARGV) ){
|
||||
$ARGV[0] = "";
|
||||
}
|
||||
|
||||
# =============== THE GET ====================
|
||||
if( $ARGV[0] eq "" ){
|
||||
my $agent = LWP::UserAgent->new();
|
||||
$agent->agent("$agentname");
|
||||
$response = $agent->get( $url );
|
||||
&response_error() unless $response->is_success;
|
||||
@content = split( /\n/, $response->content );
|
||||
|
||||
my $line = "";
|
||||
my $count = $index{from};
|
||||
my $label;
|
||||
my( $key, $value, $last );
|
||||
while( 1 ){
|
||||
&finish() if( $count == $index{to} ); # EXIT IF GENERAL SECTION FINISH
|
||||
$line = $content[$count];
|
||||
$count++;
|
||||
chomp( $line );
|
||||
next if $line eq ""; # no empty lines
|
||||
next if $line =~ /^\n$/; # no newlines
|
||||
next if $line =~ /^\r$/; # or else
|
||||
next if $line =~ /^\r\n$/; # http specific
|
||||
( $key, $value, $last) = split( /\|/, $line ); # split up to three values
|
||||
$key =~ s/^\s//g; $key =~ s/\s$//g; # no spaces at the end and the beginning
|
||||
$value =~ s/^\s//g; $value =~ s/\s$//g;
|
||||
$value =~ s/(\d*)\s*.*/$1/g; # remove more than one values from splited data
|
||||
$value =~ s/[a-zA-Z\(\)\%]//g; # and not alphanummeric glyphs
|
||||
$last =~ s/^\s//g; $last =~ s/\s$//g;
|
||||
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g; # generate a label
|
||||
$label =~ s/\-/\_/g; # the subs glyph to underline
|
||||
$label =~ s/[\(\)]//g; # no special glyphs feel free to add more
|
||||
print "$label.value $value\n"; # print the result to the label
|
||||
}
|
||||
}
|
||||
|
||||
# =============== FUNCTIONS ==================
|
||||
sub finish{
|
||||
exit 0;
|
||||
}
|
||||
sub response_error{
|
||||
if( $DEBUG ){
|
||||
foreach my $admin ( @to ){
|
||||
my %mail = ( smtp => "$smtp", To => "$admin", From => "$from", Subject => "Munin Plugin $pluginname", Message => "ERROR: $agentname at $muninnodename\n" );
|
||||
&sendmail(%mail) or die "ERROR: $Mail::Sendmail::error\n";
|
||||
|
||||
if( $EMAILDEBUG ){
|
||||
print "OK. Log says:\n$Mail::Sendmail::log\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
exit 1; # if no admin exists
|
||||
}
|
||||
|
||||
# ============== MUNIN GRAPHER COINFIG =======
|
||||
|
||||
if( $ARGV[0] eq "config" ){
|
||||
my $count = 0;
|
||||
my $label;
|
||||
foreach my $key ( @muninlabel ){
|
||||
if( $count == 0 ){ # General Runtime Information
|
||||
print "graph_title ASSP - General Runtime Information\n";
|
||||
print "graph_vlabel Counter in Percent\n";
|
||||
print "graph_category ASSP\n";
|
||||
}
|
||||
$label = $key;
|
||||
$label =~ s/\s/\_/g;
|
||||
$label =~ s/\-/\_/g;
|
||||
$label =~ s/[\(\)]//g;
|
||||
print "$label.label $key\n";
|
||||
$count++;
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue