Script for Exim-mail server

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
kiko84
Posts: 15
Joined: Mon May 17, 2004 4:06 am

Script for Exim-mail server

Post by kiko84 »

Hi,

I'm searching for scripts and XML files to graph statistic of my Mail server - Exim. I have found a script on this forum but for Postfix and it doesn't work.

Somebody can help me ?

Thanks
Lojak

Here you go.

Post by Lojak »

Here is a quick script I threw together for such a purpose. It's quick, dirty, and worked for me. YMMV. If you improve upon it, please post the new code to this topic or e-mail me.

Code: Select all

#!/usr/bin/perl
#
#
# exim_traffic.pl (c) 2004 Stephen Fulton (sfulton@connection.ca)
#
# Free to use by anyone, anywhere.  I only as that if you improve upon
# the code (and it can definitely be improved), send me a copy.   
#
# Very basic perl script to parse an Exim (v4) log file and return
# a number based on the counted instances every 5 minutes.
#
# I originally wrote this for use in our Cacti install, but it can work
# with MRTG or any other time based stats tool.  For use on external machines,
# I recommend you look into running this script via SNMP -- have Cacti poll
# the machine using a custom OID of your choice, and have it execute this script.
# As far as how to do it, maybe I'll include instructions later.  YMMV. 
#
# Syntax & Comments:
#
# in    = Number of inbound messages
# out   = Number of outbound messages 
# rbl   = Real-time block list rejects (Change to reflect your logged messages)
# rejecteduser = Number of rejected recipients (good for noting dictionary attacks)
#
#######################################################################################  

use POSIX qw(strftime);


## Replace with the location and name of your main Exim log file
##

$EXIM_LOG = "/var/log/exim/exim_mainlog";

##
##

$inbound = 0;
$outbound = 0;
$rbl = 0;
$rejected_users = 0;

print "$EXIM_LOG\n";

open(LOG, $EXIM_LOG) || die "$0: Could not open Exim log: $!";

## Okay this is cheap -- fix this. SLOPPY SLOPPY SLOPPY.     
## It will be mostly accurate, but not entirely.  More code is needed.
##           
$fivemin = strftime("%Y-%m-%d %H:%M", gmtime(time-14700));
$fourmin = strftime("%Y-%m-%d %H:%M", gmtime(time-14640));
$threemin = strftime("%Y-%m-%d %H:%M", gmtime(time-14580));
$twomin = strftime("%Y-%m-%d %H:%M", gmtime(time-14520));
$onemin = strftime("%Y-%m-%d %H:%M", gmtime(time-14460));
$zeromin = strftime("%Y-%m-%d %H:%M", gmtime(time-14400));

while(<LOG>) {

  next unless (/^$fivemin/ || /^$fourmin/ || /^$threemin/ || /^$twomin/ || /^$onemin/ || /^$zeromin/);   

  if (/<=/) {
        $inbound++;
  } elsif(/[-=]>/) {
        $outbound++;
  } elsif(/RBL:/) {
        $rbl++;
  } elsif(/rejected RCPT/) {
        $rejected_users++;
  }

    
}

$argument = lc($ARGV[0]);

if($argument eq 'in') { print "$inbound\n"; }
elsif($argument eq 'out') { print "$outbound\n"; }
elsif($argument eq 'rbl') { print "$rbl\n"; }
elsif($argument eq 'rejectedusers') { print "$rejected_users\n"; }
else {
  print "exim4_traffic.pl\n\n";
  print "in\t\tReport inbound messages.\n";
  print "out\t\tReport outbound messages.\n";
  print "rbl\t\tReport number of RBL rejects.\n";
  print "rejecteduser\t\tReport number of rejected users (dictionary attacks).\n";
 }
GoranTornqvist
Posts: 35
Joined: Wed Nov 10, 2004 5:43 am
Location: Stockholm
Contact:

Post by GoranTornqvist »

I changed the script a bit...I'm no perl programmer so feel free to point out any bad practices ;) Anyway, it's working for me.
I'm also quite new to cacti so if there's a better way do this, point that out to :)

/usr/local/share/snmp/scripts/exim.cron.pl:

Code: Select all

