Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


exim statistics
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
dmcat10



Joined: 07 Aug 2007
Posts: 2

PostPosted: Tue Aug 07, 2007 9:20 pm    Post subject: Reply with quote

hey dk10tlx,

This is excellent I'm also working on stats of exim4 on Debian.

Would you be able to post the script you are using?

thanks
Back to top
dk10tlx



Joined: 04 Aug 2007
Posts: 19
Location: Tirol / Austria

PostPosted: Wed Aug 08, 2007 9:52 am    Post subject: Reply with quote

Hi again,

the script is really tightened to vexim2/exim4 on Debian (here it is saved as /usr/local/sbin/exim4_stats.pl)

Code:
#!/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;
}
Back to top
dmcat10



Joined: 07 Aug 2007
Posts: 2

PostPosted: Wed Aug 08, 2007 9:39 pm    Post subject: Reply with quote

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?
Back to top
dk10tlx



Joined: 04 Aug 2007
Posts: 19
Location: Tirol / Austria

PostPosted: Thu Aug 09, 2007 12:46 pm    Post subject: Reply with quote

... 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
Back to top
dk10tlx



Joined: 04 Aug 2007
Posts: 19
Location: Tirol / Austria

PostPosted: Sat Aug 18, 2007 7:33 am    Post subject: Reply with quote

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.
Back to top
dk10tlx



Joined: 04 Aug 2007
Posts: 19
Location: Tirol / Austria

PostPosted: Sun Aug 19, 2007 8:32 am    Post subject: Reply with quote

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
Back to top
dogzilla



Joined: 19 Sep 2007
Posts: 2

PostPosted: Wed Sep 19, 2007 4:47 am    Post subject: Reply with quote

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!
Back to top
dk10tlx



Joined: 04 Aug 2007
Posts: 19
Location: Tirol / Austria

PostPosted: Wed Sep 19, 2007 12:01 pm    Post subject: Reply with quote

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
Back to top
dogzilla



Joined: 19 Sep 2007
Posts: 2

PostPosted: Thu Sep 20, 2007 9:12 am    Post subject: Reply with quote

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?
Back to top
Smux



Joined: 10 Sep 2007
Posts: 40

PostPosted: Thu Sep 20, 2007 11:35 am    Post subject: Reply with quote

Hi,

Im trying to import this XML files and the CACTI shows that "Error: XML: Hash version does not exist."

I use version 0.8.6j.

Anyone knows to solve this?

Thanks in advance and sorry for my bad english.
Back to top
dk10tlx



Joined: 04 Aug 2007
Posts: 19
Location: Tirol / Austria

PostPosted: Thu Sep 20, 2007 11:56 am    Post subject: Reply with quote

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
Back to top
dk10tlx



Joined: 04 Aug 2007
Posts: 19
Location: Tirol / Austria

PostPosted: Thu Sep 20, 2007 11:58 am    Post subject: Reply with quote

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.
Back to top
Smux



Joined: 10 Sep 2007
Posts: 40

PostPosted: Thu Sep 20, 2007 12:45 pm    Post subject: Reply with quote

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


Thanks Daniel, i'll try create these xml files manually.
Back to top
sjs



Joined: 24 Oct 2007
Posts: 2

PostPosted: Wed Oct 24, 2007 1:28 pm    Post subject: Reply with quote

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.
Back to top
Smux



Joined: 10 Sep 2007
Posts: 40

PostPosted: Wed Oct 24, 2007 2:14 pm    Post subject: Reply with quote

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.

I have same problem with xml hash version error...
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 



Powered by phpBB © 2001, 2005 phpBB Group