[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hobbit] graph support for later sendmail versions
In setting up the sendmail graphs, I found that some fields introduced
in later sendmail versions were not displayed.
The attached patch to do_sendmail.c will allow the extra field
introduced in sendmail 8.13.x to be graphed. It should also work with
most earlier versions of sendmail back to at least 8.9.x (if you're
running a version that old, it's time to upgrade!)
As we only run 8.13.x in production, I haven't been able to test much
the changes with prior versions of sendmail other than a quick test with
8.11.x.
Regards
Geoff Steer
Firstwave Technology
*** hobbitd/larrd/do_sendmail.c 2005-03-26 08:15:33.000000000 +1100
--- hobbitd/larrd/do_sendmail.c 2005-04-26 10:17:26.000000000 +1000
***************
*** 17,44 ****
"DS:bytes_to:DERIVE:600:0:U",
"DS:msgsrej:DERIVE:600:0:U",
"DS:msgsdis:DERIVE:600:0:U",
rra1, rra2, rra3, rra4, NULL };
int do_sendmail_larrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
! /*
! * The data we process is the output from the "mailstats" command.
! *
! * Statistics from Wed Jun 19 16:29:41 2002
! * M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis Mailer
! * 3 183435 215701K 0 0K 0 0 local
! * 5 0 0K 183435 215544K 0 0 esmtp
! * =============================================================
! * T 183435 215701K 183435 215544K 0 0
! * C 183435 183435 0
! *
! * We pick up those lines that come before the "============" line, and
! * create one RRD per "Mailer", with the counters.
! */
char *bofdata, *eofdata, *eoln;
int done, found;
! unsigned long msgsfr, bytesfr, msgsto, bytesto, msgsrej, msgsdis;
char mailer[1024];
MEMDEFINE(mailer);
--- 17,51 ----
"DS:bytes_to:DERIVE:600:0:U",
"DS:msgsrej:DERIVE:600:0:U",
"DS:msgsdis:DERIVE:600:0:U",
+ "DS:msgsqur:DERIVE:600:0:U",
rra1, rra2, rra3, rra4, NULL };
int do_sendmail_larrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
! /*
! * The data we process is the output from the "mailstats" command.
! *
! * Statistics from Mon Apr 25 16:29:41 2005
! * M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis msgsqur Mailer
! * 3 183435 215701K 0 0K 0 0 0 local
! * 5 0 0K 183435 215544K 0 0 0 esmtp
! * =====================================================================
! * T 183435 215701K 183435 215544K 0 0 0
! * C 183435 183435 0
! *
! * We pick up those lines that come before the "============" line, and
! * create one RRD per "Mailer", with the counters.
! *
! * The output of the mailstats command will depend on the version of sendmail
! * used. This example is from sendmail 8.13.x which added the msgsqur column.
! * Sendmail versions prior to 8.10.0 did not have the mgsdis and msgsrej
! * columns.
! *
! */
char *bofdata, *eofdata, *eoln;
int done, found;
! unsigned long msgsfr, bytesfr, msgsto, bytesto, msgsrej, msgsdis, msgsqur;
char mailer[1024];
MEMDEFINE(mailer);
***************
*** 63,84 ****
eoln = strchr(bofdata, '\n');
if (eoln) {
*eoln = '\0';
! found = sscanf(bofdata, "%*s %lu %luK %lu %luK %lu %lu %s",
! &msgsfr, &bytesfr, &msgsto, &bytesto, &msgsrej, &msgsdis, mailer);
! if (found == 7) {
! sprintf(rrdvalues, "%d:%lu:%lu:%lu:%lu:%lu:%lu",
! (int)tstamp, msgsfr, bytesfr*1024, msgsto, bytesto*1024, msgsrej, msgsdis);
! }
! else {
! msgsrej = msgsdis = 0;
! found = sscanf(bofdata, "%*s %lu %luK %lu %luK %s",
! &msgsfr, &bytesfr, &msgsto, &bytesto, mailer);
!
! if (found == 5) {
! sprintf(rrdvalues, "%d:%lu:%lu:%lu:%lu:U:U",
! (int)tstamp, msgsfr, bytesfr*1024, msgsto, bytesto*1024);
}
- }
if (*rrdvalues) {
sprintf(rrdfn, "sendmail.%s.rrd", mailer);
--- 70,91 ----
eoln = strchr(bofdata, '\n');
if (eoln) {
*eoln = '\0';
! found = sscanf(bofdata, "%*s %lu %luK %lu %luK %lu %lu %lu %s",
! &msgsfr, &bytesfr, &msgsto, &bytesto, &msgsrej, &msgsdis, &msgsqur, mailer);
! if (found == 8) { /* sendmail 8.13.x */
! sprintf(rrdvalues, "%d:%lu:%lu:%lu:%lu:%lu:%lu:%lu",
! (int)tstamp, msgsfr, bytesfr*1024, msgsto, bytesto*1024, msgsrej, msgsdis, msgsqur);
! }
! else if (found == 7) { /* sendmail 8.10.0 */
! msgsqur = 0;
! sprintf(rrdvalues, "%d:%lu:%lu:%lu:%lu:%lu:%lu",
! (int)tstamp, msgsfr, bytesfr*1024, msgsto, bytesto*1024, msgsrej, msgsdis);
! }
! else { /* sendmail prior to 8.10.0 */
! msgsrej = msgsdis = msgsqur = 0;
! sprintf(rrdvalues, "%d:%lu:%lu:%lu:%lu:U:U",
! (int)tstamp, msgsfr, bytesfr*1024, msgsto, bytesto*1024);
}
if (*rrdvalues) {
sprintf(rrdfn, "sendmail.%s.rrd", mailer);
***************
*** 89,95 ****
bofdata = eoln+1;
done = (*bofdata == '\0');
}
! else done=1;
}
if (eofdata) *(eofdata+1) = '=';
--- 96,102 ----
bofdata = eoln+1;
done = (*bofdata == '\0');
}
! else done=1;
}
if (eofdata) *(eofdata+1) = '=';