#!/usr/bin/perl
#
#
# exim_traffic.pl (c) 2004 Stephen Fulton (sfulton@connection.ca)
#
# Modified by:
# 2004-11-09    Goran Tornqvist (goran-nospam@aleborg.se)
#               * Changed from gmdate to localtime (works for me with CET)
#               * Added extra checking in logfile. Failed deliveries, etc
#               * Writing output to files instead of stdout
#
# Free to use by anyone, anywhere.  I only as that if you improve upon
# the code (and it can definitely be improved), send me a copy.
#
# Very basic perl script to parse an Exim (v4) log file and return
# a number based on the counted instances every 5 minutes.
#
# I originally wrote this for use in our Cacti install, but it can work
# with MRTG or any other time based stats tool.  For use on external machines,
# I recommend you look into running this script via SNMP -- have Cacti poll
# the machine using a custom OID of your choice, and have it execute this script.
# As far as how to do it, maybe I'll include instructions later.  YMMV.
#
# Syntax & Comments:
#
# in = Number of inbound messages
# out = Number of outbound messages
# rbl = Real-time block list rejects (Change to reflect your logged messages)
# rejecteduser = Number of rejected recipients (good for noting dictionary attacks)
# rejected_data = Number of messages rejected because of contents (viruses)
# rejected_by_filter = Number of messages rejected by the filter (like .pif .com files)
# del_failed = Number of failed deliveries (permanent errors)
# del_deferred = Number of deferred deliveries (temporary errors)
#
#######################################################################################

use POSIX qw(strftime);

## Replace with the location and name of your main Exim log file
##

$EXIM_LOG = "/var/log/exim/exim_mainlog";

##
##

$inbound = 0;
$outbound = 0;
$rbl = 0;
$rejected_users = 0;
$rejected_data = 0;
$rejected_by_filter = 0;
$del_failed = 0;
$del_deferred = 0;

$del_deferred = 0;

#print "$EXIM_LOG\n";

open(LOG, $EXIM_LOG) || die "$0: Could not open Exim log: $!";

## Okay this is cheap -- fix this. SLOPPY SLOPPY SLOPPY.
## It will be mostly accurate, but not entirely.  More code is needed.
##

$fivemin = strftime("%Y-%m-%d %H:%M", localtime(time-300));
$fourmin = strftime("%Y-%m-%d %H:%M", localtime(time-240));
$threemin = strftime("%Y-%m-%d %H:%M", localtime(time-180));
$twomin = strftime("%Y-%m-%d %H:%M", localtime(time-120));
$onemin = strftime("%Y-%m-%d %H:%M", localtime(time-60));
$zeromin = strftime("%Y-%m-%d %H:%M", localtime(time));

while(<LOG>) {

  next unless (/^$fivemin/ || /^$fourmin/ || /^$threemin/ || /^$twomin/ || /^$onemin/ || /^$zeromin/);

  if (/<=/) {
        $inbound++;
  } elsif(/[-=]>/) {
        $outbound++;
  } elsif(/\*\*/) {
        $del_failed++;
 } elsif(/==/) {
        $del_deferred++;
  } elsif(/RBL:/) {
        $rbl++;
  } elsif(/rejected RCPT/) {
        $rejected_users++;
  } elsif(/rejected after DATA/) {
        $rejected_data++;
  } elsif(/cancelled by system filter/) {
        $rejected_by_filter++;
  }


}

$file1 = "/usr/local/share/snmp/scripts/output/exim-traffic.output";
open($fh1,">$file1") or die("Could not open file $file1\n");
print $fh1 "inbound:$inbound outbound:$outbound";
close($fh1);

$file2 = "/usr/local/share/snmp/scripts/output/exim-rejected.output";
open($fh2,">$file2") or die("Could not open file $file2\n");
print $fh2 "rejected_users=$rejected_users rejected_data:$rejected_data rejected_by_filter:$rejected_by_filter";
close($fh2);

$file3 = "/usr/local/share/snmp/scripts/output/exim-delivery.output";
open($fh3,">$file3") or die("Could not open file $file3\n");
print $fh3 "del_failed:$del_failed del_deferred:$del_deferred";
close($fh3);

# COMMENTED OUT - Im not using RBLs. print " rbl=$rbl";

I run the above script from cron:

Code: Select all

# SNMP Scripts
*/5 * * * * /usr/local/share/snmp/scripts/cron > /dev/null 2>&1
/usr/local/share/snmp/scripts/cron:

Code: Select all

#!/usr/local/bin/bash
#SNMP scripts
/usr/local/share/snmp/scripts/exim.cron.pl >/usr/local/share/snmp/scripts/exim.cron.log
I read the data from the output/ files with scripts and snmp.

