--- smeserver-sme9admin-1.5/root/usr/bin/sme9admind.altqmail 2017-03-25 22:23:50.000000000 -0400 +++ smeserver-sme9admin-1.5/root/usr/bin/sme9admind 2017-08-14 20:00:50.324239696 -0400 @@ -94,6 +94,7 @@ "sshd/current", #pour les connexions ssh "messages", "qmail/current", #pour les mails IN/OUT + "altqmail/current", #pour les mails OUT "qpsmtpd/current", #pour les SPAM/VIRUS ?? "sqpsmtpd/current", #idem pour les connexions securisées "proftpd/current", #pour la date de fin de connection FTP @@ -177,6 +178,16 @@ $cntqm{$_} = 0; $cntqmlocal{$_} = 0; } +# pour altqmail +my ($localaqueue,$remoteaqueue); +my @resultsaqm = qw(failure deferral success total); +my %cntaqm; +my %cntaqmlocal; +foreach (@resultsaqm){ + $cntaqm{$_} = 0; + $cntaqmlocal{$_} = 0; +} +my $net_amail_out=0; #------------------------ #declaration de fonctions @@ -516,7 +527,7 @@ # reset all counter before checking logs - ($net_dhcp,$net_mail_in,$net_mail_out,$net_spam,$net_virus)=(0,0,0,0,0); + ($net_dhcp,$net_mail_in,$net_mail_out,$net_amail_out,$net_spam,$net_virus)=(0,0,0,0,0,0); foreach (keys %denied, @others){ $cnt{$_} = 0; } @@ -524,6 +535,10 @@ $cntqm{$_} = 0; $cntqmlocal{$_} = 0; } + foreach (@resultsaqm){ + $cntaqm{$_} = 0; + $cntaqmlocal{$_} = 0; + } foreach my $nom (@logs) { # on recupere un file handle positionné comme il faut my $fh = seek_log("$logdir$nom"); @@ -683,6 +698,40 @@ $net_mail_out=$cntqm{total}; } + elsif ($nom =~ /^altqmail\/current$/) { + while ( defined(my $l = <$fh>)) { + # accounting for remote connections + # @400000004994ad092afa867c delivery 96906: success etc... + if ($l =~ m/^\@[0-9a-f]{24} delivery \d+: (success|failure|deferral).*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|CNAME_lookup_failed_temporarily|Sorry,_I_wasn't_able_to_establish_an_SMTP_connection)/i) { + my $result = $1; + $cntaqm{$result}++; + next; + } + # accounting for local connections have to be after the remote + if ($l =~ m/^\@[0-9a-f]{24} delivery \d+: (success|failure|deferral).*/i) { + my $result = $1; + $cntaqmlocal{$result}++; + next; + } + + + } + + # Calcul des totaux: + foreach (@resultsqm){ + $cntaqm{total} = $cntaqm{total} + $cntaqm{$_} if $_ !~ /total/; + $cntaqmlocal{total} = $cntaqmlocal{total} + $cntaqmlocal{$_} if $_ !~ /total/; + } + ## add qmail local queue + $localaqueue=`find /var/service/altqmail/root/var/qmail/queue/local/ -type f | wc -l`; + $localaqueue=~ s/\D+//g; + ### add qmail remote queue + $remoteaqueue=`find /var/service/altqmail/root/var/qmail/queue/remote/ -type f | wc -l`; + $remoteaqueue=~ s/\D+//g; + $net_amail_out=$cntaqm{total}; + + } + elsif ($nom =~ /^s?qpsmtpd\/current$/) { while ( defined(my $l = <$fh>)) { # following code is copy paste from util_parse_mail from Daniel Berteaud for Zabbix monitoring @@ -1307,7 +1356,7 @@ # print "if_ext_bin=$if_ext_bin,if_ext_bout=$if_ext_bout,if_ext_pin=$if_ext_pin,if_ext_pout=$if_ext_pout\n"; # print "net_samba=$net_samba,net_minlatency=$net_minlatency,net_avglatency=$net_avglatency,"; # print "net_maxlatency=$net_maxlatency,net_loss=$net_loss,net_spam=$net_spam,net_virus=$net_virus,"; - print "net_dhcp=$net_dhcp,net_mail_in=$net_mail_in,net_mail_out=$net_mail_out\n"; +# print "net_dhcp=$net_dhcp,net_mail_in=$net_mail_in,net_mail_out=$net_mail_out\n"; # print "cpu_total=$cpu_total,cpu_idle=$cpu_idle,cpu_system=$cpu_system,cpu_user=$cpu_user\n"; # print "cpu_nice=$cpu_nice,cpu_plist=$cpu_plist,cpu_runq=$cpu_runq"; # print "cpu_load1=$cpu_load1,cpu_load5=$cpu_load5,cpu_load15=$cpu_load15,cpu_uptime=$cpu_uptime\n"; @@ -1321,14 +1370,19 @@ # print "squid cpu=$squid_cpu, mem=$squid_mem, nb=$squid_nbproc\n"; # print "sessions_ftp=$sessions_ftp,sessions_ssh=$sessions_ssh,"; # print "sessions_vpn=$sessions_vpn,sessions_netbios=$sessions_netbios\n"; -#print "check_basicheaders=$mail_in_check_basicheaders,check_earlytalker=$mail_in_check_earlytalker,check_goodrcptto=$mail_in_check_goodrcptto,check_spamhelo=$mail_in_check_spamhelo," +# print "check_basicheaders=$mail_in_check_basicheaders,check_earlytalker=$mail_in_check_earlytalker,check_goodrcptto=$mail_in_check_goodrcptto,check_spamhelo=$mail_in_check_spamhelo," #."clamav=$mail_in_clamav,dmarc=$mail_in_dmarc,dnsbl=$mail_in_dnsbl,fcrdns=$mail_in_fcrdns,karma=$mail_in_karma,other_denied=$mail_in_other_denied,queued=$mail_in_queued,resolvable_fromhost=$mail_in_resolvable_fromhost," #."rhsbl=$mail_in_rhsbl,spam_denied=$mail_in_spam_denied,spam_queued=$mail_in_spam_queued,spf=$mail_in_spf,tls_failed=$mail_in_tls_failed,total=$mail_in_total,total_denied=$mail_in_total_denied,uribl=$mail_in_uribl\n"; # foreach (keys %denied,@others){ print "$_: $cnt{$_},";}; print "\n"; # print join(':', map {$cnt{$_}} keys %denied,@others); print "\n"; + print "qmail "; foreach (@resultsqm){ print "local_$_:$cntqmlocal{$_},";}; foreach (@resultsqm){ print "$_:$cntqm{$_},";}; print "localqueue=$localqueue,remotequeue=$remotequeue\n"; - print join(':', map {$cntqmlocal{$_}} @resultsqm) .":". join(':', map {$cntqm{$_}} @resultsqm); print ":". $localqueue .":". $remotequeue; print "\n"; +# print join(':', map {$cntqmlocal{$_}} @resultsqm) .":". join(':', map {$cntqm{$_}} @resultsqm); print ":". $localqueue .":". $remotequeue; print "\n"; + print "altqmail "; + foreach (@resultsaqm){ print "local_$_:$cntaqmlocal{$_},";}; foreach (@resultsaqm){ print "$_:$cntaqm{$_},";}; + print "localqueue=$localaqueue,remotequeue=$remoteaqueue\n"; +# print join(':', map {$cntaqmlocal{$_}} @resultsaqm) .":". join(':', map {$cntaqm{$_}} @resultsaqm); print ":". $localaqueue .":". $remoteaqueue; print "\n"; my %rrds=( "sensors"=>"$sensors_temp1:$sensors_temp2:$sensors_temp_hd1:$sensors_temp_hd2:$sensors_fan_speed:$sensors_fan2_speed:$sensors_temp_hd3:$sensors_temp_hd4:$sensors_temp_hd5:$sensors_temp_hd6", @@ -1344,8 +1398,8 @@ "squid"=>"$squid_cpu:$squid_mem:$squid_nbproc", "sessions"=>"$sessions_ssh:$sessions_ftp:$sessions_vpn:$sessions_netbios:$sessions_afp", "qpsmtpd" => join(':', map {$cnt{$_}} keys %denied,@others), - "qmail" => join(':', map {$cntqmlocal{$_}} @resultsqm) .":". join(':', map {$cntqm{$_}} @resultsqm) . ":". $localqueue .":". $remotequeue); - + "qmail" => join(':', map {$cntqmlocal{$_}} @resultsqm) .":". join(':', map {$cntqm{$_}} @resultsqm) . ":". $localqueue .":". $remotequeue, + "altqmail" => join(':', map {$cntaqmlocal{$_}} @resultsaqm) .":". join(':', map {$cntaqm{$_}} @resultsaqm) . ":". $localaqueue .":". $remoteaqueue); my $error; foreach my $rrd (keys %rrds) { --- smeserver-sme9admin-1.5/root/usr/share/doc/smeserver-sme9admin/create-rrd.sh.altqmail 2017-03-25 22:23:50.000000000 -0400 +++ smeserver-sme9admin-1.5/root/usr/share/doc/smeserver-sme9admin/create-rrd.sh 2017-07-10 14:08:12.687683984 -0400 @@ -506,6 +506,36 @@ RRA:MIN:0.5:24:372 \ RRA:MIN:0.5:288:365 \ +# nombre et raisons de connexions refusées ou acceptées et file d'attente +rrdtool create /var/lib/sme9admin/altqmail.rrd -s 300 \ + DS:local_failure:GAUGE:600:0:U \ + DS:local_deferral:GAUGE:600:0:U \ + DS:local_success:GAUGE:600:0:U \ + DS:local_total:GAUGE:600:0:U \ + DS:remote_failure:GAUGE:600:0:U \ + DS:remote_deferral:GAUGE:600:0:U \ + DS:remote_success:GAUGE:600:0:U \ + DS:remote_total:GAUGE:600:0:U \ + DS:local_queue:GAUGE:600:0:U \ + DS:remote_queue:GAUGE:600:0:U \ + RRA:AVERAGE:0.5:1:12 \ + RRA:AVERAGE:0.5:1:72 \ + RRA:AVERAGE:0.5:1:288 \ + RRA:AVERAGE:0.5:6:336 \ + RRA:AVERAGE:0.5:24:372 \ + RRA:AVERAGE:0.5:288:365 \ + RRA:MAX:0.5:1:12 \ + RRA:MAX:0.5:1:72 \ + RRA:MAX:0.5:1:288 \ + RRA:MAX:0.5:6:336 \ + RRA:MAX:0.5:24:372 \ + RRA:MAX:0.5:288:365 \ + RRA:MIN:0.5:1:12 \ + RRA:MIN:0.5:1:72 \ + RRA:MIN:0.5:1:288 \ + RRA:MIN:0.5:6:336 \ + RRA:MIN:0.5:24:372 \ + RRA:MIN:0.5:288:365 \ echo -e "Creation of rrds files :\t\t[OK]" --- smeserver-sme9admin-1.5/root/etc/e-smith/web/functions/sme9admin.altqmail 2017-03-25 22:23:50.000000000 -0400 +++ smeserver-sme9admin-1.5/root/etc/e-smith/web/functions/sme9admin 2017-07-10 14:16:57.349464605 -0400 @@ -370,7 +370,7 @@ "#".gettext("Administrative services"), "sshd", "sme9admind", "#".gettext("Network services"),"wan","dhcpd","pptpd","ippp", "#".gettext("File-sharing services"),"smb","smbd","nmbd","ftp", - "#".gettext("E-mail services"),"pop3","pop3s","dovecot","imaps","imap","qmail","qpsmtpd","sqpsmtpd", "clamd", "freshclam","spamd",#mail + "#".gettext("E-mail services"),"pop3","pop3s","dovecot","imaps","imap","qmail","altqmail","qpsmtpd","sqpsmtpd", "clamd", "freshclam","spamd",#mail "#".gettext("DNS services"),"tinydns","dnscache", #dns "#".gettext("Authentication services"),"oidentd","ldap","smtp-auth-proxy","radiusd", #auth "#".gettext("Misc. services"),"mysqld","ntpd","lpd", #misc @@ -401,7 +401,7 @@ else { #si c'est un service pour lequel on a des infos complementaires... - if($svc=~/^(httpd-e-smith|httpd-admin|smb|smbd|nmbd|squid|pptpd|dhcpd|sshd|ftp|pppoe|pppd|wan|qmail|qpsmtpd|sqpsmtpd)$/) {$details=1;} + if($svc=~/^(httpd-e-smith|httpd-admin|smb|smbd|nmbd|squid|pptpd|dhcpd|sshd|ftp|pppoe|pppd|wan|altqmail|qmail|qpsmtpd|sqpsmtpd)$/) {$details=1;} if ( -d "/service/$svc") {$cmd = "/usr/bin/sv s $svc";} # was -d /var/service or -d /service/ elsif ($svc=~/^(imaps|imap)$/) { $cmd = "/usr/bin/sv s dovecot"; } else {$cmd = "/sbin/e-smith/service $svc status|/bin/grep $svc";} @@ -1066,6 +1066,7 @@ elsif ($q->param('service') eq 'pppoe' || $q->param('service') eq 'wan' || $q->param('service') eq 'pppd' ) {showPppoe();} elsif ($q->param('service') eq 'qpsmtpd' || $q->param('service') eq 'sqpsmtpd' ) {showQpsmtpd();} elsif ($q->param('service') eq 'qmail') {showQmail();} + elsif ($q->param('service') eq 'altqmail') {showQmail();} } #---------------------------------------------------------------- @@ -1085,7 +1086,7 @@ print $q->p($q->a ({href => "$progname"},gettext("Back\n"))); #qmail local and remote email createGraphQmail($start); - + createGraphAltQmail($start); } #---------------------------------------------------------------- #details du service s?qpsmtpd @@ -1927,6 +1928,39 @@ } +sub createGraphAltQmail { + my($start)=(@_); + #qmail entrant/sortant + createShowGraph(gettext("Number of remote e-mails handled by the alternative mail service (altqmail)."),"altqmail", + "--title=".gettext("Remote e-mails (altqmail)"), + "--start=$start", + "DEF:local_failure=$rrddir/altqmail.rrd:local_failure:AVERAGE","DEF:maxlocal_failure=$rrddir/altqmail.rrd:local_failure:MAX","DEF:minlocal_failure=$rrddir/altqmail.rrd:local_failure:MIN", + "DEF:local_deferral=$rrddir/altqmail.rrd:local_deferral:AVERAGE","DEF:maxlocal_deferral=$rrddir/altqmail.rrd:local_deferral:MAX","DEF:minlocal_deferral=$rrddir/altqmail.rrd:local_deferral:MIN", + "DEF:local_success=$rrddir/altqmail.rrd:local_success:AVERAGE","DEF:maxlocal_success=$rrddir/altqmail.rrd:local_success:MAX","DEF:minlocal_success=$rrddir/altqmail.rrd:local_success:MIN", + "DEF:local_total=$rrddir/altqmail.rrd:local_total:AVERAGE","DEF:maxlocal_total=$rrddir/altqmail.rrd:local_total:MAX","DEF:minlocal_total=$rrddir/altqmail.rrd:local_total:MIN", + "DEF:remote_failure=$rrddir/altqmail.rrd:remote_failure:AVERAGE","DEF:maxremote_failure=$rrddir/altqmail.rrd:remote_failure:MAX","DEF:minremote_failure=$rrddir/altqmail.rrd:remote_failure:MIN", + "DEF:remote_deferral=$rrddir/altqmail.rrd:remote_deferral:AVERAGE","DEF:maxremote_deferral=$rrddir/altqmail.rrd:remote_deferral:MAX","DEF:minremote_deferral=$rrddir/altqmail.rrd:remote_deferral:MIN", + "DEF:remote_success=$rrddir/altqmail.rrd:remote_success:AVERAGE","DEF:maxremote_success=$rrddir/altqmail.rrd:remote_success:MAX","DEF:minremote_success=$rrddir/altqmail.rrd:remote_success:MIN", + "DEF:remote_total=$rrddir/altqmail.rrd:remote_total:AVERAGE","DEF:maxremote_total=$rrddir/altqmail.rrd:remote_total:MAX","DEF:minremote_total=$rrddir/altqmail.rrd:remote_total:MIN", + "DEF:local_queue=$rrddir/altqmail.rrd:local_queue:AVERAGE","DEF:maxlocal_queue=$rrddir/altqmail.rrd:local_queue:MAX","DEF:minlocal_queue=$rrddir/altqmail.rrd:local_queue:MIN", + "DEF:remote_queue=$rrddir/altqmail.rrd:remote_queue:AVERAGE","DEF:maxremote_queue=$rrddir/altqmail.rrd:remote_queue:MAX","DEF:minremote_queue=$rrddir/altqmail.rrd:remote_queue:MIN", + "CDEF:adj_remote_total=0,remote_total,-", "CDEF:adj_remote_queue=0,remote_queue,-", + "CDEF:adj_remote_failure=0,remote_failure,-", "CDEF:adj_remote_deferral=0,remote_deferral,-","CDEF:adj_remote_success=0,remote_success,-", + "COMMENT:Last\\t Min\\t Avg\\t Max\\r", + "COMMENT:\\n","AREA:local_total#1ED408:".gettext("Total local e-mails"),"COMMENT:\\u","GPRINT:local_total:LAST:%4.0lf ","GPRINT:minlocal_total:MIN:%4.0lf ","GPRINT:local_total:AVERAGE:%4.0lf ","GPRINT:maxlocal_total:MAX:%4.0lf \\r", + "COMMENT:\\n","COMMENT: ".gettext("Total remote e-mails"), "COMMENT:\\u","GPRINT:remote_total:LAST:%4.0lf ","GPRINT:minremote_total:MIN:%4.0lf ","GPRINT:remote_total:AVERAGE:%4.0lf ","GPRINT:maxremote_total:MAX:%4.0lf \\r", + + "COMMENT:\\n","COMMENT: ","AREA:adj_remote_success#0000ff:".gettext("Remote e-mail success"), "COMMENT:\\u","GPRINT:remote_success:LAST:%4.0lf ","GPRINT:minremote_success:MIN:%4.0lf ","GPRINT:remote_success:AVERAGE:%4.0lf ","GPRINT:maxremote_success:MAX:%4.0lf \\r", + "COMMENT:\\n","COMMENT: ","AREA:adj_remote_deferral#ffff00:".gettext("Remote e-mail deferral").":STACK", "COMMENT:\\u","GPRINT:remote_deferral:LAST:%4.0lf ","GPRINT:minremote_deferral:MIN:%4.0lf ","GPRINT:remote_deferral:AVERAGE:%4.0lf ","GPRINT:maxremote_deferral:MAX:%4.0lf \\r", + "COMMENT:\\n","COMMENT: ","AREA:adj_remote_failure#ff0000:".gettext("Remote e-mail failure").":STACK", "COMMENT:\\u","GPRINT:remote_failure:LAST:%4.0lf ","GPRINT:minremote_failure:MIN:%4.0lf ","GPRINT:remote_failure:AVERAGE:%4.0lf ","GPRINT:maxremote_failure:MAX:%4.0lf \\r", + + "COMMENT:\\n","LINE2:local_queue#666666:".gettext("Local queue"),"COMMENT:\\u", "GPRINT:local_queue:LAST:%4.0lf ","GPRINT:minlocal_queue:MIN:%4.0lf ","GPRINT:local_queue:AVERAGE:%4.0lf ","GPRINT:maxlocal_queue:MAX:%4.0lf \\r", + "COMMENT:\\n","LINE2:adj_remote_queue#000000:".gettext("Remote queue"),"COMMENT:\\u", "GPRINT:remote_queue:LAST:%4.0lf ","GPRINT:minremote_queue:MIN:%4.0lf ","GPRINT:remote_queue:AVERAGE:%4.0lf ","GPRINT:maxremote_queue:MAX:%4.0lf \\r", + "COMMENT:\\n"); + + +} + sub createGraphQpsmtpd { my($start)=(@_); #qpsmtpd --- smeserver-sme9admin-1.5/root/etc/e-smith/sql/init/sme9admin.altqmail 2017-08-14 20:11:09.554000000 -0400 +++ smeserver-sme9admin-1.5/root/etc/e-smith/sql/init/sme9admin 2017-08-14 20:18:50.221000000 -0400 @@ -118,3 +118,36 @@ RRA:MIN:0.5:24:372 \ RRA:MIN:0.5:288:365 fi + if [[ ! -f /var/lib/sme9admin/altqmail.rrd ]]; then + # nombre et raisons de connexions refusées ou acceptées et file d'attente + rrdtool create /var/lib/sme9admin/altqmail.rrd -s 300 \ + DS:local_failure:GAUGE:600:0:U \ + DS:local_deferral:GAUGE:600:0:U \ + DS:local_success:GAUGE:600:0:U \ + DS:local_total:GAUGE:600:0:U \ + DS:remote_failure:GAUGE:600:0:U \ + DS:remote_deferral:GAUGE:600:0:U \ + DS:remote_success:GAUGE:600:0:U \ + DS:remote_total:GAUGE:600:0:U \ + DS:local_queue:GAUGE:600:0:U \ + DS:remote_queue:GAUGE:600:0:U \ + RRA:AVERAGE:0.5:1:12 \ + RRA:AVERAGE:0.5:1:72 \ + RRA:AVERAGE:0.5:1:288 \ + RRA:AVERAGE:0.5:6:336 \ + RRA:AVERAGE:0.5:24:372 \ + RRA:AVERAGE:0.5:288:365 \ + RRA:MAX:0.5:1:12 \ + RRA:MAX:0.5:1:72 \ + RRA:MAX:0.5:1:288 \ + RRA:MAX:0.5:6:336 \ + RRA:MAX:0.5:24:372 \ + RRA:MAX:0.5:288:365 \ + RRA:MIN:0.5:1:12 \ + RRA:MIN:0.5:1:72 \ + RRA:MIN:0.5:1:288 \ + RRA:MIN:0.5:6:336 \ + RRA:MIN:0.5:24:372 \ + RRA:MIN:0.5:288:365 + fi +