exim statistics
Moderators: Developers, Moderators
Hi again,
the script is really tightened to vexim2/exim4 on Debian (here it is saved as /usr/local/sbin/exim4_stats.pl)
the script is really tightened to vexim2/exim4 on Debian (here it is saved as /usr/local/sbin/exim4_stats.pl)
Code: Select all
#!/usr/bin/perl
# originally: exim_perf.pl - gathers performance data from the exim log file
# adapted and fixed for VEXIM 2.2 and Exim 4.x on Debian Lenny
# by Daniel Knabl
use strict;
use File::stat qw(:FIELDS);
my $exim_log = "/var/log/exim4/mainlog";
my $exim_sta = "/etc/snmp/exim_perf.stat";
my $exim_tmp = "/tmp/exim_perf.temp";
my $exim_1 = "/var/log/exim4/mainlog.1";
my $logchunk = get_newest($exim_log);
open STATS, "|eximstats > $exim_tmp" or die;
foreach my $line (@$logchunk) {
print STATS $line;
}
close STATS;
my $remote_smtp = 0;
my $local_delivery = 0;
my $virtual_delivery = 0;
my $virtual_vacation_delivery = 0;
my $ditch_spam_transport = 0;
my $mailman_transport = 0;
my $blackhole = 0;
open STATS, "<$exim_tmp" or die;
while (my $line = <STATS>) {
chomp $line;
if ($line =~ m/remote_smtp .* ([0-9]+)$/) {
$remote_smtp = $1;
}
if ($line =~ m/local_delivery .* ([0-9]+)$/) {
$local_delivery = $1;
}
if ($line =~ m/virtual_delivery .* ([0-9]+)$/) {
$virtual_delivery = $1;
}
if ($line =~ m/virtual_vacation_delivery .* ([0-9]+)$/) {
$virtual_vacation_delivery = $1;
}
if ($line =~ m/ditch_spam_transport .* ([0-9]+)$/) {
$ditch_spam_transport = $1;
}
if ($line =~ m/mailman_transport .* ([0-9]+)$/) {
$mailman_transport = $1;
}
if ($line =~ m/:blackhole: .* ([0-9]+)$/) {
$blackhole = $1;
}
}
close STATS;
print "remote_smtp\n";
print "$remote_smtp\n";
print "local_delivery\n";
print "$local_delivery\n";
print "virtual_delivery\n";
print "$virtual_delivery\n";
print "virtual_vacation_delivery\n";
print "$virtual_vacation_delivery\n";
print "ditch_spam_transport\n";
print "$ditch_spam_transport\n";
print "mailman_transport\n";
print "$mailman_transport\n";
print "blackhole\n";
print "$blackhole\n";
exit (0);
sub get_newest ($) {
my $file = shift;
my $position= 0;
my $timestamp = 1000000000000000;
my @log;
if (-e "$exim_sta") {
open FILE, "<$exim_sta" or die;
my $line = <FILE>;
chomp $line;
($position, $timestamp) = split " ", $line;
close FILE;
}
open FILE, "<$exim_log" or die;
my $st = stat("$exim_1") or die;
if ($st->ctime > $timestamp) {
# File has been rotated, read the old file first.
open OLDFILE, "<$exim_1" or die;
seek (OLDFILE, $position, 0);
while (my $line = <OLDFILE>) {
push @log, $line;
}
close OLDFILE;
$position = 0;
}
seek (FILE, $position, 0);
# now read the new file.
while (my $line = <FILE>) {
push @log, $line;
}
$position = tell(FILE);
close FILE;
open FILE, ">$exim_sta" or die;
print FILE "$position " . $st->ctime . "\n";
close FILE;
return \@log;
}
regards
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
thanks,
ah, but i'm using sa-exim. this doesn't return any information on spam stats for me
i'm not sure exactly how i'm going to get the spam stats as eximstats doesn't seem to report them when using sa-exim.
i'm just running a mail relay so i don't need any of the local delivery stats. anyone using cacti to graph what sa-exim is doing?
ah, but i'm using sa-exim. this doesn't return any information on spam stats for me
i'm not sure exactly how i'm going to get the spam stats as eximstats doesn't seem to report them when using sa-exim.
i'm just running a mail relay so i don't need any of the local delivery stats. anyone using cacti to graph what sa-exim is doing?
... something is going wrong here ...
The script does only give reasonable results if I run it by hand, although it seems to work correctly. It is chmod'ed to 750, it is in the path, the cron job runs the script as user root (yes, it is chown'ed to root.root) ... still no output.
My perl knowledge is pretty poor which means: I can read and understand, what the script does, but I can't modify it furthermore to do what I want it to do. So, if there's anyone using this kind of solution successfully, then PLEASE share your wisdom with me
I'm willing to provide any information needed to debug, even a limited shell account would be an option ... so you can see my desperation
The script does only give reasonable results if I run it by hand, although it seems to work correctly. It is chmod'ed to 750, it is in the path, the cron job runs the script as user root (yes, it is chown'ed to root.root) ... still no output.
My perl knowledge is pretty poor which means: I can read and understand, what the script does, but I can't modify it furthermore to do what I want it to do. So, if there's anyone using this kind of solution successfully, then PLEASE share your wisdom with me
I'm willing to provide any information needed to debug, even a limited shell account would be an option ... so you can see my desperation
regards
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Ladies and Gentlemen
Now I've got it up and running. My modifications seem to work perfectly, also there's now a way to query the rejected ones.
Though my modifications are based on an installation where exim4 is used together with vexim2/mysql. For this reason it is important to use exactly the same transports as provided with vexim2 - for example one could use our Debian packages that we provide on http://pkg-vexim.alioth.debian.org
For any ideas to improve or simplify my setup please pm me.
Now I've got it up and running. My modifications seem to work perfectly, also there's now a way to query the rejected ones.
Though my modifications are based on an installation where exim4 is used together with vexim2/mysql. For this reason it is important to use exactly the same transports as provided with vexim2 - for example one could use our Debian packages that we provide on http://pkg-vexim.alioth.debian.org
For any ideas to improve or simplify my setup please pm me.
regards
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Hi again,
is there still some need or interest in this template? If so, I could provide the latest version of it. Please don't hit me, but there's one question remaining:
How can I make one xml file out of those numerous files? Is it even possible?
Please help me with this issue if someone needs the working version
is there still some need or interest in this template? If so, I could provide the latest version of it. Please don't hit me, but there's one question remaining:
How can I make one xml file out of those numerous files? Is it even possible?
Please help me with this issue if someone needs the working version
regards
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Yes PLEASE! I have been unable to set this up correctly.
This is my cron entry :
*/5 * * * * /etc/snmp/exim_perf.pl > /etc/snmp/exim_perf.stats
And this is the output :
[root@smtp snmp]# /etc/snmp/exim_perf.pl > /etc/snmp/exim_perf.stats
[root@smtp snmp]# cat exim_perf.stats
clamcheck
0
local_delivery
0
remote_smtp
1
spamcheck
0
trend_micro
0
remote_smtp_single_recipient_domains
0
It only shows 1 message because my mail server is quiet at the moment. When i ran earlier i saw it correctly counting.
At the bottom of my SNMPD config file i have the following :
exec .1.3.6.1.4.1.14464.25 exim_perf.pl /bin/cat /etc/snmp/exim_perf.stats
So whats up? My graph is returning null values!
This is my cron entry :
*/5 * * * * /etc/snmp/exim_perf.pl > /etc/snmp/exim_perf.stats
And this is the output :
[root@smtp snmp]# /etc/snmp/exim_perf.pl > /etc/snmp/exim_perf.stats
[root@smtp snmp]# cat exim_perf.stats
clamcheck
0
local_delivery
0
remote_smtp
1
spamcheck
0
trend_micro
0
remote_smtp_single_recipient_domains
0
It only shows 1 message because my mail server is quiet at the moment. When i ran earlier i saw it correctly counting.
At the bottom of my SNMPD config file i have the following :
exec .1.3.6.1.4.1.14464.25 exim_perf.pl /bin/cat /etc/snmp/exim_perf.stats
So whats up? My graph is returning null values!
Your graph is most probably returning NULL values, because you seem to use the original script. You should instead use the modified script which i posted before. Here everything works fine with some different machines.
regards
Daniel
regards
Daniel
regards
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Actually that script is working fine but i have changed to yours now.
This what keeps happening, i run the script manually and it count mail just fine however if i leave it on its own and i check it later and the file is 0 bytes, completely empty!
I think maybe somehow the file is getting locked and the SNMP poll is interfering or something?
This what keeps happening, i run the script manually and it count mail just fine however if i leave it on its own and i check it later and the file is 0 bytes, completely empty!
I think maybe somehow the file is getting locked and the SNMP poll is interfering or something?
Normally this message means, that your version is older than the version the tamplate was created with. In this special case I'm rather unsure, because I also used version 0.8.6j to create the template/s.
Sorry, but I don't know a good answer though.
regrads
Daniel
Sorry, but I don't know a good answer though.
regrads
Daniel
regards
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
dogzilla: have you cron'ed the script before the poller tries to access and fetch data via snmp? Normally this should work without any complications.
regards
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Thanks Daniel, i'll try create these xml files manually.dk10tlx wrote:Normally this message means, that your version is older than the version the tamplate was created with. In this special case I'm rather unsure, because I also used version 0.8.6j to create the template/s.
Sorry, but I don't know a good answer though.
regrads
Daniel
I have same problem with xml hash version error...sjs wrote:Hi!
I'm using cacti 0.8.6i (which is part of the Debian Etch) and I'm also getting the "XML: Hash version does not exist." error when trying to import dk10tlx's XMLs.
Any chance I'll get that stuff up and running?
Regards,
Sebastian
PS: The debian-specific perl script seems to be working already.
Who is online
Users browsing this forum: No registered users and 3 guests