snmpd.conf:

Code: Select all

#Custom OIDs
exec .1.3.6.1.4.1.3032.64 exim-traffic /usr/local/share/snmp/scripts/exim-traffic
exec .1.3.6.1.4.1.3032.65 exim-rejected /usr/local/share/snmp/scripts/exim-rejected
exec .1.3.6.1.4.1.3032.66 exim-delivery /usr/local/share/snmp/scripts/exim-delivery
exim-traffic script is simple:

Code: Select all

#!/usr/local/bin/bash
cat /usr/local/share/snmp/scripts/output/exim-traffic.output
the others look the same.

After you added the lines snmpd.conf do a kill -HUP snmpd-pid and:
run script: /usr/local/share/snmp/scripts/exim.cron.pl
try this: snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.3032
Should give you something like:

Code: Select all

SNMPv2-SMI::enterprises.3032.64.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.64.2.1 = STRING: "exim-traffic"
SNMPv2-SMI::enterprises.3032.64.3.1 = STRING: "/usr/local/share/snmp/scripts/exim-traffic"
SNMPv2-SMI::enterprises.3032.64.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.64.101.1 = STRING: "inbound:1 outbound:1"
SNMPv2-SMI::enterprises.3032.64.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.65.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.65.2.1 = STRING: "exim-rejected"
SNMPv2-SMI::enterprises.3032.65.3.1 = STRING: "/usr/local/share/snmp/scripts/exim-rejected"
SNMPv2-SMI::enterprises.3032.65.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.65.101.1 = STRING: "rejected_users:0 rejected_data:0 rejected_by_filter:0"
SNMPv2-SMI::enterprises.3032.65.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.66.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.66.2.1 = STRING: "exim-delivery"
SNMPv2-SMI::enterprises.3032.66.3.1 = STRING: "/usr/local/share/snmp/scripts/exim-delivery"
SNMPv2-SMI::enterprises.3032.66.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.66.101.1 = STRING: "del_failed:0 del_deferred:0"
SNMPv2-SMI::enterprises.3032.66.102.1 = INTEGER: 0
Nothing left but to get the data in to cacti:

exim-traffic:

Code: Select all

#!/usr/local/bin/bash
snmpdata=`snmpget -v 2c -c $1 $2 .1.3.6.1.4.1.3032.64.101.1 | awk -F"\"" '{ print $2 }'`
echo $snmpdata
Input parameters
$1 is communityname
$2 is hostname
arti
Posts: 9
Joined: Sat May 21, 2005 5:21 am

Post by arti »

i tried this, but i get:

root@host [~]# ./exim-traffic public athens.dnsrouter.com
stdin: is not a tty
root@host [~]#

also when doing an snmpwalk, i get the following:

SNMPv2-SMI::enterprises.3032.64.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.64.2.1 = STRING: "exim-traffic"
SNMPv2-SMI::enterprises.3032.64.3.1 = STRING: "/usr/local/share/snmp/scripts/exim-traffic"
SNMPv2-SMI::enterprises.3032.64.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.64.101.1 = STRING: "stdin: is not a tty"
SNMPv2-SMI::enterprises.3032.64.101.2 = STRING: "inbound:49 outbound:47"
SNMPv2-SMI::enterprises.3032.64.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.64.103.1 = ""
SNMPv2-SMI::enterprises.3032.65.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.65.2.1 = STRING: "exim-rejected"
SNMPv2-SMI::enterprises.3032.65.3.1 = STRING: "/usr/local/share/snmp/scripts/exim-rejected"
SNMPv2-SMI::enterprises.3032.65.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.65.101.1 = STRING: "stdin: is not a tty"
SNMPv2-SMI::enterprises.3032.65.101.2 = STRING: "rejected_users=65 rejected_data:2 rejected_by_filter:1"
SNMPv2-SMI::enterprises.3032.65.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.65.103.1 = ""
SNMPv2-SMI::enterprises.3032.66.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.66.2.1 = STRING: "exim-delivery"
SNMPv2-SMI::enterprises.3032.66.3.1 = STRING: "/usr/local/share/snmp/scripts/exim-delivery"
SNMPv2-SMI::enterprises.3032.66.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.66.101.1 = STRING: "stdin: is not a tty"
SNMPv2-SMI::enterprises.3032.66.101.2 = STRING: "del_failed:4 del_deferred:5"
SNMPv2-SMI::enterprises.3032.66.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.66.103.1 = ""

