initial commit of file from CVS for smeserver-mailstats on Sun 9 Jul 11:18:48 BST 2023

This commit is contained in:
Brian Read 2023-07-09 11:18:48 +01:00
parent 082a886144
commit 56bb9c9681
11 changed files with 2187 additions and 2 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.rpm
*.log
*spec-20*
*.tgz

21
Makefile Normal file
View File

@ -0,0 +1,21 @@
# Makefile for source rpm: smeserver-mailstats
# $Id: Makefile,v 1.1 2020/04/13 18:12:06 brianr Exp $
NAME := smeserver-mailstats
SPECFILE = $(firstword $(wildcard *.spec))
define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
endef
MAKEFILE_COMMON := $(shell $(find-makefile-common))
ifeq ($(MAKEFILE_COMMON),)
# attept a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif
include $(MAKEFILE_COMMON)

View File

@ -1,3 +1,17 @@
# smeserver-mailstats # <img src="https://www.koozali.org/images/koozali/Logo/Png/Koozali_logo_2016.png" width="25%" vertical="auto" style="vertical-align:bottom"> smeserver-mailstats
SMEServer Koozali developed git repo for smeserver-mailstats smecontribs SMEServer Koozali developed git repo for smeserver-mailstats smecontribs
## Wiki
<br />https://wiki.koozali.org/Mailstats
## Bugzilla
Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=smeserver-mailstats&product=SME%20Contribs&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED)
## Description
<br />*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.*
*Once it has been checked, then this comment will be deleted*
<br />
The Mailstats contrib is an invaluable tool for small and medium-sized businesses that use the SME Server operating system. This software is designed to give detailed statistics about an email server, providing crucial information such as the number of emails sent and received, and the average response time. The data it provides is essential for businesses to ensure their email system is running as efficiently as possible. Mailstats is an easy-to-use, graphical interface that gives clear, comprehensive information at a glance, enabling businesses to quickly identify any potential problems or areas that may need improvement. The Mailstats contrib is an invaluable asset to any business running the SME Server operating system, and can ensure the smooth running of their email system in the most efficient way possible.

1
contriborbase Normal file
View File

@ -0,0 +1 @@
contribs10

25
createlinks Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/perl -w
use esmith::Build::CreateLinks qw(:all);
# our event specific for updating with yum without reboot
$event = 'smeserver-mailstats-update';
#add here the path to your templates needed to expand
#see the /etc/systemd/system-preset/49-koozali.preset should be present for systemd integration on all you yum update event
foreach my $file (qw(
/etc/systemd/system-preset/49-koozali.preset
/etc/e-smith/sql/init/99smeserver-mailstats.sql
))
{
templates2events( $file, $event );
}
#action needed in case we have a systemd unit
event_link('systemd-default', $event, '10');
event_link('systemd-reload', $event, '50');
#action specific to this package
#event_link('action', $event, '30');
#services we need to restart
#safe_symlink('restart', 'root/etc/e-smith/events/$event/services2adjust/<service>)
#and Server Mmanager panel link
#panel_link('somefunction', 'manager');
templates2events("/etc/e-smith/sql/init/99smeserver-mailstats.sql", "post-upgrade");

View File

@ -0,0 +1 @@
0 0 * * * root sleep $[ $RANDOM \% 3600 ]; /usr/bin/runmailstats.sh

View File

