HotSaNIC/multiple postfix module
From AdminWiki
Patches for the multiple postifx module
diagrams.pl
--- /usr/local/src/HotSaNIC/modules/mailq/diagrams.pl 2004-05-24 08:53:39.000000000 +0900 +++ /usr/local/HotSaNIC/modules/mailq/diagrams.pl 2006-03-23 16:38:01.689559750 +0900 @@ -31,115 +31,134 @@ my ($FORCE,$DEBUGLEVEL,%PLOT)=HotSaNICdiagram::check_args(@ARGV); my @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG); -# generate diagrams -# -my $DB_FILE="./rrd/queue.rrd"; -# if database exists, create images... -if ( -e $DB_FILE) { - # handle module-specific settings - # - my $LEGEND="bytes"; - my $name=$LEGEND; - my $title="bytes in Queue"; +# read out each QUEUE file entry +# +foreach my $entry (@{$MODULECONFIG{QUEUE}}) { - # common options - # - push @OPTIONS,( - "-v", $LEGEND, # Y-legend - "--alt-autoscale-max"); # alternate scaling + my (undef,undef,$item,$DB_FILE,$name,$file,$description)=HotSaNICmod::common::get_names($entry,""); - # graph "bytes in queue" + # generate diagrams # - print "creating images for bytes in queue ...\n"; - - foreach my $range ("1h","6h","1day","1week","1month","1year") { - my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); + $DB_FILE="./rrd/$DB_FILE.rrd"; - my @EXTOPTIONS=("-s","-$fullrange", "--title", "$title - last $descr ($DATESTRING)"); - my @COMMANDS=(); + # if database exists, create images... + if ( -e $DB_FILE) { - if ($range eq "1h") { - @COMMANDS=("DEF:avg1=$DB_FILE:kbytes:AVERAGE", - "CDEF:avg=avg1,1024,*", - "AREA:avg#".$MODULECONFIG{COLOR_AREA}.":", - HotSaNICdiagram::insert_data("LINE1","avg",$MODULECONFIG{COLOR_LINE},"avg","min avg max cur",$LEGEND,1), - HotSaNICdiagram::insert_lines(%MODULECONFIG)); - } - else { - @COMMANDS=("DEF:avg1=$DB_FILE:kbytes:AVERAGE", - "DEF:max1=$DB_FILE:kbytes:MAX", - "DEF:min1=$DB_FILE:kbytes:MIN", - "CDEF:min=min1,1024,*", - "CDEF:avg=avg1,1024,*", - "CDEF:max=max1,1024,*", - HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1), - HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE},"avg ","min avg max",$LEGEND,1), - HotSaNICdiagram::insert_lines(%MODULECONFIG)); - } + + # handle module-specific settings + # + my $LEGEND="bytes"; + my $name=$LEGEND; + my $title="bytes in Queue"; + + # common options + # + push @OPTIONS,( + "-v", $LEGEND, # Y-legend + "--alt-autoscale-max"); # alternate scaling + + # graph "bytes in queue" + # + print "creating images for bytes in queue ...\n"; + + foreach my $range ("1h","6h","1day","1week","1month","1year") { + my ($descr,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); + + my @EXTOPTIONS=("-s","-$fullrange", "--title", "$title - last $descr ($DATESTRING)"); + my @COMMANDS=(); + + if ($range eq "1h") { + @COMMANDS=("DEF:avg1=$DB_FILE:kbytes:AVERAGE", + "CDEF:avg=avg1,1024,*", + "AREA:avg#".$MODULECONFIG{COLOR_AREA}.":", + HotSaNICdiagram::insert_data("LINE1","avg",$MODULECONFIG{COLOR_LINE},"avg","min avg max cur",$LEGEND,1), + HotSaNICdiagram::insert_lines(%MODULECONFIG)); + } + else { + @COMMANDS=("DEF:avg1=$DB_FILE:kbytes:AVERAGE", + "DEF:max1=$DB_FILE:kbytes:MAX", + "DEF:min1=$DB_FILE:kbytes:MIN", + "CDEF:min=min1,1024,*", + "CDEF:avg=avg1,1024,*", + "CDEF:max=max1,1024,*", + HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1), + HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE},"avg ","min avg max",$LEGEND,1), + HotSaNICdiagram::insert_lines(%MODULECONFIG)); + } + + my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$file-$name-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME); + HotSaNICdiagram::graph(%CONF); + } + print "\n"; + + @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG); + + $LEGEND="requests"; + $name="req"; + $title="requests in queue"; + + # common options + # + push @OPTIONS,( + "-v",$LEGEND, # Y-legend + "--alt-autoscale-max"); # alternate scaling + + # graph "items in queue" + print "creating images for requests ...\n"; + + foreach my $range ("1h","6h","1day","1week","1month","1year") { + my ($descr,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); + + my $legends="min avg max"; + if ($range eq "1h") { $legends="min avg max cur"; } + + my @EXTOPTIONS=("-s","-$fullrange", "--title", "$title - last $descr ($DATESTRING)"); + my @COMMANDS=( + "DEF:req=$DB_FILE:req:AVERAGE", + "DEF:crefused=$DB_FILE:crefused:AVERAGE", + "DEF:msrefused=$DB_FILE:msrefused:AVERAGE", + "DEF:ctimeout=$DB_FILE:ctimeout:AVERAGE", + "DEF:rtimeout=$DB_FILE:rtimeout:AVERAGE", + "DEF:nohost=$DB_FILE:nohost:AVERAGE", + "DEF:noroute=$DB_FILE:noroute:AVERAGE", + "DEF:err450=$DB_FILE:err450:AVERAGE", + "DEF:err421=$DB_FILE:err421:AVERAGE", + "DEF:err4=$DB_FILE:err4:AVERAGE", + "DEF:other=$DB_FILE:other:AVERAGE", + "CDEF:active=req,crefused,-,msrefused,-,ctimeout,-,rtimeout,-,nohost,-,noroute,-,err450,-,err421,-,err4,-,other,-,"); + + if ($range ne "1h") { + push @COMMANDS,("DEF:maxreq=$DB_FILE:req:MAX", + HotSaNICdiagram::insert_data("AREA","maxreq",$MODULECONFIG{COLOR_MINMAX},"abs. maximum ",$legends,$LEGEND,1), + "LINE1:maxreq#".$MODULECONFIG{COLOR_LINE}.":"); + } + # draw "unseen" line for "total" with "other"-value to have it on top of the legend + push @COMMANDS,( + HotSaNICdiagram::insert_data("LINE1","other req",$MODULECONFIG{COLOR_LINE} ,"total ",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("AREA" ,"msrefused",$MODULECONFIG{COLOR_AREA_MSREFUSED},"mail service refused",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","crefused" ,$MODULECONFIG{COLOR_AREA_CREFUSED} ,"connection refused ",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","other" ,$MODULECONFIG{COLOR_AREA_OTHER} ,"other ",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","nohost" ,$MODULECONFIG{COLOR_AREA_NOHOST} ,"host not found ",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","noroute" ,$MODULECONFIG{COLOR_AREA_NOROUTE} ,"route not found ",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","ctimeout" ,$MODULECONFIG{COLOR_AREA_CTIMEOUT} ,"connection timed out",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","err450" ,$MODULECONFIG{COLOR_AREA_ERR450} ,"450 mbox not okay ",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","err421" ,$MODULECONFIG{COLOR_AREA_ERR421} ,"421 service not okay",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","err4" ,$MODULECONFIG{COLOR_AREA_ERR4} ,"general 4xx error ",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","rtimeout" ,$MODULECONFIG{COLOR_AREA_RTIMEOUT} ,"read timed out ",$legends,$LEGEND,1), + HotSaNICdiagram::insert_data("STACK","active" ,$MODULECONFIG{COLOR_AREA} ,"active ",$legends,$LEGEND,1), + "LINE1:req#".$MODULECONFIG{COLOR_LINE}.":", + HotSaNICdiagram::insert_lines(%MODULECONFIG)); - my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$name-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME); - HotSaNICdiagram::graph(%CONF); - } - print "\n"; - - @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG); - - $LEGEND="requests"; - $name="req"; - $title="requests in queue"; - - # common options - # - push @OPTIONS,( - "-v",$LEGEND, # Y-legend - "--alt-autoscale-max"); # alternate scaling - -# graph "items in queue" - print "creating images for requests ...\n"; - - foreach my $range ("1h","6h","1day","1week","1month","1year") { - my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); - - my $legends="min avg max"; - if ($range eq "1h") { $legends="min avg max cur"; } - - my @EXTOPTIONS=("-s","-$fullrange", "--title", "$title - last $descr ($DATESTRING)"); - my @COMMANDS=( - "DEF:req=$DB_FILE:req:AVERAGE", - "DEF:crefused=$DB_FILE:crefused:AVERAGE", - "DEF:msrefused=$DB_FILE:msrefused:AVERAGE", - "DEF:ctimeout=$DB_FILE:ctimeout:AVERAGE", - "DEF:rtimeout=$DB_FILE:rtimeout:AVERAGE", - "DEF:nohost=$DB_FILE:nohost:AVERAGE", - "DEF:other=$DB_FILE:other:AVERAGE", - "CDEF:active=req,crefused,-,msrefused,-,ctimeout,-,rtimeout,-,nohost,-,other,-,"); - - if ($range ne "1h") { - push @COMMANDS,("DEF:maxreq=$DB_FILE:req:MAX", - HotSaNICdiagram::insert_data("AREA","maxreq",$MODULECONFIG{COLOR_MINMAX},"abs. maximum ",$legends,$LEGEND,1), - "LINE1:maxreq#".$MODULECONFIG{COLOR_LINE}.":"); - } - # draw "unseen" line for "total" with "other"-value to have it on top of the legend - push @COMMANDS,( - HotSaNICdiagram::insert_data("LINE1","other req",$MODULECONFIG{COLOR_LINE} ,"total ",$legends,$LEGEND,1), - HotSaNICdiagram::insert_data("AREA" ,"msrefused",$MODULECONFIG{COLOR_AREA_MSREFUSED},"mail service refused",$legends,$LEGEND,1), - HotSaNICdiagram::insert_data("STACK","crefused" ,$MODULECONFIG{COLOR_AREA_CREFUSED} ,"connection refused ",$legends,$LEGEND,1), - HotSaNICdiagram::insert_data("STACK","other" ,$MODULECONFIG{COLOR_AREA_OTHER} ,"other ",$legends,$LEGEND,1), - HotSaNICdiagram::insert_data("STACK","nohost" ,$MODULECONFIG{COLOR_AREA_NOHOST} ,"host not found ",$legends,$LEGEND,1), - HotSaNICdiagram::insert_data("STACK","ctimeout" ,$MODULECONFIG{COLOR_AREA_CTIMEOUT} ,"connection timed out",$legends,$LEGEND,1), - HotSaNICdiagram::insert_data("STACK","rtimeout" ,$MODULECONFIG{COLOR_AREA_RTIMEOUT} ,"read timed out ",$legends,$LEGEND,1), - HotSaNICdiagram::insert_data("STACK","active" ,$MODULECONFIG{COLOR_AREA} ,"active ",$legends,$LEGEND,1), - "LINE1:req#".$MODULECONFIG{COLOR_LINE}.":", - HotSaNICdiagram::insert_lines(%MODULECONFIG)); + my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$file-$name-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME); + HotSaNICdiagram::graph(%CONF); - my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$name-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME); - HotSaNICdiagram::graph(%CONF); + } } + else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n"; } } -else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n"; } print "\n"; exit 0;
makeindex.pl
--- /usr/local/src/HotSaNIC/modules/mailq/makeindex.pl 2004-05-29 18:43:00.000000000 +0900 +++ /usr/local/HotSaNIC/modules/mailq/makeindex.pl 2006-03-23 16:25:34.642872250 +0900 @@ -8,10 +8,10 @@ # include HotSaNIC libraries use lib "../../lib"; - +use lib "./platform"; use HotSaNICparser; use HotSaNIChtml; - +use common; (my $VERSION = '$Revision: 1.13 $') =~ s/.*(\d+\.\d+).*/$1/; (my $IDENTIFIER = '$Id: makeindex.pl,v 1.13 2004/05/29 09:43:00 bernisys Exp $') =~ s/.*,v (.*) \$/$1/; @@ -26,7 +26,7 @@ $REFRESH=$CONFIG{REFRESH}; $REFRESH=0 if !defined $REFRESH; - +%MODCONFIG=HotSaNICmod::common::configure(); @DIAGRAMS=("hour","6h","day","week","month","year"); @TIMES=("6h","week"); @@ -38,10 +38,10 @@ print FILE HotSaNIChtml::create_header($MODNAME,$REFRESH,"$time overview page")."<table>\n"; foreach $proc (keys %DESCR) { - $descr=$DESCR{$proc}; - ($name = $proc) =~ s/_/:/; - ($page=$proc) =~ s/[.:]/_/g; - print FILE HotSaNIChtml::create_table_entry($IMAGEFORMAT,$page,$time,$name,$descr,1); + foreach $entry (@{$MODCONFIG{QUEUE}}) { + my (undef,undef,undef,$dbname,$name,$file,$description)=HotSaNICmod::common::get_names($entry,$proc); + print FILE HotSaNIChtml::create_table_entry($IMAGEFORMAT,$file."-".$proc,$time,$name,$description,1); + } } print FILE "</table>\n".HotSaNIChtml::create_footer($MODNAME); close FILE; @@ -49,16 +49,17 @@ # build device-based .html files and complete index # +my $maxcols = scalar@{$MODCONFIG{QUEUE}}; open (IDXFILE,">$VARDIR/idxdata"); -print IDXFILE HotSaNIChtml::create_overview_table_header($MODNAME,join(" ",@TIMES),1); +print IDXFILE HotSaNIChtml::create_overview_table_header($MODNAME,join(" ",@TIMES),$maxcols); $num=0; foreach $proc (sort keys %DESCR) { $num++; - $description=$DESCR{$proc}; - ($file=$proc) =~ s/[.:]/_/g; - ($name = $proc) =~ s/_/:/; - print IDXFILE HotSaNIChtml::create_overview_table_entry($MODNAME,$IMAGEFORMAT,$num,$file,$name,$description); - HotSaNIChtml::make_device_page($MODNAME,$WEBDIR,$IMAGEFORMAT,$file,$description,@DIAGRAMS); + foreach $entry (@{$MODCONFIG{QUEUE}}) { + my (undef,undef,undef,$dbname,$name,$file,$description)=HotSaNICmod::common::get_names($entry,$proc); + print IDXFILE HotSaNIChtml::create_overview_table_entry($MODNAME,$IMAGEFORMAT,$num,$file."-".$proc,$name,$description); + HotSaNIChtml::make_device_page($MODNAME,$WEBDIR,$IMAGEFORMAT,$file."-".$proc,$description,@DIAGRAMS); + } } close IDXFILE;
makerrd
--- /usr/local/src/HotSaNIC/modules/mailq/makerrd 2004-04-19 01:35:24.000000000 +0900 +++ /usr/local/HotSaNIC/modules/mailq/makerrd 2006-03-23 16:34:00.242470250 +0900 @@ -2,14 +2,18 @@ . ../../settings +PROC=$1 + SECS=`date +%s` MODNAME=`pwd|sed -e "s/.*\///g" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` - echo $SECS $MODNAME: setting up database +if [ "$PROC" = "" ] ; then echo "arguments missing!" ; else + + echo $SECS $MODNAME: setting up database for $PROC - $BINPATH/rrdtool create rrd/queue.rrd --step 10 \ + $BINPATH/rrdtool create rrd/$PROC.rrd --step 10 \ DS:kbytes:GAUGE:300:0:U \ DS:req:GAUGE:300:0:U \ DS:crefused:GAUGE:300:0:U \ @@ -18,6 +22,10 @@ DS:nohost:GAUGE:300:0:U \ DS:other:GAUGE:300:0:U \ DS:msrefused:GAUGE:300:0:U \ + DS:noroute:GAUGE:300:0:U \ + DS:err450:GAUGE:300:0:U \ + DS:err421:GAUGE:300:0:U \ + DS:err4:GAUGE:300:0:U \ RRA:AVERAGE:0:1:720 \ RRA:AVERAGE:0.3:6:2880 \ RRA:AVERAGE:0.3:60:2016 \ @@ -32,6 +40,8 @@ RRA:MAX:0.3:360:1488 \ RRA:MAX:0.3:4320:1460 +fi; + # 2h -> 720 Werte alle 10sec # 2d = 48h -> 2880 Werte alle 1min (6*10sec) # 2w = 14d -> 2016 Werte alle 10min (60*10sec)
setup.pl
--- /usr/local/src/HotSaNIC/modules/mailq/setup.pl 2004-07-12 16:50:14.000000000 +0900 +++ /usr/local/HotSaNIC/modules/mailq/setup.pl 2006-03-22 17:49:56.041398000 +0900 @@ -11,7 +11,7 @@ use lib "../../lib"; use lib "./platform"; use HotSaNICparser; - +use HotSaNICshellio; use HotSaNIClog; use common; @@ -21,18 +21,36 @@ (my $IDENTIFIER = '$Id: setup.pl,v 1.6 2004/07/12 07:50:14 bernisys Exp $') =~ s/.*,v (.*) \$/$1/; my $MODNAME=HotSaNICparser::get_module_name(); - +my %MODCONF=HotSaNICmod::common::configure(); my $OUTFILE="settings.new"; if ( ! -e "settings" ) { $OUTFILE="settings"; } open OUTFILE,">$OUTFILE" || die "could not open ".HotSaNICparser::get_module_name()." settings file for writing.\n"; +if (! @{$MODCONF{QUEUE}}) { @{$MODCONF{QUEUE}}="" } +if (@{$MODCONF{QUEUE}}) { $MODCONF{QUEUE}="QUEUE=\"".join("\"\nQUEUE=\"",@{$MODCONF{QUEUE}})."\""; } +else { $MODCONF{QUEUE}=""; } + + print OUTFILE "# SHORT DESCRIPTION # -# This module doesn't need any configuration right now. +# configure queues # +# QUEUE=\"<name>,<description>\" +# +# name is the path to the main.cf file, eg /usr/local/postfix/etc/postifx/ +# if there is no entry, the default path is taken. +# if you have several running, and one is the default, you have to add +# the default too +# +$MODCONF{QUEUE} "; close OUTFILE; -print "This module doesn't need any configuration right now.\n"; +if ($OUTFILE eq "settings.new") { + HotSaNICparser::backup_file("settings"); + rename "settings.new","settings"; + } + +print "Please check the settings file and adapt it to satisfy your needs.\n";
in the platform folder common.pm
--- /usr/local/src/HotSaNIC/modules/mailq/platform/common.pm 2004-05-24 08:53:39.000000000 +0900 +++ /usr/local/HotSaNIC/modules/mailq/platform/common.pm 2006-03-23 16:29:05.364041500 +0900 @@ -6,7 +6,40 @@ } sub configure { - return HotSaNICparser::get_moduleconfig("."); + %MODULECONFIG=HotSaNICparser::get_moduleconfig(".",(QUEUE=>"array")); + if (!@{$MODULECONFIG{QUEUE}}) { @{$MODULECONFIG{QUEUE}}=(""); } +# if (! @list) { @list=HotSaNICparser::locate_files("bin/xntpdc"); } + + return %MODULECONFIG; } +sub get_names { + my $entry=shift || ","; + my $item=shift || ""; + my $community=""; + + my %DESCR=(""=>"","bytes"=>"Bytes in ","req"=>"Requests in "); + + my ($queue,$description)=split /,/,$entry; + if ($queue eq "") { + $dbname="queue"; + @list=HotSaNICparser::locate_files("/etc/postfix/main.cf"); + if ( @list < 1 ) + { + @list=HostSaNICparser::locate_files("main.cf"); + } + # always use first found + $queue = $list[0]; + $file=$item; + $name=$item; + $description=$DESCR{$item}; + } + else { + ($dbname=$queue) =~ s/[:\/]/_/g; + ($file=$queue) =~ s/[.:\/]/_/g; + $name=$queue; + $description=$DESCR{$item}."Postifx Queue $queue"; + } + return ($queue,$community,$item,$dbname,$name,$file,$description); + } 1;
default.pl
--- /usr/local/src/HotSaNIC/modules/mailq/platform/default.pm 2004-07-01 19:28:50.000000000 +0900 +++ /usr/local/HotSaNIC/modules/mailq/platform/default.pm 2006-03-23 16:34:55.249908000 +0900 @@ -11,34 +11,49 @@ sub sample { my %args=@_; - $kbytes=0; - $crefused=0; - $ctimeout=0; - $rtimeout=0; - $nohost=0; - $other=0; - $msrefused=0; - $active=0; - - open FILE,"mailq|"; - while (<FILE>) { - if (/^\w{10,}\*\s/o) { $active++; } - elsif (/^\s*\(/o) { - if (index($_,"Connection refused") >=0 ) { $crefused++; } - elsif (index($_,"Connection timed out") >=0 ) { $ctimeout++; } - elsif (index($_,"Host not found") >=0 ) { $nohost++; } - elsif (index($_,"read timeout") >=0 ) { $rtimeout++; } - elsif (index($_,"server refused mail service") >=0 ) { $msrefused++; } - else { $other++; } + foreach $entry (@{$args{QUEUE}}) { + my ($queue,undef,undef,$dbname,undef,undef,undef)=HotSaNICmod::common::get_names($entry,""); + + $kbytes=0; + $crefused=0; + $ctimeout=0; + $rtimeout=0; + $nohost=0; + $other=0; + $msrefused=0; + $active=0; + $noroute=0; + $err450=0; + $err421=0; + $err4=0; + + my $command="mailq -C $queue"; + + open FILE,"$command|"; + while (<FILE>) { + if (/^\w{10,}\*\s/o) { $active++; } + elsif (/^\s*\(/o) { + if (index($_,"Connection refused") >=0 ) { $crefused++; } + elsif (index($_,"Connection timed out") >=0 ) { $ctimeout++; } + elsif (index($_,"Host not found") >=0 ) { $nohost++; } + elsif (index($_,"read timeout") >=0 ) { $rtimeout++; } + elsif (index($_,"server refused mail service") >=0 ) { $msrefused++; } + elsif (index($_,"No route to host") >=0 ) { $noroute++; } + elsif (index($_,"said: 450") >=0 ) { $err450++; } + elsif (index($_,"said: 421") >=0 ) { $err421++; } + elsif (index($_,"said: 4") >=0 ) { $err4++; } # all other 4xx errors are collected here + else { $other++; } + } + elsif (/^--/o) { (undef,$kbytes)=split; } } - elsif (/^--/o) { (undef,$kbytes)=split; } - } - close FILE; + close FILE; - my $req=$crefused+$ctimeout+$rtimeout+$nohost+$other+$msrefused+$active; + my $req=$crefused+$ctimeout+$rtimeout+$nohost+$other+$msrefused+$active+$noroute+$err450+$err421+$err4; +print "DB: $dbname, running: $command\n"; - HotSaNICmod::do_rrd("queue","U",time,$kbytes,$req,$crefused,$ctimeout,$rtimeout,$nohost,$other,$msrefused); + HotSaNICmod::do_rrd($dbname,"U",time,$kbytes,$req,$crefused,$ctimeout,$rtimeout,$nohost,$other,$msrefused,$noroute,$err450,$err421,$err4); + } } 1;