note the stdin: is not a tty how do i get rid of this? :(
Hildebrand
Posts: 18
Joined: Thu Oct 27, 2005 9:24 am
Location: Germany, Bavaria

Post by Hildebrand »

Hello,

i tested this Script and get also an error:

Code: Select all

mail:/usr/local/share/cacti/scripts# snmpget -v 2c -c public localhost .1.3.6.1.4.1.3032
SNMPv2-SMI::enterprises.3032 = No Such Object available on this agent at this OID
mail:/usr/local/share/cacti/scripts# snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.3032
SNMPv2-SMI::enterprises.3032.64.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.64.2.1 = STRING: "exim-traffic"
SNMPv2-SMI::enterprises.3032.64.3.1 = STRING: "/usr/local/share/cacti/scripts/exim-traffic"
SNMPv2-SMI::enterprises.3032.64.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.64.101.1 = STRING: "No hostname specified."
SNMPv2-SMI::enterprises.3032.64.101.2 = STRING: "USAGE: snmpget [OPTIONS] AGENT OID [OID]..."
SNMPv2-SMI::enterprises.3032.64.101.3 = ""
SNMPv2-SMI::enterprises.3032.64.101.4 = STRING: "  Version:  5.1.2"
SNMPv2-SMI::enterprises.3032.64.101.5 = STRING: "  Web:      http://www.net-snmp.org/"
SNMPv2-SMI::enterprises.3032.64.101.6 = STRING: "  Email:    net-snmp-coders@lists.sourceforge.net"
SNMPv2-SMI::enterprises.3032.64.101.7 = ""
SNMPv2-SMI::enterprises.3032.64.101.8 = STRING: "OPTIONS:"
SNMPv2-SMI::enterprises.3032.64.101.9 = STRING: "  -h, --help..display this help message"
SNMPv2-SMI::enterprises.3032.64.101.10 = STRING: "  -H...display configuration file directives understood"
SNMPv2-SMI::enterprises.3032.64.101.11 = STRING: "  -v 1|2c|3..specifies SNMP version to use"
SNMPv2-SMI::enterprises.3032.64.101.12 = STRING: "  -V, --version..display package version number"
SNMPv2-SMI::enterprises.3032.64.101.13 = STRING: "SNMP Version 1 or 2c specific"
SNMPv2-SMI::enterprises.3032.64.101.14 = STRING: "  -c COMMUNITY..set the community string"
SNMPv2-SMI::enterprises.3032.64.101.15 = STRING: "SNMP Version 3 specific"
SNMPv2-SMI::enterprises.3032.64.101.16 = STRING: "  -a PROTOCOL..set authentication protocol (MD5|SHA)"
SNMPv2-SMI::enterprises.3032.64.101.17 = STRING: "  -A PASSPHRASE..set authentication protocol pass phrase"
SNMPv2-SMI::enterprises.3032.64.101.18 = STRING: "  -e ENGINE-ID..set security engine ID (e.g. 800000020109840301)"
SNMPv2-SMI::enterprises.3032.64.101.19 = STRING: "  -E ENGINE-ID..set context engine ID (e.g. 800000020109840301)"
SNMPv2-SMI::enterprises.3032.64.101.20 = STRING: "  -l LEVEL..set security level (noAuthNoPriv|authNoPriv|authPriv)"
SNMPv2-SMI::enterprises.3032.64.101.21 = STRING: "  -n CONTEXT..set context name (e.g. bridge1)"
SNMPv2-SMI::enterprises.3032.64.101.22 = STRING: "  -u USER-NAME..set security name (e.g. bert)"
SNMPv2-SMI::enterprises.3032.64.101.23 = STRING: "  -x PROTOCOL..set privacy protocol (DES)"
SNMPv2-SMI::enterprises.3032.64.101.24 = STRING: "  -X PASSPHRASE..set privacy protocol pass phrase"
SNMPv2-SMI::enterprises.3032.64.101.25 = STRING: "  -Z BOOTS,TIME..set destination engine boots/time"
SNMPv2-SMI::enterprises.3032.64.101.26 = STRING: "General communicat"
SNMPv2-SMI::enterprises.3032.64.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.64.103.1 = ""
SNMPv2-SMI::enterprises.3032.65.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.65.2.1 = STRING: "exim-rejected"
SNMPv2-SMI::enterprises.3032.65.3.1 = STRING: "/usr/local/share/cacti/scripts/exim-rejected"
SNMPv2-SMI::enterprises.3032.65.100.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.65.101.1 = STRING: "/usr/local/share/cacti/scripts/exim-rejected: No such file or directory"
SNMPv2-SMI::enterprises.3032.65.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.65.103.1 = ""
SNMPv2-SMI::enterprises.3032.66.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.66.2.1 = STRING: "exim-delivery"
SNMPv2-SMI::enterprises.3032.66.3.1 = STRING: "/usr/local/share/cacti/scripts/exim-delivery"
SNMPv2-SMI::enterprises.3032.66.100.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.66.101.1 = STRING: "/usr/local/share/cacti/scripts/exim-delivery: No such file or directory"
SNMPv2-SMI::enterprises.3032.66.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.66.103.1 = ""
mail:/usr/local/share/cacti/scripts#
Is there an wrong Syntax?? :roll:
No Hostname? No such file or directory??

Can someone Help me?
FunkY
Posts: 2
Joined: Fri Jun 06, 2008 3:48 am

Post by FunkY »

do you have a XML file for this nice script?

thx
GoranTornqvist wrote:I changed the script a bit...I'm no perl programmer so feel free to point out any bad practices ;) Anyway, it's working for me.
I'm also quite new to cacti so if there's a better way do this, point that out to :)

