PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Logiciels d'hébergement > comp.mail.sendmail > Converting sendmail logs to SQL
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.mail.sendmail Configuring and using the BSD sendmail agent.

Converting sendmail logs to SQL

Réponse
 
LinkBack Outils de la discussion
Vieux 24/08/2007, 02h01   #1
kelly.terry.jones
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Converting sendmail logs to SQL

Sendmail's default logging is ugly, because the logs for a single
message are spread across several lines. If I want to find emails
from
x@x.com to y@y.com, I can't do:

grep x@x.com /var/log/maillog | grep y@y.com

because the sender and recipient aren't on the same log line.
Instead,
you have to do:

grep x@x.com /var/log/maillog | tee somefile.txt

extract the message ids from somefile.txt to msgids.txt and then do

grep -f msgids.txt /var/log/maillog | grep y@y.com

or something similar.

An obvious workaround would be to put the logs into an SQL db (each
record would represent one message, and have columns for message id,
sender, recipient, sending relay, receiving relay, message status,
xdelay, etc. Then I could do:

SELECT * FROM logs WHERE sender = 'x@x.com' AND recipent = 'y@y.com';

Is there any open source software that does this? I believe splunk
and
some other commercial products may do this, but I'm looking for
something open source.

  Réponse avec citation
Vieux 24/08/2007, 21h45   #2
Per Hedeland
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Converting sendmail logs to SQL

In article <1187917309.343053.6130@q5g2000prf.googlegroups.co m>
"kelly.terry.jones" <kelly.terry.jones@gmail.com> writes:
>Sendmail's default logging is ugly, because the logs for a single
>message are spread across several lines.


Well, that's because it's, uh, a log - and all things don't happen to a
message at a single point in time.

> If I want to find emails
>from
>x@x.com to y@y.com, I can't do:
>
>grep x@x.com /var/log/maillog | grep y@y.com
>
>because the sender and recipient aren't on the same log line.
>Instead,
>you have to do:
>
>grep x@x.com /var/log/maillog | tee somefile.txt
>
>extract the message ids from somefile.txt to msgids.txt and then do
>
>grep -f msgids.txt /var/log/maillog | grep y@y.com
>
>or something similar.


I occasionally use the perl script below - it prints all lines for a
message if one of them matches the given pattern, so it doesn't quite do
what you want (match on the combined lines), but could easily be changed
to do so. However it will read the complete log into memory, so will
probably not be usable by really high-volume sites.

>An obvious workaround would be to put the logs into an SQL db (each
>record would represent one message, and have columns for message id,
>sender, recipient, sending relay, receiving relay, message status,
>xdelay, etc. Then I could do:
>
>SELECT * FROM logs WHERE sender = 'x@x.com' AND recipent = 'y@y.com';


Well, in general messages may have multiple recipients (one of the
reasons for the multiple log lines, since delivery to different
recipients may be days apart), but you could probably handle that
somehow.

>Is there any open source

matching entries may be good enough if your volume isn't too high.
otherwise you software that does this? I believe splunk
>and
>some other commercial products may do this, but I'm looking for
>something open source.


I don't know of anything like that (which doesn't mean anything since
I've never looked for it). But it doesn't seem like a difficult problem,
assuming you know how to feed data into your SQL db. Using a syslogd
implementation that allows you to specify a program/script to be fed
matching entries, and a bit of regexp matching in that program/script,
should do the trick. FreeBSD syslogd has this funtionality, as well as
syslog-ng that can be used on on a variety of Unices.

--Per Hedeland
per@hedeland.org

------------------------
#!/usr/bin/perl

$pattern = shift;

while (<>) {
split;
$id = $_[5];
$lines{$id} .= $_;
if (!$want{$id} && /$pattern/o) {
$want{$id} = 1;
$wantid[++$n] = $id;
}
}
for ($i = 1; $i <= $n; $i++) {
print $lines{$wantid[$i]};
}
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h28.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09248 seconds with 10 queries