2013-01-04 08:27:05 +00:00
#
# Monitorix - A lightweight system monitoring tool.
#
2020-02-21 09:36:35 +00:00
# Copyright (C) 2005-2020 by Jordi Sanfeliu <jordi@fibranet.cat>
2013-01-04 08:27:05 +00:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
package mail ;
use strict ;
use warnings ;
use Monitorix ;
use RRDs ;
use POSIX qw( strftime ) ;
use Exporter 'import' ;
our @ EXPORT = qw( mail_init mail_update mail_cgi ) ;
sub mail_init {
my $ myself = ( caller ( 0 ) ) [ 3 ] ;
my ( $ package , $ config , $ debug ) = @ _ ;
my $ rrd = $ config - > { base_lib } . $ package . ".rrd" ;
2013-01-22 14:51:37 +00:00
my $ mail = $ config - > { mail } ;
2013-01-04 08:27:05 +00:00
2013-10-24 12:00:58 +01:00
my $ info ;
my @ rra ;
my @ tmp ;
my $ n ;
my @ average ;
my @ min ;
my @ max ;
my @ last ;
if ( - e $ rrd ) {
$ info = RRDs:: info ( $ rrd ) ;
for my $ key ( keys %$ info ) {
if ( index ( $ key , 'rra[' ) == 0 ) {
if ( index ( $ key , '.rows' ) != - 1 ) {
push ( @ rra , substr ( $ key , 4 , index ( $ key , ']' ) - 4 ) ) ;
}
}
}
2013-11-04 15:51:19 +00:00
if ( scalar ( @ rra ) < 12 + ( 4 * $ config - > { max_historic_years } ) ) {
2013-10-24 12:00:58 +01:00
logger ( "$myself: Detected size mismatch between 'max_historic_years' (" . $ config - > { max_historic_years } . ") and $rrd (" . ( ( scalar ( @ rra ) - 12 ) / 4 ) . "). Resizing it accordingly. All historical data will be lost. Backup file created." ) ;
rename ( $ rrd , "$rrd.bak" ) ;
}
}
2013-01-04 08:27:05 +00:00
if ( ! ( - e $ rrd ) ) {
logger ( "Creating '$rrd' file." ) ;
2013-10-24 12:00:58 +01:00
for ( $ n = 1 ; $ n <= $ config - > { max_historic_years } ; $ n + + ) {
push ( @ average , "RRA:AVERAGE:0.5:1440:" . ( 365 * $ n ) ) ;
push ( @ min , "RRA:MIN:0.5:1440:" . ( 365 * $ n ) ) ;
push ( @ max , "RRA:MAX:0.5:1440:" . ( 365 * $ n ) ) ;
push ( @ last , "RRA:LAST:0.5:1440:" . ( 365 * $ n ) ) ;
}
2013-01-04 08:27:05 +00:00
eval {
RRDs:: create ( $ rrd ,
"--step=60" ,
"DS:mail_in:GAUGE:120:0:U" ,
"DS:mail_out:GAUGE:120:0:U" ,
"DS:mail_recvd:GAUGE:120:0:U" ,
"DS:mail_delvd:GAUGE:120:0:U" ,
"DS:mail_bytes_recvd:GAUGE:120:0:U" ,
"DS:mail_bytes_delvd:GAUGE:120:0:U" ,
"DS:mail_rejtd:GAUGE:120:0:U" ,
"DS:mail_spam:GAUGE:120:0:U" ,
"DS:mail_virus:GAUGE:120:0:U" ,
"DS:mail_bouncd:GAUGE:120:0:U" ,
"DS:mail_queued:GAUGE:120:0:U" ,
"DS:mail_discrd:GAUGE:120:0:U" ,
"DS:mail_held:GAUGE:120:0:U" ,
"DS:mail_forwrd:GAUGE:120:0:U" ,
"DS:mail_queues:GAUGE:120:0:U" ,
2014-07-16 10:20:22 +01:00
"DS:mail_val01:GAUGE:120:0:U" ,
"DS:mail_val02:GAUGE:120:0:U" ,
"DS:mail_val03:GAUGE:120:0:U" ,
"DS:mail_val04:GAUGE:120:0:U" ,
"DS:mail_val05:GAUGE:120:0:U" ,
2013-01-04 08:27:05 +00:00
"DS:mail_val06:GAUGE:120:0:U" ,
"DS:mail_val07:GAUGE:120:0:U" ,
"DS:mail_val08:GAUGE:120:0:U" ,
"DS:mail_val09:GAUGE:120:0:U" ,
"DS:mail_val10:GAUGE:120:0:U" ,
"RRA:AVERAGE:0.5:1:1440" ,
"RRA:AVERAGE:0.5:30:336" ,
"RRA:AVERAGE:0.5:60:744" ,
2013-10-24 12:00:58 +01:00
@ average ,
2013-01-04 08:27:05 +00:00
"RRA:MIN:0.5:1:1440" ,
"RRA:MIN:0.5:30:336" ,
"RRA:MIN:0.5:60:744" ,
2013-10-24 12:00:58 +01:00
@ min ,
2013-01-04 08:27:05 +00:00
"RRA:MAX:0.5:1:1440" ,
"RRA:MAX:0.5:30:336" ,
"RRA:MAX:0.5:60:744" ,
2013-10-24 12:00:58 +01:00
@ max ,
2013-01-04 08:27:05 +00:00
"RRA:LAST:0.5:1:1440" ,
"RRA:LAST:0.5:30:336" ,
"RRA:LAST:0.5:60:744" ,
2013-10-24 12:00:58 +01:00
@ last ,
2013-01-04 08:27:05 +00:00
) ;
} ;
my $ err = RRDs:: error ;
if ( $@ || $ err ) {
logger ( "$@" ) unless ! $@ ;
if ( $ err ) {
logger ( "ERROR: while creating $rrd: $err" ) ;
if ( $ err eq "RRDs::error" ) {
logger ( "... is the RRDtool Perl package installed?" ) ;
}
}
return ;
}
}
2013-01-22 14:51:37 +00:00
# check dependencies
2013-01-23 11:06:19 +00:00
if ( lc ( $ mail - > { alerts } - > { delvd_enabled } ) eq "y" ) {
2013-01-22 14:51:37 +00:00
if ( ! - x $ mail - > { alerts } - > { delvd_script } ) {
logger ( "$myself: ERROR: script '$mail->{alerts}->{delvd_script}' doesn't exist or don't has execution permissions." ) ;
}
}
2013-01-23 11:06:19 +00:00
if ( lc ( $ mail - > { alerts } - > { mqueued_enabled } ) eq "y" ) {
if ( ! - x $ mail - > { alerts } - > { mqueued_script } ) {
logger ( "$myself: ERROR: script '$mail->{alerts}->{mqueued_script}' doesn't exist or don't has execution permissions." ) ;
}
}
2017-07-10 11:06:06 +01:00
if ( ! $ mail - > { stats_rate } ) {
$ mail - > { stats_rate } = "per_second" ;
}
2013-01-22 14:51:37 +00:00
2014-07-16 10:20:22 +01:00
# Since 3.6.0 all DS changed from COUNTER to GAUGE
RRDs:: tune ( $ rrd ,
"--data-source-type=mail_val01:GAUGE" ,
"--data-source-type=mail_val02:GAUGE" ,
"--data-source-type=mail_val03:GAUGE" ,
"--data-source-type=mail_val04:GAUGE" ,
"--data-source-type=mail_val05:GAUGE" ,
) ;
2013-01-04 08:27:05 +00:00
$ config - > { mail_hist } = 0 ;
2013-01-22 14:51:37 +00:00
$ config - > { mail_hist_alert1 } = 0 ;
2013-04-19 12:19:42 +01:00
$ config - > { mail_hist_alert2 } = 0 ;
2013-01-04 08:27:05 +00:00
push ( @ { $ config - > { func_update } } , $ package ) ;
logger ( "$myself: Ok" ) if $ debug ;
}
sub mail_update {
my $ myself = ( caller ( 0 ) ) [ 3 ] ;
my ( $ package , $ config , $ debug ) = @ _ ;
my $ rrd = $ config - > { base_lib } . $ package . ".rrd" ;
my $ mail = $ config - > { mail } ;
my $ in_conn ;
my $ out_conn ;
my $ recvd ;
my $ delvd ;
my $ bytes_recvd ;
my $ bytes_delvd ;
my $ rejtd ;
my $ spam ;
my $ virus ;
my $ bouncd ;
my $ queued ;
my $ discrd ;
my $ held ;
my $ forwrd ;
my $ queues ;
2014-07-16 10:20:22 +01:00
my $ spf_none ;
my $ spf_pass ;
my $ spf_softfail ;
my $ spf_fail ;
2016-01-28 14:53:32 +00:00
my $ rbl ;
2017-06-22 14:30:48 +01:00
my $ gl_records ; # means 'passed' in Postgrey
2013-01-04 08:27:05 +00:00
my $ gl_greylisted ;
my $ gl_whitelisted ;
2017-06-22 14:30:48 +01:00
my $ gl_delayed ; # specific for Postgrey
2013-01-04 08:27:05 +00:00
my @ mta = ( 0 ) x 15 ;
my @ gen = ( 0 ) x 10 ;
2014-07-16 10:20:22 +01:00
my @ mta_h = ( 0 ) x 15 ;
my @ gen_h = ( 0 ) x 10 ;
2013-01-04 08:27:05 +00:00
my $ n ;
2017-08-03 16:27:52 +01:00
my $ first_read ;
2013-01-04 08:27:05 +00:00
my $ mail_log_seekpos ;
2014-01-08 08:57:33 +00:00
my $ mail_log_size = 0 ;
2013-01-04 08:27:05 +00:00
my $ sa_log_seekpos ;
2014-01-08 08:57:33 +00:00
my $ sa_log_size = 0 ;
2013-01-04 08:27:05 +00:00
my $ clamav_log_seekpos ;
my $ clamav_log_size = 0 ;
my $ rrdata = "N" ;
# Read last MAIL data from historic
2014-07-16 10:20:22 +01:00
( $ mail_log_seekpos , $ sa_log_seekpos , $ clamav_log_seekpos , @ mta_h [ 0 .. 15 - 1 ] , @ gen_h [ 0 .. 10 - 1 ] ) = split ( ';' , $ config - > { mail_hist } ) ;
2013-01-04 08:27:05 +00:00
$ mail_log_seekpos = defined ( $ mail_log_seekpos ) ? int ( $ mail_log_seekpos ) : 0 ;
$ sa_log_seekpos = defined ( $ sa_log_seekpos ) ? int ( $ sa_log_seekpos ) : 0 ;
$ clamav_log_seekpos = defined ( $ clamav_log_seekpos ) ? int ( $ clamav_log_seekpos ) : 0 ;
2017-08-03 16:27:52 +01:00
$ first_read = $ mail_log_seekpos ? 0 : 1 ;
2013-01-04 08:27:05 +00:00
$ recvd = $ delvd = $ bytes_recvd = $ bytes_delvd = 0 ;
$ in_conn = $ out_conn = $ rejtd = 0 ;
$ bouncd = $ discrd = $ held = $ forwrd = 0 ;
$ queued = $ queues = 0 ;
if ( lc ( $ mail - > { mta } ) eq "sendmail" ) {
if ( open ( IN , "mailstats -P |" ) ) {
while ( <IN> ) {
if ( /^ T\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ ) {
$ recvd = $ 1 ;
$ bytes_recvd = $ 2 ;
$ delvd = $ 3 ;
$ bytes_delvd = $ 4 ;
}
if ( /^ C\s+(\d+)\s+(\d+)\s+(\d+)/ ) {
$ in_conn = $ 1 ;
$ out_conn = $ 2 ;
$ rejtd = $ 3 ;
}
}
close ( IN ) ;
$ bytes_recvd *= 1024 ;
$ bytes_delvd *= 1024 ;
}
if ( open ( IN , "mailq |" ) ) {
while ( <IN> ) {
my ( $ tmp ) = ( $ _ =~ m/^\w{14}[ *X-]\s*(\d{1,8}) / ) ;
$ queues += $ tmp if $ tmp ;
if ( /^\s+Total requests: (\d+)$/ ) {
$ queued = $ 1 ;
}
}
close ( IN ) ;
}
} elsif ( lc ( $ mail - > { mta } ) eq "postfix" ) {
my @ data ;
for my $ path ( split /:/ , $ ENV { PATH } ) {
if ( - f "$path/pflogsumm" && - x _ ) {
2020-02-06 14:21:57 +00:00
if ( open ( IN , "pflogsumm -d today -h 0 -u 0 --smtpd_stats --bounce_detail=0 --deferral_detail=0 --reject_detail=0 --no_no_msg_size --smtpd_warning_detail=0 $config->{mail_log} 2>/dev/null |" ) ) {
2014-02-14 11:26:42 +00:00
@ data = <IN> ;
close ( IN ) ;
last ;
}
2013-01-04 08:27:05 +00:00
}
if ( - f "$path/pflogsumm.pl" && - x _ ) {
2020-02-06 14:21:57 +00:00
if ( open ( IN , "pflogsumm.pl -d today -h 0 -u 0 --smtpd_stats --bounce_detail=0 --deferral_detail=0 --reject_detail=0 --no_no_msg_size --smtpd_warning_detail=0 $config->{mail_log} 2>/dev/null |" ) ) {
2014-02-14 11:26:42 +00:00
@ data = <IN> ;
close ( IN ) ;
last ;
}
2013-01-04 08:27:05 +00:00
}
}
2014-02-14 11:26:42 +00:00
2015-05-06 17:31:33 +01:00
logger ( "$myself: 'pflogsumm' returned empty data. Is it really installed?" )
2014-02-14 11:26:42 +00:00
if ! @ data ;
2013-01-04 08:27:05 +00:00
foreach ( @ data ) {
if ( /^\s*(\d{1,7})([ km])\s*received$/ ) {
$ recvd = $ 1 ;
$ recvd = $ 1 * 1024 if $ 2 eq "k" ;
$ recvd = $ 1 * 1024 * 1024 if $ 2 eq "m" ;
}
if ( /^\s*(\d{1,7})([ km])\s*delivered$/ ) {
$ delvd = $ 1 ;
$ delvd = $ 1 * 1024 if $ 2 eq "k" ;
$ delvd = $ 1 * 1024 * 1024 if $ 2 eq "m" ;
}
if ( /^\s*(\d{1,7})([ km])\s*forwarded$/ ) {
$ forwrd = $ 1 ;
$ forwrd = $ 1 * 1024 if $ 2 eq "k" ;
$ forwrd = $ 1 * 1024 * 1024 if $ 2 eq "m" ;
}
if ( /^\s*(\d{1,7})([ km])\s*bounced$/ ) {
$ bouncd = $ 1 ;
$ bouncd = $ 1 * 1024 if $ 2 eq "k" ;
$ bouncd = $ 1 * 1024 * 1024 if $ 2 eq "m" ;
}
if ( /^\s*(\d{1,7})([ km])\s*rejected \(/ ) {
$ rejtd = $ 1 ;
$ rejtd = $ 1 * 1024 if $ 2 eq "k" ;
$ rejtd = $ 1 * 1024 * 1024 if $ 2 eq "m" ;
}
if ( /^\s*(\d{1,7})([ km])\s*held/ ) {
$ held = $ 1 ;
$ held = $ 1 * 1024 if $ 2 eq "k" ;
$ held = $ 1 * 1024 * 1024 if $ 2 eq "m" ;
}
if ( /^\s*(\d{1,7})([ km])\s*discarded \(/ ) {
$ discrd = $ 1 ;
$ discrd = $ 1 * 1024 if $ 2 eq "k" ;
$ discrd = $ 1 * 1024 * 1024 if $ 2 eq "m" ;
}
if ( /^\s*(\d{1,7})([ km])\s*bytes received$/ ) {
$ bytes_recvd = $ 1 ;
$ bytes_recvd = $ 1 * 1024 if $ 2 eq "k" ;
$ bytes_recvd = $ 1 * 1024 * 1024 if $ 2 eq "m" ;
}
if ( /^\s*(\d{1,7})([ km])\s*bytes delivered$/ ) {
$ bytes_delvd = $ 1 ;
$ bytes_delvd = $ 1 * 1024 if $ 2 eq "k" ;
$ bytes_delvd = $ 1 * 1024 * 1024 if $ 2 eq "m" ;
}
}
if ( open ( IN , "mailq |" ) ) {
while ( <IN> ) {
if ( /^-- (\d+) Kbytes in (\d+) Request/ ) {
$ queues = $ 1 ;
$ queued = $ 2 ;
}
}
close ( IN ) ;
}
2019-02-25 08:38:00 +00:00
} elsif ( lc ( $ mail - > { mta } ) eq "exim" ) {
2019-03-18 18:01:31 +00:00
if ( open ( IN , "eximstats -h0 -ne -nr -t0 $config->{mail_log} |" ) ) {
2019-02-25 08:38:00 +00:00
while ( <IN> ) {
if ( /^ Received\s+(\d+)(\S\S)\s+(\d+).*?$/ ) {
$ bytes_recvd = $ 1 ;
$ bytes_recvd = $ 1 * 1024 if $ 2 eq "KB" ;
$ bytes_recvd = $ 1 * 1024 * 1024 if $ 2 eq "MB" ;
$ recvd = $ 3 ;
}
if ( /^ Delivered\s+(\d+)(\S\S)\s+(\d+).*?$/ ) {
$ bytes_delvd = $ 1 ;
$ bytes_delvd = $ 1 * 1024 if $ 2 eq "KB" ;
$ bytes_delvd = $ 1 * 1024 * 1024 if $ 2 eq "MB" ;
$ delvd = $ 3 ;
}
if ( /^ Rejects\s+(\d+).*?$/ ) {
$ rejtd = $ 1 ;
}
if ( /^ remote_smtp\s+\d+\S*\s+(\d+)$/ ) {
$ out_conn = $ 1 ;
}
}
close ( IN ) ;
$ in_conn = $ recvd - $ rejtd ;
$ delvd -= $ out_conn ;
}
if ( open ( IN , "exim -bp |" ) ) {
while ( <IN> ) {
# discard blank lines and lines with recipients
if ( ! /^$/ && ! /^\s{10}\S+$/ ) {
my ( $ size , undef , $ unit ) = ( $ _ =~ m/^\s*\d+.\s+(\d(.\d)?)(\S*)\s.*?$/ ) ;
$ queues += int ( $ size ) if ! $ unit ;
$ queues += int ( $ size * 1024 ) if $ unit eq "K" ;
$ queues += int ( $ size * 1024 * 1024 ) if $ unit eq "M" ;
$ queued + + ;
}
}
close ( IN ) ;
}
2013-01-04 08:27:05 +00:00
}
2017-06-22 14:30:48 +01:00
$ gl_records = $ gl_greylisted = $ gl_whitelisted = $ gl_delayed = 0 ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ mail - > { greylist } ) eq "milter-greylist" ) {
if ( - r $ config - > { milter_gl } ) {
open ( IN , $ config - > { milter_gl } ) ;
if ( ! seek ( IN , - 80 , 2 ) ) {
logger ( "Couldn't seek to the end ($config->{milter_gl}): $!" ) ;
return ;
}
while ( <IN> ) {
2014-02-12 16:35:14 +00:00
if ( /^# Summary:\s+(\d+) records,\s+(\d+) greylisted,\s+(\d+) whitelisted/ ) {
2013-01-04 08:27:05 +00:00
$ gl_records = $ 1 ;
$ gl_greylisted = $ 2 ;
$ gl_whitelisted = $ 3 ;
}
}
close ( IN ) ;
}
}
$ spam = $ virus = 0 ;
2014-07-16 10:20:22 +01:00
$ spf_none = $ spf_pass = $ spf_softfail = $ spf_fail = 0 ;
2016-01-28 14:53:32 +00:00
$ rbl = 0 ;
2013-01-04 08:27:05 +00:00
if ( - r $ config - > { mail_log } ) {
2014-01-08 09:13:40 +00:00
my $ date = strftime ( "%b %e" , localtime ) ;
2017-07-05 14:19:23 +01:00
open ( IN , $ config - > { mail_log } ) ;
2013-01-04 08:27:05 +00:00
if ( ! seek ( IN , 0 , 2 ) ) {
logger ( "Couldn't seek to the end ($config->{mail_log}): $!" ) ;
return ;
}
$ mail_log_size = tell ( IN ) ;
if ( $ mail_log_size < $ mail_log_seekpos ) {
$ mail_log_seekpos = 0 ;
}
if ( ! seek ( IN , $ mail_log_seekpos , 0 ) ) {
logger ( "Couldn't seek to $mail_log_seekpos ($config->{mail_log}): $!" ) ;
return ;
}
while ( <IN> ) {
my @ line ;
2015-05-05 15:55:51 +01:00
if ( /^$date/ ) {
if ( /MailScanner/ && /Spam Checks:/ && /Found/ && /spam messages/ ) {
@ line = split ( ' ' , $ _ ) ;
$ spam += int ( $ line [ 8 ] ) ;
}
if ( /MailScanner/ && /Virus Scanning:/ && /Found/ && /viruses/ ) {
@ line = split ( ' ' , $ _ ) ;
$ virus += int ( $ line [ 8 ] ) ;
}
if ( /amavis\[.* SPAM/ ) {
$ spam + + ;
}
if ( /amavis\[.* INFECTED|amavis\[.* BANNED/ ) {
$ virus + + ;
}
# postfix-policyd-spf-perl
if ( /policy-spf/ ) {
if ( /: pass/ ) {
$ spf_pass + + ;
} elsif ( /: none/ ) {
$ spf_none + + ;
} elsif ( / action=550 / ) {
$ spf_fail + + ;
} else {
# There one line per spf check, so it gets here, we'll consider it is a softfail
$ spf_softfail + + ;
}
# for other SPF handlers (smf-spf)
} else {
if ( / SPF none/ ) {
$ spf_none + + ;
2015-05-07 11:47:44 +01:00
} elsif ( / SPF pass/ ) {
2015-05-05 15:55:51 +01:00
$ spf_pass + + ;
2015-05-07 11:47:44 +01:00
} elsif ( / SPF softfail/ ) {
2015-05-05 15:55:51 +01:00
$ spf_softfail + + ;
2015-05-07 11:47:44 +01:00
} elsif ( / SPF fail/ ) {
2015-05-05 15:55:51 +01:00
$ spf_fail + + ;
}
}
2016-01-28 14:53:32 +00:00
# postfix RBL
if ( / postfix\/smtpd\[\d+\]: NOQUEUE: reject: RCPT from / ) {
2017-07-06 07:30:26 +01:00
# postgrey
if ( lc ( $ mail - > { greylist } ) eq "postgrey" ) {
if ( / Recipient address rejected: Greylisted, / ) {
2017-07-07 11:14:55 +01:00
next ; # ignored
2017-07-06 07:30:26 +01:00
}
}
2016-01-28 14:53:32 +00:00
$ rbl + + ;
}
2017-06-20 10:26:08 +01:00
# postgrey
if ( lc ( $ mail - > { greylist } ) eq "postgrey" ) {
if ( / action=greylist, reason=new, / ) {
$ gl_greylisted + + ;
}
if ( / action=greylist, reason=early-retry / ) {
2017-06-22 14:30:48 +01:00
$ gl_delayed + + ;
2017-06-20 10:26:08 +01:00
}
if ( / action=pass, reason=triplet found, / ) {
$ gl_records + + ;
}
2017-08-03 16:27:52 +01:00
if ( / action=pass, reason=client (whitelist|AWL), / ) {
2017-06-20 10:26:08 +01:00
$ gl_whitelisted + + ;
}
}
2014-07-16 10:20:22 +01:00
}
2013-01-04 08:27:05 +00:00
}
close ( IN ) ;
}
if ( - r $ config - > { spamassassin_log } ) {
my $ date = strftime ( "%b %e" , localtime ) ;
open ( IN , $ config - > { spamassassin_log } ) ;
if ( ! seek ( IN , 0 , 2 ) ) {
logger ( "Couldn't seek to the end ($config->{spamassassin_log}): $!" ) ;
return ;
}
$ sa_log_size = tell ( IN ) ;
if ( $ sa_log_size < $ sa_log_seekpos ) {
$ sa_log_seekpos = 0 ;
}
if ( ! seek ( IN , $ sa_log_seekpos , 0 ) ) {
logger ( "Couldn't seek to $sa_log_seekpos ($config->{spamassassin_log}): $!" ) ;
return ;
}
while ( <IN> ) {
if ( /^$date/ && /spamd: identified spam/ ) {
$ spam + + ;
}
}
close ( IN ) ;
}
if ( - r $ config - > { clamav_log } ) {
my $ date = strftime ( "%a %b %e" , localtime ) ;
open ( IN , $ config - > { clamav_log } ) ;
if ( ! seek ( IN , 0 , 2 ) ) {
logger ( "Couldn't seek to the end ($config->{clamav_log}): $!" ) ;
return ;
}
$ clamav_log_size = tell ( IN ) ;
if ( $ clamav_log_size < $ clamav_log_seekpos ) {
$ clamav_log_seekpos = 0 ;
}
if ( ! seek ( IN , $ clamav_log_seekpos , 0 ) ) {
logger ( "Couldn't seek to $clamav_log_seekpos ($config->{clamav_log}): $!" ) ;
return ;
}
while ( <IN> ) {
if ( /^$date/ && / FOUND/ ) {
$ virus + + ;
}
}
close ( IN ) ;
}
$ mta [ 0 ] = int ( $ in_conn ) - ( $ mta_h [ 0 ] || 0 ) ;
$ mta [ 0 ] = 0 unless $ mta [ 0 ] != int ( $ in_conn ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 0 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 0 ] = int ( $ in_conn ) ;
$ mta [ 1 ] = int ( $ out_conn ) - ( $ mta_h [ 1 ] || 0 ) ;
$ mta [ 1 ] = 0 unless $ mta [ 1 ] != int ( $ out_conn ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 1 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 1 ] = int ( $ out_conn ) ;
$ mta [ 2 ] = int ( $ recvd ) - ( $ mta_h [ 2 ] || 0 ) ;
$ mta [ 2 ] = 0 unless $ mta [ 2 ] != int ( $ recvd ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 2 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 2 ] = int ( $ recvd ) ;
$ mta [ 3 ] = int ( $ delvd ) - ( $ mta_h [ 3 ] || 0 ) ;
$ mta [ 3 ] = 0 unless $ mta [ 3 ] != int ( $ delvd ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 3 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 3 ] = int ( $ delvd ) ;
$ mta [ 4 ] = int ( $ bytes_recvd ) - ( $ mta_h [ 4 ] || 0 ) ;
$ mta [ 4 ] = 0 unless $ mta [ 4 ] != int ( $ bytes_recvd ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 4 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 4 ] = int ( $ bytes_recvd ) ;
$ mta [ 5 ] = int ( $ bytes_delvd ) - ( $ mta_h [ 5 ] || 0 ) ;
$ mta [ 5 ] = 0 unless $ mta [ 5 ] != int ( $ bytes_delvd ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 5 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 5 ] = int ( $ bytes_delvd ) ;
$ mta [ 6 ] = int ( $ rejtd ) - ( $ mta_h [ 6 ] || 0 ) ;
$ mta [ 6 ] = 0 unless $ mta [ 6 ] != int ( $ rejtd ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 6 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 6 ] = int ( $ rejtd ) ;
2013-04-15 08:49:17 +01:00
# avoid initial peak
2017-08-03 16:27:52 +01:00
$ mta_h [ 7 ] = 0 ;
if ( ! $ first_read ) {
$ mta [ 7 ] = int ( $ spam ) ;
$ mta [ 7 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
}
2013-04-15 08:49:17 +01:00
# avoid initial peak
2017-08-03 16:27:52 +01:00
$ mta_h [ 8 ] = 0 ;
if ( ! $ first_read ) {
$ mta [ 8 ] = int ( $ virus ) ;
$ mta [ 8 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
}
2013-01-04 08:27:05 +00:00
$ mta [ 9 ] = int ( $ bouncd ) - ( $ mta_h [ 9 ] || 0 ) ;
$ mta [ 9 ] = 0 unless $ mta [ 9 ] != int ( $ bouncd ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 9 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 9 ] = int ( $ bouncd ) ;
$ mta [ 10 ] = int ( $ queued ) || 0 ;
$ mta_h [ 10 ] = 0 ;
$ mta [ 11 ] = int ( $ discrd ) - ( $ mta_h [ 11 ] || 0 ) ;
$ mta [ 11 ] = 0 unless $ mta [ 11 ] != int ( $ discrd ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 11 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 11 ] = int ( $ discrd ) ;
$ mta [ 12 ] = int ( $ held ) - ( $ mta_h [ 12 ] || 0 ) ;
$ mta [ 12 ] = 0 unless $ mta [ 12 ] != int ( $ held ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 12 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 12 ] = int ( $ held ) ;
$ mta [ 13 ] = int ( $ forwrd ) - ( $ mta_h [ 13 ] || 0 ) ;
$ mta [ 13 ] = 0 unless $ mta [ 13 ] != int ( $ forwrd ) ;
2017-07-10 11:06:06 +01:00
$ mta [ 13 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-01-04 08:27:05 +00:00
$ mta_h [ 13 ] = int ( $ forwrd ) ;
$ mta [ 14 ] = int ( $ queues ) || 0 ;
$ mta_h [ 14 ] = 0 ;
2014-07-16 10:20:22 +01:00
# avoid initial peak
2017-08-03 16:27:52 +01:00
$ gen_h [ 0 ] = 0 ;
if ( ! $ first_read ) {
$ gen [ 0 ] = int ( $ spf_none ) ;
}
2014-07-16 10:20:22 +01:00
# avoid initial peak
2017-08-03 16:27:52 +01:00
$ gen_h [ 1 ] = 0 ;
if ( ! $ first_read ) {
$ gen [ 1 ] = int ( $ spf_pass ) ;
}
2014-07-16 10:20:22 +01:00
# avoid initial peak
2017-08-03 16:27:52 +01:00
$ gen_h [ 2 ] = 0 ;
if ( ! $ first_read ) {
$ gen [ 2 ] = int ( $ spf_softfail ) ;
}
2014-07-16 10:20:22 +01:00
# avoid initial peak
2017-08-03 16:27:52 +01:00
$ gen_h [ 3 ] = 0 ;
if ( ! $ first_read ) {
$ gen [ 3 ] = int ( $ spf_fail ) ;
}
# avoid initial peak
$ gen_h [ 4 ] = 0 ;
if ( ! $ first_read ) {
$ gen [ 4 ] = int ( $ rbl ) ;
2017-09-01 10:58:27 +01:00
$ gen [ 4 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2017-08-03 16:27:52 +01:00
}
2017-07-06 11:38:43 +01:00
if ( lc ( $ mail - > { greylist } ) eq "milter-greylist" ) {
$ gen_h [ 5 ] = $ gen [ 5 ] = 0 ;
$ gen_h [ 6 ] = $ gen [ 6 ] = int ( $ gl_records ) || 0 ;
$ gen_h [ 7 ] = $ gen [ 7 ] = int ( $ gl_greylisted ) || 0 ;
$ gen_h [ 8 ] = $ gen [ 8 ] = int ( $ gl_whitelisted ) || 0 ;
$ gen_h [ 9 ] = $ gen [ 9 ] = int ( $ gl_delayed ) || 0 ;
}
if ( lc ( $ mail - > { greylist } ) eq "postgrey" ) {
$ gen_h [ 5 ] = $ gen [ 5 ] = 0 ;
2017-08-03 16:27:52 +01:00
$ gen_h [ 6 ] = $ gen [ 6 ] = 0 ;
$ gen_h [ 7 ] = $ gen [ 7 ] = 0 ;
$ gen_h [ 8 ] = $ gen [ 8 ] = 0 ;
$ gen_h [ 9 ] = $ gen [ 9 ] = 0 ;
# avoid initial peak
if ( ! $ first_read ) {
$ gen [ 6 ] = int ( $ gl_records ) ;
$ gen [ 6 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
}
# avoid initial peak
if ( ! $ first_read ) {
$ gen [ 7 ] = int ( $ gl_greylisted ) ;
$ gen [ 7 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
}
# avoid initial peak
if ( ! $ first_read ) {
$ gen [ 8 ] = int ( $ gl_whitelisted ) ;
$ gen [ 8 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
}
# avoid initial peak
if ( ! $ first_read ) {
$ gen [ 9 ] = int ( $ gl_delayed ) ;
$ gen [ 9 ] /= 60 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
}
2017-07-06 11:38:43 +01:00
}
2014-07-16 10:20:22 +01:00
$ config - > { mail_hist } = join ( ";" , $ mail_log_size , $ sa_log_size , $ clamav_log_size , @ mta_h , @ gen_h ) ;
2013-01-04 08:27:05 +00:00
for ( $ n = 0 ; $ n < 15 ; $ n + + ) {
$ rrdata . = ":" . $ mta [ $ n ] ;
}
for ( $ n = 0 ; $ n < 10 ; $ n + + ) {
$ rrdata . = ":" . $ gen [ $ n ] ;
}
2013-01-22 14:51:37 +00:00
# MAIL alert
2013-01-23 11:06:19 +00:00
if ( lc ( $ mail - > { alerts } - > { delvd_enabled } ) eq "y" ) {
2017-09-01 10:58:27 +01:00
my $ val = int ( $ mta [ 3 ] ) ;
2017-09-01 11:13:03 +01:00
$ val *= 60 + 0.5 if lc ( $ mail - > { stats_rate } ) eq "per_second" ;
2013-04-19 12:19:42 +01:00
if ( ! $ mail - > { alerts } - > { delvd_threshold } || $ val < $ mail - > { alerts } - > { delvd_threshold } ) {
2013-01-22 14:51:37 +00:00
$ config - > { mail_hist_alert1 } = 0 ;
} else {
if ( ! $ config - > { mail_hist_alert1 } ) {
$ config - > { mail_hist_alert1 } = time ;
}
2013-04-19 12:19:42 +01:00
if ( $ config - > { mail_hist_alert1 } > 0 && ( time - $ config - > { mail_hist_alert1 } ) >= $ mail - > { alerts } - > { delvd_timeintvl } ) {
2013-01-22 14:51:37 +00:00
if ( - x $ mail - > { alerts } - > { delvd_script } ) {
2013-01-23 11:06:19 +00:00
logger ( "$myself: ALERT: executing script '$mail->{alerts}->{delvd_script}'." ) ;
2013-04-19 12:19:42 +01:00
system ( $ mail - > { alerts } - > { delvd_script } . " " . $ mail - > { alerts } - > { delvd_timeintvl } . " " . $ mail - > { alerts } - > { delvd_threshold } . " " . $ val ) ;
2013-01-22 14:51:37 +00:00
} else {
2013-01-23 11:06:19 +00:00
logger ( "$myself: ERROR: script '$mail->{alerts}->{delvd_script}' doesn't exist or don't has execution permissions." ) ;
2013-01-22 14:51:37 +00:00
}
$ config - > { mail_hist_alert1 } = time ;
}
}
2013-01-23 11:06:19 +00:00
}
if ( lc ( $ mail - > { alerts } - > { mqueued_enabled } ) eq "y" ) {
2013-04-29 14:31:14 +01:00
my $ val = $ mta [ 10 ] ;
if ( ! $ mail - > { alerts } - > { mqueued_threshold } || $ val < $ mail - > { alerts } - > { mqueued_threshold } ) {
2013-04-19 12:19:42 +01:00
$ config - > { mail_hist_alert2 } = 0 ;
2013-01-22 14:51:37 +00:00
} else {
2013-04-19 12:19:42 +01:00
if ( ! $ config - > { mail_hist_alert2 } ) {
$ config - > { mail_hist_alert2 } = time ;
2013-01-22 14:51:37 +00:00
}
2013-04-29 14:31:14 +01:00
if ( $ config - > { mail_hist_alert2 } > 0 && ( time - $ config - > { mail_hist_alert2 } ) >= $ mail - > { alerts } - > { mqueued_timeintvl } ) {
2013-01-22 14:51:37 +00:00
if ( - x $ mail - > { alerts } - > { mqueued_script } ) {
2013-01-23 11:06:19 +00:00
logger ( "$myself: ALERT: executing script '$mail->{alerts}->{mqueued_script}'." ) ;
2013-04-29 14:31:14 +01:00
system ( $ mail - > { alerts } - > { mqueued_script } . " " . $ mail - > { alerts } - > { mqueued_timeintvl } . " " . $ mail - > { alerts } - > { mqueued_threshold } . " " . $ val ) ;
2013-01-22 14:51:37 +00:00
} else {
2013-01-23 11:06:19 +00:00
logger ( "$myself: ERROR: script '$mail->{alerts}->{mqueued_script}' doesn't exist or don't has execution permissions." ) ;
2013-01-22 14:51:37 +00:00
}
2013-04-19 12:19:42 +01:00
$ config - > { mail_hist_alert2 } = time ;
2013-01-22 14:51:37 +00:00
}
}
}
2013-01-04 08:27:05 +00:00
RRDs:: update ( $ rrd , $ rrdata ) ;
logger ( "$myself: $rrdata" ) if $ debug ;
my $ err = RRDs:: error ;
logger ( "ERROR: while updating $rrd: $err" ) if $ err ;
}
sub mail_cgi {
my ( $ package , $ config , $ cgi ) = @ _ ;
2017-08-01 12:24:49 +01:00
my @ output ;
2013-01-04 08:27:05 +00:00
my $ mail = $ config - > { mail } ;
2014-06-19 09:47:10 +01:00
my @ rigid = split ( ',' , ( $ mail - > { rigid } || "" ) ) ;
my @ limit = split ( ',' , ( $ mail - > { limit } || "" ) ) ;
2013-01-04 08:27:05 +00:00
my $ tf = $ cgi - > { tf } ;
my $ colors = $ cgi - > { colors } ;
my $ graph = $ cgi - > { graph } ;
my $ silent = $ cgi - > { silent } ;
2013-07-29 17:03:13 +01:00
my $ zoom = "--zoom=" . $ config - > { global_zoom } ;
2015-01-21 16:28:01 +00:00
my % rrd = (
'new' = > \ & RRDs:: graphv ,
'old' = > \ & RRDs:: graph ,
) ;
my $ version = "new" ;
my $ pic ;
my $ picz ;
my $ picz_width ;
my $ picz_height ;
2013-01-04 08:27:05 +00:00
my $ u = "" ;
my $ width ;
my $ height ;
2019-05-08 11:54:03 +01:00
my @ extra ;
2013-01-04 08:27:05 +00:00
my @ riglim ;
my $ T = "B" ;
my $ vlabel = "bytes/s" ;
2017-07-10 11:06:06 +01:00
my $ rate_label = "Messages" ;
my $ valform = "%5.0lf" ;
my $ gl_valform = "%5.0lf" ;
2013-01-04 08:27:05 +00:00
my @ tmp ;
my @ tmpz ;
my @ CDEF ;
my $ n ;
my $ str ;
my $ err ;
2015-01-21 16:28:01 +00:00
$ version = "old" if $ RRDs:: VERSION < 1.3 ;
2013-01-04 08:27:05 +00:00
my $ rrd = $ config - > { base_lib } . $ package . ".rrd" ;
my $ title = $ config - > { graph_title } - > { $ package } ;
2016-01-25 17:35:30 +00:00
my $ IMG_DIR = $ config - > { base_dir } . "/" . $ config - > { imgs_dir } ;
my $ imgfmt_uc = uc ( $ config - > { image_format } ) ;
my $ imgfmt_lc = lc ( $ config - > { image_format } ) ;
2019-05-08 11:54:03 +01:00
foreach my $ i ( split ( ',' , $ config - > { rrdtool_extra_options } || "" ) ) {
push ( @ extra , trim ( $ i ) ) if trim ( $ i ) ;
}
2013-01-04 08:27:05 +00:00
$ title = ! $ silent ? $ title : "" ;
if ( lc ( $ config - > { netstats_in_bps } ) eq "y" ) {
$ T = "b" ;
$ vlabel = "bits/s" ;
}
2017-07-10 11:06:06 +01:00
if ( ! $ mail - > { stats_rate } ) {
$ mail - > { stats_rate } = "per_second" ;
}
if ( lc ( $ mail - > { stats_rate } ) eq "per_second" ) {
$ rate_label = "Messages/s" ;
$ valform = "%5.2lf" ;
$ gl_valform = "%5.1lf" ;
}
2013-01-04 08:27:05 +00:00
# mode text
#
if ( lc ( $ config - > { iface_mode } ) eq "text" ) {
if ( $ title ) {
2017-08-01 12:24:49 +01:00
push ( @ output , main:: graph_header ( $ title , 2 ) ) ;
push ( @ output , " <tr>\n" ) ;
push ( @ output , " <td bgcolor='$colors->{title_bg_color}'>\n" ) ;
2013-01-04 08:27:05 +00:00
}
my ( undef , undef , undef , $ data ) = RRDs:: fetch ( "$rrd" ,
2019-11-22 07:46:02 +00:00
"--resolution=$tf->{res}" ,
2013-01-04 08:27:05 +00:00
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2019-11-22 07:46:02 +00:00
"AVERAGE" ) ;
2013-01-04 08:27:05 +00:00
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while fetching $rrd: $err\n" ) if $ err ;
push ( @ output , " <pre style='font-size: 12px; color: $colors->{fg_color}';>\n" ) ;
push ( @ output , "Time In.Conn Out.Conn Receivd Delivd Bytes.R Bytes.D Rejectd Bounced Discard Held Forward Spam Virus Queued Queue.S\n" ) ;
push ( @ output , "------------------------------------------------------------------------------------------------------------------------------------------- \n" ) ;
2013-01-04 08:27:05 +00:00
my $ line ;
my @ row ;
my $ time ;
for ( $ n = 0 , $ time = $ tf - > { tb } ; $ n < ( $ tf - > { tb } * $ tf - > { ts } ) ; $ n + + ) {
$ line = @$ data [ $ n ] ;
$ time = $ time - ( 1 / $ tf - > { ts } ) ;
my ( $ in , $ out , $ recvd , $ delvd , $ bytes_recvd , $ bytes_delvd , $ rejtd , $ spam , $ virus , $ bouncd , $ queued , $ discrd , $ held , $ forwrd , $ queues ) = @$ line ;
@ row = ( $ in , $ out , $ recvd , $ delvd , $ bytes_recvd , $ bytes_delvd , $ rejtd , $ bouncd , $ discrd , $ held , $ forwrd , $ spam , $ virus , $ queued , $ queues ) ;
2017-08-01 12:24:49 +01:00
push ( @ output , sprintf ( " %2d$tf->{tc} %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n" , $ time , @ row ) ) ;
2013-01-04 08:27:05 +00:00
}
2017-08-01 12:24:49 +01:00
push ( @ output , " </pre>\n" ) ;
2013-01-04 08:27:05 +00:00
if ( $ title ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " </td>\n" ) ;
push ( @ output , " </tr>\n" ) ;
push ( @ output , main:: graph_footer ( ) ) ;
2013-01-04 08:27:05 +00:00
}
2017-08-01 12:24:49 +01:00
push ( @ output , " <br>\n" ) ;
return @ output ;
2013-01-04 08:27:05 +00:00
}
# graph mode
#
if ( $ silent eq "yes" || $ silent eq "imagetag" ) {
$ colors - > { fg_color } = "#000000" ; # visible color for text mode
$ u = "_" ;
}
if ( $ silent eq "imagetagbig" ) {
$ colors - > { fg_color } = "#000000" ; # visible color for text mode
$ u = "" ;
}
2016-01-25 17:35:30 +00:00
my $ IMG1 = $ u . $ package . "1." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG2 = $ u . $ package . "2." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG3 = $ u . $ package . "3." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG4 = $ u . $ package . "4." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG5 = $ u . $ package . "5." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG6 = $ u . $ package . "6." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG1z = $ u . $ package . "1z." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG2z = $ u . $ package . "2z." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG3z = $ u . $ package . "3z." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG4z = $ u . $ package . "4z." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG5z = $ u . $ package . "5z." . $ tf - > { when } . ".$imgfmt_lc" ;
my $ IMG6z = $ u . $ package . "6z." . $ tf - > { when } . ".$imgfmt_lc" ;
unlink ( "$IMG_DIR" . "$IMG1" ,
"$IMG_DIR" . "$IMG2" ,
"$IMG_DIR" . "$IMG3" ,
"$IMG_DIR" . "$IMG4" ,
"$IMG_DIR" . "$IMG5" ,
"$IMG_DIR" . "$IMG6" ) ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
2016-01-25 17:35:30 +00:00
unlink ( "$IMG_DIR" . "$IMG1z" ,
"$IMG_DIR" . "$IMG2z" ,
"$IMG_DIR" . "$IMG3z" ,
"$IMG_DIR" . "$IMG4z" ,
"$IMG_DIR" . "$IMG5z" ,
"$IMG_DIR" . "$IMG6z" ) ;
2013-01-04 08:27:05 +00:00
}
if ( $ title ) {
2017-08-01 12:24:49 +01:00
push ( @ output , main:: graph_header ( $ title , 2 ) ) ;
2013-01-04 08:27:05 +00:00
}
2014-06-19 09:47:10 +01:00
@ riglim = @ { setup_riglim ( $ rigid [ 0 ] , $ limit [ 0 ] ) } ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ mail - > { mta } ) eq "sendmail" ) {
push ( @ tmp , "AREA:in#44EE44:In Connections" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:in:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:in:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:in:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:in:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:rejtd#EE4444:Rejected" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:rejtd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:rejtd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:rejtd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:rejtd:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:recvd#448844:Received" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:recvd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:recvd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:recvd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:recvd:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:spam#EEEE44:Spam" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:spam:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:spam:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:spam:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:spam:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:virus#EE44EE:Virus" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:virus:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:virus:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:virus:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:virus:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:n_delvd#4444EE:Delivered" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:delvd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:delvd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:delvd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:delvd:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:n_out#44EEEE:Out Connections" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:out:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:out:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:out:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:out:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "LINE1:in#00EE00" ) ;
push ( @ tmp , "LINE1:rejtd#EE0000" ) ;
push ( @ tmp , "LINE1:recvd#1F881F" ) ;
push ( @ tmp , "LINE1:spam#EEEE00" ) ;
push ( @ tmp , "LINE1:virus#EE00EE" ) ;
push ( @ tmp , "LINE1:n_delvd#0000EE" ) ;
push ( @ tmp , "LINE1:n_out#00EEEE" ) ;
2014-07-16 10:20:22 +01:00
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmpz , "AREA:in#44EE44:In Connections" ) ;
push ( @ tmpz , "AREA:rejtd#EE4444:Rejected" ) ;
push ( @ tmpz , "AREA:recvd#448844:Received" ) ;
push ( @ tmpz , "AREA:spam#EEEE44:Spam" ) ;
push ( @ tmpz , "AREA:virus#EE44EE:Virus" ) ;
push ( @ tmpz , "AREA:n_delvd#4444EE:Delivered" ) ;
push ( @ tmpz , "AREA:n_out#44EEEE:Out Connections" ) ;
push ( @ tmpz , "LINE1:in#00EE00" ) ;
push ( @ tmpz , "LINE1:rejtd#EE0000" ) ;
push ( @ tmpz , "LINE1:recvd#1F881F" ) ;
push ( @ tmpz , "LINE1:spam#EEEE00" ) ;
push ( @ tmpz , "LINE1:virus#EE00EE" ) ;
push ( @ tmpz , "LINE1:n_delvd#0000EE" ) ;
push ( @ tmpz , "LINE1:n_out#00EEEE" ) ;
} elsif ( lc ( $ mail - > { mta } ) eq "postfix" ) {
push ( @ tmp , "AREA:rejtd#EE4444:Rejected" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:rejtd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:rejtd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:rejtd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:rejtd:MAX: Max\\: $valform\\n" ) ;
2016-01-28 14:53:32 +00:00
push ( @ tmp , "AREA:rbl#963C74:Rejected (RBL)" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:rbl:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:rbl:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:rbl:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:rbl:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:recvd#448844:Received" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:recvd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:recvd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:recvd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:recvd:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:spam#EEEE44:Spam" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:spam:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:spam:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:spam:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:spam:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:virus#EE44EE:Virus" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:virus:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:virus:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:virus:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:virus:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:bouncd#FFA500:Bounced" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:bouncd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:bouncd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:bouncd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:bouncd:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:discrd#CCCCCC:Discarded" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:discrd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:discrd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:discrd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:discrd:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:held#44EE44:Held" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:held:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:held:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:held:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:held:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:n_forwrd#44EEEE:Forwarded" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:forwrd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:forwrd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:forwrd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:forwrd:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:n_delvd#4444EE:Delivered" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:delvd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:delvd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:delvd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:delvd:MAX: Max\\: $valform\\n" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "LINE1:rejtd#EE0000" ) ;
2016-01-28 14:53:32 +00:00
push ( @ tmp , "LINE1:rbl#963C74" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "LINE1:recvd#1F881F" ) ;
push ( @ tmp , "LINE1:spam#EEEE00" ) ;
push ( @ tmp , "LINE1:virus#EE00EE" ) ;
push ( @ tmp , "LINE1:bouncd#FFA500" ) ;
push ( @ tmp , "LINE1:discrd#888888" ) ;
push ( @ tmp , "LINE1:held#00EE00" ) ;
push ( @ tmp , "LINE1:n_forwrd#00EEEE" ) ;
push ( @ tmp , "LINE1:n_delvd#0000EE" ) ;
push ( @ tmpz , "AREA:rejtd#EE4444:Rejected" ) ;
2016-01-28 14:53:32 +00:00
push ( @ tmpz , "AREA:rbl#963C74:Rejected (RBL)" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmpz , "AREA:recvd#448844:Received" ) ;
push ( @ tmpz , "AREA:spam#EEEE44:Spam" ) ;
push ( @ tmpz , "AREA:virus#EE44EE:Virus" ) ;
push ( @ tmpz , "AREA:bouncd#FFA500:Bounced" ) ;
push ( @ tmpz , "AREA:discrd#888888:Discarded" ) ;
push ( @ tmpz , "AREA:held#44EE44:Held" ) ;
push ( @ tmpz , "AREA:n_forwrd#44EEEE:Forwarded" ) ;
push ( @ tmpz , "AREA:n_delvd#4444EE:Delivered" ) ;
push ( @ tmpz , "LINE1:rejtd#EE0000" ) ;
2016-01-28 14:53:32 +00:00
push ( @ tmpz , "LINE1:rbl#963C74" ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmpz , "LINE1:recvd#1F881F" ) ;
push ( @ tmpz , "LINE1:spam#EEEE00" ) ;
push ( @ tmpz , "LINE1:virus#EE00EE" ) ;
push ( @ tmpz , "LINE1:bouncd#FFA500" ) ;
push ( @ tmpz , "LINE1:discrd#888888" ) ;
push ( @ tmpz , "LINE1:held#00EE00" ) ;
push ( @ tmpz , "LINE1:n_forwrd#00EEEE" ) ;
push ( @ tmpz , "LINE1:n_delvd#0000EE" ) ;
2019-02-25 08:38:00 +00:00
} elsif ( lc ( $ mail - > { mta } ) eq "exim" ) {
push ( @ tmp , "AREA:in#44EE44:In Connections" ) ;
push ( @ tmp , "GPRINT:in:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:in:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:in:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:in:MAX: Max\\: $valform\\n" ) ;
push ( @ tmp , "AREA:rejtd#EE4444:Rejected" ) ;
push ( @ tmp , "GPRINT:rejtd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:rejtd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:rejtd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:rejtd:MAX: Max\\: $valform\\n" ) ;
push ( @ tmp , "AREA:recvd#448844:Received" ) ;
push ( @ tmp , "GPRINT:recvd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:recvd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:recvd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:recvd:MAX: Max\\: $valform\\n" ) ;
push ( @ tmp , "AREA:spam#EEEE44:Spam" ) ;
push ( @ tmp , "GPRINT:spam:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:spam:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:spam:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:spam:MAX: Max\\: $valform\\n" ) ;
push ( @ tmp , "AREA:virus#EE44EE:Virus" ) ;
push ( @ tmp , "GPRINT:virus:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:virus:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:virus:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:virus:MAX: Max\\: $valform\\n" ) ;
push ( @ tmp , "AREA:n_delvd#4444EE:Delivered" ) ;
push ( @ tmp , "GPRINT:delvd:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:delvd:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:delvd:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:delvd:MAX: Max\\: $valform\\n" ) ;
push ( @ tmp , "AREA:n_out#44EEEE:Out Connections" ) ;
push ( @ tmp , "GPRINT:out:LAST: Cur\\: $valform" ) ;
push ( @ tmp , "GPRINT:out:AVERAGE: Avg\\: $valform" ) ;
push ( @ tmp , "GPRINT:out:MIN: Min\\: $valform" ) ;
push ( @ tmp , "GPRINT:out:MAX: Max\\: $valform\\n" ) ;
push ( @ tmp , "LINE1:in#00EE00" ) ;
push ( @ tmp , "LINE1:rejtd#EE0000" ) ;
push ( @ tmp , "LINE1:recvd#1F881F" ) ;
push ( @ tmp , "LINE1:spam#EEEE00" ) ;
push ( @ tmp , "LINE1:virus#EE00EE" ) ;
push ( @ tmp , "LINE1:n_delvd#0000EE" ) ;
push ( @ tmp , "LINE1:n_out#00EEEE" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmpz , "AREA:in#44EE44:In Connections" ) ;
push ( @ tmpz , "AREA:rejtd#EE4444:Rejected" ) ;
push ( @ tmpz , "AREA:recvd#448844:Received" ) ;
push ( @ tmpz , "AREA:spam#EEEE44:Spam" ) ;
push ( @ tmpz , "AREA:virus#EE44EE:Virus" ) ;
push ( @ tmpz , "AREA:n_delvd#4444EE:Delivered" ) ;
push ( @ tmpz , "AREA:n_out#44EEEE:Out Connections" ) ;
push ( @ tmpz , "LINE1:in#00EE00" ) ;
push ( @ tmpz , "LINE1:rejtd#EE0000" ) ;
push ( @ tmpz , "LINE1:recvd#1F881F" ) ;
push ( @ tmpz , "LINE1:spam#EEEE00" ) ;
push ( @ tmpz , "LINE1:virus#EE00EE" ) ;
push ( @ tmpz , "LINE1:n_delvd#0000EE" ) ;
push ( @ tmpz , "LINE1:n_out#00EEEE" ) ;
2013-01-04 08:27:05 +00:00
}
2013-07-02 11:56:47 +01:00
if ( lc ( $ config - > { show_gaps } ) eq "y" ) {
2013-12-23 08:39:53 +00:00
push ( @ tmp , "AREA:wrongdata_p#$colors->{gap}:" ) ;
push ( @ tmp , "AREA:wrongdata_m#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata_p#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata_m#$colors->{gap}:" ) ;
push ( @ CDEF , "CDEF:wrongdata_p=allvalues_p,UN,INF,UNKN,IF" ) ;
push ( @ CDEF , "CDEF:wrongdata_m=allvalues_m,0,LT,INF,-1,*,UNKN,IF" ) ;
2013-07-02 11:56:47 +01:00
}
2013-01-04 08:27:05 +00:00
if ( $ title ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " <tr>\n" ) ;
push ( @ output , " <td bgcolor='$colors->{title_bg_color}'>\n" ) ;
2013-01-04 08:27:05 +00:00
}
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) ;
if ( $ silent =~ /imagetag/ ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { remote } ) if $ silent eq "imagetag" ;
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) if $ silent eq "imagetagbig" ;
@ tmp = @ tmpz ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
}
2016-01-25 17:35:30 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG1" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_mail1} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2017-07-10 11:06:06 +01:00
"--vertical-label=$rate_label" ,
2013-01-04 08:27:05 +00:00
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2013-07-29 17:03:13 +01:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:in=$rrd:mail_in:AVERAGE" ,
"DEF:out=$rrd:mail_out:AVERAGE" ,
"DEF:recvd=$rrd:mail_recvd:AVERAGE" ,
"DEF:delvd=$rrd:mail_delvd:AVERAGE" ,
"DEF:rejtd=$rrd:mail_rejtd:AVERAGE" ,
"DEF:spam=$rrd:mail_spam:AVERAGE" ,
"DEF:virus=$rrd:mail_virus:AVERAGE" ,
"DEF:bouncd=$rrd:mail_bouncd:AVERAGE" ,
"DEF:discrd=$rrd:mail_discrd:AVERAGE" ,
"DEF:held=$rrd:mail_held:AVERAGE" ,
"DEF:forwrd=$rrd:mail_forwrd:AVERAGE" ,
2016-01-28 14:53:32 +00:00
"DEF:rbl=$rrd:mail_val05:AVERAGE" ,
"CDEF:allvalues_p=in,out,recvd,delvd,rejtd,spam,virus,bouncd,discrd,held,forwrd,rbl,+,+,+,+,+,+,+,+,+,+,+" ,
2013-12-23 08:39:53 +00:00
"CDEF:allvalues_m=allvalues_p,UN,-1,UNKN,IF" ,
2013-07-02 11:56:47 +01:00
@ CDEF ,
2013-01-04 08:27:05 +00:00
"CDEF:n_forwrd=forwrd,-1,*" ,
"CDEF:n_delvd=delvd,-1,*" ,
"CDEF:n_out=out,-1,*" ,
2014-07-16 10:20:22 +01:00
"COMMENT: \\n" ,
2013-01-04 08:27:05 +00:00
@ tmp ) ;
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG1: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2016-01-25 17:35:30 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG1z" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_mail1} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2017-07-10 11:06:06 +01:00
"--vertical-label=$rate_label" ,
2013-01-04 08:27:05 +00:00
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2015-01-21 16:28:01 +00:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:in=$rrd:mail_in:AVERAGE" ,
"DEF:out=$rrd:mail_out:AVERAGE" ,
"DEF:recvd=$rrd:mail_recvd:AVERAGE" ,
"DEF:delvd=$rrd:mail_delvd:AVERAGE" ,
"DEF:rejtd=$rrd:mail_rejtd:AVERAGE" ,
"DEF:spam=$rrd:mail_spam:AVERAGE" ,
"DEF:virus=$rrd:mail_virus:AVERAGE" ,
"DEF:bouncd=$rrd:mail_bouncd:AVERAGE" ,
"DEF:discrd=$rrd:mail_discrd:AVERAGE" ,
"DEF:held=$rrd:mail_held:AVERAGE" ,
"DEF:forwrd=$rrd:mail_forwrd:AVERAGE" ,
2016-01-28 14:53:32 +00:00
"DEF:rbl=$rrd:mail_val05:AVERAGE" ,
"CDEF:allvalues_p=in,out,recvd,delvd,rejtd,spam,virus,bouncd,discrd,held,forwrd,rbl,+,+,+,+,+,+,+,+,+,+,+" ,
2013-12-23 08:44:12 +00:00
"CDEF:allvalues_m=allvalues_p,UN,-1,UNKN,IF" ,
2013-07-02 11:56:47 +01:00
@ CDEF ,
2013-01-04 08:27:05 +00:00
"CDEF:n_forwrd=forwrd,-1,*" ,
"CDEF:n_delvd=delvd,-1,*" ,
"CDEF:n_out=out,-1,*" ,
@ tmpz ) ;
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG1z: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
}
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /mail1/ ) ) {
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG1z . "\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG1 . "' border='0'></a>\n" ) ;
2015-02-12 15:27:03 +00:00
} else {
2015-01-21 16:28:01 +00:00
if ( $ version eq "new" ) {
$ picz_width = $ picz - > { image_width } * $ config - > { global_zoom } ;
$ picz_height = $ picz - > { image_height } * $ config - > { global_zoom } ;
} else {
$ picz_width = $ width + 115 ;
$ picz_height = $ height + 100 ;
}
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"javascript:void(window.open('" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG1z . "','','width=" . $ picz_width . ",height=" . $ picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG1 . "' border='0'></a>\n" ) ;
2013-01-04 08:27:05 +00:00
}
} else {
2017-08-01 12:24:49 +01:00
push ( @ output , " <img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG1 . "'>\n" ) ;
2013-01-04 08:27:05 +00:00
}
}
2014-06-19 09:47:10 +01:00
@ riglim = @ { setup_riglim ( $ rigid [ 1 ] , $ limit [ 1 ] ) } ;
2013-01-04 08:27:05 +00:00
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
2013-07-02 11:56:47 +01:00
undef ( @ CDEF ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:B_in#44EE44:K$T/s Received" ) ;
push ( @ tmp , "GPRINT:K_in:LAST: Cur\\: %5.0lf" ) ;
push ( @ tmp , "GPRINT:K_in:AVERAGE: Avg\\: %5.0lf" ) ;
push ( @ tmp , "GPRINT:K_in:MIN: Min\\: %5.0lf" ) ;
push ( @ tmp , "GPRINT:K_in:MAX: Max\\: %5.0lf\\n" ) ;
push ( @ tmp , "AREA:B_out#4444EE:K$T/s Delivered" ) ;
push ( @ tmp , "GPRINT:K_out:LAST: Cur\\: %5.0lf" ) ;
push ( @ tmp , "GPRINT:K_out:AVERAGE: Avg\\: %5.0lf" ) ;
push ( @ tmp , "GPRINT:K_out:MIN: Min\\: %5.0lf" ) ;
push ( @ tmp , "GPRINT:K_out:MAX: Max\\: %5.0lf\\n" ) ;
push ( @ tmp , "AREA:B_out#4444EE:" ) ;
push ( @ tmp , "AREA:B_in#44EE44:" ) ;
push ( @ tmp , "LINE1:B_out#0000EE" ) ;
push ( @ tmp , "LINE1:B_in#00EE00" ) ;
push ( @ tmpz , "AREA:B_in#44EE44:Received" ) ;
push ( @ tmpz , "AREA:B_out#4444EE:Delivered" ) ;
push ( @ tmpz , "AREA:B_out#4444EE:" ) ;
push ( @ tmpz , "AREA:B_in#44EE44:" ) ;
push ( @ tmpz , "LINE1:B_out#0000EE" ) ;
push ( @ tmpz , "LINE1:B_in#00EE00" ) ;
if ( lc ( $ config - > { netstats_in_bps } ) eq "y" ) {
push ( @ CDEF , "CDEF:B_in=in,8,*" ) ;
2020-07-13 09:13:55 +01:00
if ( lc ( $ config - > { netstats_mode } || "" ) eq "separated" ) {
push ( @ CDEF , "CDEF:B_out=out,8,*,-1,*" ) ;
} else {
push ( @ CDEF , "CDEF:B_out=out,8,*" ) ;
}
2013-01-04 08:27:05 +00:00
} else {
push ( @ CDEF , "CDEF:B_in=in" ) ;
2020-07-13 09:13:55 +01:00
if ( lc ( $ config - > { netstats_mode } || "" ) eq "separated" ) {
push ( @ CDEF , "CDEF:B_out=out,-1,*" ) ;
} else {
push ( @ CDEF , "CDEF:B_out=out" ) ;
}
2013-01-04 08:27:05 +00:00
}
2013-07-02 11:56:47 +01:00
if ( lc ( $ config - > { show_gaps } ) eq "y" ) {
push ( @ tmp , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ CDEF , "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF" ) ;
}
2013-01-04 08:27:05 +00:00
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) ;
if ( $ silent =~ /imagetag/ ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { remote } ) if $ silent eq "imagetag" ;
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) if $ silent eq "imagetagbig" ;
@ tmp = @ tmpz ;
push ( @ tmp , "COMMENT: \\n" ) ;
}
2016-01-25 17:35:30 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG2" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_mail2} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=$vlabel" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2013-07-29 17:03:13 +01:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:in=$rrd:mail_bytes_recvd:AVERAGE" ,
"DEF:out=$rrd:mail_bytes_delvd:AVERAGE" ,
2013-07-02 11:56:47 +01:00
"CDEF:allvalues=in,out,+" ,
2013-01-04 08:27:05 +00:00
@ CDEF ,
"CDEF:K_in=B_in,1024,/" ,
"CDEF:K_out=B_out,1024,/" ,
2014-07-16 10:20:22 +01:00
"COMMENT: \\n" ,
@ tmp ,
"COMMENT: \\n" ) ;
2013-01-04 08:27:05 +00:00
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG2: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2016-01-25 17:35:30 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG2z" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_mail2} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=$vlabel" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2015-01-21 16:28:01 +00:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:in=$rrd:mail_bytes_recvd:AVERAGE" ,
"DEF:out=$rrd:mail_bytes_delvd:AVERAGE" ,
2013-07-02 11:56:47 +01:00
"CDEF:allvalues=in,out,+" ,
2013-01-04 08:27:05 +00:00
@ CDEF ,
"CDEF:K_in=B_in,1024,/" ,
"CDEF:K_out=B_out,1024,/" ,
@ tmpz ) ;
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG2z: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
}
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /mail2/ ) ) {
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG2z . "\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG2 . "' border='0'></a>\n" ) ;
2015-02-12 15:27:03 +00:00
} else {
2015-01-21 16:28:01 +00:00
if ( $ version eq "new" ) {
$ picz_width = $ picz - > { image_width } * $ config - > { global_zoom } ;
$ picz_height = $ picz - > { image_height } * $ config - > { global_zoom } ;
} else {
$ picz_width = $ width + 115 ;
$ picz_height = $ height + 100 ;
}
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"javascript:void(window.open('" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG2z . "','','width=" . $ picz_width . ",height=" . $ picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG2 . "' border='0'></a>\n" ) ;
2013-01-04 08:27:05 +00:00
}
} else {
2017-08-01 12:24:49 +01:00
push ( @ output , " <img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG2 . "'>\n" ) ;
2013-01-04 08:27:05 +00:00
}
}
2013-01-04 09:40:31 +00:00
2013-01-04 08:27:05 +00:00
if ( $ title ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " </td>\n" ) ;
push ( @ output , " <td valign='top' bgcolor='" . $ colors - > { title_bg_color } . "'>\n" ) ;
2013-01-04 08:27:05 +00:00
}
2014-06-19 09:47:10 +01:00
@ riglim = @ { setup_riglim ( $ rigid [ 2 ] , $ limit [ 2 ] ) } ;
2013-01-04 08:27:05 +00:00
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
2013-07-02 11:56:47 +01:00
undef ( @ CDEF ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:queued#EEEE44:Queued" ) ;
push ( @ tmp , "LINE1:queued#EEEE00" ) ;
push ( @ tmp , "GPRINT:queued:LAST: Current\\: %5.0lf\\n" ) ;
push ( @ tmpz , "AREA:queued#EEEE44:Queued" ) ;
push ( @ tmpz , "LINE1:queued#EEEE00" ) ;
2013-07-02 11:56:47 +01:00
if ( lc ( $ config - > { show_gaps } ) eq "y" ) {
push ( @ tmp , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ CDEF , "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF" ) ;
}
2013-01-04 08:27:05 +00:00
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { small } ) ;
if ( $ silent =~ /imagetag/ ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { remote } ) if $ silent eq "imagetag" ;
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) if $ silent eq "imagetagbig" ;
@ tmp = @ tmpz ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
}
2016-01-25 17:35:30 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG3" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_mail3} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=Messages" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2013-07-29 17:03:13 +01:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:queued=$rrd:mail_queued:AVERAGE" ,
2013-07-02 11:56:47 +01:00
"CDEF:allvalues=queued" ,
@ CDEF ,
2014-07-16 10:20:22 +01:00
@ tmp ) ;
2013-01-04 08:27:05 +00:00
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG3: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2016-01-25 17:35:30 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG3z" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_mail3} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=Messages" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2015-01-21 16:28:01 +00:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:queued=$rrd:mail_queued:AVERAGE" ,
2013-07-02 11:56:47 +01:00
"CDEF:allvalues=queued" ,
@ CDEF ,
2013-01-04 08:27:05 +00:00
@ tmpz ) ;
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG3z: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
}
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /mail3/ ) ) {
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG3z . "\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG3 . "' border='0'></a>\n" ) ;
2015-02-12 15:27:03 +00:00
} else {
2015-01-21 16:28:01 +00:00
if ( $ version eq "new" ) {
$ picz_width = $ picz - > { image_width } * $ config - > { global_zoom } ;
$ picz_height = $ picz - > { image_height } * $ config - > { global_zoom } ;
} else {
$ picz_width = $ width + 115 ;
$ picz_height = $ height + 100 ;
}
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"javascript:void(window.open('" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG3z . "','','width=" . $ picz_width . ",height=" . $ picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG3 . "' border='0'></a>\n" ) ;
2013-01-04 08:27:05 +00:00
}
} else {
2017-08-01 12:24:49 +01:00
push ( @ output , " <img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG3 . "'>\n" ) ;
2013-01-04 08:27:05 +00:00
}
}
2014-06-19 09:47:10 +01:00
@ riglim = @ { setup_riglim ( $ rigid [ 3 ] , $ limit [ 3 ] ) } ;
2013-01-04 08:27:05 +00:00
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
2013-07-02 11:56:47 +01:00
undef ( @ CDEF ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:queues#44AAEE:Size in KB" ) ;
push ( @ tmp , "LINE1:queues#00AAEE" ) ;
push ( @ tmp , "GPRINT:K_queues:LAST: Current\\: %5.1lf\\n" ) ;
push ( @ tmpz , "AREA:queues#44AAEE:Size" ) ;
push ( @ tmpz , "LINE1:queues#00AAEE" ) ;
2013-07-02 11:56:47 +01:00
if ( lc ( $ config - > { show_gaps } ) eq "y" ) {
push ( @ tmp , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ CDEF , "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF" ) ;
}
2013-01-04 08:27:05 +00:00
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { small } ) ;
if ( $ silent =~ /imagetag/ ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { remote } ) if $ silent eq "imagetag" ;
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) if $ silent eq "imagetagbig" ;
@ tmp = @ tmpz ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
}
2016-01-25 17:35:30 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG4" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_mail4} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2015-05-19 11:57:18 +01:00
"--vertical-label=bytes" ,
2013-01-04 08:27:05 +00:00
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2013-07-29 17:03:13 +01:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:queues=$rrd:mail_queues:AVERAGE" ,
2013-07-02 11:56:47 +01:00
"CDEF:allvalues=queues" ,
@ CDEF ,
2013-01-04 08:27:05 +00:00
"CDEF:K_queues=queues,1024,/" ,
2014-07-16 10:20:22 +01:00
@ tmp ) ;
2013-01-04 08:27:05 +00:00
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG4: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2016-01-25 17:35:30 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG4z" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_mail4} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2015-05-19 11:57:18 +01:00
"--vertical-label=bytes" ,
2013-01-04 08:27:05 +00:00
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2015-01-21 16:28:01 +00:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:queues=$rrd:mail_queues:AVERAGE" ,
2013-07-02 11:56:47 +01:00
"CDEF:allvalues=queues" ,
@ CDEF ,
2013-01-04 08:27:05 +00:00
@ tmpz ) ;
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG4z: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
}
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /mail4/ ) ) {
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG4z . "\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG4 . "' border='0'></a>\n" ) ;
2015-02-12 15:27:03 +00:00
} else {
2015-01-21 16:28:01 +00:00
if ( $ version eq "new" ) {
$ picz_width = $ picz - > { image_width } * $ config - > { global_zoom } ;
$ picz_height = $ picz - > { image_height } * $ config - > { global_zoom } ;
} else {
$ picz_width = $ width + 115 ;
$ picz_height = $ height + 100 ;
}
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"javascript:void(window.open('" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG4z . "','','width=" . $ picz_width . ",height=" . $ picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG4 . "' border='0'></a>\n" ) ;
2013-01-04 08:27:05 +00:00
}
} else {
2017-08-01 12:24:49 +01:00
push ( @ output , " <img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG4 . "'>\n" ) ;
2013-01-04 08:27:05 +00:00
}
}
2014-06-19 09:47:10 +01:00
@ riglim = @ { setup_riglim ( $ rigid [ 4 ] , $ limit [ 4 ] ) } ;
2013-01-04 08:27:05 +00:00
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
2013-07-02 11:56:47 +01:00
undef ( @ CDEF ) ;
2014-07-16 10:20:22 +01:00
push ( @ tmp , "LINE2:none#4444EE:None" ) ;
push ( @ tmp , "GPRINT:none:LAST: Current\\: %5.0lf\\n" ) ;
push ( @ tmp , "LINE2:pass#44EE44:Pass" ) ;
push ( @ tmp , "GPRINT:pass:LAST: Current\\: %5.0lf\\n" ) ;
push ( @ tmp , "LINE2:softfail#EEEE44:SoftFail" ) ;
push ( @ tmp , "GPRINT:softfail:LAST: Current\\: %5.0lf\\n" ) ;
push ( @ tmp , "LINE2:fail#EE4444:Fail" ) ;
push ( @ tmp , "GPRINT:fail:LAST: Current\\: %5.0lf\\n" ) ;
push ( @ tmpz , "LINE2:none#4444EE:None" ) ;
push ( @ tmpz , "LINE2:pass#44EE44:Pass" ) ;
push ( @ tmpz , "LINE2:softfail#EEEE44:SoftFail" ) ;
push ( @ tmpz , "LINE2:fail#EE4444:Fail" ) ;
if ( lc ( $ config - > { show_gaps } ) eq "y" ) {
push ( @ tmp , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ CDEF , "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF" ) ;
}
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { small } ) ;
if ( $ silent =~ /imagetag/ ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { remote } ) if $ silent eq "imagetag" ;
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) if $ silent eq "imagetagbig" ;
@ tmp = @ tmpz ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
}
2016-01-25 17:35:30 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG5" ,
2014-07-16 10:20:22 +01:00
"--title=$config->{graphs}->{_mail5} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2014-07-16 10:20:22 +01:00
"--vertical-label=Messages" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2014-07-16 10:20:22 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:none=$rrd:mail_val01:AVERAGE" ,
"DEF:pass=$rrd:mail_val02:AVERAGE" ,
"DEF:softfail=$rrd:mail_val03:AVERAGE" ,
"DEF:fail=$rrd:mail_val04:AVERAGE" ,
"CDEF:allvalues=none,pass,softfail,fail,+,+,+" ,
@ CDEF ,
@ tmp ) ;
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG5: $err\n" ) if $ err ;
2014-07-16 10:20:22 +01:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2016-01-25 17:35:30 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG5z" ,
2014-07-16 10:20:22 +01:00
"--title=$config->{graphs}->{_mail5} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2014-07-16 10:20:22 +01:00
"--vertical-label=Messages" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2014-07-16 10:20:22 +01:00
@ riglim ,
2015-01-21 16:28:01 +00:00
$ zoom ,
2014-07-16 10:20:22 +01:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:none=$rrd:mail_val01:AVERAGE" ,
"DEF:pass=$rrd:mail_val02:AVERAGE" ,
"DEF:softfail=$rrd:mail_val03:AVERAGE" ,
"DEF:fail=$rrd:mail_val04:AVERAGE" ,
"CDEF:allvalues=none,pass,softfail,fail,+,+,+" ,
@ CDEF ,
@ tmpz ) ;
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG5z: $err\n" ) if $ err ;
2014-07-16 10:20:22 +01:00
}
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /mail5/ ) ) {
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG5z . "\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG5 . "' border='0'></a>\n" ) ;
2015-02-12 15:27:03 +00:00
} else {
2015-01-21 16:28:01 +00:00
if ( $ version eq "new" ) {
$ picz_width = $ picz - > { image_width } * $ config - > { global_zoom } ;
$ picz_height = $ picz - > { image_height } * $ config - > { global_zoom } ;
} else {
$ picz_width = $ width + 115 ;
$ picz_height = $ height + 100 ;
}
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"javascript:void(window.open('" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG5z . "','','width=" . $ picz_width . ",height=" . $ picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG5 . "' border='0'></a>\n" ) ;
2014-07-16 10:20:22 +01:00
}
} else {
2017-08-01 12:24:49 +01:00
push ( @ output , " <img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG5 . "'>\n" ) ;
2014-07-16 10:20:22 +01:00
}
}
@ riglim = @ { setup_riglim ( $ rigid [ 5 ] , $ limit [ 5 ] ) } ;
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
undef ( @ CDEF ) ;
2017-06-20 10:26:08 +01:00
if ( lc ( $ mail - > { greylist } ) eq "milter-greylist" ) {
push ( @ tmp , "AREA:greylisted#4444EE:Greylisted" ) ;
push ( @ tmp , "GPRINT:greylisted:LAST: Current\\: %5.0lf\\n" ) ;
push ( @ tmp , "AREA:whitelisted#44EEEE:Whitelisted" ) ;
push ( @ tmp , "GPRINT:whitelisted:LAST: Current\\: %5.0lf\\n" ) ;
push ( @ tmp , "LINE2:greylisted#0000EE" ) ;
push ( @ tmp , "LINE2:whitelisted#00EEEE" ) ;
push ( @ tmp , "LINE2:records#EE0000:Records" ) ;
push ( @ tmp , "GPRINT:records:LAST: Current\\: %5.0lf\\n" ) ;
push ( @ tmpz , "AREA:greylisted#4444EE:Greylisted" ) ;
push ( @ tmpz , "AREA:whitelisted#44EEEE:Whitelisted" ) ;
push ( @ tmpz , "LINE2:greylisted#0000EE" ) ;
push ( @ tmpz , "LINE2:whitelisted#00EEEE" ) ;
push ( @ tmpz , "LINE2:records#EE0000:Records" ) ;
}
if ( lc ( $ mail - > { greylist } ) eq "postgrey" ) {
push ( @ tmp , "LINE2:greylisted#0000EE:Greylisted" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:greylisted:LAST: Current\\: $gl_valform\\n" ) ;
2017-06-22 14:30:48 +01:00
push ( @ tmp , "LINE2:delayed#EEEE00:Delayed" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:delayed:LAST: Current\\: $gl_valform\\n" ) ;
2017-06-20 10:26:08 +01:00
push ( @ tmp , "LINE2:whitelisted#00EEEE:Whitelisted" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:whitelisted:LAST: Current\\: $gl_valform\\n" ) ;
2017-06-20 10:26:08 +01:00
push ( @ tmp , "LINE2:records#EE00EE:Passed" ) ;
2017-07-10 11:06:06 +01:00
push ( @ tmp , "GPRINT:records:LAST: Current\\: $gl_valform\\n" ) ;
2017-06-20 10:26:08 +01:00
push ( @ tmpz , "LINE2:greylisted#0000EE:Greylisted" ) ;
2017-06-22 14:30:48 +01:00
push ( @ tmpz , "LINE2:delayed#EEEE00:Delayed" ) ;
2017-06-20 10:26:08 +01:00
push ( @ tmpz , "LINE2:whitelisted#00EEEE:Whitelisted" ) ;
push ( @ tmpz , "LINE2:records#EE00EE:Passed" ) ;
}
2013-07-02 11:56:47 +01:00
if ( lc ( $ config - > { show_gaps } ) eq "y" ) {
push ( @ tmp , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ CDEF , "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF" ) ;
}
2013-01-04 08:27:05 +00:00
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { small } ) ;
if ( $ silent =~ /imagetag/ ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { remote } ) if $ silent eq "imagetag" ;
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) if $ silent eq "imagetagbig" ;
@ tmp = @ tmpz ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
}
2016-01-25 17:35:30 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG6" ,
2014-07-16 10:20:22 +01:00
"--title=$config->{graphs}->{_mail6} ($tf->{nwhen}$tf->{twhen})" ,
2013-01-04 08:27:05 +00:00
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2017-07-10 11:06:06 +01:00
"--vertical-label=$rate_label" ,
2013-01-04 08:27:05 +00:00
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2013-07-29 17:03:13 +01:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:records=$rrd:mail_val07:AVERAGE" ,
"DEF:greylisted=$rrd:mail_val08:AVERAGE" ,
"DEF:whitelisted=$rrd:mail_val09:AVERAGE" ,
2017-06-22 14:30:48 +01:00
"DEF:delayed=$rrd:mail_val10:AVERAGE" ,
"CDEF:allvalues=records,greylisted,whitelisted,delayed,+,+,+" ,
2013-07-02 11:56:47 +01:00
@ CDEF ,
2013-01-04 08:27:05 +00:00
@ tmp ) ;
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG6: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2016-01-25 17:35:30 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG6z" ,
2014-07-16 10:20:22 +01:00
"--title=$config->{graphs}->{_mail6} ($tf->{nwhen}$tf->{twhen})" ,
2013-01-04 08:27:05 +00:00
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2017-07-10 11:06:06 +01:00
"--vertical-label=$rate_label" ,
2013-01-04 08:27:05 +00:00
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2015-01-21 16:28:01 +00:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:records=$rrd:mail_val07:AVERAGE" ,
"DEF:greylisted=$rrd:mail_val08:AVERAGE" ,
"DEF:whitelisted=$rrd:mail_val09:AVERAGE" ,
2017-06-22 14:30:48 +01:00
"DEF:delayed=$rrd:mail_val10:AVERAGE" ,
"CDEF:allvalues=records,greylisted,whitelisted,delayed,+,+,+" ,
2013-07-02 11:56:47 +01:00
@ CDEF ,
2013-01-04 08:27:05 +00:00
@ tmpz ) ;
$ err = RRDs:: error ;
2017-08-01 12:24:49 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG6z: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
}
2014-07-16 10:20:22 +01:00
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /mail6/ ) ) {
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG6z . "\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG6 . "' border='0'></a>\n" ) ;
2015-02-12 15:27:03 +00:00
} else {
2015-01-21 16:28:01 +00:00
if ( $ version eq "new" ) {
$ picz_width = $ picz - > { image_width } * $ config - > { global_zoom } ;
$ picz_height = $ picz - > { image_height } * $ config - > { global_zoom } ;
} else {
$ picz_width = $ width + 115 ;
$ picz_height = $ height + 100 ;
}
2017-08-01 12:24:49 +01:00
push ( @ output , " <a href=\"javascript:void(window.open('" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG6z . "','','width=" . $ picz_width . ",height=" . $ picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG6 . "' border='0'></a>\n" ) ;
2013-01-04 08:27:05 +00:00
}
} else {
2017-08-01 12:24:49 +01:00
push ( @ output , " <img src='" . $ config - > { url } . "/" . $ config - > { imgs_dir } . $ IMG6 . "'>\n" ) ;
2013-01-04 08:27:05 +00:00
}
}
if ( $ title ) {
2017-08-01 12:24:49 +01:00
push ( @ output , " </td>\n" ) ;
push ( @ output , " </tr>\n" ) ;
push ( @ output , main:: graph_footer ( ) ) ;
2013-01-04 08:27:05 +00:00
}
2017-08-01 12:24:49 +01:00
push ( @ output , " <br>\n" ) ;
return @ output ;
2013-01-04 08:27:05 +00:00
}
1 ;