/usr/local/share/snmp/scripts/exim.cron.pl:

Code: Select all

#!/usr/bin/perl
#
#
# exim_traffic.pl (c) 2004 Stephen Fulton (sfulton@connection.ca)
#
# Modified by:
# 2004-11-09    Goran Tornqvist (goran-nospam@aleborg.se)
#               * Changed from gmdate to localtime (works for me with CET)
#               * Added extra checking in logfile. Failed deliveries, etc
#               * Writing output to files instead of stdout
#
# Free to use by anyone, anywhere.  I only as that if you improve upon
# the code (and it can definitely be improved), send me a copy.
#
# Very basic perl script to parse an Exim (v4) log file and return
# a number based on the counted instances every 5 minutes.
#
# I originally wrote this for use in our Cacti install, but it can work
# with MRTG or any other time based stats tool.  For use on external machines,
# I recommend you look into running this script via SNMP -- have Cacti poll
# the machine using a custom OID of your choice, and have it execute this script.
# As far as how to do it, maybe I'll include instructions later.  YMMV.
#
# Syntax & Comments:
#
# in = Number of inbound messages
# out = Number of outbound messages
# rbl = Real-time block list rejects (Change to reflect your logged messages)
# rejecteduser = Number of rejected recipients (good for noting dictionary attacks)
# rejected_data = Number of messages rejected because of contents (viruses)
# rejected_by_filter = Number of messages rejected by the filter (like .pif .com files)
# del_failed = Number of failed deliveries (permanent errors)
# del_deferred = Number of deferred deliveries (temporary errors)
#
#######################################################################################

use POSIX qw(strftime);

## Replace with the location and name of your main Exim log file
##

$EXIM_LOG = "/var/log/exim/exim_mainlog";

##
##

$inbound = 0;
$outbound = 0;
$rbl = 0;
$rejected_users = 0;
$rejected_data = 0;
$rejected_by_filter = 0;
$del_failed = 0;
$del_deferred = 0;

$del_deferred = 0;

#print "$EXIM_LOG\n";

open(LOG, $EXIM_LOG) || die "$0: Could not open Exim log: $!";

## Okay this is cheap -- fix this. SLOPPY SLOPPY SLOPPY.
## It will be mostly accurate, but not entirely.  More code is needed.
##

$fivemin = strftime("%Y-%m-%d %H:%M", localtime(time-300));
$fourmin = strftime("%Y-%m-%d %H:%M", localtime(time-240));
$threemin = strftime("%Y-%m-%d %H:%M", localtime(time-180));
$twomin = strftime("%Y-%m-%d %H:%M", localtime(time-120));
$onemin = strftime("%Y-%m-%d %H:%M", localtime(time-60));
$zeromin = strftime("%Y-%m-%d %H:%M", localtime(time));

