Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
centos:mail_c7:mta_13 [03.02.2015 22:05. ] – [Ausgabe individualisieren] django | centos:mail_c7:mta_13 [18.11.2024 19:00. ] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== Mailserver - Logfileauswertungen unter CentOS 7.x ====== | ====== Mailserver - Logfileauswertungen unter CentOS 7.x ====== | ||
Oft werden vom Management hübsche bunte Auswertungsgraphiken gewünscht, um sich so mehr oder weniger ein Bild davon zu machen, ob und wie der/die Mailserver mit der anfallenden Menge an elektronischer Post umgehen können. | Oft werden vom Management hübsche bunte Auswertungsgraphiken gewünscht, um sich so mehr oder weniger ein Bild davon zu machen, ob und wie der/die Mailserver mit der anfallenden Menge an elektronischer Post umgehen können. | ||
- | Auch als Postmaster und Admin können wir uns so einen kurzen Überblick verschaffen, | + | Auch als Postmaster und Admin können wir uns so einen kurzen Überblick verschaffen, |
Im Detail wollen wir uns nun drei der Varianten genauer ansehen. | Im Detail wollen wir uns nun drei der Varianten genauer ansehen. | ||
- **[[centos: | - **[[centos: | ||
- | - **WEB-GUIs** Graphisch sehr ansprechende | + | - **WEB-GUIs** Graphisch sehr ansprechende |
- **[[centos: | - **[[centos: | ||
- **[[centos: | - **[[centos: | ||
Zeile 34: | Zeile 34: | ||
Build Host : vml000200.dmz.nausch.org | Build Host : vml000200.dmz.nausch.org | ||
Relocations : (not relocatable) | Relocations : (not relocatable) | ||
- | Packager | + | Packager |
Vendor | Vendor | ||
URL : http:// | URL : http:// | ||
Zeile 559: | Zeile 559: | ||
===== mailgraph ===== | ===== mailgraph ===== | ||
- | Eine ansprechende graphische Übersicht kann mittels [[http:// | + | Eine ansprechende graphische Übersicht kann mittels [[http:// |
Mailgraph besteht im wesentlichen aus zwei Teilen. Das eine perl-Script ist zuständig für das Durchsuchen und Analysieren des Mailserver-Logdatei. Die gewonnenen Daten werden in **rrd**-Datendateien geschrieben. Ein zweites Perl **cgi**-Script generiert dann beim Aufrufen der zugehörigen Webseite Graphiken mit den Daten der **rrd**-Dateien. | Mailgraph besteht im wesentlichen aus zwei Teilen. Das eine perl-Script ist zuständig für das Durchsuchen und Analysieren des Mailserver-Logdatei. Die gewonnenen Daten werden in **rrd**-Datendateien geschrieben. Ein zweites Perl **cgi**-Script generiert dann beim Aufrufen der zugehörigen Webseite Graphiken mit den Daten der **rrd**-Dateien. | ||
Zeile 583: | Zeile 583: | ||
Build Host : vml000200.dmz.nausch.org | Build Host : vml000200.dmz.nausch.org | ||
Relocations : (not relocatable) | Relocations : (not relocatable) | ||
- | Packager | + | Packager |
URL : http:// | URL : http:// | ||
Summary | Summary | ||
Zeile 615: | Zeile 615: | ||
Will man die Sprache bei der Webseite, oder die Farben der Grafiken anpassen, schreibt man einfach seine Änderungen direkt in das übersichtliche CGI-Script. | Will man die Sprache bei der Webseite, oder die Farben der Grafiken anpassen, schreibt man einfach seine Änderungen direkt in das übersichtliche CGI-Script. | ||
- | # | + | # cat / |
- | <file perl cat / | + | <file perl / |
# mailgraph -- postfix mail traffic statistics | # mailgraph -- postfix mail traffic statistics | ||
Zeile 878: | Zeile 878: | ||
AddHandler cgi-script .cgi | AddHandler cgi-script .cgi | ||
- | < | + | < |
- | AllowOverride None | + | AllowOverride None |
- | Options +ExecCGI | + | Options +ExecCGI |
- | DirectoryIndex mailgraph.cgi | + | DirectoryIndex mailgraph.cgi |
- | Order deny, | + | Order deny, |
- | require IP 10.0. | + | |
</ | </ | ||
ErrorLog logs/ | ErrorLog logs/ | ||
Zeile 978: | Zeile 978: | ||
Möchte man einen graphischen Überblick über die Queues haben, so liefert uns das gerade vorgestellte und installierte **Mailgraph** leider keine grafischen werte. Hierzu greifen wir auf das Programm **[[http:// | Möchte man einen graphischen Überblick über die Queues haben, so liefert uns das gerade vorgestellte und installierte **Mailgraph** leider keine grafischen werte. Hierzu greifen wir auf das Programm **[[http:// | ||
- | Das passende Programmpaket **queuegraph** installieren am einfachsten aus dem Repository **[[centos:mailserver.guru|mailserver.guru]]**. | + | Das passende Programmpaket **queuegraph** installieren am einfachsten aus dem Repository **[[centos:nausch.org|nausch.org]]**. |
==== Installation ==== | ==== Installation ==== | ||
Zeile 999: | Zeile 999: | ||
Build Host : vml000200.dmz.nausch.org | Build Host : vml000200.dmz.nausch.org | ||
Relocations : (not relocatable) | Relocations : (not relocatable) | ||
- | Packager | + | Packager |
URL : http:// | URL : http:// | ||
Summary | Summary | ||
Zeile 1374: | Zeile 1374: | ||
=== RPM-Installation === | === RPM-Installation === | ||
- | Die wohl einfachste Art ist die der RPM-basierten Installation. Das passende Paket **mailgraph** installieren wir aus dem Repository **[[centos:mailserver.guru|mailserver.guru]]**. Aktuell wird vom Paketmaintainer die [[http:// | + | Die wohl einfachste Art ist die der RPM-basierten Installation. Das passende Paket **mailgraph** installieren wir aus dem Repository **[[centos:nausch.org|nausch.org]]**. Aktuell wird vom Paketmaintainer die [[http:// |
- | Haben wir das Repository **[[centos:mailserver.guru|mailserver.guru]]** installiert, | + | Haben wir das Repository **[[centos:nausch.org|nausch.org]]** installiert, |
# yum install mailgraph | # yum install mailgraph | ||
Zeile 1381: | Zeile 1381: | ||
Will man die beiden Pakete "nur lokal" installieren verwendet man folgenden Aufruf. | Will man die beiden Pakete "nur lokal" installieren verwendet man folgenden Aufruf. | ||
- | # yum localinstall http:// | + | # yum localinstall http:// |
- | http:// | + | http:// |
=== manuelle Installation === | === manuelle Installation === | ||
Zeile 1430: | Zeile 1430: | ||
# copyright (c) 2000-2007 David Schweikert < | # copyright (c) 2000-2007 David Schweikert < | ||
# modified 2011 for queuegraph by Ralf Hildebrandt < | # modified 2011 for queuegraph by Ralf Hildebrandt < | ||
- | # modified 2015 for mailgraph-ng by Django <django@mailserver.guru> based on | + | # modified 2015 for mailgraph-ng by Django <django@nausch.org> based on |
# patches from Sebastian van de Meer < | # patches from Sebastian van de Meer < | ||
# released under the GNU General Public License | # released under the GNU General Public License | ||
Zeile 2135: | Zeile 2135: | ||
<td class=" | <td class=" | ||
<a href=" | <a href=" | ||
- | <a href=" | + | <a href=" |
</td> | </td> | ||
<td> | <td> | ||
Zeile 2294: | Zeile 2294: | ||
# copyright (c) 2000-2007 David Schweikert < | # copyright (c) 2000-2007 David Schweikert < | ||
# copyright (c) 2011 Markus Neubauer < | # copyright (c) 2011 Markus Neubauer < | ||
- | # copyright (c) 2014-2015 Django <django@mailserver.guru> | + | # copyright (c) 2014-2015 Django <django@nausch.org> |
# released under the GNU General Public License | # released under the GNU General Public License | ||
# with spf-, dkim-, dmarc, and dane-patch Sebastian van de Meer < | # with spf-, dkim-, dmarc, and dane-patch Sebastian van de Meer < | ||
Zeile 2780: | Zeile 2780: | ||
if($opt{version}) { | if($opt{version}) { | ||
- | print " | + | print " |
exit; | exit; | ||
} | } | ||
Zeile 3807: | Zeile 3807: | ||
So lassen sich z.B. auch die Reports zu **SPF**, **DKIM** und **DMARC** ausblenden, wenn man diese (aktuell noch) nicht haben möchte. Will man später die Graphen wieder sehen, reicht das Entfernen des Kommentarzeichens **#** am Anfang der betreffenden Zeilen. | So lassen sich z.B. auch die Reports zu **SPF**, **DKIM** und **DMARC** ausblenden, wenn man diese (aktuell noch) nicht haben möchte. Will man später die Graphen wieder sehen, reicht das Entfernen des Kommentarzeichens **#** am Anfang der betreffenden Zeilen. | ||
+ | ===== Mailgraph-NG für mehrere Mailserver ===== | ||
+ | Betreibt man mehrere Mailserver will man neben den Einzelstatistiken der einzelnen Mailserver oft auch einen Überblick über den gesamten Mail-Server-Verkehr haben. | ||
+ | Auch das lässt sich mit einem überschaubaren Aufwand realisieren. Hierzu gehen wir wie folgt vor. | ||
+ | |||
+ | - Von den einzelnen Mailservern holen wir die RRD-Dateien ab. | ||
+ | - Diese kopieren wir dann auf ein zentrales Verzeichnis auf unserem WEB-Server. | ||
+ | - Wir passen unser CGI-Script, welches für die dynamische Generierung der WEB-Seite benutzt wird, soweit an, dass beim Erstellen eines Graphen nicht nur eine Datenquelle herangezogen wird, sondern die Summe unserer einzelnen Mailserver verwendet werden soll. | ||
+ | |||
+ | Auf diese drei Schritte gehen wir nun im Detail noch ein. | ||
+ | |||
+ | ==== RRD-Dateien einsammeln ==== | ||
+ | Die einzelnen RRD-Dateien unserer Mailserver kopieren wir mit scp in ein temporäres Arbeitsverzeichnis unseres WEB-Servers. Hierzu legen wir uns erst einmal einen eigenen User an. | ||
+ | # groupadd -g 1100 mx-transfer && useradd -c "MX Transfer User" -d / | ||
+ | |||
+ | <WRAP center round tip 80%> | ||
+ | Das Gleiche machen wir auf jedem der MX-Hosts, von denen wir später die Dateien einsammeln möchten. | ||
+ | </ | ||
+ | |||
+ | |||
+ | Anschließend generieren wir uns einen ssh-key für diesen transfer-User. Hierzu schlüpfen wir erst in die Rolle dieses speziellen Users. | ||
+ | # su - mx-transfer | ||
+ | |||
+ | Anschließend legen wir das Unterverzeichnis für den SSH-Schlüssel an und passen dessen Verzeichnisrechte an. | ||
+ | $ mkdir ~/.ssh | ||
+ | $ chmod 700 ~/.ssh | ||
+ | |||
+ | <WRAP center round tip 80%> | ||
+ | Auch hier legen wir auf jedem der MX-Hosts, von denen wir später die Dateien einsammeln möchten, das Verzeichnis mit den nötigen Berechtigungen an. | ||
+ | </ | ||
+ | |||
+ | Nun legen wir uns einen ssh-key ohne Passphrase an, in dem wir bei der Frage nach der Passphrase einfach keine angeben. | ||
+ | $ ssh-keygen -b 4096 -t rsa -C "MX Transfer User" | ||
+ | |||
+ | < | ||
+ | Enter file in which to save the key (/ | ||
+ | Enter passphrase (empty for no passphrase): | ||
+ | Enter same passphrase again: | ||
+ | Your identification has been saved in / | ||
+ | Your public key has been saved in / | ||
+ | The key fingerprint is: | ||
+ | 30: | ||
+ | The key's randomart image is: | ||
+ | +--[ RSA 4096]----+ | ||
+ | | | | ||
+ | | . . | | ||
+ | | o o | | ||
+ | |. = o . | | ||
+ | | = + S | | ||
+ | |o + o . | | ||
+ | |o* * . | | ||
+ | |oE@ o | | ||
+ | | = .. . | | ||
+ | +-----------------+ | ||
+ | </ | ||
+ | |||
+ | Den public-key kopieren wir nun anschließend auf jeden unserer MX-Hosts. | ||
+ | $ ssh-copy-id -i ~/ | ||
+ | |||
+ | $ ssh-copy-id -i ~/ | ||
+ | |||
+ | $ ssh-copy-id -i ~/ | ||
+ | |||
+ | $ ssh-copy-id -i ~/ | ||
+ | |||
+ | Als nächstes legen wir uns die temporären Zielverzeichnisse auf unserem Webserver an, in die wir später via scp die RRD-Dateien kopieren. | ||
+ | $ mkdir -p ~/ | ||
+ | |||
+ | Somit haben wir folgende Verzeichnisstruktur auf unserem Server. | ||
+ | < | ||
+ | └── mailgraph | ||
+ | ├── mx11 | ||
+ | ├── mx12 | ||
+ | ├── mx13 | ||
+ | └── mx14 | ||
+ | </ | ||
+ | |||
+ | Für das Einsammeln der RRD-Dateien legen wir uns ein passendes Script im Verzeichnis // | ||
+ | $ mkdir ~/bin | ||
+ | |||
+ | $ vim ~/ | ||
+ | |||
+ | <file bash ~/ | ||
+ | # Django : 2015-02-26 | ||
+ | # Einsammeln der RRD-Files von den einzelnen Mailservern | ||
+ | |||
+ | cd / | ||
+ | scp 10.100.0.87:/ | ||
+ | scp 10.100.0.87:/ | ||
+ | |||
+ | cd / | ||
+ | scp 10.200.0.87:/ | ||
+ | scp 10.200.0.87:/ | ||
+ | |||
+ | cd / | ||
+ | scp 10.300.0.87:/ | ||
+ | scp 10.300.0.87:/ | ||
+ | |||
+ | cd / | ||
+ | scp 10.400.0.87:/ | ||
+ | scp 10.400.0.87:/ | ||
+ | </ | ||
+ | |||
+ | Damit das Script auch ausgeführt werden kann, geben wir ihm noch das entsprechende **x**-Recht. | ||
+ | $ chmod +x ~/ | ||
+ | |||
+ | Im 5-minütigen Abstand holen wird dann die Daten von den Mailservern ab. Hierzu nutzen wir die benutzerindividuelle **crontab** unseres Transfer-Users. | ||
+ | $ crontab -e | ||
+ | |||
+ | < | ||
+ | # alles 5 Minuten die RRD-Files von den einzelnen Mailservern einsammeln | ||
+ | 2, | ||
+ | </ | ||
+ | |||
+ | Nach kurzer Zeit haben wir nunmehr von den einzelnen Mailservern die Statistikdaten mit einer Aktualität von 5 Minuten vorliegen. | ||
+ | < | ||
+ | ├── mx11 | ||
+ | │ ├── mailgraph_dane.rrd | ||
+ | │ ├── mailgraph_dmarc.rrd | ||
+ | │ ├── mailgraph_grey.rrd | ||
+ | │ ├── mailgraph_post.rrd | ||
+ | │ ├── mailgraph.rrd | ||
+ | │ ├── mailgraph_smtpd.rrd | ||
+ | │ ├── mailgraph_virus.rrd | ||
+ | │ └── mailqueues.rrd | ||
+ | ├── mx12 | ||
+ | │ ├── mailgraph_dane.rrd | ||
+ | │ ├── mailgraph_dmarc.rrd | ||
+ | │ ├── mailgraph_grey.rrd | ||
+ | │ ├── mailgraph_post.rrd | ||
+ | │ ├── mailgraph.rrd | ||
+ | │ ├── mailgraph_smtpd.rrd | ||
+ | │ ├── mailgraph_virus.rrd | ||
+ | │ └── mailqueues.rrd | ||
+ | ├── mx13 | ||
+ | │ ├── mailgraph_dane.rrd | ||
+ | │ ├── mailgraph_dmarc.rrd | ||
+ | │ ├── mailgraph_grey.rrd | ||
+ | │ ├── mailgraph_post.rrd | ||
+ | │ ├── mailgraph.rrd | ||
+ | │ ├── mailgraph_smtpd.rrd | ||
+ | │ ├── mailgraph_virus.rrd | ||
+ | │ └── mailqueues.rrd | ||
+ | └── mx14 | ||
+ | ├── mailgraph_dane.rrd | ||
+ | ├── mailgraph_dmarc.rrd | ||
+ | ├── mailgraph_grey.rrd | ||
+ | ├── mailgraph_post.rrd | ||
+ | ├── mailgraph.rrd | ||
+ | ├── mailgraph_smtpd.rrd | ||
+ | ├── mailgraph_virus.rrd | ||
+ | └── mailqueues.rrd | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Datenbereitstellung ==== | ||
+ | Das CGI-Script, welches wir zum dynamischen Generieren der Statistikgraphen verwenden, bekommt im Verzeichnis // | ||
+ | # mkdir -p / | ||
+ | |||
+ | Die Befüllung dieser Zeilverzeichnisse nehmen wir jeweils mit Hilfe eines **rsync**-Aufrufs vor, den wir via cronjob ausführen lassen. | ||
+ | # vim / | ||
+ | |||
+ | <file bash / | ||
+ | PATH=/ | ||
+ | MAILTO=root | ||
+ | HOME=/ | ||
+ | |||
+ | # For details see man 4 crontabs | ||
+ | |||
+ | # Example of job definition: | ||
+ | # .---------------- minute (0 - 59) | ||
+ | # | .------------- hour (0 - 23) | ||
+ | # | | .---------- day of month (1 - 31) | ||
+ | # | | | .------- month (1 - 12) OR jan, | ||
+ | # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun, | ||
+ | # | | | | | | ||
+ | # * * * * * user-name command to be executed | ||
+ | |||
+ | # Django : 2015-02-26 | ||
+ | # alles 5 Minuten die RRD-Files vom Transfer-Verzeichnis abholen und in den Zielverzeichnissen ablegen | ||
+ | */5 * * * * root / | ||
+ | */5 * * * * root / | ||
+ | */5 * * * * root / | ||
+ | */5 * * * * root / | ||
+ | </ | ||
+ | |||
+ | Nach wenigen Minuten stehen die Statistikdaten, | ||
+ | |||
+ | ==== Generierung Statistikgraphen und Webseite(n) ==== | ||
+ | Zur Präsentation unserer Statistikdaten benötigen wir nun noch einen Webserver, der die aufbereiteten Daten bereitstellt. Hierzu legen wir uns folgende Verzeichnisstruktur an. | ||
+ | < | ||
+ | ├── mx | ||
+ | ├── mx11 | ||
+ | ├── mx12 | ||
+ | ├── mx13 | ||
+ | └── mx14 | ||
+ | </ | ||
+ | |||
+ | # mkdir -p / | ||
+ | |||
+ | Bei der **[[centos: | ||
+ | {{ : | ||
+ | body { width: 900px; background-color: | ||
+ | font-family: | ||
+ | font-size: 12pt; | ||
+ | margin: 5px } | ||
+ | h1 { margin-top: 20px; margin-bottom: | ||
+ | text-align: center } | ||
+ | h2 { background-color: | ||
+ | padding: 2px 0 2px 4px } | ||
+ | h3 { margin-top: 10px; margin-bottom: | ||
+ | text-align: center } | ||
+ | hr { height: 1px; | ||
+ | border: 0; | ||
+ | border-top: 1px solid #aaa } | ||
+ | table { border: 0px; width: 100% } | ||
+ | img { border: 0 } | ||
+ | a { text-decoration: | ||
+ | a: | ||
+ | #jump { margin: 0 0 10px 4px } | ||
+ | #jump li { list-style: none; display: inline; | ||
+ | | ||
+ | #jump li: | ||
+ | #jump li: | ||
+ | </ | ||
+ | |||
+ | Das Logo und die CSS-Date kopieren wir nun die die einzelnen Unterverzeichnisse. | ||
+ | # cp / | ||
+ | # cp / | ||
+ | # cp / | ||
+ | # cp / | ||
+ | # cp / | ||
+ | |||
+ | # cp / | ||
+ | # cp / | ||
+ | # cp / | ||
+ | # cp / | ||
+ | # cp / | ||
+ | |||
+ | In den Unterverzeichnissen **mx11** bis **mx14** legen wir jeweils ein CGI-Script ab. Damit wir später zwischen den Einzelanzeigen der Mailserver und der kumulierten Übersicht jeweils wechseln können, versehen wir das Originalscript aus dem RPM **[[http:// | ||
+ | |||
+ | Die wesentlichen Änderungen/ | ||
+ | * Änderungen des Verzeichnisses der Datenquellen (RRD-Dateien). \\ **Bsp. MX11:** <code perl>... | ||
+ | |||
+ | my $rrd = '/ | ||
+ | my $rrd_virus = '/ | ||
+ | my $rrd_grey | ||
+ | my $rrd_dane | ||
+ | my $rrd_dmarc = '/ | ||
+ | my $rrd_smtpd = '/ | ||
+ | my $rrd_queue = '/ | ||
+ | my $rrd_post | ||
+ | |||
+ | ... | ||
+ | </ | ||
+ | * Einfügen der Variablen **url** für die Verweise zu den jeweils anderen Statistikseiten. | ||
+ | |||
+ | my $url = " | ||
+ | my $urlg = " | ||
+ | my $url1 = " | ||
+ | my $url2 = " | ||
+ | my $url3 = " | ||
+ | my $url4 = " | ||
+ | my $url11 = " | ||
+ | my $url12 = " | ||
+ | my $url13 = " | ||
+ | my $url14 = " | ||
+ | |||
+ | |||
+ | ... | ||
+ | </ | ||
+ | * Erweiterung des Unterprogramms **print_html** um die links zu den verweisenden Statistikseiten.< | ||
+ | |||
+ | sub print_html() | ||
+ | { | ||
+ | print " | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | <meta http-equiv=" | ||
+ | <link rel=" | ||
+ | </ | ||
+ | < | ||
+ | HEADER | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | #print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | |||
+ | print "< | ||
+ | for my $n (0..$# | ||
+ | print " | ||
+ | } | ||
+ | print "</ | ||
+ | |||
+ | for my $n (0..$# | ||
+ | print "< | ||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | } | ||
+ | |||
+ | print << | ||
+ | <hr/> | ||
+ | <table border=" | ||
+ | < | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </td> | ||
+ | <td> | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </td> | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | </td> | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | </td> | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </td> | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | FOOTER | ||
+ | } | ||
+ | |||
+ | ... | ||
+ | </ | ||
+ | |||
+ | ==== CGI-Scripte für die Einzelsysteme ==== | ||
+ | Für die vier Mailserver ergeben sich folgende CGI-Scripte. | ||
+ | |||
+ | === / | ||
+ | |||
+ | # vim / | ||
+ | <file perl / | ||
+ | |||
+ | # mailgraph -- detailed postfix mail traffic statistics | ||
+ | # copyright (c) 2000-2007 ETH Zurich | ||
+ | # copyright (c) 2000-2007 David Schweikert < | ||
+ | # modified 2011 for queuegraph by Ralf Hildebrandt < | ||
+ | # modified 2015 for mailgraph-ng by Django < | ||
+ | # patches from Sebastian van de Meer < | ||
+ | # released under the GNU General Public License | ||
+ | |||
+ | use RRDs; | ||
+ | use POSIX qw(uname); | ||
+ | |||
+ | my $VERSION = " | ||
+ | |||
+ | my $host = (POSIX:: | ||
+ | my $scriptname = $ENV{" | ||
+ | my $xpoints = 800; | ||
+ | my $points_per_sample = 3; | ||
+ | my $ypoints = 160; | ||
+ | my $rrd = '/ | ||
+ | my $rrd_virus = '/ | ||
+ | my $rrd_grey = '/ | ||
+ | my $rrd_dane = '/ | ||
+ | my $rrd_dmarc = '/ | ||
+ | my $rrd_smtpd = '/ | ||
+ | my $rrd_queue = '/ | ||
+ | my $rrd_post = '/ | ||
+ | |||
+ | my $tmp_dir = '/ | ||
+ | my @graphs = ( | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | ); | ||
+ | |||
+ | my %color = ( # rrggbb in hex | ||
+ | # n | ||
+ | sent => ' | ||
+ | received | ||
+ | |||
+ | bounced | ||
+ | virus => ' | ||
+ | spam => ' | ||
+ | rejected | ||
+ | |||
+ | greylisted | ||
+ | delayed | ||
+ | whitelist | ||
+ | awl => ' | ||
+ | early => ' | ||
+ | |||
+ | pswl => ' | ||
+ | psbl => ' | ||
+ | passold | ||
+ | veto => ' | ||
+ | pregreet | ||
+ | dnsbl => ' | ||
+ | pipelining | ||
+ | nonsmtp | ||
+ | barenewline | ||
+ | command | ||
+ | hangup | ||
+ | passnew | ||
+ | |||
+ | new => ' | ||
+ | reconnectok | ||
+ | |||
+ | active | ||
+ | deferred | ||
+ | |||
+ | untrustedtls | ||
+ | anonymoustls | ||
+ | trustedtls | ||
+ | verifiedtls | ||
+ | |||
+ | untrustedtlsin | ||
+ | anonymoustlsin | ||
+ | trustedtlsin | ||
+ | |||
+ | spfnone | ||
+ | spffail | ||
+ | spfpass | ||
+ | |||
+ | dkimnone | ||
+ | dkimfail | ||
+ | dkimpass | ||
+ | |||
+ | dmarcnone | ||
+ | dmarcfail | ||
+ | dmarcpass | ||
+ | ); | ||
+ | |||
+ | my $url = " | ||
+ | my $urlg = " | ||
+ | my $url1 = " | ||
+ | my $url2 = " | ||
+ | my $url3 = " | ||
+ | my $url4 = " | ||
+ | my $url11 = " | ||
+ | my $url12 = " | ||
+ | my $url13 = " | ||
+ | my $url14 = " | ||
+ | |||
+ | sub rrd_graph(@) | ||
+ | { | ||
+ | my ($range, $file, $ypoints, @rrdargs) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | my $end = time; $end -= $end % $step; | ||
+ | my $date = localtime(time); | ||
+ | $date =~ s|:|\\:|g unless $RRDs:: | ||
+ | |||
+ | my ($graphret, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | $RRDs:: | ||
+ | |||
+ | @rrdargs, | ||
+ | |||
+ | ' | ||
+ | ); | ||
+ | |||
+ | my $ERR=RRDs:: | ||
+ | die " | ||
+ | } | ||
+ | |||
+ | sub graph($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_virus($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greylist($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greystats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreen($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreenstats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_dane($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_smtpd($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_spf($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dkim($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dmarc($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_queue($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | sub print_html() | ||
+ | { | ||
+ | print " | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | <meta http-equiv=" | ||
+ | <link rel=" | ||
+ | </ | ||
+ | < | ||
+ | HEADER | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | #print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | |||
+ | print "< | ||
+ | for my $n (0..$# | ||
+ | print " | ||
+ | } | ||
+ | print "</ | ||
+ | |||
+ | for my $n (0..$# | ||
+ | print "< | ||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | rint "<a href=' | ||
+ | print "< | ||
+ | |||
+ | } | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | <table border=" | ||
+ | < | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | < | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | FOOTER | ||
+ | } | ||
+ | |||
+ | sub send_image($) | ||
+ | { | ||
+ | my ($file)= @_; | ||
+ | |||
+ | -r $file or do { | ||
+ | print " | ||
+ | exit 1; | ||
+ | }; | ||
+ | |||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | open(IMG, $file) or die; | ||
+ | my $data; | ||
+ | print $data while read(IMG, $data, 16384)> | ||
+ | } | ||
+ | |||
+ | sub main() | ||
+ | { | ||
+ | my $uri = $ENV{REQUEST_URI} || ''; | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | mkdir $tmp_dir, 0777 unless -d $tmp_dir; | ||
+ | mkdir " | ||
+ | |||
+ | my $img = $ENV{QUERY_STRING}; | ||
+ | if(defined $img and $img =~ /\S/) { | ||
+ | if($img =~ / | ||
+ | my $file = " | ||
+ | graph($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_virus($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greylist($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greystats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreen($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreenstats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_queue($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dane($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_smtpd($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_spf($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dkim($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dmarc($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | else { | ||
+ | die " | ||
+ | } | ||
+ | } | ||
+ | else { | ||
+ | print_html; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | main; | ||
+ | </ | ||
+ | |||
+ | === / | ||
+ | |||
+ | # vim / | ||
+ | <file perl / | ||
+ | |||
+ | # mailgraph -- detailed postfix mail traffic statistics | ||
+ | # copyright (c) 2000-2007 ETH Zurich | ||
+ | # copyright (c) 2000-2007 David Schweikert < | ||
+ | # modified 2011 for queuegraph by Ralf Hildebrandt < | ||
+ | # modified 2015 for mailgraph-ng by Django < | ||
+ | # patches from Sebastian van de Meer < | ||
+ | # released under the GNU General Public License | ||
+ | |||
+ | use RRDs; | ||
+ | use POSIX qw(uname); | ||
+ | |||
+ | my $VERSION = " | ||
+ | |||
+ | my $host = (POSIX:: | ||
+ | my $scriptname = $ENV{" | ||
+ | my $xpoints = 800; | ||
+ | my $points_per_sample = 3; | ||
+ | my $ypoints = 160; | ||
+ | my $rrd = '/ | ||
+ | my $rrd_virus = '/ | ||
+ | my $rrd_grey | ||
+ | my $rrd_dane | ||
+ | my $rrd_dmarc = '/ | ||
+ | my $rrd_smtpd = '/ | ||
+ | my $rrd_queue = '/ | ||
+ | my $rrd_post | ||
+ | |||
+ | my $tmp_dir = '/ | ||
+ | my @graphs = ( | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | ); | ||
+ | |||
+ | my %color = ( # rrggbb in hex | ||
+ | # n | ||
+ | sent => ' | ||
+ | received | ||
+ | |||
+ | bounced | ||
+ | virus => ' | ||
+ | spam => ' | ||
+ | rejected | ||
+ | |||
+ | greylisted | ||
+ | delayed | ||
+ | whitelist | ||
+ | awl => ' | ||
+ | early => ' | ||
+ | |||
+ | pswl => ' | ||
+ | psbl => ' | ||
+ | passold | ||
+ | veto => ' | ||
+ | pregreet | ||
+ | dnsbl => ' | ||
+ | pipelining | ||
+ | nonsmtp | ||
+ | barenewline | ||
+ | command | ||
+ | hangup | ||
+ | passnew | ||
+ | |||
+ | new => ' | ||
+ | reconnectok | ||
+ | |||
+ | active | ||
+ | deferred | ||
+ | |||
+ | untrustedtls | ||
+ | anonymoustls | ||
+ | trustedtls | ||
+ | verifiedtls | ||
+ | |||
+ | untrustedtlsin | ||
+ | anonymoustlsin | ||
+ | trustedtlsin | ||
+ | |||
+ | spfnone | ||
+ | spffail | ||
+ | spfpass | ||
+ | |||
+ | dkimnone | ||
+ | dkimfail | ||
+ | dkimpass | ||
+ | |||
+ | dmarcnone | ||
+ | dmarcfail | ||
+ | dmarcpass | ||
+ | ); | ||
+ | |||
+ | my $url = " | ||
+ | my $urlg = " | ||
+ | my $url1 = " | ||
+ | my $url2 = " | ||
+ | my $url3 = " | ||
+ | my $url4 = " | ||
+ | my $url11 = " | ||
+ | my $url12 = " | ||
+ | my $url13 = " | ||
+ | my $url14 = " | ||
+ | |||
+ | sub rrd_graph(@) | ||
+ | { | ||
+ | my ($range, $file, $ypoints, @rrdargs) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | my $end = time; $end -= $end % $step; | ||
+ | my $date = localtime(time); | ||
+ | $date =~ s|:|\\:|g unless $RRDs:: | ||
+ | |||
+ | my ($graphret, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | $RRDs:: | ||
+ | |||
+ | @rrdargs, | ||
+ | |||
+ | ' | ||
+ | ); | ||
+ | |||
+ | my $ERR=RRDs:: | ||
+ | die " | ||
+ | } | ||
+ | |||
+ | sub graph($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_virus($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greylist($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greystats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreen($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreenstats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_dane($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_smtpd($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_spf($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dkim($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dmarc($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_queue($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | sub print_html() | ||
+ | { | ||
+ | print " | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | <meta http-equiv=" | ||
+ | <link rel=" | ||
+ | </ | ||
+ | < | ||
+ | HEADER | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | #print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | |||
+ | print "< | ||
+ | for my $n (0..$# | ||
+ | print " | ||
+ | } | ||
+ | print "</ | ||
+ | |||
+ | for my $n (0..$# | ||
+ | print "< | ||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | } | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | <table border=" | ||
+ | < | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | < | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | FOOTER | ||
+ | } | ||
+ | |||
+ | sub send_image($) | ||
+ | { | ||
+ | my ($file)= @_; | ||
+ | |||
+ | -r $file or do { | ||
+ | print " | ||
+ | exit 1; | ||
+ | }; | ||
+ | |||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | open(IMG, $file) or die; | ||
+ | my $data; | ||
+ | print $data while read(IMG, $data, 16384)> | ||
+ | } | ||
+ | |||
+ | sub main() | ||
+ | { | ||
+ | my $uri = $ENV{REQUEST_URI} || ''; | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | mkdir $tmp_dir, 0777 unless -d $tmp_dir; | ||
+ | mkdir " | ||
+ | |||
+ | my $img = $ENV{QUERY_STRING}; | ||
+ | if(defined $img and $img =~ /\S/) { | ||
+ | if($img =~ / | ||
+ | my $file = " | ||
+ | graph($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_virus($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greylist($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greystats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreen($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreenstats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_queue($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dane($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_smtpd($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_spf($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dkim($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dmarc($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | else { | ||
+ | die " | ||
+ | } | ||
+ | } | ||
+ | else { | ||
+ | print_html; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | main; | ||
+ | </ | ||
+ | |||
+ | === / | ||
+ | |||
+ | # vim / | ||
+ | <file perl / | ||
+ | |||
+ | # mailgraph -- detailed postfix mail traffic statistics | ||
+ | # copyright (c) 2000-2007 ETH Zurich | ||
+ | # copyright (c) 2000-2007 David Schweikert < | ||
+ | # modified 2011 for queuegraph by Ralf Hildebrandt < | ||
+ | # modified 2015 for mailgraph-ng by Django < | ||
+ | # patches from Sebastian van de Meer < | ||
+ | # released under the GNU General Public License | ||
+ | |||
+ | use RRDs; | ||
+ | use POSIX qw(uname); | ||
+ | |||
+ | my $VERSION = " | ||
+ | |||
+ | my $host = (POSIX:: | ||
+ | my $scriptname = $ENV{" | ||
+ | my $xpoints = 800; | ||
+ | my $points_per_sample = 3; | ||
+ | my $ypoints = 160; | ||
+ | my $rrd = '/ | ||
+ | my $rrd_virus = '/ | ||
+ | my $rrd_grey | ||
+ | my $rrd_dane | ||
+ | my $rrd_dmarc = '/ | ||
+ | my $rrd_smtpd = '/ | ||
+ | my $rrd_queue = '/ | ||
+ | my $rrd_post | ||
+ | |||
+ | my $tmp_dir = '/ | ||
+ | my @graphs = ( | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | ); | ||
+ | |||
+ | my %color = ( # rrggbb in hex | ||
+ | # n | ||
+ | sent => ' | ||
+ | received | ||
+ | |||
+ | bounced | ||
+ | virus => ' | ||
+ | spam => ' | ||
+ | rejected | ||
+ | |||
+ | greylisted | ||
+ | delayed | ||
+ | whitelist | ||
+ | awl => ' | ||
+ | early => ' | ||
+ | |||
+ | pswl => ' | ||
+ | psbl => ' | ||
+ | passold | ||
+ | veto => ' | ||
+ | pregreet | ||
+ | dnsbl => ' | ||
+ | pipelining | ||
+ | nonsmtp | ||
+ | barenewline | ||
+ | command | ||
+ | hangup | ||
+ | passnew | ||
+ | |||
+ | new => ' | ||
+ | reconnectok | ||
+ | |||
+ | active | ||
+ | deferred | ||
+ | |||
+ | untrustedtls | ||
+ | anonymoustls | ||
+ | trustedtls | ||
+ | verifiedtls | ||
+ | |||
+ | untrustedtlsin | ||
+ | anonymoustlsin | ||
+ | trustedtlsin | ||
+ | |||
+ | spfnone | ||
+ | spffail | ||
+ | spfpass | ||
+ | |||
+ | dkimnone | ||
+ | dkimfail | ||
+ | dkimpass | ||
+ | |||
+ | dmarcnone | ||
+ | dmarcfail | ||
+ | dmarcpass | ||
+ | ); | ||
+ | |||
+ | my $url = " | ||
+ | my $urlg = " | ||
+ | my $url1 = " | ||
+ | my $url2 = " | ||
+ | my $url3 = " | ||
+ | my $url4 = " | ||
+ | my $url11 = " | ||
+ | my $url12 = " | ||
+ | my $url13 = " | ||
+ | my $url14 = " | ||
+ | |||
+ | sub rrd_graph(@) | ||
+ | { | ||
+ | my ($range, $file, $ypoints, @rrdargs) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | my $end = time; $end -= $end % $step; | ||
+ | my $date = localtime(time); | ||
+ | $date =~ s|:|\\:|g unless $RRDs:: | ||
+ | |||
+ | my ($graphret, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | $RRDs:: | ||
+ | |||
+ | @rrdargs, | ||
+ | |||
+ | ' | ||
+ | ); | ||
+ | |||
+ | my $ERR=RRDs:: | ||
+ | die " | ||
+ | } | ||
+ | |||
+ | sub graph($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_virus($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greylist($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greystats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreen($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreenstats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_dane($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_smtpd($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_spf($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dkim($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dmarc($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_queue($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | sub print_html() | ||
+ | { | ||
+ | print " | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | <meta http-equiv=" | ||
+ | <link rel=" | ||
+ | </ | ||
+ | < | ||
+ | HEADER | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | #print "<a href=' | ||
+ | print "<a href=' | ||
+ | |||
+ | print "< | ||
+ | for my $n (0..$# | ||
+ | print " | ||
+ | } | ||
+ | print "</ | ||
+ | |||
+ | for my $n (0..$# | ||
+ | print "< | ||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | } | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | <table border=" | ||
+ | < | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | < | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | FOOTER | ||
+ | } | ||
+ | |||
+ | sub send_image($) | ||
+ | { | ||
+ | my ($file)= @_; | ||
+ | |||
+ | -r $file or do { | ||
+ | print " | ||
+ | exit 1; | ||
+ | }; | ||
+ | |||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | open(IMG, $file) or die; | ||
+ | my $data; | ||
+ | print $data while read(IMG, $data, 16384)> | ||
+ | } | ||
+ | |||
+ | sub main() | ||
+ | { | ||
+ | my $uri = $ENV{REQUEST_URI} || ''; | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | mkdir $tmp_dir, 0777 unless -d $tmp_dir; | ||
+ | mkdir " | ||
+ | |||
+ | my $img = $ENV{QUERY_STRING}; | ||
+ | if(defined $img and $img =~ /\S/) { | ||
+ | if($img =~ / | ||
+ | my $file = " | ||
+ | graph($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_virus($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greylist($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greystats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreen($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreenstats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_queue($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dane($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_smtpd($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_spf($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dkim($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dmarc($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | else { | ||
+ | die " | ||
+ | } | ||
+ | } | ||
+ | else { | ||
+ | print_html; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | main; | ||
+ | </ | ||
+ | |||
+ | === / | ||
+ | # vim / | ||
+ | <file perl / | ||
+ | |||
+ | # mailgraph -- detailed postfix mail traffic statistics | ||
+ | # copyright (c) 2000-2007 ETH Zurich | ||
+ | # copyright (c) 2000-2007 David Schweikert < | ||
+ | # modified 2011 for queuegraph by Ralf Hildebrandt < | ||
+ | # modified 2015 for mailgraph-ng by Django < | ||
+ | # patches from Sebastian van de Meer < | ||
+ | # released under the GNU General Public License | ||
+ | |||
+ | use RRDs; | ||
+ | use POSIX qw(uname); | ||
+ | |||
+ | my $VERSION = " | ||
+ | |||
+ | my $host = (POSIX:: | ||
+ | my $scriptname = $ENV{" | ||
+ | my $xpoints = 800; | ||
+ | my $points_per_sample = 3; | ||
+ | my $ypoints = 160; | ||
+ | my $rrd = '/ | ||
+ | my $rrd_virus = '/ | ||
+ | my $rrd_grey | ||
+ | my $rrd_dane | ||
+ | my $rrd_dmarc = '/ | ||
+ | my $rrd_smtpd = '/ | ||
+ | my $rrd_queue = '/ | ||
+ | my $rrd_post | ||
+ | |||
+ | my $tmp_dir = '/ | ||
+ | my @graphs = ( | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | ); | ||
+ | |||
+ | my %color = ( # rrggbb in hex | ||
+ | # n | ||
+ | sent => ' | ||
+ | received | ||
+ | |||
+ | bounced | ||
+ | virus => ' | ||
+ | spam => ' | ||
+ | rejected | ||
+ | |||
+ | greylisted | ||
+ | delayed | ||
+ | whitelist | ||
+ | awl => ' | ||
+ | early => ' | ||
+ | |||
+ | pswl => ' | ||
+ | psbl => ' | ||
+ | passold | ||
+ | veto => ' | ||
+ | pregreet | ||
+ | dnsbl => ' | ||
+ | pipelining | ||
+ | nonsmtp | ||
+ | barenewline | ||
+ | command | ||
+ | hangup | ||
+ | passnew | ||
+ | |||
+ | new => ' | ||
+ | reconnectok | ||
+ | |||
+ | active | ||
+ | deferred | ||
+ | |||
+ | untrustedtls | ||
+ | anonymoustls | ||
+ | trustedtls | ||
+ | verifiedtls | ||
+ | |||
+ | untrustedtlsin | ||
+ | anonymoustlsin | ||
+ | trustedtlsin | ||
+ | |||
+ | spfnone | ||
+ | spffail | ||
+ | spfpass | ||
+ | |||
+ | dkimnone | ||
+ | dkimfail | ||
+ | dkimpass | ||
+ | |||
+ | dmarcnone | ||
+ | dmarcfail | ||
+ | dmarcpass | ||
+ | ); | ||
+ | |||
+ | my $url = " | ||
+ | my $urlg = " | ||
+ | my $url1 = " | ||
+ | my $url2 = " | ||
+ | my $url3 = " | ||
+ | my $url4 = " | ||
+ | my $url11 = " | ||
+ | my $url12 = " | ||
+ | my $url13 = " | ||
+ | my $url14 = " | ||
+ | |||
+ | sub rrd_graph(@) | ||
+ | { | ||
+ | my ($range, $file, $ypoints, @rrdargs) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | my $end = time; $end -= $end % $step; | ||
+ | my $date = localtime(time); | ||
+ | $date =~ s|:|\\:|g unless $RRDs:: | ||
+ | |||
+ | my ($graphret, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | $RRDs:: | ||
+ | |||
+ | @rrdargs, | ||
+ | |||
+ | ' | ||
+ | ); | ||
+ | |||
+ | my $ERR=RRDs:: | ||
+ | die " | ||
+ | } | ||
+ | |||
+ | sub graph($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_virus($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greylist($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greystats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreen($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreenstats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_dane($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_smtpd($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_spf($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dkim($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dmarc($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_queue($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | sub print_html() | ||
+ | { | ||
+ | print " | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | <meta http-equiv=" | ||
+ | <link rel=" | ||
+ | </ | ||
+ | < | ||
+ | HEADER | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | #print "<a href=' | ||
+ | |||
+ | print "< | ||
+ | for my $n (0..$# | ||
+ | print " | ||
+ | } | ||
+ | print "</ | ||
+ | |||
+ | for my $n (0..$# | ||
+ | print "< | ||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | } | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | <table border=" | ||
+ | < | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | < | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | FOOTER | ||
+ | } | ||
+ | |||
+ | sub send_image($) | ||
+ | { | ||
+ | my ($file)= @_; | ||
+ | |||
+ | -r $file or do { | ||
+ | print " | ||
+ | exit 1; | ||
+ | }; | ||
+ | |||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | open(IMG, $file) or die; | ||
+ | my $data; | ||
+ | print $data while read(IMG, $data, 16384)> | ||
+ | } | ||
+ | |||
+ | sub main() | ||
+ | { | ||
+ | my $uri = $ENV{REQUEST_URI} || ''; | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | mkdir $tmp_dir, 0777 unless -d $tmp_dir; | ||
+ | mkdir " | ||
+ | |||
+ | my $img = $ENV{QUERY_STRING}; | ||
+ | if(defined $img and $img =~ /\S/) { | ||
+ | if($img =~ / | ||
+ | my $file = " | ||
+ | graph($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_virus($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greylist($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greystats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreen($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreenstats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_queue($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dane($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_smtpd($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_spf($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dkim($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dmarc($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | else { | ||
+ | die " | ||
+ | } | ||
+ | } | ||
+ | else { | ||
+ | print_html; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | main; | ||
+ | </ | ||
+ | |||
+ | ==== CGI-Erweiterung für die Σ-Seite ==== | ||
+ | Wie auch schon bei den Einzelstatistiken sind bei der Σ-Seite, die die kumulierten Einzelgraphen enthält, umfangreichere Änderungen/ | ||
+ | |||
+ | === Datenquellen === | ||
+ | Da wir bei der Gesamtstatistik die Summe der einzelnen Mailserver zur Anzeige bringen wollen, benötigen wir daher auch alle Datenquellen. Die Anzahl der Variablen **$rrd_* ** erhöht sich daher entsprechend! | ||
+ | <code perl>... | ||
+ | |||
+ | my $rrd_11 | ||
+ | my $rrd_12 | ||
+ | my $rrd_13 | ||
+ | my $rrd_14 | ||
+ | my $rrd_virus_11 | ||
+ | my $rrd_virus_12 | ||
+ | my $rrd_virus_13 | ||
+ | my $rrd_virus_14 | ||
+ | my $rrd_grey_11 | ||
+ | my $rrd_grey_12 | ||
+ | my $rrd_grey_13 | ||
+ | my $rrd_grey_14 | ||
+ | my $rrd_dane_11 | ||
+ | my $rrd_dane_12 | ||
+ | my $rrd_dane_13 | ||
+ | my $rrd_dane_14 | ||
+ | my $rrd_dmarc_11 | ||
+ | my $rrd_dmarc_12 | ||
+ | my $rrd_dmarc_13 | ||
+ | my $rrd_dmarc_14 | ||
+ | my $rrd_smtpd_11 | ||
+ | my $rrd_smtpd_12 | ||
+ | my $rrd_smtpd_13 | ||
+ | my $rrd_smtpd_14 | ||
+ | my $rrd_queue_11 | ||
+ | my $rrd_queue_12 | ||
+ | my $rrd_queue_13 | ||
+ | my $rrd_queue_14 | ||
+ | my $rrd_post_11 | ||
+ | my $rrd_post_12 | ||
+ | my $rrd_post_13 | ||
+ | my $rrd_post_14 | ||
+ | |||
+ | ... | ||
+ | </ | ||
+ | |||
+ | === URL-Definitionen === | ||
+ | Damit die Seite bei Portierungen ohne große Änderungen im Code realisiert werden können, wird für die Querverweise jeweils zugehörige URL's definiert. | ||
+ | |||
+ | <code perl>... | ||
+ | |||
+ | my $url = " | ||
+ | my $urlg = " | ||
+ | my $url1 = " | ||
+ | my $url2 = " | ||
+ | my $url3 = " | ||
+ | my $url4 = " | ||
+ | my $url11 = " | ||
+ | my $url12 = " | ||
+ | my $url13 = " | ||
+ | my $url14 = " | ||
+ | |||
+ | |||
+ | ... | ||
+ | </ | ||
+ | |||
+ | === Unterprogramme graph_xxx - kumulierte Werte für die Generierung der RRD-Graphiken === | ||
+ | Bei der Generierung der kumulierten Graphiken stellt sich grundsätzlich die Frage, wie führt man den Inhalt mehrerer RRD-Dateien zusammen um einen Summengraph zu erstellen. Anstatt nun einen neue RRD-Datei mit dem Inhalt der vier einzelnen RRD-Dateien zu erstellen um daraus dann den Graphen zu generieren, wählen wir einen anderen Weg. Bei der Erstellung eines Summengraphen mit Hilfe von **RRD_GRAPH** bedienen wir uns nicht nur einer Quelle (RRD-Datei), | ||
+ | |||
+ | Dazu müssen wir im ersten Schritt **alle Datenquellen** beim RRD_GRAPH Parameter **DEF** benennen. Somit wird z.B. beim Graphen mit den nicht angenommenen Nachrichten **Rejected** statt der **beiden Zeilen** < | ||
+ | " | ||
+ | " | ||
+ | </ | ||
+ | entsprechend **acht Zeilen** | ||
+ | < | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | Bei der Generierung der eigentlichen Graphen ziehen wir die **Summe der vier RRD-Dateien** heran, egal ob eine einfache Fläche, ein gestapelter Bereich oder ein Liniengraph erzeugt werden soll. Beim RRD_GRAPH Parameter **CDEF** lassen wir daher die Summe aus den Variablen // | ||
+ | |||
+ | Hierzu verwenden wir die //RRD_GRAPH eigene Berechnungssyntax// | ||
+ | |||
+ | Im Falle unseres Graphen über die Abgelehneten Nachrichten (**rejected**) berechnet sich die Gesamtsumme also wie folgt: \\ < | ||
+ | |||
+ | Daraus wird dann in der //RRD_GRAPH eigenen Berechnungssyntax//: | ||
+ | | ||
+ | |||
+ | Anstatt der ursprünglichen **CDEF**-Definitionen | ||
+ | < | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | </ | ||
+ | verwenden wir also nachfolgende **CDEF**-Definitionen: | ||
+ | |||
+ | < | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | Diese Änderungen tragen wir nun bei den Unterprogrammen **graph_xxx** nach. | ||
+ | |||
+ | === Unterprogramm print_html | ||
+ | Wie auch schon bei den [[centos: | ||
+ | <code perl> | ||
+ | |||
+ | sub print_html() | ||
+ | { | ||
+ | print " | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | <meta http-equiv=" | ||
+ | <link rel=" | ||
+ | </ | ||
+ | < | ||
+ | HEADER | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | for my $n (0..$# | ||
+ | print " | ||
+ | } | ||
+ | print "</ | ||
+ | |||
+ | for my $n (0..$# | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | } | ||
+ | |||
+ | print << | ||
+ | <hr/> | ||
+ | <table border=" | ||
+ | < | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </td> | ||
+ | <td> | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </td> | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | </td> | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | </td> | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </td> | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | FOOTER | ||
+ | } | ||
+ | |||
+ | ... | ||
+ | </ | ||
+ | |||
+ | |||
+ | === CGI-Script für die ∑-Auswertung === | ||
+ | Mit allen Änderungen und Erweiterungen ergibt sich dann folgendes Gesamt-CGI-Script: | ||
+ | # vim / | ||
+ | |||
+ | <file perl / | ||
+ | |||
+ | # mailgraph -- detailed postfix mail traffic statistics | ||
+ | # copyright (c) 2000-2007 ETH Zurich | ||
+ | # copyright (c) 2000-2007 David Schweikert < | ||
+ | # modified 2011 for queuegraph by Ralf Hildebrandt < | ||
+ | # modified 2015 for mailgraph-ng by Django < | ||
+ | # patches from Sebastian van de Meer < | ||
+ | # released under the GNU General Public License | ||
+ | |||
+ | use RRDs; | ||
+ | use POSIX qw(uname); | ||
+ | |||
+ | my $VERSION = " | ||
+ | |||
+ | my $host = (POSIX:: | ||
+ | my $scriptname = $ENV{" | ||
+ | my $xpoints | ||
+ | my $points_per_sample = 3; | ||
+ | my $ypoints | ||
+ | my $rrd_11 | ||
+ | my $rrd_12 | ||
+ | my $rrd_13 | ||
+ | my $rrd_14 | ||
+ | my $rrd_virus_11 | ||
+ | my $rrd_virus_12 | ||
+ | my $rrd_virus_13 | ||
+ | my $rrd_virus_14 | ||
+ | my $rrd_grey_11 | ||
+ | my $rrd_grey_12 | ||
+ | my $rrd_grey_13 | ||
+ | my $rrd_grey_14 | ||
+ | my $rrd_dane_11 | ||
+ | my $rrd_dane_12 | ||
+ | my $rrd_dane_13 | ||
+ | my $rrd_dane_14 | ||
+ | my $rrd_dmarc_11 | ||
+ | my $rrd_dmarc_12 | ||
+ | my $rrd_dmarc_13 | ||
+ | my $rrd_dmarc_14 | ||
+ | my $rrd_smtpd_11 | ||
+ | my $rrd_smtpd_12 | ||
+ | my $rrd_smtpd_13 | ||
+ | my $rrd_smtpd_14 | ||
+ | my $rrd_queue_11 | ||
+ | my $rrd_queue_12 | ||
+ | my $rrd_queue_13 | ||
+ | my $rrd_queue_14 | ||
+ | my $rrd_post_11 | ||
+ | my $rrd_post_12 | ||
+ | my $rrd_post_13 | ||
+ | my $rrd_post_14 | ||
+ | |||
+ | my $tmp_dir = '/ | ||
+ | my @graphs = ( | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | { title => ' | ||
+ | ); | ||
+ | |||
+ | my %color = ( # rrggbb in hex | ||
+ | # n | ||
+ | sent => ' | ||
+ | received | ||
+ | |||
+ | bounced | ||
+ | virus => ' | ||
+ | spam => ' | ||
+ | rejected | ||
+ | |||
+ | greylisted | ||
+ | delayed | ||
+ | whitelist | ||
+ | awl => ' | ||
+ | early => ' | ||
+ | |||
+ | pswl => ' | ||
+ | psbl => ' | ||
+ | passold | ||
+ | veto => ' | ||
+ | pregreet | ||
+ | dnsbl => ' | ||
+ | pipelining | ||
+ | nonsmtp | ||
+ | barenewline | ||
+ | command | ||
+ | hangup | ||
+ | passnew | ||
+ | |||
+ | new => ' | ||
+ | reconnectok | ||
+ | |||
+ | active | ||
+ | deferred | ||
+ | |||
+ | untrustedtls | ||
+ | anonymoustls | ||
+ | trustedtls | ||
+ | verifiedtls | ||
+ | |||
+ | untrustedtlsin | ||
+ | anonymoustlsin | ||
+ | trustedtlsin | ||
+ | |||
+ | spfnone | ||
+ | spffail | ||
+ | spfpass | ||
+ | |||
+ | dkimnone | ||
+ | dkimfail | ||
+ | dkimpass | ||
+ | |||
+ | dmarcnone | ||
+ | dmarcfail | ||
+ | dmarcpass | ||
+ | ); | ||
+ | |||
+ | my $url = " | ||
+ | my $url1 = " | ||
+ | my $url2 = " | ||
+ | my $url3 = " | ||
+ | my $url4 = " | ||
+ | my $url11 | ||
+ | my $url12 | ||
+ | my $url13 | ||
+ | my $url14 | ||
+ | |||
+ | sub rrd_graph(@) | ||
+ | { | ||
+ | my ($range, $file, $ypoints, @rrdargs) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | my $end = time; $end -= $end % $step; | ||
+ | my $date = localtime(time); | ||
+ | $date =~ s|:|\\:|g unless $RRDs:: | ||
+ | |||
+ | my ($graphret, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | $RRDs:: | ||
+ | |||
+ | @rrdargs, | ||
+ | |||
+ | ' | ||
+ | ); | ||
+ | |||
+ | my $ERR=RRDs:: | ||
+ | die " | ||
+ | } | ||
+ | |||
+ | sub graph($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_virus($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greylist($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | sub graph_greystats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | |||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreen($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_postscreenstats($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_dane($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_smtpd($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_spf($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dkim($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | sub graph_dmarc($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | sub graph_queue($$) | ||
+ | { | ||
+ | my ($range, $file) = @_; | ||
+ | my $step = $range*$points_per_sample/ | ||
+ | rrd_graph($range, | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | sub print_html() | ||
+ | { | ||
+ | print " | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | <meta http-equiv=" | ||
+ | <link rel=" | ||
+ | </ | ||
+ | < | ||
+ | HEADER | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | for my $n (0..$# | ||
+ | print " | ||
+ | } | ||
+ | print "</ | ||
+ | |||
+ | for my $n (0..$# | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | | ||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | |||
+ | print "< | ||
+ | print "< | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "<a href=' | ||
+ | print "< | ||
+ | } | ||
+ | |||
+ | print << | ||
+ | < | ||
+ | <table border=" | ||
+ | < | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | <col width=" | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | < | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <td class=" | ||
+ | </ | ||
+ | <td class=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | FOOTER | ||
+ | } | ||
+ | |||
+ | sub send_image($) | ||
+ | { | ||
+ | my ($file)= @_; | ||
+ | |||
+ | -r $file or do { | ||
+ | print " | ||
+ | exit 1; | ||
+ | }; | ||
+ | |||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | open(IMG, $file) or die; | ||
+ | my $data; | ||
+ | print $data while read(IMG, $data, 16384)> | ||
+ | } | ||
+ | |||
+ | sub main() | ||
+ | { | ||
+ | my $uri = $ENV{REQUEST_URI} || ''; | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | $uri =~ s/ | ||
+ | mkdir $tmp_dir, 0777 unless -d $tmp_dir; | ||
+ | mkdir " | ||
+ | |||
+ | my $img = $ENV{QUERY_STRING}; | ||
+ | if(defined $img and $img =~ /\S/) { | ||
+ | if($img =~ / | ||
+ | my $file = " | ||
+ | graph($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_virus($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greylist($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_greystats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreen($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_postscreenstats($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_queue($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dane($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_smtpd($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_spf($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dkim($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | elsif($img =~ / | ||
+ | my $file = " | ||
+ | graph_dmarc($graphs[$1]{seconds}, | ||
+ | send_image($file); | ||
+ | } | ||
+ | else { | ||
+ | die " | ||
+ | } | ||
+ | } | ||
+ | else { | ||
+ | print_html; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | main; | ||
+ | </ | ||
+ | |||
+ | ==== Apache VHost anlegen ==== | ||
+ | Damit wir bequem von unserem Browser aus, die aktuellen Graphiken abfragen können, bearbeiten wir entweder die aus dem RPM stammende Konfigurationsdatei oder legen wir nun einen passenden VHost an. | ||
+ | # vim / | ||
+ | <file apache / | ||
+ | # | ||
+ | # mailgraph.nausch.org | ||
+ | # | ||
+ | < | ||
+ | ServerAdmin webmaster@nausch.org | ||
+ | ServerName mailgraph.nausch.org | ||
+ | ServerAlias www.mailgraph.nausch.org | ||
+ | ServerPath / | ||
+ | DocumentRoot "/ | ||
+ | AddHandler cgi-script .cgi | ||
+ | |||
+ | < | ||
+ | AllowOverride None | ||
+ | Options +ExecCGI | ||
+ | DirectoryIndex mailgraph.cgi | ||
+ | require IP 10.0. | ||
+ | </ | ||
+ | < | ||
+ | AllowOverride None | ||
+ | Options +ExecCGI | ||
+ | DirectoryIndex mailgraph.cgi | ||
+ | require IP 10.0. | ||
+ | </ | ||
+ | < | ||
+ | AllowOverride None | ||
+ | Options +ExecCGI | ||
+ | DirectoryIndex mailgraph.cgi | ||
+ | require IP 10.0. | ||
+ | </ | ||
+ | < | ||
+ | AllowOverride None | ||
+ | Options +ExecCGI | ||
+ | DirectoryIndex mailgraph.cgi | ||
+ | require IP 10.0. | ||
+ | </ | ||
+ | < | ||
+ | AllowOverride None | ||
+ | Options +ExecCGI | ||
+ | DirectoryIndex mailgraph.cgi | ||
+ | require IP 10.0. | ||
+ | </ | ||
+ | |||
+ | ErrorLog logs/ | ||
+ | CustomLog logs/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | Bevor wir bei unserem Webserver eine Reload der Konfiguration vornehmen, testen wir unsere neue Konfigurationsdatei auf syntaktische Fehler. | ||
+ | # apachectl -t | ||
+ | |||
+ | | ||
+ | |||
+ | Da keine Fehler aufgetreten sind, aktivieren wir die neue Konfiguration durch einen Reload des Webserver-Daemon. | ||
+ | # systemctl reload postfix | ||
+ | |||
+ | ==== NGiNX vHost anlegen ==== | ||
+ | Nutzen wir als Webserver **[[centos: | ||
+ | # vim / | ||
+ | <file http / | ||
+ | listen | ||
+ | server_name | ||
+ | access_log | ||
+ | error_log | ||
+ | |||
+ | root / | ||
+ | index mailgraph.cgi; | ||
+ | |||
+ | | ||
+ | fastcgi_split_path_info ^(.+\.cgi)(/ | ||
+ | fastcgi_index mailgraph.cgi; | ||
+ | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Den Parameter **fastcgi_pass** setzen wir im übrigen auf den Wert aus der Konfigurationsdatei // | ||
+ | |||
+ | Haben wir die Konfigurationsdatei vervollständigt, | ||
+ | # nginx -t | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | Somit können wir unsere Konfiguration nun noch aktivieren. | ||
+ | # systemctl reload nginx | ||
+ | |||
+ | ==== Webaufruf ==== | ||
+ | Rufen wir nun die definierte Webseite unserer Gesamtstatistikübersicht auf, erhalten wir nachfolgende Ansicht. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Hier können wir nun gezielt einzelne Systeme auswählen, bzw. bei einer ausgewählten Detailstatistikseite zur Summenseite hin und her wechseln. | ||
===== AWStats ===== | ===== AWStats ===== | ||
Auch mit Hilfe des Projektes/ | Auch mit Hilfe des Projektes/ | ||
Zeile 5654: | Zeile 11555: | ||
- | + | ====== Links ====== | |
- | + | * **[[centos: | |
- | FIXME //... do geds weida ... // FIXME | + | * **[[wiki: |
- | + | * **[[http://dokuwiki.nausch.org/doku.php/|Zurück zur Startseite]]** | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||