@ -0,0 +1,94 @@
CREATE DATABASE IF NOT EXISTS `mailstats`;
USE `mailstats`;
CREATE TABLE IF NOT EXISTS `ColumnStats` (
`ColumnStatsid` int(11) NOT NULL auto_increment,
`dateid` int(11) NOT NULL default '0',
`timeid` int(11) NOT NULL default '0',
`descr` varchar(20) NOT NULL default '',
`count` bigint(20) NOT NULL default '0',
`servername` varchar(30) NOT NULL default '',
PRIMARY KEY (`ColumnStatsid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `JunkMailStats` (
`JunkMailstatsid` int(11) NOT NULL auto_increment,
`dateid` int(11) NOT NULL default '0',
`user` varchar(12) NOT NULL default '',
`count` bigint(20) NOT NULL default '0',
`servername` varchar(30) default NULL,
PRIMARY KEY (`JunkMailstatsid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `SARules` (
`SARulesid` int(11) NOT NULL auto_increment,
`dateid` int(11) NOT NULL default '0',
`rule` varchar(50) NOT NULL default '',
`count` bigint(20) NOT NULL default '0',
`totalhits` bigint(20) NOT NULL default '0',
`servername` varchar(30) NOT NULL default '',
PRIMARY KEY (`SARulesid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `SAscores` (
`SAscoresid` int(11) NOT NULL auto_increment,
`dateid` int(11) NOT NULL default '0',
`acceptedcount` bigint(20) NOT NULL default '0',
`rejectedcount` bigint(20) NOT NULL default '0',
`hamcount` bigint(20) NOT NULL default '0',
`acceptedscore` decimal(20,2) NOT NULL default '0.00',
`rejectedscore` decimal(20,2) NOT NULL default '0.00',
`hamscore` decimal(20,2) NOT NULL default '0.00',
`totalsmtp` bigint(20) NOT NULL default '0',
`totalrecip` bigint(20) NOT NULL default '0',
`servername` varchar(30) NOT NULL default '',
PRIMARY KEY (`SAscoresid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `VirusStats` (
`VirusStatsid` int(11) NOT NULL auto_increment,
`dateid` int(11) NOT NULL default '0',
`descr` varchar(40) NOT NULL default '',
`count` bigint(20) NOT NULL default '0',
`servername` varchar(30) NOT NULL default '',
PRIMARY KEY (`VirusStatsid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `date` (
`dateid` int(11) NOT NULL auto_increment,
`date` date NOT NULL default '0000-00-00',
PRIMARY KEY (`dateid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `domains` (
`domainsid` int(11) NOT NULL auto_increment,
`dateid` int(11) NOT NULL default '0',
`domain` varchar(40) NOT NULL default '',
`type` varchar(10) NOT NULL default '',
`total` bigint(20) NOT NULL default '0',
`denied` bigint(20) NOT NULL default '0',
`xfererr` bigint(20) NOT NULL default '0',
`accept` bigint(20) NOT NULL default '0',
`servername` varchar(30) NOT NULL default '',
PRIMARY KEY (`domainsid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `qpsmtpdcodes` (
`qpsmtpdcodesid` int(11) NOT NULL auto_increment,
`dateid` int(11) NOT NULL default '0',
`reason` varchar(40) NOT NULL default '',
`count` bigint(20) NOT NULL default '0',
`servername` varchar(30) NOT NULL default '',
PRIMARY KEY (`qpsmtpdcodesid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `time` (
`timeid` int(11) NOT NULL auto_increment,
`time` time NOT NULL default '00:00:00',
PRIMARY KEY (`timeid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
grant all privileges on mailstats.* to 'mailstats'@'localhost' identified by 'mailstats';

1902
root/usr/bin/mailstats.pl Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
#!/bin/bash
exec 1> >(logger -t $(basename $0)) 2>&1
perl /usr/bin/mailstats.pl /var/log/qpsmtpd/\@* /var/log/qpsmtpd/current /var/log/sqpsmtpd/\@* /var/log/sqpsmtpd/current

119
smeserver-mailstats.spec Normal file
View File

@ -0,0 +1,119 @@
# $Id: smeserver-mailstats.spec,v 1.8 2023/02/15 09:40:09 brianr Exp $
# Authority: brianread
# Name: Brian Read
Summary: Daily mail statistics for SME Server
%define name smeserver-mailstats
Name: %{name}
%define version 1.1
%define release 18
Version: %{version}
Release: %{release}%{?dist}
License: GPL
Group: SME/addon
Source: %{name}-%{version}.tar.xz
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot
BuildArchitectures: noarch
Requires: smeserver-release => 9.0
Requires: qpsmtpd >= 0.96
BuildRequires: e-smith-devtools >= 1.13.1-03
Requires: perl-Switch
%description
A script that via cron.d e-mails mail statistics to admin on a daily basis.
See http://www.contribs.org/bugzilla/show_bug.cgi?id=819
%changelog
* Sun Jul 09 2023 cvs2git.sh aka Brian Read <brianr@koozali.org> 1.1-18.sme
- Roll up patches and move to git repo [SME: 12338]
* Sun Jul 09 2023 BogusDateBot
- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday,
by assuming the date is correct and changing the weekday.
* Wed Feb 15 2023 Brian Read <brianr@bjsystems.co.uk> 1.1-17.sme
- Add-in-imap-authorisation-log-string [SME: 12327]
* Fri Apr 02 2021 Brian Read <brianr@bjsystems.co.uk> 1.1-16.sme
- Take out dot in cron file and also re-direct errors to syslog [SME: 11519]
* Wed Mar 24 2021 Brian Read <brianr@bjsystems.co.uk> 1.1-15.sme
- Add Update event to createlinks [SME: 10923]
* Thu Dec 17 2020 Brian Read <brianr@bjsystems.co.uk> 1.1-14.sme
- Add in perl-Switch as requirement [SME: 11044]
* Mon Oct 19 2020 Brian Read <brianr@bjsystems.co.uk> 1.1-13.sme
- More uninitialised data [SME: 11044]
* Thu Apr 16 2020 brian read <brianr@bjsystems.co.uk> 1.1-12.sme
- Sort out uninitialised variable on no data.
* Sun Jan 5 2020 brian read <brianr@bjsystems.co.uk> 1.1-11.sme
- [sme:10858][sme:10327] Sort out email truncate and generally cleanup code format and take out debug crud
- Also change perl script file name to mailstats.pl
* Fri Oct 18 2019 brian read <brianr@bjsystems.co.uk> 1.1-10.sme
- Add Update event to createlinks display of geoip [SME: 9888]
* Wed Oct 12 2016 brian read <brianr@bjsystems.co.uk> 1.1-9.sme
- [sme:9716][sme:9717] add email specific stats and enhance relay monitoring and add code for smeoptimizer
* Sun Jul 03 2016 Jean-Philipe Pialasse <tests@pialasse.com> 1.1-7.sme
- set Requires qpsmtpd >=0.96
* Sat Jul 02 2016 Jean-Philipe Pialasse <tests@pialasse.com> 1.1-6.sme
- make compatible with qpstmpd 0.96 and new plugins [SME: 9588]
- work in progress : html version of email
- code by Brian Read <brianr@bjsystems.co.uk>
- thanks to Michael Doerner for his extensive testing
* Sun Apr 10 2016 Jean-Philipe Pialasse <tests@pialasse.com> 1.1-5.sme
- account for all unknown qpsmtpd plugins [SME: 9434]
- extra for "unofficial" extra clamav signatures
- code by Brian Read <brianr@bjsystems.co.uk>
- (only small suggestions from JP Pialasse aka Unnilennium)
* Thu Jun 25 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 1.1-4
- creates the "mailstats" user [SME: 8957]
- Fixed the problem with Spamassassin scores and tags.
- Also added Geoip league table [SME: 8656]
- code done by Brian Read <brianr@bjsystems.co.uk>
* Sun Jun 14 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 1.1-3
- added a random cron job
- spamfilter-stats-7-update
- code done by Brian Read <brianr@bjsystems.co.uk> and John Crisp <jcrisp@safeandsoundit.co.uk>
* Mon Jun 16 2014 JP Pialasse <tests@pialasse.com> 1.1-1.sme
- initial import to SME9 contribs
* Mon Sep 23 2013 JP Pialasse <tests@pialasse.com> 1.1-4.sme
- uninitialized value in sprintf [SME: 4747]
- patch smeserver-mailstats-1.0-spamfilter.patch
* Sun Sep 09 2012 JP Pialasse <tests@pialasse.com> 1.1-2.sme
- Add Update event to createlinks Unexpected failure string in log file: auth::auth_cvm_unix_local see [SME 7089]
* Sat May 26 2012 Brian J read <brianr@bjsystems.co.uk> 1.0-1.sme
- Initial version
%prep
%setup
%build
perl createlinks
%install
/bin/rm -rf $RPM_BUILD_ROOT
(cd root ; /usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT)
chmod +x $RPM_BUILD_ROOT/usr/bin/runmailstats.sh
/bin/rm -f %{name}-%{version}-filelist
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT > %{name}-%{version}-filelist
%clean
/bin/rm -rf $RPM_BUILD_ROOT
%files -f %{name}-%{version}-filelist
%defattr(-,root,root)