while(<LOG>) {

  next unless (/^$fivemin/ || /^$fourmin/ || /^$threemin/ || /^$twomin/ || /^$onemin/ || /^$zeromin/);

  if (/<=/) {
        $inbound++;
  } elsif(/[-=]>/) {
        $outbound++;
  } elsif(/\*\*/) {
        $del_failed++;
 } elsif(/==/) {
        $del_deferred++;
  } elsif(/RBL:/) {
        $rbl++;
  } elsif(/rejected RCPT/) {
        $rejected_users++;
  } elsif(/rejected after DATA/) {
        $rejected_data++;
  } elsif(/cancelled by system filter/) {
        $rejected_by_filter++;
  }


}

$file1 = "/usr/local/share/snmp/scripts/output/exim-traffic.output";
open($fh1,">$file1") or die("Could not open file $file1\n");
print $fh1 "inbound:$inbound outbound:$outbound";
close($fh1);

$file2 = "/usr/local/share/snmp/scripts/output/exim-rejected.output";
open($fh2,">$file2") or die("Could not open file $file2\n");
print $fh2 "rejected_users=$rejected_users rejected_data:$rejected_data rejected_by_filter:$rejected_by_filter";
close($fh2);

$file3 = "/usr/local/share/snmp/scripts/output/exim-delivery.output";
open($fh3,">$file3") or die("Could not open file $file3\n");
print $fh3 "del_failed:$del_failed del_deferred:$del_deferred";
close($fh3);

# COMMENTED OUT - Im not using RBLs. print " rbl=$rbl";

I run the above script from cron:

Code: Select all

# SNMP Scripts
*/5 * * * * /usr/local/share/snmp/scripts/cron > /dev/null 2>&1
/usr/local/share/snmp/scripts/cron:

Code: Select all

#!/usr/local/bin/bash
#SNMP scripts
/usr/local/share/snmp/scripts/exim.cron.pl >/usr/local/share/snmp/scripts/exim.cron.log
I read the data from the output/ files with scripts and snmp.

snmpd.conf:

Code: Select all

#Custom OIDs
exec .1.3.6.1.4.1.3032.64 exim-traffic /usr/local/share/snmp/scripts/exim-traffic
exec .1.3.6.1.4.1.3032.65 exim-rejected /usr/local/share/snmp/scripts/exim-rejected
exec .1.3.6.1.4.1.3032.66 exim-delivery /usr/local/share/snmp/scripts/exim-delivery
exim-traffic script is simple:

Code: Select all

#!/usr/local/bin/bash
cat /usr/local/share/snmp/scripts/output/exim-traffic.output
the others look the same.

After you added the lines snmpd.conf do a kill -HUP snmpd-pid and:
run script: /usr/local/share/snmp/scripts/exim.cron.pl
try this: snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.3032
Should give you something like:

Code: Select all

SNMPv2-SMI::enterprises.3032.64.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.64.2.1 = STRING: "exim-traffic"
SNMPv2-SMI::enterprises.3032.64.3.1 = STRING: "/usr/local/share/snmp/scripts/exim-traffic"
SNMPv2-SMI::enterprises.3032.64.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.64.101.1 = STRING: "inbound:1 outbound:1"
SNMPv2-SMI::enterprises.3032.64.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.65.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.65.2.1 = STRING: "exim-rejected"
SNMPv2-SMI::enterprises.3032.65.3.1 = STRING: "/usr/local/share/snmp/scripts/exim-rejected"
SNMPv2-SMI::enterprises.3032.65.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.65.101.1 = STRING: "rejected_users:0 rejected_data:0 rejected_by_filter:0"
SNMPv2-SMI::enterprises.3032.65.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.66.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.3032.66.2.1 = STRING: "exim-delivery"
SNMPv2-SMI::enterprises.3032.66.3.1 = STRING: "/usr/local/share/snmp/scripts/exim-delivery"
SNMPv2-SMI::enterprises.3032.66.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.3032.66.101.1 = STRING: "del_failed:0 del_deferred:0"
SNMPv2-SMI::enterprises.3032.66.102.1 = INTEGER: 0
Nothing left but to get the data in to cacti:

exim-traffic:

Code: Select all

#!/usr/local/bin/bash
snmpdata=`snmpget -v 2c -c $1 $2 .1.3.6.1.4.1.3032.64.101.1 | awk -F""" '{ print $2 }'`
echo $snmpdata
Input parameters
$1 is communityname
$2 is hostname
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests