-
Notifications
You must be signed in to change notification settings - Fork 9
/
pflogsummUIReport.sh
executable file
·1593 lines (1350 loc) · 70 KB
/
pflogsummUIReport.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# Debug option - should be disabled unless required
#set -x
#=====================================================================================================================
# DESCRIPTION Generating a stand alone web report for postix log files,
# Runs on all Linux platforms with postfix installed
# AUTHOR Riaan Pretorius <[email protected]>
# IDIOCRACY yes.. i know.. bash??? WTF was i thinking?? Well it works, runs every
# where and it is portable
#
# https://en.wikipedia.org/wiki/MIT_License
#
# LICENSE
# MIT License
#
# Copyright (c) 2018 Riaan Pretorius
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
# and associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial
# portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#=====================================================================================================================
#CONFIG FILE LOCATION
PFSYSCONFDIR="/etc"
#Create Blank Config File if it does not exist
if [ ! -f ${PFSYSCONFDIR}/"pflogsumui.conf" ]
then
tee ${PFSYSCONFDIR}/"pflogsumui.conf" <<EOF
#PFLOGSUMUI CONFIG
## Postfix Log Location
LOGFILELOCATION="/var/log/maillog"
## pflogsumm details
## NOTE: DONT USE -d today - breaks the script
PFLOGSUMMOPTIONS=" --verbose_msg_detail --zero_fill "
PFLOGSUMMBIN="/usr/sbin/pflogsumm "
## HTML Output
HTMLOUTPUTDIR="/var/www/html/"
HTMLOUTPUT_INDEXDASHBOARD="index.html"
EOF
echo "DEFAULT configuration file writen to ${PFSYSCONFDIR}/pflogsumui.conf, Please verify the paths before you continue"
exit 0
fi
#Load Config File
. ${PFSYSCONFDIR}/"pflogsumui.conf"
#Create the Cache Directory if it does not exist
if [ ! -d $HTMLOUTPUTDIR/data ]; then
mkdir $HTMLOUTPUTDIR/data;
fi
#TOOLS
ACTIVEHOSTNAME=$(cat /proc/sys/kernel/hostname)
MOVEF="/usr/bin/mv -f "
#Temporal Values
REPORTDATE=$(date '+%Y-%m-%d %H:%M:%S')
CURRENTYEAR=$(date +'%Y')
CURRENTMONTH=$(date +'%b')
CURRENTDAY=$(date +"%e")
$PFLOGSUMMBIN $PFLOGSUMMOPTIONS -e $LOGFILELOCATION > /tmp/mailreport
#Extract Sections from PFLOGSUMM
sed -n '/^Grand Totals/,/^Per-Day/p;/^Per-Day/q' /tmp/mailreport | sed -e '1,4d' | sed -e :a -e '$d;N;2,3ba' -e 'P;D' | sed '/^$/d' > /tmp/GrandTotals
sed -n '/^Per-Day Traffic Summary/,/^Per-Hour/p;/^Per-Hour/q' /tmp/mailreport | sed -e '1,4d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' > /tmp/PerDayTrafficSummary
sed -n '/^Per-Hour Traffic Daily Average/,/^Host\//p;/^Host\//q' /tmp/mailreport | sed -e '1,4d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' > /tmp/PerHourTrafficDailyAverage
sed -n '/^Host\/Domain Summary\: Message Delivery/,/^Host\/Domain Summary\: Messages Received/p;/^Host\/Domain Summary\: Messages Received/q' /tmp/mailreport | sed -e '1,4d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' > /tmp/HostDomainSummaryMessageDelivery
sed -n '/^Host\/Domain Summary\: Messages Received/,/^Senders by message count/p;/^Senders by message count/q' /tmp/mailreport | sed -e '1,4d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' > /tmp/HostDomainSummaryMessagesReceived
sed -n '/^Senders by message count/,/^Recipients by message count/p;/^Recipients by message count/q' /tmp/mailreport | sed -e '1,2d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' | sed '/^$/d' > /tmp/Sendersbymessagecount
sed -n '/^Recipients by message count/,/^Senders by message size/p;/^Senders by message size/q' /tmp/mailreport | sed -e '1,2d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' | sed '/^$/d' > /tmp/Recipientsbymessagecount
sed -n '/^Senders by message size/,/^Recipients by message size/p;/^Recipients by message size/q' /tmp/mailreport | sed -e '1,2d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' | sed '/^$/d' > /tmp/Sendersbymessagesize
sed -n '/^Recipients by message size/,/^Messages with no size data/p;/^Messages with no size data/q' /tmp/mailreport | sed -e '1,2d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' | sed '/^$/d' > /tmp/Recipientsbymessagesize
sed -n '/^Messages with no size data/,/^message deferral detail/p;/^message deferral detail/q' /tmp/mailreport | sed -e '1,2d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' | sed '/^$/d' > /tmp/Messageswithnosizedata
sed -n '/^message deferral detail/,/^message bounce detail (by relay)/p;/^message bounce detail (by relay)/q' /tmp/mailreport | sed -e '1,2d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' | sed '/^$/d' > /tmp/messagedeferraldetail
sed -n '/^message bounce detail (by relay)/,/^message reject detail/p;/^message reject detail/q' /tmp/mailreport | sed -e '1,2d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' | sed '/^$/d' > /tmp/messagebouncedetaibyrelay
sed -n '/^Warnings/,/^Fatal Errors/p;/^Fatal Errors/q' /tmp/mailreport | sed -e '1,2d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' | sed '/^$/d' > /tmp/warnings
sed -n '/^Fatal Errors/,/^Master daemon messages/p;/^Master daemon messages/q' /tmp/mailreport | sed -e '1,2d' | sed -e :a -e '$d;N;2,2ba' -e 'P;D' | sed '/^$/d' > /tmp/FatalErrors
#======================================================
# Extract Information into variables -> Grand Totals
#======================================================
ReceivedEmail=$(awk '$2=="received" {print $1}' /tmp/GrandTotals)
DeliveredEmail=$(awk '$2=="delivered" {print $1}' /tmp/GrandTotals)
ForwardedEmail=$(awk '$2=="forwarded" {print $1}' /tmp/GrandTotals)
DeferredEmailCount=$(awk '$2=="deferred" {print $1}' /tmp/GrandTotals)
DeferredEmailDeferralsCount=$(awk '$2=="deferred" {print $3" "$4}' /tmp/GrandTotals)
BouncedEmail=$(awk '$2=="bounced" {print $1}' /tmp/GrandTotals)
RejectedEmailCount=$(awk '$2=="rejected" {print $1}' /tmp/GrandTotals)
RejectedEmailPercentage=$(awk '$2=="rejected" {print $3}' /tmp/GrandTotals)
RejectedWarningsEmail=$(sed 's/reject warnings/rejectwarnings/' /tmp/GrandTotals | awk '$2=="rejectwarnings" {print $1}')
HeldEmail=$(awk '$2=="held" {print $1}' /tmp/GrandTotals)
DiscardedEmailCount=$(awk '$2=="discarded" {print $1}' /tmp/GrandTotals)
DiscardedEmailPercentage=$(awk '$2=="discarded" {print $3}' /tmp/GrandTotals)
BytesReceivedEmail=$(sed 's/bytes received/bytesreceived/' /tmp/GrandTotals | awk '$2=="bytesreceived" {print $1}'|sed 's/[^0-9]*//g' )
BytesDeliveredEmail=$(sed 's/bytes delivered/bytesdelivered/' /tmp/GrandTotals | awk '$2=="bytesdelivered" {print $1}'|sed 's/[^0-9]*//g')
SendersEmail=$(awk '$2=="senders" {print $1}' /tmp/GrandTotals)
SendingHostsDomainsEmail=$(sed 's/sending hosts\/domains/sendinghostsdomains/' /tmp/GrandTotals | awk '$2=="sendinghostsdomains" {print $1}')
RecipientsEmail=$(awk '$2=="recipients" {print $1}' /tmp/GrandTotals)
RecipientHostsDomainsEmail=$(sed 's/recipient hosts\/domains/recipienthostsdomains/' /tmp/GrandTotals | awk '$2=="recipienthostsdomains" {print $1}')
#======================================================
# Extract Information into variable -> Per-Day Traffic Summary
#======================================================
while IFS= read -r var
do
PerDayTrafficSummaryTable=""
PerDayTrafficSummaryTable+="<tr>"
PerDayTrafficSummaryTable+=$(echo "$var" | awk '{print "<td>"$1" "$2" "$3"</td>""<td>"$4"</td>""<td>"$5"</td>""<td>"$6"</td>""<td>"$7"</td>""<td>"$8"</td>"}')
PerDayTrafficSummaryTable+="</tr>"
echo $PerDayTrafficSummaryTable >> /tmp/PerDayTrafficSummary_tmp
done < /tmp/PerDayTrafficSummary
$MOVEF /tmp/PerDayTrafficSummary_tmp /tmp/PerDayTrafficSummary &> /dev/null
#======================================================
# Extract Information into variable -> Per-Hour Traffic Daily Average
#======================================================
while IFS= read -r var
do
PerHourTrafficDailyAverageTable=""
PerHourTrafficDailyAverageTable+="<tr>"
PerHourTrafficDailyAverageTable+=$(echo "$var" | awk '{print "<td>"$1"</td>""<td>"$2"</td>""<td>"$3"</td>""<td>"$4"</td>""<td>"$5"</td>""<td>"$6"</td>"}')
PerHourTrafficDailyAverageTable+="</tr>"
echo $PerHourTrafficDailyAverageTable >> /tmp/PerHourTrafficDailyAverage_tmp
done < /tmp/PerHourTrafficDailyAverage
$MOVEF /tmp/PerHourTrafficDailyAverage_tmp /tmp/PerHourTrafficDailyAverage &> /dev/null
#======================================================
# Extract Information into variable -> Per-Hour Traffic Daily Average
#======================================================
while IFS= read -r var
do
HostDomainSummaryMessageDeliveryTable=""
HostDomainSummaryMessageDeliveryTable+="<tr>"
HostDomainSummaryMessageDeliveryTable+=$(echo "$var" | awk '{print "<td>"$1"</td>""<td>"$2"</td>""<td>"$3"</td>""<td>"$4" "$5"</td>""<td>"$6" "$7"</td>""<td>"$8"</td>" }')
HostDomainSummaryMessageDeliveryTable+="</tr>"
echo $HostDomainSummaryMessageDeliveryTable >> /tmp/HostDomainSummaryMessageDelivery_tmp
done < /tmp/HostDomainSummaryMessageDelivery
$MOVEF /tmp/HostDomainSummaryMessageDelivery_tmp /tmp/HostDomainSummaryMessageDelivery &> /dev/null
#======================================================
# Extract Information into variable -> Host Domain Summary Messages Received
#======================================================
while IFS= read -r var
do
HostDomainSummaryMessagesReceivedTable=""
HostDomainSummaryMessagesReceivedTable+="<tr>"
HostDomainSummaryMessagesReceivedTable+=$(echo "$var" | awk '{print "<td>"$1"</td>""<td>"$2"</td>""<td>"$3"</td>"}')
HostDomainSummaryMessagesReceivedTable+="</tr>"
echo $HostDomainSummaryMessagesReceivedTable >> /tmp/HostDomainSummaryMessagesReceived_tmp
done < /tmp/HostDomainSummaryMessagesReceived
$MOVEF /tmp/HostDomainSummaryMessagesReceived_tmp /tmp/HostDomainSummaryMessagesReceived &> /dev/null
#======================================================
# Extract Information into variable -> Host Domain Summary Messages Received
#======================================================
while IFS= read -r var
do
SendersbymessagecountTable=""
SendersbymessagecountTable+="<tr>"
SendersbymessagecountTable+=$(echo "$var" | awk '{print "<td>"$1"</td>""<td>"$2"</td>"}')
SendersbymessagecountTable+="</tr>"
echo $SendersbymessagecountTable >> /tmp/Sendersbymessagecount_tmp
done < /tmp/Sendersbymessagecount
$MOVEF /tmp/Sendersbymessagecount_tmp /tmp/Sendersbymessagecount &> /dev/null
#======================================================
# Extract Information into variable -> Recipients by message count
#======================================================
while IFS= read -r var
do
RecipientsbymessagecountTable=""
RecipientsbymessagecountTable+="<tr>"
RecipientsbymessagecountTable+=$(echo "$var" | awk '{print "<td>"$1"</td>""<td>"$2"</td>"}')
RecipientsbymessagecountTable+="</tr>"
echo $RecipientsbymessagecountTable >> /tmp/Recipientsbymessagecount_tmp
done < /tmp/Recipientsbymessagecount
$MOVEF /tmp/Recipientsbymessagecount_tmp /tmp/Recipientsbymessagecount &> /dev/null
#======================================================
# Extract Information into variable -> Senders by message size
#======================================================
while IFS= read -r var
do
SendersbymessagesizeTable=""
SendersbymessagesizeTable+="<tr>"
SendersbymessagesizeTable+=$(echo "$var" | awk '{print "<td>"$1"</td>""<td>"$2"</td>"}')
SendersbymessagesizeTable+="</tr>"
echo $SendersbymessagesizeTable >> /tmp/Sendersbymessagesize_tmp
done < /tmp/Sendersbymessagesize
$MOVEF /tmp/Sendersbymessagesize_tmp /tmp/Sendersbymessagesize &> /dev/null
#======================================================
# Extract Information into variable -> Recipients by messagesize Table
#======================================================
while IFS= read -r var
do
RecipientsbymessagesizeTable=""
RecipientsbymessagesizeTable+="<tr>"
RecipientsbymessagesizeTable+=$(echo "$var" | awk '{print "<td>"$1"</td>""<td>"$2"</td>"}')
RecipientsbymessagesizeTable+="</tr>"
echo $RecipientsbymessagesizeTable >> /tmp/Recipientsbymessagesize_tmp
done < /tmp/Recipientsbymessagesize
$MOVEF /tmp/Recipientsbymessagesize_tmp /tmp/Recipientsbymessagesize &> /dev/null
#======================================================
# Extract Information into variable -> Recipients by messagesize Table
#======================================================
while IFS= read -r var
do
MessageswithnosizedataTable=""
MessageswithnosizedataTable+="<tr>"
MessageswithnosizedataTable+=$(echo "$var" | awk '{print "<td>"$1"</td>""<td>"$2"</td>"}')
MessageswithnosizedataTable+="</tr>"
echo $MessageswithnosizedataTable >> /tmp/Messageswithnosizedata_tmp
echo $MessageswithnosizedataTable
done < /tmp/Messageswithnosizedata
$MOVEF /tmp/Messageswithnosizedata_tmp /tmp/Messageswithnosizedata &> /dev/null
#======================================================
# Single PAGE INDEX HTML TEMPLATE
# Using embedded HTML makes the script highly portable
# SED search and replace tags to fill the content
#======================================================
cat > $HTMLOUTPUTDIR/$HTMLOUTPUT_INDEXDASHBOARD << 'HTMLOUTPUTINDEXDASHBOARD'
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Postfix PFLOGSUMM Dashboard Index">
<meta name="author" content="Riaan Pretorius">
<link rel="icon" href="http://www.postfix.org/favicon.ico">
<title>Postfix PFLOGSUMM Dashboard Index</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
<style>
body {
padding-top: 5rem;
}
footer {
background-color: #eee;
padding: 25px;
}
.spacer10 {
height: 10px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Postfix PFLOGSUMM Dashboard</a>
</nav>
<div class="container">
<h3 class="pb-3 mb-4 font-italic border-bottom">
Select Report
<dl class="row">
<dt class="col-sm-3" style="font-size: 0.5em;">Last Update</dt>
<dd class="col-sm-9" style="font-size: 0.5em;">##REPORTDATE##</dd>
<dt class="col-sm-3" style="font-size: 0.5em;">Server</dt>
<dd class="col-sm-9" style="font-size: 0.5em;">##ACTIVEHOSTNAME##</dd>
</dl>
</h3>
<div class="row">
<div class="col-sm">
<!-- January Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">January</strong></h5>
<h6>Report Count <span class="badge badge-primary">##JanuaryCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#JanuaryCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="JanuaryCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush JanuaryList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- January End -->
</div>
<div class="col-sm">
<!-- February Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">February</strong></h5>
<h6>Report Count <span class="badge badge-primary">##FebruaryCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#FebruaryCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="FebruaryCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush FebruaryList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- February End -->
</div>
<div class="col-sm">
<!-- March Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">March</strong></h5>
<h6>Report Count <span class="badge badge-primary">##MarchCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#MarchCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="MarchCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush MarchList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- March End -->
</div>
<div class="col-sm">
<!-- April Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">April</strong></h5>
<h6>Report Count <span class="badge badge-primary">##AprilCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#AprilCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="AprilCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush AprilList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- April End -->
</div>
</div>
<br>
<div class="row">
<div class="col-sm">
<!-- May Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">May</strong></h5>
<h6>Report Count <span class="badge badge-primary">##MayCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#MayCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="MayCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush MayList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- May End -->
</div>
<div class="col-sm">
<!-- June Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">June</strong></h5>
<h6>Report Count <span class="badge badge-primary">##JuneCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#JuneCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="JuneCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush JuneList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- June End -->
</div>
<div class="col-sm">
<!-- July Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">July</strong></h5>
<h6>Report Count <span class="badge badge-primary">##JulyCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#JulyCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="JulyCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush JulyList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- July End -->
</div>
<div class="col-sm">
<!-- August Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">August</strong></h5>
<h6>Report Count <span class="badge badge-primary">##AugustCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#AugustCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="AugustCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush AugustList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- August End -->
</div>
</div>
<br>
<div class="row">
<div class="col-sm">
<!-- September Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">September</strong></h5>
<h6>Report Count <span class="badge badge-primary">##SeptemberCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#SeptemberCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="SeptemberCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush SeptemberList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- September End -->
</div>
<div class="col-sm">
<!-- October Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">October</strong></h5>
<h6>Report Count <span class="badge badge-primary">##OctoberCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#OctoberCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="OctoberCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush OctoberList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- October End -->
</div>
<div class="col-sm">
<!-- November Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">November</strong></h5>
<h6>Report Count <span class="badge badge-primary">##NovemberCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#NovemberCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="NovemberCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush NovemberList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- November End -->
</div>
<div class="col-sm">
<!-- December Start-->
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<h5><strong class="d-inline-block mb-2 text-primary">December</strong></h5>
<h6>Report Count <span class="badge badge-primary">##DecemberCount##</span></h6>
<div class="spacer10"></div>
<a data-toggle="collapse" href="#DecemberCard" aria-expanded="true" class="d-block"> View
Reports </a>
<div id="DecemberCard" class="collapse hide">
<div class="card-body ">
<div class="list-group list-group-flush DecemberList ">
<!-- Dynamic Item List-->
</div>
</div>
</div>
</div>
</div>
<!-- December End -->
</div>
</div>
</div>
<br>
<!-- Footer -->
<footer class="container-fluid bg-dark text-center text-white-50">
<div class="copyrights" style="margin-top:5px;">
<p>©
<script>new Date().getFullYear() > 2010 && document.write(new Date().getFullYear());</script>
<br>
<span>Powered by <a href="https://github.com/KTamas/pflogsumm">PFLOGSUMM</a> </span> /
<span><a href="https://github.com/RiaanPretoriusSA/PFLogSumm-HTML-GUI">PFLOGSUMM HTML UI Report</a>
</span>
</p>
</div>
</footer>
<!-- Footer -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js"></script>
<!-- Popper.JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.5/umd/popper.min.js"></script>
</body>
<script>
$(document).ready(function () {
$('.JanuaryList').load("data/jan_rpt.html?rnd=" + Math.random());
$('.FebruaryList').load("data/feb_rpt.html?rnd=" + Math.random());
$('.MarchList').load("data/mar_rpt.html?rnd=" + Math.random());
$('.AprilList').load("data/apr_rpt.html?rnd=" + Math.random());
$('.MayList').load("data/may_rpt.html?rnd=" + Math.random());
$('.JuneList').load("data/jun_rpt.html?rnd=" + Math.random());
$('.JulyList').load("data/jul_rpt.html?rnd=" + Math.random());
$('.AugustList').load("data/aug_rpt.html?rnd=" + Math.random());
$('.SeptemberList').load("data/sep_rpt.html?rnd=" + Math.random());
$('.OctoberList').load("data/oct_rpt.html?rnd=" + Math.random());
$('.NovemberList').load("data/nov_rpt.html?rnd=" + Math.random());
$('.DecemberList').load("data/dec_rpt.html?rnd=" + Math.random());
});
</script>
</body>
</html>
HTMLOUTPUTINDEXDASHBOARD
#======================================================
# Single PAGE REPORT HTML TEMPLATE
# Using embedded HTML makes the script highly portable
# SED search and replace tags to fill the content
#======================================================
#2018-Nov-17.html
cat > $HTMLOUTPUTDIR/data/$CURRENTYEAR-$CURRENTMONTH-$CURRENTDAY.html << 'HTMLREPORTDASHBOARD'
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Postfix Report">
<meta name="author" content="">
<link rel="icon" href="http://www.postfix.org/favicon.ico">
<title>Postfix PFLOGSUMM Report</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns"
crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/themes/prism.css">
<style>
body {
padding-top: 5rem;
}
footer {
background-color: #eee;
padding: 25px;
}
.spacer15 {
height: 15px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="../">Postfix Report</a>
</nav>
<!-- Server/Report INFO -->
<div class="container rounded shadow-sm p-3 my-3 text-white-50 bg-dark ">
<div class="row">
<div class="card-body">
<div class="row mb-4">
<div class="col-sm-12">
<div> <strong>Hostname</strong> </div>
<h6 class="mb-3">##ACTIVEHOSTNAME##</h6>
<div> <strong>Report Date</strong> </div>
<div>##REPORTDATE##</div>
<div class="spacer15"></div>
<div>This report exposes email addresses of end users / Please password protect this resource</div>
</div>
</div>
</div>
</div>
</div>
<!-- Server/Report INFO -->
<br>
<!-- Quick Status Blocks -->
<div class="container rounded shadow-sm text-white bg-dark ">
<!-- Row -->
<div class="row counter-box text-center">
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##ReceivedEmail##</span></h5>
<span style="font-size: 0.85em;">Received Email</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##DeliveredEmail##</span></h5>
<span style="font-size: 0.85em;">Delivered Mail</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##ForwardedEmail##</span></h5>
<span style="font-size: 0.85em;">Forwarded Mail</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##DeferredEmailCount##</span></h5>
<span style="font-size: 0.85em;">Deferred ##DeferredEmailDeferralsCount##</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##BouncedEmail##</span></h5>
<span style="font-size: 0.85em;">Bounced Mail</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##RejectedWarningsEmail##</span></h5>
<span style="font-size: 0.85em;">Rejected Warning ##RejectedEmailPercentage##</span>
</div>
</div>
<!-- column -->
</div>
<div class="spacer15"></div>
<!-- Row -->
<div class="row counter-box text-center">
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##RejectedEmailCount##</span></h5>
<span style="font-size: 0.85em;">Rejected Mail ##RejectedEmailPercentage##</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##HeldEmail##</span></h5>
<span style="font-size: 0.85em;">Held Mail</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##DiscardedEmailCount##</span></h5>
<span style="font-size: 0.85em;">Discarded Mail ##DiscardedEmailPercentage##</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##BytesReceivedEmail##</span></h5>
<span style="font-size: 0.85em;">Bytes Received</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##BytesDeliveredEmail##</span></h5>
<span style="font-size: 0.85em;">Bytes Delivered</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##SendersEmail##</span></h5>
<span style="font-size: 0.85em;">Mail Senders</span>
</div>
</div>
<!-- column -->
</div>
<div class="spacer15"></div>
<!-- Row -->
<div class="row counter-box text-center">
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##SendingHostsDomainsEmail##</span></h5>
<span style="font-size: 0.85em;">Sending Hosts/Domains</span>
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-lg-2 col-6">
<div class="">
<h5 class="font-mute text-mute"><span class="counter font-weight-bold">##RecipientsEmail##</span></h5>
<span style="font-size: 0.85em;">Mail Recipients</span>
</div>
</div>
<!-- column -->
</div>
<!-- Quick Status Blocks -->
</div>
<div class="container rounded shadow-sm p-3 my-3 ">
<div class="my-3 p-3 bg-white rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0">Graphs</h6>
<div class="container">
<div class="row">
<div class="col-md-12">
<div id="PerDayTrafficSummaryTableGraph" style="width: auto; height: 400px; "></div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div id="PerHourTrafficDailyAverageTableGraph" style="width: auto; height: 400px;"></div>
</div>
</div>
</div>
</div>
<div class="my-3 p-3 bg-white rounded shadow-sm">
<a data-toggle="collapse" href="#PerDayTrafficSummary" role="button" aria-expanded="false" aria-controls="PerDayTrafficSummary">
<h6 class="border-bottom border-gray pb-2 mb-0">Per-Day Traffic Summary</h6>
</a>
<div class="container collapse" id="PerDayTrafficSummary">
<div class="row">
<div class="col-md-12">
<div class="table-responsive" id="PerDayTrafficSummaryTable">
<table class="table-responsive table-striped table-sm">
<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Received</th>
<th scope="col">Delivered</th>
<th scope="col">Deferred</th>
<th scope="col">Bounced</th>
<th scope="col">Rejected</th>
</tr>
</thead>
<tbody>
##PerDayTrafficSummaryTable##
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="my-3 p-3 bg-white rounded shadow-sm">
<a data-toggle="collapse" href="#PerHourTrafficDailyAverage" role="button" aria-expanded="false"
aria-controls="PerHourTrafficDailyAverage">
<h6 class="border-bottom border-gray pb-2 mb-0">Per-Hour Traffic Daily Average</h6>
</a>
<div class="container collapse" id="PerHourTrafficDailyAverage">
<div class="row">
<div class="col-md-12">
<div class="table-responsive" id="PerHourTrafficDailyAverageTable">
<table class="table-responsive table-striped table-sm">
<thead>
<tr>
<th scope="col">Time</th>
<th scope="col">Received</th>
<th scope="col">Delivered</th>
<th scope="col">Deferred</th>
<th scope="col">Bounced</th>
<th scope="col">Rejected</th>
</tr>
</thead>
<tbody>
##PerHourTrafficDailyAverageTable##
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="my-3 p-3 bg-white rounded shadow-sm">
<a data-toggle="collapse" href="#HostDomainSummaryMessagesReceived" role="button" aria-expanded="false"
aria-controls="HostDomainSummaryMessagesReceived">
<h6 class="border-bottom border-gray pb-2 mb-0">Host/Domain Summary: Messages Received</h6>
</a>
<div class="container collapse" id="HostDomainSummaryMessagesReceived">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table-responsive table-striped table-sm">
<thead>
<tr>
<th scope="col">Message Count</th>
<th scope="col">Bytes</th>
<th scope="col">Host/Domain</th>
</tr>
</thead>
<tbody>
##HostDomainSummaryMessagesReceived##
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="my-3 p-3 bg-white rounded shadow-sm">
<a data-toggle="collapse" href="#SendersbyMessageSize" role="button" aria-expanded="false" aria-controls="SendersbyMessageSize">
<h6 class="border-bottom border-gray pb-2 mb-0">Senders by Message Size</h6>
</a>
<div class="container collapse" id="SendersbyMessageSize">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table-responsive table-striped table-sm">
<thead>
<tr>
<th scope="col">Size</th>
<th scope="col">Sender</th>
</tr>
</thead>
<tbody>
##SendersbyMessageSize##
</tbody>
</table>
</div>
</div>