commit mailgraph for openSUSE:Factory
Hello community, here is the log from the commit of package mailgraph for openSUSE:Factory checked in at 2019-07-01 10:44:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/mailgraph (Old) and /work/SRC/openSUSE:Factory/.mailgraph.new.4615 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "mailgraph" Mon Jul 1 10:44:13 2019 rev:4 rq:706139 version:1.14 Changes: -------- --- /work/SRC/openSUSE:Factory/mailgraph/mailgraph.changes 2017-11-24 10:56:13.416443302 +0100 +++ /work/SRC/openSUSE:Factory/.mailgraph.new.4615/mailgraph.changes 2019-07-01 10:44:14.557464507 +0200 @@ -1,0 +2,39 @@ +Tue May 28 21:02:11 UTC 2019 - chris@computersalat.de + +- change dependency of systemd to pkgconfig(systemd) + +------------------------------------------------------------------- +Fri May 17 21:07:06 UTC 2019 - chris@computersalat.de + +- merge changes +- cleanup spec +- cleanup service file +- remove perl(RRDs) cause it is Provided by rrdtool + +------------------------------------------------------------------- +Sun May 12 15:25:33 UTC 2019 - lars@linux-schulserver.de - 1.14 + +- Require perl(RRDs) +- added mailgraph-1.14-tracking.patch to stop requesting an image + from http://oss.oetiker.ch every time the mailgraph.cgi is opened + including new source: rrdtool.gif +- added mailgraph-1.14-add_postgrey_and_greylisting_support.patch + which adds support (graphs) to postgrey and greylisting +- added mailgraph-1.14-add_postscreen_support.patch which handles + postscreen in the same way as smtpd +- added mailgraph.service file -> use systemd + +------------------------------------------------------------------- +Fri Dec 21 12:47:46 UTC 2018 - chris@computersalat.de + +- fix for boo#1116020 + * add systemd support + * add file mailgraph.service + * set defaults in sysconfig file +- format_spec_file +- use %license +- rebase mailgraph_for_nagios-plugins-mailgraph.patch +- rework mailgraph-1.14-pl.patch + * add support for rsyslog + +------------------------------------------------------------------- New: ---- mailgraph-1.14-add_postgrey_and_greylisting_support.patch mailgraph-1.14-add_postscreen_support.patch mailgraph-1.14-tracking.patch mailgraph.service rrdtool.gif ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ mailgraph.spec ++++++ --- /var/tmp/diff_new_pack.pqb2Ub/_old 2019-07-01 10:44:15.177465519 +0200 +++ /var/tmp/diff_new_pack.pqb2Ub/_new 2019-07-01 10:44:15.177465519 +0200 @@ -1,7 +1,7 @@ # # spec file for package mailgraph # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -28,15 +28,17 @@ Name: mailgraph Version: 1.14 Release: 0 -Summary: Very simple mail statistics RRDtool frontend for Postfix -License: GPL-2.0+ +Summary: RRDtool frontend for Mail statistics +License: GPL-2.0-or-later Group: Productivity/Networking/Diagnostic Url: http://mailgraph.schweikert.ch/ Source0: %{name}-%{version}.tar.bz2 Source1: %{name}.init -Source2: %{name}.logrotate -Source3: %{name}.sysconfig -# PATCH-FIX-openSUSE -- adapt pathnames for daemon_logfile and daemon_rrd_dir to openSUSE +Source2: %{name}.service +Source3: %{name}.logrotate +Source4: %{name}.sysconfig +Source5: rrdtool.gif +# PATCH-FIX-openSUSE -- rsyslog support, adapt pathnames for daemon_logfile and daemon_rrd_dir to openSUSE Patch0: %{name}-1.14-pl.patch # PATCH-FIX-openSUSE -- adapt/enhance css usage and skip $uri in ref Patch1: %{name}-1.14-cgi.patch @@ -44,23 +46,33 @@ Patch2: %{name}-1.14-css.patch # PATCH-FIX-openSUSE -- integrate patch from nagios-plugins-mailgraph Patch3: mailgraph_for_nagios-plugins-mailgraph.patch +# PATCH-FIX-UPSTREAM -- do not get an image from http://oss.oetiker.ch every time the mailgraph.cgi is called +Patch4: mailgraph-1.14-tracking.patch +# PATCH-FIX-UPSTREAM -- include postgrey and greylisting graphs in output (and add corresponding options) +Patch5: mailgraph-1.14-add_postgrey_and_greylisting_support.patch +# PATCH-FIX-UPSTREAM -- handle postscreen in the same way as smtpd +Patch6: mailgraph-1.14-add_postscreen_support.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildArch: noarch BuildRequires: apache2-devel -PreReq: coreutils -PreReq: diffutils -PreReq: fillup -PreReq: grep -PreReq: sed -PreReq: %insserv_prereq +Requires(pre): %fillup_prereq Requires: apache2-mod_perl Requires: logrotate Requires: postfix Requires: rrdtool Requires: perl(File::Tail) -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildArch: noarch +# %if 0%{?suse_version} > 1100 Provides: %{css_dir} %endif +# +%if 0%{?suse_version} >= 1210 +BuildRequires: pkgconfig(systemd) +%{?systemd_requires} +%define has_systemd 1 +%else +Requires(pre): %insserv_prereq +%endif %description Mailgraph is a very simple mail statistics RRDtool frontend for Postfix @@ -73,52 +85,84 @@ %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 %build %install -%{__install} -d -m 755 %{buildroot}%{_bindir} %{buildroot}%{_sbindir} -%{__install} -d -m 755 %{buildroot}%{_fillupdir} -%{__install} -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}/img -%{__install} -d -m 755 %{buildroot}%{_localstatedir}/log/%{name} -%{__install} -d -m 755 %{buildroot}%{_sysconfdir}/init.d -%{__install} -d -m 755 %{buildroot}%{_sysconfdir}/logrotate.d -%{__install} -d -m 755 %{buildroot}%{cgi_dir} -%{__install} -d -m 755 %{buildroot}%{css_dir} - -%{__install} -m 755 %{name}.pl %{buildroot}%{_bindir}/ -%{__install} -m 755 %{name}.cgi %{buildroot}%{cgi_dir}/ -%{__install} -m 644 %{name}.css %{buildroot}%{css_dir}/ -%{__install} -m 755 %{S:1} %{buildroot}%{_sysconfdir}/init.d/%{name} -%{__install} -m 644 %{S:2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} -%{__install} -m 644 %{S:3} %{buildroot}%{_fillupdir}/sysconfig.%{name} -%{__ln_s} -f ../../etc/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name} +install -d -m 755 %{buildroot}%{_sbindir} +install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}/img +install -d -m 755 %{buildroot}%{_localstatedir}/log/%{name} + +install -D -m 755 %{name}.pl %{buildroot}%{_bindir}/%{name}.pl +install -D -m 755 %{name}.cgi %{buildroot}%{cgi_dir}/%{name}.cgi +install -D -m 644 %{name}.css %{buildroot}%{css_dir}/%{name}.css +install -D -m 644 %{S:3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} +install -D -m 644 %{S:4} %{buildroot}%{_fillupdir}/sysconfig.%{name} +install -D -m 644 %{S:5} %{buildroot}%{css_dir}/rrdtool.gif + +# systemd vs SysVinit +%if 0%{?has_systemd} +install -D -m 0644 %{S:2} %{buildroot}%{_unitdir}/%{name}.service +ln -sf %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name} +%else #SysVinit +install -D -m 0755 %{S:1} %{buildroot}/%{_sysconfdir}/init.d/%{name} +ln -sf %{_sysconfdir}/init.d/%{name} %{buildroot}/%{_sbindir}/rc%{name} +%endif -%post -%{fillup_and_insserv mailgraph} +%pre +%if 0%{?has_systemd} +%service_add_pre %{name}.service +%endif %preun -%stop_on_removal mailgraph +%if 0%{?has_systemd} +%service_del_preun %{name}.service +%else +%stop_on_removal %{name} +%endif + +%post +%if 0%{?has_systemd} +%service_add_post %{name}.service +%{fillup_only mailgraph} +%else +%{fillup_and_insserv -f mailgraph} +install -d %{_localstatedir}/run/%{name} +%endif %postun -%restart_on_update mailgraph +%if 0%{?has_systemd} +%service_del_postun %{name}.service +%else +%restart_on_update %{name} %{insserv_cleanup} - -%clean -%{__rm} -rf %{buildroot} +%endif %files %defattr(-,root,root) -%doc CHANGES COPYING README +%doc CHANGES README +%if 0%{?suse_version} >= 01200 +%license COPYING +%else +%doc COPYING +%endif +%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} +%{_fillupdir}/sysconfig.%{name} %dir %{_localstatedir}/lib/%{name} %attr(755,wwwrun,www) %dir %{_localstatedir}/lib/%{name}/img %dir %{_localstatedir}/log/%{name} %{_bindir}/%{name}.pl %{_sbindir}/rc%{name} +%if 0%{?has_systemd} +%{_unitdir}/%{name}.service +%else +%{_sysconfdir}/init.d/%{name} +%endif %{cgi_dir}/%{name}.cgi %{css_dir}/%{name}.css -%{_sysconfdir}/init.d/%{name} -%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} -%{_fillupdir}/sysconfig.%{name} +%{css_dir}/rrdtool.gif %changelog ++++++ mailgraph-1.14-add_postgrey_and_greylisting_support.patch ++++++ Index: mailgraph-1.14/mailgraph.cgi =================================================================== --- mailgraph-1.14.orig/mailgraph.cgi +++ mailgraph-1.14/mailgraph.cgi @@ -28,12 +28,14 @@ my @graphs = ( ); my %color = ( - sent => '000099', # rrggbb in hex - received => '009900', - rejected => 'AA0000', - bounced => '000000', - virus => 'DDBB00', - spam => '999999', + sent => '000099', # rrggbb in hex + received => '009900', + rejected => 'AA0000', + bounced => '000000', + virus => 'DDBB00', + spam => '999999', + greylisted => '999999', + delayed => '006400', ); sub rrd_graph(@) @@ -151,6 +153,36 @@ sub graph_err($$) ); } +sub graph_grey($$) +{ + my ($range, $file) = @_; + my $step = $range*$points_per_sample/$xpoints; + rrd_graph($range, $file, $ypoints_grey, + "DEF:greylisted=$rrd_greylist:greylisted:AVERAGE", + "DEF:mgreylisted=$rrd_greylist:greylisted:MAX", + "CDEF:rgreylisted=greylisted,60,*", + "CDEF:dgreylisted=greylisted,UN,0,greylisted,IF,$step,*", + "CDEF:sgreylisted=PREV,UN,dgreylisted,PREV,IF,dgreylisted,+", + "CDEF:rmgreylisted=mgreylisted,60,*", + "AREA:rgreylisted#$color{greylisted}:Greylisted", + 'GPRINT:sgreylisted:MAX:total\: %8.0lf msgs', + 'GPRINT:rgreylisted:AVERAGE:avg\: %5.2lf msgs/min', + 'GPRINT:rmgreylisted:MAX:max\: %4.0lf msgs/min\l', + + "DEF:delayed=$rrd_greylist:delayed:AVERAGE", + "DEF:mdelayed=$rrd_greylist:delayed:MAX", + "CDEF:rdelayed=delayed,60,*", + "CDEF:ddelayed=delayed,UN,0,delayed,IF,$step,*", + "CDEF:sdelayed=PREV,UN,ddelayed,PREV,IF,ddelayed,+", + "CDEF:rmdelayed=mdelayed,60,*", + "LINE2:rdelayed#$color{delayed}:Delayed ", + 'GPRINT:sdelayed:MAX:total\: %8.0lf msgs', + 'GPRINT:rdelayed:AVERAGE:avg\: %5.2lf msgs/min', + 'GPRINT:rmdelayed:MAX:max\: %4.0lf msgs/min\l', + ); +} + + sub print_html() { print "Content-Type: text/html\n\n"; @@ -180,6 +212,7 @@ HEADER print "<h2 id=\"G$n\">$graphs[$n]{title}<a href=\"#TOP\"> TOP</a></h2>\n"; print "<p><img src=\"$scriptname?${n}-n\" alt=\"mailgraph\"/><br/>\n"; print "<img src=\"$scriptname?${n}-e\" alt=\"mailgraph\"/></p>\n"; + print "<img src=\"$scriptname?${n}-g\" alt=\"mailgraph\"/></p>\n"; } print <<FOOTER; @@ -232,6 +265,11 @@ sub main() graph_err($graphs[$1]{seconds}, $file); send_image($file); } + elsif($img =~ /^(\d+)-g$/) { + my $file = "$tmp_dir/$uri/mailgraph_$1_grey.png"; + graph_grey($graphs[$1]{seconds}, $file); + send_image($file); + } else { die "ERROR: invalid argument\n"; } Index: mailgraph-1.14/mailgraph.pl =================================================================== --- mailgraph-1.14.orig/mailgraph.pl +++ mailgraph-1.14/mailgraph.pl @@ -380,9 +380,10 @@ my $statfile=''; my $logfile; my $rrd = "mailgraph.rrd"; my $rrd_virus = "mailgraph_virus.rrd"; +my $rrd_greylist = "mailgraph_greylist.rrd"; my $year; my $this_minute; -my %sum = ( sent => 0, received => 0, bounced => 0, rejected => 0, virus => 0, spam => 0 ); +my %sum = ( sent => 0, received => 0, bounced => 0, rejected => 0, virus => 0, spam => 0, greylisted => 0, delayed => 0); my %sum_stat = %sum; my $rrd_inited=0; @@ -397,6 +398,8 @@ sub event_bounced($); sub event_rejected($); sub event_virus($); sub event_spam($); +sub event_greylisted($); +sub event_delayed($); sub init_rrd($); sub update($); @@ -418,8 +421,9 @@ sub usage print " --daemon-log=FILE write verbose-log to FILE instead of /var/log/mailgraph.log\n"; print " --ignore-localhost ignore mail to/from localhost (used for virus scanner)\n"; print " --ignore-host=HOST ignore mail to/from HOST regexp (used for virus scanner)\n"; - print " --only-mail-rrd update only the mail rrd\n"; - print " --only-virus-rrd update only the virus rrd\n"; + print " --no-mail-rrd no update mail rrd\n"; + print " --no-virus-rrd no update virus rrd\n"; + print " --no-greylist-rrd no update greylist rrd\n"; print " --rrd-name=NAME use NAME.rrd and NAME_virus.rrd for the rrd files\n"; print " --rbl-is-spam count rbl rejects as spam\n"; print " --virbl-is-virus count virbl rejects as viruses\n"; @@ -434,7 +438,7 @@ sub main 'year|y=i', 'host=s', 'verbose|v', 'daemon|d!', 'statfile|s=s', 'daemon_pid|daemon-pid=s', 'daemon_rrd|daemon-rrd=s', 'daemon_log|daemon-log=s', 'ignore-localhost!', 'ignore-host=s@', - 'only-mail-rrd', 'only-virus-rrd', 'rrd_name|rrd-name=s', + 'no-mail-rrd', 'no-virus-rrd', 'no-greylist-rrd', 'rrd_name|rrd-name=s', 'rbl-is-spam', 'virbl-is-virus' ) or exit(1); usage if $opt{help}; @@ -450,6 +454,7 @@ sub main $statfile = $opt{statfile} if defined $opt{statfile}; $rrd = $opt{rrd_name}.".rrd" if defined $opt{rrd_name}; $rrd_virus = $opt{rrd_name}."_virus.rrd" if defined $opt{rrd_name}; + $rrd_greylist = $opt{rrd_name}."_greylist.rrd" if defined $opt{rrd_name}; # compile --ignore-host regexps if(defined $opt{'ignore-host'}) { @@ -526,7 +531,7 @@ sub init_rrd($) my $year_steps = $month_steps*12; # mail rrd - if(! -f $rrd and ! $opt{'only-virus-rrd'}) { + if(! -f $rrd and ! $opt{'no-mail-rrd'}) { RRDs::create($rrd, '--start', $m, '--step', $rrdstep, 'DS:sent:ABSOLUTE:'.($rrdstep*2).':0:U', 'DS:recv:ABSOLUTE:'.($rrdstep*2).':0:U', @@ -548,7 +553,7 @@ sub init_rrd($) } # virus rrd - if(! -f $rrd_virus and ! $opt{'only-mail-rrd'}) { + if(! -f $rrd_virus and ! $opt{'no-virus-rrd'}) { RRDs::create($rrd_virus, '--start', $m, '--step', $rrdstep, 'DS:virus:ABSOLUTE:'.($rrdstep*2).':0:U', 'DS:spam:ABSOLUTE:'.($rrdstep*2).':0:U', @@ -565,6 +570,25 @@ sub init_rrd($) elsif(-f $rrd_virus and ! defined $rrd_virus) { $this_minute = RRDs::last($rrd_virus) + $rrdstep; } + # greylist rrd + if(! -f $rrd_greylist and ! $opt{'no-greylist-rrd'}) { + RRDs::create($rrd_greylist, '--start', $m, '--step', $rrdstep, + 'DS:greylisted:ABSOLUTE:'.($rrdstep*2).':0:U', + 'DS:delayed:ABSOLUTE:'.($rrdstep*2).':0:U', + "RRA:AVERAGE:0.5:$day_steps:$realrows", # day + "RRA:AVERAGE:0.5:$week_steps:$realrows", # week + "RRA:AVERAGE:0.5:$month_steps:$realrows", # month + "RRA:AVERAGE:0.5:$year_steps:$realrows", # year + "RRA:MAX:0.5:$day_steps:$realrows", # day + "RRA:MAX:0.5:$week_steps:$realrows", # week + "RRA:MAX:0.5:$month_steps:$realrows", # month + "RRA:MAX:0.5:$year_steps:$realrows", # year + ); + $this_minute = $m; + } + elsif(-f $rrd_greylist and ! defined $rrd_greylist) { + $this_minute = RRDs::last($rrd_greylist) + $rrdstep; + } $rrd_inited=1; } @@ -614,6 +638,9 @@ sub process_line($) elsif($opt{'rbl-is-spam'} and $text =~ /^(?:[0-9A-Z]+: |NOQUEUE: )?reject: .*: 554.* blocked using/) { event($time, 'spam'); } + elsif($text =~ /Greylisted/) { + event($time, 'greylisted'); + } elsif($text =~ /^(?:[0-9A-Z]+: |NOQUEUE: )?reject: /) { event($time, 'rejected'); } @@ -857,6 +884,21 @@ sub process_line($) event($time, 'virus'); } } + elsif($prog eq 'postgrey') { + # Old versions (up to 1.27) + if($text =~ /delayed [0-9]+ seconds: client/) { + event($time, 'delayed'); + } + # New versions (from 1.28) + if($text =~ /delay=[0-9]+/) { + event($time, 'delayed'); + } + } + elsif($prog eq 'grossd') { + if($text =~ /a\=greylist/) { + event($time, 'greylisted'); + } + } } sub event($$) @@ -875,14 +917,16 @@ sub update($) return 1 if $m == $this_minute; return 0 if $m < $this_minute; - print "update $this_minute:$sum{sent}:$sum{received}:$sum{bounced}:$sum{rejected}:$sum{virus}:$sum{spam}\n" if $opt{verbose}; - RRDs::update $rrd, "$this_minute:$sum{sent}:$sum{received}:$sum{bounced}:$sum{rejected}" unless $opt{'only-virus-rrd'}; - RRDs::update $rrd_virus, "$this_minute:$sum{virus}:$sum{spam}" unless $opt{'only-mail-rrd'}; + print "update $this_minute:$sum{sent}:$sum{received}:$sum{bounced}:$sum{rejected}:$sum{virus}:$sum{spam}:$sum{greylisted}:$sum{delayed}\n" if $opt{verbose}; + RRDs::update $rrd, "$this_minute:$sum{sent}:$sum{received}:$sum{bounced}:$sum{rejected}" unless $opt{'no-mail-rrd'}; + RRDs::update $rrd_virus, "$this_minute:$sum{virus}:$sum{spam}" unless $opt{'no-virus-rrd'}; + RRDs::update $rrd_greylist, "$this_minute:$sum{greylisted}:$sum{delayed}" unless $opt{'no-greylist-rrd'}; if($m > $this_minute+$rrdstep) { for(my $sm=$this_minute+$rrdstep;$sm<$m;$sm+=$rrdstep) { - print "update $sm:0:0:0:0:0:0 (SKIP)\n" if $opt{verbose}; - RRDs::update $rrd, "$sm:0:0:0:0" unless $opt{'only-virus-rrd'}; - RRDs::update $rrd_virus, "$sm:0:0" unless $opt{'only-mail-rrd'}; + print "update $sm:0:0:0:0:0:0:0:0 (SKIP)\n" if $opt{verbose}; + RRDs::update $rrd, "$sm:0:0:0:0" unless $opt{'no-mail-rrd'}; + RRDs::update $rrd_virus, "$sm:0:0" unless $opt{'no-virus-rrd'}; + RRDs::update $rrd_greylist, "$sm:0:0" unless $opt{'no-greylist-rrd'}; } } if ("$statfile" ne ""){ @@ -895,6 +939,8 @@ sub update($) $sum{rejected}=0; $sum{virus}=0; $sum{spam}=0; + $sum{greylisted}=0; + $sum{delayed}=0; return 1; } @@ -936,8 +982,9 @@ B<mailgraph> [I<options>...] --daemon-log=FILE write verbose-log to FILE instead of /var/log/mailgraph.log --ignore-localhost ignore mail to/from localhost (used for virus scanner) --ignore-host=HOST ignore mail to/from HOST regexp (used for virus scanner) - --only-mail-rrd update only the mail rrd - --only-virus-rrd update only the virus rrd + --no-mail-rrd do not update mail rrd + --no-virus-rrd do not update virus rrd + --no-greylist-rrd do not update greylist rrd --rrd-name=NAME use NAME.rrd and NAME_virus.rrd for the rrd files --rbl-is-spam count rbl rejects as spam --virbl-is-virus count virbl rejects as viruses ++++++ mailgraph-1.14-add_postscreen_support.patch ++++++ Index: mailgraph-1.14/mailgraph.pl =================================================================== --- mailgraph-1.14.orig/mailgraph.pl +++ mailgraph-1.14/mailgraph.pl @@ -623,7 +623,7 @@ sub process_line($) event($time, 'bounced'); } } - elsif($prog eq 'smtpd') { + elsif($prog eq 'smtpd' || $prog eq 'postscreen') { if($text =~ /^[0-9A-Z]+: client=(\S+)/) { my $client = $1; return if $opt{'ignore-localhost'} and ++++++ mailgraph-1.14-pl.patch ++++++ --- /var/tmp/diff_new_pack.pqb2Ub/_old 2019-07-01 10:44:15.225465597 +0200 +++ /var/tmp/diff_new_pack.pqb2Ub/_new 2019-07-01 10:44:15.229465603 +0200 @@ -2,7 +2,120 @@ =================================================================== --- mailgraph-1.14.orig/mailgraph.pl +++ mailgraph-1.14/mailgraph.pl -@@ -371,9 +371,9 @@ my $rrdstep = 60; +@@ -287,6 +287,102 @@ sub _next_syslog($) + } + return undef; + } ++sub _next_rsyslog($) ++{ ++ my ($self) = @_; ++ while($self->{_repeat}>0) { ++ $self->{_repeat}--; ++ return $self->{_repeat_data}; ++ } ++ my $file = $self->{file}; ++ line: while(defined (my $str = $self->_next_line)) { ++ # date, time and host ++ $str =~ /^ ++ (\d+)-(\d+)-(\d+) # date -- 1, 2, 3 (YYYY-MM-DD) ++ T ++ (\d+):(\d+):(\d+) # time -- 4, 5, 6 (HH:MM:SS) ++ \.\d+(\+\d+:\d+) # time -- 7 nanoseconds (+HH:MM) ++ \s ++ ([-\w\.\@:]+) # host -- 8 ++ \s+ ++ (?:\[LOG_[A-Z]+\]\s+)? # FreeBSD ++ (.*) # text -- 9 ++ $/x or do ++ { ++ warn "WARNING: line not in rsyslog format: $str"; ++ next line; ++ }; ++ # subtract 1 from month, cause month is an array from 0-11 ++ # prevent 'Day '31' out of range 1..30' message ++ my $mon = $2 -1; ++ #defined $mon or croak "unknown month $1\n"; ++ #$self->_year_increment($mon); ++ # convert to unix time ++ my $time = $self->str2time($6,$5,$4,$3,$mon,$1,$7); ++ if(not $self->{allow_future}) { ++ # accept maximum one day in the present future ++ if($time - time > 86400) { ++ warn "WARNING: ignoring future date in rsyslog line: $str"; ++ next line; ++ } ++ } ++ my ($host, $text) = ($8, $9); ++ # last message repeated ... times ++ if($text =~ /^(?:last message repeated|above message repeats) (\d+) time/) { ++ next line if defined $self->{repeat} and not $self->{repeat}; ++ next line if not defined $self->{_last_data}{$host}; ++ $1 > 0 or do { ++ warn "WARNING: last message repeated 0 or less times??\n"; ++ next line; ++ }; ++ $self->{_repeat}=$1-1; ++ $self->{_repeat_data}=$self->{_last_data}{$host}; ++ return $self->{_last_data}{$host}; ++ } ++ # marks ++ next if $text eq '-- MARK --'; ++ # some systems send over the network their ++ # hostname prefixed to the text. strip that. ++ $text =~ s/^$host\s+//; ++ # discard ':' in HP-UX 'su' entries like this: ++ # Apr 24 19:09:40 remedy : su : + tty?? root-oracle ++ $text =~ s/^:\s+//; ++ $text =~ /^ ++ ([^:]+?) # program -- 1 ++ (?:\[(\d+)\])? # PID -- 2 ++ :\s+ ++ (?:\[ID\ (\d+)\ ([a-z0-9]+)\.([a-z]+)\]\ )? # Solaris 8 "message id" -- 3, 4, 5 ++ (.*) # text -- 6 ++ $/x or do ++ { ++ warn "WARNING: line not in rsyslog format: $str"; ++ next line; ++ }; ++ if($self->{arrayref}) { ++ $self->{_last_data}{$host} = [ ++ $time, # 0: timestamp ++ $host, # 1: host ++ $1, # 2: program ++ $2, # 3: pid ++ $6, # 4: text ++ ]; ++ } ++ else { ++ $self->{_last_data}{$host} = { ++ timestamp => $time, ++ host => $host, ++ program => $1, ++ pid => $2, ++ msgid => $3, ++ facility => $4, ++ level => $5, ++ text => $6, ++ }; ++ } ++ return $self->{_last_data}{$host}; ++ } ++ return undef; ++} + sub _next_metalog($) + { + my ($self) = @_; +@@ -347,6 +443,9 @@ sub next($) + if($self->{type} eq 'syslog') { + return $self->_next_syslog(); + } ++ elsif($self->{type} eq 'rsyslog') { ++ return $self->_next_rsyslog(); ++ } + elsif($self->{type} eq 'metalog') { + return $self->_next_metalog(); + } +@@ -371,9 +470,9 @@ my $rrdstep = 60; my $xpoints = 540; my $points_per_sample = 3; ++++++ mailgraph-1.14-tracking.patch ++++++ Index: mailgraph-1.14/mailgraph.cgi =================================================================== --- mailgraph-1.14.orig/mailgraph.cgi +++ mailgraph-1.14/mailgraph.cgi @@ -188,7 +188,7 @@ HEADER <a href="http://mailgraph.schweikert.ch/">Mailgraph</a> $VERSION by <a href="http://david.schweikert.ch/">David Schweikert</a></td> <td align="right"> -<a href="http://oss.oetiker.ch/rrdtool/"><img src="http://oss.oetiker.ch/rrdtool/.pics/rrdtool.gif" alt="" width="120" height="34"/></a> +<a href="http://oss.oetiker.ch/rrdtool/"><img src="/css/rrdtool.gif" alt="" width="120" height="34"/></a> </td></tr></table> </body></html> FOOTER ++++++ mailgraph.logrotate ++++++ --- /var/tmp/diff_new_pack.pqb2Ub/_old 2019-07-01 10:44:15.265465662 +0200 +++ /var/tmp/diff_new_pack.pqb2Ub/_new 2019-07-01 10:44:15.269465669 +0200 @@ -9,6 +9,6 @@ create 644 root root sharedscripts postrotate - /etc/init.d/mailgraph restart + /usr/sbin/rcmailgraph restart endscript } ++++++ mailgraph.service ++++++ [Unit] Description=RRDtool frontend for Mail statistic (mailgraph) Documentation=http://mailgraph.schweikert.ch/ After=mail-transfer-agent.target [Service] EnvironmentFile=-/etc/sysconfig/mailgraph Nice=19 ExecStart=/usr/bin/mailgraph.pl ${MAILGRAPH_OPTS} --logfile ${MAILGRAPH_LOG_FILE} --logtype ${MAILGRAPH_LOG_TYPE} --daemon-rrd ${MAILGRAPH_RRD} --daemon-log ${MAILGRAPH_LOG} ExecStop=/sbin/killproc /usr/bin/mailgraph.pl [Install] WantedBy=multi-user.target ++++++ mailgraph.sysconfig ++++++ --- /var/tmp/diff_new_pack.pqb2Ub/_old 2019-07-01 10:44:15.309465734 +0200 +++ /var/tmp/diff_new_pack.pqb2Ub/_new 2019-07-01 10:44:15.313465741 +0200 @@ -16,30 +16,32 @@ ## --rbl-is-spam count rbl rejects as spam ## --virbl-is-virus count virbl rejects as viruses # -MAILGRAPH_OPTS="" +## for systemd there needs to be a [SPACE] before first option +# +MAILGRAPH_OPTS=" -d -v" ## Type: string ## Default: "/var/run/mailgraph.pid" ## Config: daemon-pid -MAILGRAPH_PID="" +MAILGRAPH_PID="/var/run/mailgraph.pid" ## Type: string ## Default: "/var/lib/mailgraph" ## Config: daemon-rrd -MAILGRAPH_RRD="" +MAILGRAPH_RRD="/var/lib/mailgraph" ## Type: string ## Default: "/var/log/mailgraph/mailgraph.log" ## Config: daemon-log -MAILGRAPH_LOG="" +MAILGRAPH_LOG="/var/log/mailgraph/mailgraph.log" ## Type: string ## Default: "/var/log/mail" ## Config: -l, --logfile f -MAILGRAPH_LOG_FILE="" +MAILGRAPH_LOG_FILE="/var/log/mail" -## Type: string +## Type: string(syslog,rsyslog,metalog) ## Default: "syslog" ## Config: -l, --logtype t -MAILGRAPH_LOG_TYPE="" +MAILGRAPH_LOG_TYPE="syslog" ++++++ mailgraph_for_nagios-plugins-mailgraph.patch ++++++ --- /var/tmp/diff_new_pack.pqb2Ub/_old 2019-07-01 10:44:15.321465754 +0200 +++ /var/tmp/diff_new_pack.pqb2Ub/_new 2019-07-01 10:44:15.325465760 +0200 @@ -2,7 +2,7 @@ =================================================================== --- mailgraph-1.14.orig/mailgraph.pl +++ mailgraph-1.14/mailgraph.pl -@@ -374,6 +374,7 @@ my $points_per_sample = 3; +@@ -473,6 +473,7 @@ my $points_per_sample = 3; my $daemon_logfile = '/var/log/mailgraph/mailgraph.log'; my $daemon_pidfile = '/var/run/mailgraph.pid'; my $daemon_rrd_dir = '/var/lib/mailgraph'; @@ -10,7 +10,7 @@ # global variables my $logfile; -@@ -382,6 +383,7 @@ my $rrd_virus = "mailgraph_virus.rrd"; +@@ -481,6 +482,7 @@ my $rrd_virus = "mailgraph_virus.rrd"; my $year; my $this_minute; my %sum = ( sent => 0, received => 0, bounced => 0, rejected => 0, virus => 0, spam => 0 ); @@ -18,7 +18,7 @@ my $rrd_inited=0; my %opt = (); -@@ -410,6 +412,7 @@ sub usage +@@ -509,6 +511,7 @@ sub usage print " -y, --year starting year of the log file (default: current year)\n"; print " --host=HOST use only entries for HOST (regexp) in syslog\n"; print " -d, --daemon start in the background\n"; @@ -26,7 +26,7 @@ print " --daemon-pid=FILE write PID to FILE instead of /var/run/mailgraph.pid\n"; print " --daemon-rrd=DIR write RRDs to DIR instead of /var/log\n"; print " --daemon-log=FILE write verbose-log to FILE instead of /var/log/mailgraph.log\n"; -@@ -428,7 +431,7 @@ sub main +@@ -527,7 +530,7 @@ sub main { Getopt::Long::Configure('no_ignore_case'); GetOptions(\%opt, 'help|h', 'cat|c', 'logfile|l=s', 'logtype|t=s', 'version|V', @@ -35,7 +35,7 @@ 'daemon_pid|daemon-pid=s', 'daemon_rrd|daemon-rrd=s', 'daemon_log|daemon-log=s', 'ignore-localhost!', 'ignore-host=s@', 'only-mail-rrd', 'only-virus-rrd', 'rrd_name|rrd-name=s', -@@ -444,6 +447,7 @@ sub main +@@ -543,6 +546,7 @@ sub main $daemon_pidfile = $opt{daemon_pid} if defined $opt{daemon_pid}; $daemon_logfile = $opt{daemon_log} if defined $opt{daemon_log}; $daemon_rrd_dir = $opt{daemon_rrd} if defined $opt{daemon_rrd}; @@ -43,7 +43,7 @@ $rrd = $opt{rrd_name}.".rrd" if defined $opt{rrd_name}; $rrd_virus = $opt{rrd_name}."_virus.rrd" if defined $opt{rrd_name}; -@@ -858,6 +862,7 @@ sub process_line($) +@@ -957,6 +961,7 @@ sub process_line($) sub event($$) { my ($t, $type) = @_; @@ -51,7 +51,7 @@ update($t) and $sum{$type}++; } -@@ -880,6 +885,9 @@ sub update($) +@@ -979,6 +984,9 @@ sub update($) RRDs::update $rrd_virus, "$sm:0:0" unless $opt{'only-mail-rrd'}; } } @@ -61,7 +61,7 @@ $this_minute = $m; $sum{sent}=0; $sum{received}=0; -@@ -890,6 +898,14 @@ sub update($) +@@ -989,6 +997,14 @@ sub update($) return 1; } @@ -76,7 +76,7 @@ main; __END__ -@@ -914,6 +930,7 @@ B<mailgraph> [I<options>...] +@@ -1013,6 +1029,7 @@ B<mailgraph> [I<options>...] -y, --year starting year of the log file (default: current year) --host=HOST use only entries for HOST (regexp) in syslog -d, --daemon start in the background
participants (1)
-
root