/* * sma -- Sendmail log analyser * * Copyright (c) 2000 - 2003 Jarkko Turkulainen. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY JARKKO TURKULAINEN ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL JARKKO TURKULAINEN BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Date: 2003/03/22 15:30:37 $ */ #include "sma.h" void html(FILE *fp) { unsigned int j, h; struct host *hptr; const char *wdtab[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; const char *hrtab[] = { "00-01", "01-02", "02-03", "03-04", "04-05", "05-06", "06-07", "07-08", "08-09", "09-10", "10-11", "11-12", "12-13", "13-14", "14-15", "15-16", "16-17", "17-18", "18-19", "19-20", "20-21", "21-22", "22-23", "23-00" }; curr = localtime(&tval); fprintf(fp, "\n"); if (iflag) { /* Print embedded ASCII report */ fprintf(fp, "\n"); } fprintf(fp, "\n" "
\n" " \n" " \n", VERSION); fprintf(fp, "First log entry | \n", tbchar); fprintf(fp, "%s | \n", stripn(ctime(&hptr->ftime))); fprintf(fp, "
Last log entry | \n", tbchar); fprintf(fp, "%s | \n", stripn(ctime(&hptr->ltime))); fprintf(fp, "
" "Alias table rebuilds | \n", tbchar); fprintf(fp, "%d | \n", hptr->alias); fprintf(fp, "
" "Too many hops | \n", tbchar); fprintf(fp, "%d | \n", hptr->hopc); fprintf(fp, "
" "Mail loops | \n", tbchar); fprintf(fp, "%d | \n", hptr->lcerror); fprintf(fp, "
" "Other SYSERR | \n", tbchar); fprintf(fp, "%d | \n", hptr->oserror); fprintf(fp, "
" "Ruleset based rejections | \n", tbchar); fprintf(fp, "%d | \n", hptr->rule); fprintf(fp, "
" "Sendmail daemon restarts | \n", tbchar); fprintf(fp, "%d | \n", hptr->dstart); fprintf(fp, "
\n" "
Inbound messages \n" "
| \n"
" Outbound messages \n" "
| \n"
"
\n\n" " [Index]\n"); fprintf(fp, " [%s]\n\n", hptr->name, hptr->name); } if (epnum) { fprintf(fp, " \n", hptr->name); fprintf(fp, "
Top envelope pairs");
fprintf(fp, "
\n");
fprintf(fp, "
" "Number | \n" "Sender/Recipient | \n" "" "Messages | \n" "" "Transfers (MB) | \n" "" "%% | \n" "|
%d | \n", j+1); fprintf(fp, "%s %s | \n", hptr->setab[j]->fname, hptr->setab[j]->tname);
fprintf(fp, " %d | \n", hptr->setab[j]->num); #ifdef _WIN32 fprintf(fp, "%.2f | \n", (double)hptr->setab[j]->size/1000000); #else fprintf(fp, "%.2Lf | \n", hptr->setab[j]->size/1000000); #endif if (sflag) { fprintf(fp, "%.2f | \n", 100*(float)hptr->setab[j]->size/(float)hptr->osize); fprintf(fp, "%.2f | \n", 100*(float)hptr->setab[j]->num/(float)hptr->onum); fprintf(fp, " \n"); } } fprintf(fp, "
\n\n" " [Index]\n"); fprintf(fp, " [%s]\n\n", hptr->name, hptr->name); } if (lnum) { fprintf(fp, " \n", hptr->name); fprintf(fp, "
Top envelope senders");
if (sef) fprintf(fp, " (filter: %s)
\n", sef);
else fprintf(fp, "
\n");
fprintf(fp, "
" "Number | \n" "Sender | \n" "" "Messages | \n" "" "Transfers (MB) | \n" "" "%% | \n" "|
%d | \n", j+1); fprintf(fp, "%s | \n", hptr->sitab[j]->name); fprintf(fp, "%d | \n", hptr->sitab[j]->num); #ifdef _WIN32 fprintf(fp, "%.2f | \n", (double)hptr->sitab[j]->size/1000000); #else fprintf(fp, "%.2Lf | \n", hptr->sitab[j]->size/1000000); #endif if (sflag) { fprintf(fp, "%.2f | \n", 100*(float)hptr->sitab[j]->size/(float)hptr->isize); fprintf(fp, "%.2f | \n", 100*(float)hptr->sitab[j]->num/(float)hptr->inum); fprintf(fp, " \n"); } } fprintf(fp, "
\n\n" " [Index]\n"); fprintf(fp, " [%s]\n\n", hptr->name, hptr->name); } if (lrnum) { fprintf(fp, " \n", hptr->name); fprintf(fp, "
Top envelope recipients");
if (ref) fprintf(fp, " (filter: %s)
\n", ref);
else fprintf(fp, "
\n");
fprintf(fp, "
" "Number | \n" "Recipient | \n" "" "Messages | \n" "" "Transfers (MB) | \n" "" "%% | \n" "|
%d | \n", j+1); fprintf(fp, "%s | \n", hptr->sotab[j]->name); fprintf(fp, "%d | \n", hptr->sotab[j]->num); #ifdef _WIN32 fprintf(fp, "%.2f | \n", (double)hptr->sotab[j]->size/1000000); #else fprintf(fp, "%.2Lf | \n", hptr->sotab[j]->size/1000000); #endif if (sflag) { fprintf(fp, "%.2f | \n", 100*(float)hptr->sotab[j]->size/(float)hptr->osize); fprintf(fp, "%.2f | \n", 100*(float)hptr->sotab[j]->num/(float)hptr->onum); fprintf(fp, " \n"); } } fprintf(fp, "
\n\n" " [Index]\n"); fprintf(fp, " [%s]\n\n", hptr->name, hptr->name); } if (rpnum) { fprintf(fp, " \n", hptr->name); fprintf(fp, "
Top relay pairs");
fprintf(fp, "
\n");
fprintf(fp, "
" "Number | \n" "Sender relay/Recipient relay | \n" "" "Messages | \n" "" "Transfers (MB) | \n" "" "%% | \n" "|
%d | \n", j+1); fprintf(fp, "%s %s | \n", hptr->srtab[j]->fname, hptr->srtab[j]->tname);
fprintf(fp, " %d | \n", hptr->srtab[j]->num); #ifdef _WIN32 fprintf(fp, "%.2f | \n", (double)hptr->srtab[j]->size/1000000); #else fprintf(fp, "%.2Lf | \n", hptr->srtab[j]->size/1000000); #endif if (sflag) { fprintf(fp, "%.2f | \n", 100*(float)hptr->srtab[j]->size/(float)hptr->osize); fprintf(fp, "%.2f | \n", 100*(float)hptr->srtab[j]->num/(float)hptr->onum); fprintf(fp, " \n"); } } fprintf(fp, "
\n\n" " [Index]\n"); fprintf(fp, " [%s]\n\n", hptr->name, hptr->name); } if (rnum) { fprintf(fp, " \n", hptr->name); fprintf(fp, "
Top relay addresses, sender");
if (srf) fprintf(fp, " (filter: %s)
\n", srf);
else fprintf(fp, "
\n");
fprintf(fp, "
" "Number | \n" "Relay | \n" "" "Messages | \n" "" "Transfers (MB) | \n" "" "%% | \n" "||
%d | \n", j+1); fprintf(fp, "%s | \n", hptr->rsitab[j]->name); fprintf(fp, "%d | \n", hptr->rsitab[j]->num); #ifdef _WIN32 fprintf(fp, "%.2f | \n", (double)hptr->rsitab[j]->size/1000000); #else fprintf(fp, "%.2Lf | \n", hptr->rsitab[j]->size/1000000); #endif if (sflag) { fprintf(fp, "%.2f | \n", 100*(float)hptr->rsitab[j]->size/(float)hptr->isize); } else { fprintf(fp, "%.2f | \n", 100*(float)hptr->rsitab[j]->num/(float)hptr->rinum); } fprintf(fp, "
\n\n" " [Index]\n"); fprintf(fp, " [%s]\n\n", hptr->name, hptr->name); } if (rrnum) { fprintf(fp, " \n", hptr->name); fprintf(fp, "
Top relay addresses, recipient");
if (rrf) fprintf(fp, " (filter: %s)
\n", rrf);
else fprintf(fp, "
\n");
fprintf(fp, "
" "Number | \n" "Relay | \n" "" "Messages | \n" "" "Transfers (MB) | \n" "" "%% | \n" "||
%d | \n", j+1); fprintf(fp, "%s | \n", hptr->rsotab[j]->name); fprintf(fp, "%d | \n", hptr->rsotab[j]->num); #ifdef _WIN32 fprintf(fp, "%.2f | \n", (double)hptr->rsotab[j]->size/1000000); #else fprintf(fp, "%.2Lf | \n", hptr->rsotab[j]->size/1000000); #endif if (sflag) { fprintf(fp, "%.2f | \n", 100*(float)hptr->rsotab[j]->size/(float)hptr->osize); } else { fprintf(fp, "%.2f | \n", 100*(float)hptr->rsotab[j]->num/(float)hptr->ronum); } fprintf(fp, "
\n\n" " [Index]\n"); fprintf(fp, " [%s]\n\n", hptr->name, hptr->name); } if (stnum) { fprintf(fp, " \n", hptr->name); fprintf(fp, "
Top status messages");
fprintf(fp, "
\n");
fprintf(fp, "
" "Number | \n" "Msgs | \n" "%% | \n" "" "Status | \n" "
%d | \n", j+1); fprintf(fp, "%d | \n", hptr->ssttab[j]->num); fprintf(fp, "%.2f | \n", 100*(float)hptr->ssttab[j]->num/(float)hptr->onum); fprintf(fp, "%s | \n", hptr->ssttab[j]->name); fprintf(fp, "
\n\n" " [Index]\n"); fprintf(fp, " [%s]\n\n", hptr->name, hptr->name); } if (rsnum) { fprintf(fp, " \n", hptr->name); fprintf(fp, "
Top ruleset rejections");
fprintf(fp, "
\n");
fprintf(fp, "
" "Number | \n" "Msgs | \n" "%% | \n" "" "%s | \n" "
%d | \n", j+1); fprintf(fp, "%d | \n", hptr->sruletab[j]->num); fprintf(fp, "%.2f | \n", 100*(float)hptr->sruletab[j]->num/(float)hptr->rule); fprintf(fp, ""); while (*(hptr->sruletab[j]->name) != '\0') { if (*(hptr->sruletab[j]->name) == '<') fprintf(fp, "<"); else if (*(hptr->sruletab[j]->name) == '>') fprintf(fp, ">"); else fputc(*(hptr->sruletab[j]->name), fp); hptr->sruletab[j]->name++; } fprintf(fp, " | \n"); fprintf(fp, "
\n"); fprintf(fp, " | %d | \n", hptr->sruletab[j]->srrelaytab[h]->num); fprintf(fp, "%.2f | \n", 100*(float)hptr->sruletab[j]->srrelaytab[h]->num/(float)hptr->sruletab[j]->num); fprintf(fp, "%s | \n", hptr->sruletab[j]->srrelaytab[h]->name); fprintf(fp, "
\n\n" " [Index]\n"); fprintf(fp, " [%s]\n\n", hptr->name, hptr->name); } if (!nflag) { fprintf(fp, "
\n", hptr->name); fprintf(fp, "
Inbound messages per day \n" "
| \n"
" Outbound messages per day \n" "
| \n"
"
\n" "
Inbound messages per hour \n" "
| \n"
" Outbound messages per hour \n" "
| \n"
"
\n\n"
" [Index]\n");
fprintf(fp, " [%s]\n\n", hptr->name, hptr->name);
}
fprintf(fp, "