Debian logcheck ignore file for sSMTP
On a server, I use logcheck to get an email based on logfile analysis if anything goes wrong and doesn’t fit the usual patterns. In addition, I use sSMTP to forward all sent mails to my mailserver. Unfortunately, this solution ends up in sending a mail like the following every hour because of a bug in logcheck’s ignorefile for sSMTP.
Dec 12 22:02:06 hostname sSMTP[22391]: Sent mail for logcheck@hostname (221 2.0.0 Bye) uid=101 username=logcheck outbytes=639
To fix this, I replaced the contents of the file /etc/logcheck/ignore.d.server/ssmtp with the following lines:
^w{3} [0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [a-zA-Z0-9]+ sSMTP[[0-9]+]: Sent mail for logcheck@.*$
^w{3} [0-9] [0-9]{2}:[0-9]{2}:[0-9]{2} [a-zA-Z0-9]+ sSMTP[[0-9]+]: Sent mail for logcheck@.*$
I removed the other lines, because sSMTP shouldn’t do anything else on the system and if it would, I’d like to be informed. If you need more ignore patterns you might have to keep/edit some of the original lines.
Notepad++: Code durch RegEx bereinigen
Obwohl ich mit regulären Ausdrücken schon immer auf Kriegsfuß gestanden bin, habe ich gerade mit der RegEx Search&Replace Funktion von Notepad++ rumgespielt um meinen Code etwas aufzuräumen. Konkret wollte ich folgendes erreichen, einfach weil es sich besser lesen lässt und übersichtlicher ist:
[code lang='php']
// altes Schema: öffnende Klammern in der gleichen Zeile
function doSomeThing($params) {
while(true) {
do();
}
}
// neues Schema: öffnende Klammern in neuer Zeile
function doSomeThing($params)
{
while(true)
{
do();
}
}
[/code]
Also CTRL+H gedrückt und folgendes eingegeben:
Search: ^(t*)(.*)(s*){
Replace: 12n1{
Und schwupps … tausende Zeilen Code bereinigt. Bis jetzt sieht’s gut aus, mal sehen wann ich drauf komme, dass sich ein gravierender Fehler eingeschlichen hat und ich alles per Hand durchgehen kann ;-)