Hallo miteinander, bei mir werkelt ein Linux-Server u.a. als Router und Firewall. Verständlicherweise möchte ich nicht ständig in /var/log/messages nach Wörtern wie 'DENY' oder 'scanlogd' greppen sondern den Vorgang weitestgehend automatisieren. Mein Ziel ist folgendes: Meldet beispielsweise der scanlogd einen Portscan, so möchte ich möglichst schnell per eMail oder SMS davon unterrichtet werden. Das Tool der Wahl ist wohl der logsurfer. Allerdings habe ich beim Durchstöbern der Man-Page noch keinen Hinweis dazu gefunden, ob und wie ich das Programm in einer Art "daemon mode" laufen lassen kann, so daß die Logfiles quasi ständig ausgewertet werden. Oder gibt es sinnvollere Lösungsansätze, z.B. mit cron? Sicherlich hat doch jemand eine solche Lösung am Laufen... Für Tips, Anregungen, RTFMs und URLs bin ich wie immer dankbar. Ciao, Christian -- Made with a Macintosh... ChriSchmi@t-online.de http://home.t-online.de/home/chrischmi/
Laß ein IDS laufen. Snort ist hier eine vernünftige Wahl Gruß Ralf ----- Original Message ----- From: "Christian Schmidt" <ChriSchmi@t-online.de> To: "Suse-Linux Mailingliste" <suse-linux@suse.com> Sent: Monday, January 29, 2001 1:08 AM Subject: Logfiles ueberwachen
Hallo miteinander, bei mir werkelt ein Linux-Server u.a. als Router und Firewall.
Verständlicherweise möchte ich nicht ständig in /var/log/messages nach Wörtern wie 'DENY' oder 'scanlogd' greppen sondern den Vorgang weitestgehend automatisieren. Mein Ziel ist folgendes: Meldet beispielsweise der scanlogd einen Portscan, so möchte ich möglichst schnell per eMail oder SMS davon unterrichtet werden.
Das Tool der Wahl ist wohl der logsurfer. Allerdings habe ich beim Durchstöbern der Man-Page noch keinen Hinweis dazu gefunden, ob und wie ich das Programm in einer Art "daemon mode" laufen lassen kann, so daß die Logfiles quasi ständig ausgewertet werden.
Oder gibt es sinnvollere Lösungsansätze, z.B. mit cron? Sicherlich hat doch jemand eine solche Lösung am Laufen...
Für Tips, Anregungen, RTFMs und URLs bin ich wie immer dankbar.
Ciao, Christian
-- Made with a Macintosh... ChriSchmi@t-online.de http://home.t-online.de/home/chrischmi/
---------------------------------------------------------------
To unsubscribe, e-mail: suse-linux-unsubscribe@suse.com For additional commands, e-mail: suse-linux-help@suse.com
* Christian Schmidt -- Monday 29 January 2001 01:08:
Das Tool der Wahl ist wohl der logsurfer. Allerdings habe ich beim Durchstöbern der Man-Page noch keinen Hinweis dazu gefunden, ob und wie ich das Programm in einer Art "daemon mode" laufen lassen kann, so daß die Logfiles quasi ständig ausgewertet werden.
Einfach ein kleines Script nach /sbin/init.d/ und die entsprechenden Links in die Runlevel-Ordner, fertig. Ach ja, Deine /etc/logsurfer.conf musst Du natuerlich noch konfigurieren ... #! /bin/sh . /etc/rc.config return=$rc_done case "$1" in start) echo -n "Starting logsurfer" FILE=/var/log/messages LASTLINE=$(cat $FILE|wc -l) startproc -u logsurfer /usr/bin/logsurfer -f $FILE \ -d /tmp/logsurfer.dump -l $LASTLINE -s || return=$rc_failed echo -e "$return" ;; stop) echo -n "Shutting down logsurfer" killproc -TERM /usr/bin/logsurfer || return=$rc_failed echo -e "$return" ;; restart) $0 stop && $0 start || return=$rc_failed ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac test "$return" = "$rc_done" || exit 1 exit 0
Hallo, On Mon, 29 Jan 2001, Melchior FRANZ wrote:
LASTLINE=$(cat $FILE|wc -l)
Useless use of cat! LASTILE=$(wc -l $FILE) ist ausserdem um ca. 1/3tel schneller (wenn das File im filecache ist). CU David, SCNR -- Als ob das so schwer wäre? Rekusion = REKURSIONOISRUKEREKUSIONOIRUKEREKURSION ! Bitte nur das Grossgeschriebene Lesen! So damit haste jetzt ne Weile was zu tun! [WoKo in dag°]
* David Haller -- Monday 29 January 2001 10:45:
* On Mon, 29 Jan 2001, Melchior FRANZ wrote:
LASTLINE=$(cat $FILE|wc -l)
Useless use of cat! LASTILE=$(wc -l $FILE) ist ausserdem um ca. 1/3tel schneller (wenn das File im filecache ist).
Offensichtlicht hast Du beides ausprobiert. Dann haettest Du aber auch erkennen sollen, dass die beiden Varianten =nicht= zur gleichen Ausgabe fuehren: $ wc -l .procmailrc 140 .procmailrc $ cat .procmailrc|wc -l 140 Faellt Dir was auf? Bei meiner Variante fehlt der Dateiname, mit dem der logsurfer nix anzufangen wuesste. Natuerlich koennte man den auch mit cut oder awk abschneiden. Aber dann ist der Zeitvorsprung vermutlich auch dahin ... SCNR m.
Hallo, On Mon, 29 Jan 2001, Melchior FRANZ wrote:
* David Haller -- Monday 29 January 2001 10:45:
* On Mon, 29 Jan 2001, Melchior FRANZ wrote:
LASTLINE=$(cat $FILE|wc -l)
Useless use of cat! LASTILE=$(wc -l $FILE) ist ausserdem um ca. 1/3tel schneller (wenn das File im filecache ist).
Offensichtlicht hast Du beides ausprobiert. Dann haettest Du aber auch erkennen sollen, dass die beiden Varianten =nicht= zur gleichen Ausgabe fuehren:
$ wc -l .procmailrc 140 .procmailrc
$ cat .procmailrc|wc -l 140
Faellt Dir was auf?
Ja.
Bei meiner Variante fehlt der Dateiname, mit dem der logsurfer nix anzufangen wuesste. Natuerlich koennte man den auch mit cut oder awk abschneiden. Aber dann ist der Zeitvorsprung vermutlich auch dahin ...
Aeh, so ja. Wenn du aber auf die Leerzeichen vor der 'wc -l'-Ausgabe verzichten kannst (in diesem Falle wohl gegeben), dann wuerde ich L=$(wc -l /var/log/messages); echo ${L//[\/.a-zA-Z]*/} vorschlagen. Ich muss aber zugeben, dass auch ich ueber die Geschwindigkeit der bash dabei erstaunt bin *vbg* /tmp (0) $ z_bench real 0m4.609s user 0m1.800s sys 0m2.390s real 0m7.099s user 0m2.440s sys 0m3.950s /tmp (0) $ cat z_bench time for i in `seq 99`; do L=$(wc -l messages); echo ${L//[\/.a-zA-Z]*/}>/dev/null; done time for i in `seq 99`; do cat messages | wc -l>/dev/null; done Sogar das geschaetzte Verhaeltnis bestaetigt sich: 0.649 zu 1 ;) Das Zuweisen, ersetzen und dann mit echo Ausgeben scheint sich praktisch nicht bemerkbar zu machen... Achso, die '/tmp/messages' ist schlappe 44444 Zeilen lang und befand sich schon im Cache.
SCNR
dito, aber mit 2(!) Ausrufezeichen CU David, millisekunden zaehlend :)) P.S: nebenher lief seti, hatte aber keine (relevanten) Auswirkungen auf das Verhaeltnis der Laufzeiten... Ohne seti: 0.657 zu 1 und 0.622 zu 1 -- I don't consider NT/Win network maintenance adminning at all. Daily multiple performance of the single finger flip of the power switch to at least get the piece of crap that masquerades as an OS to a level of something approaching stability (unless the gnats are around, and for a very weird #define of stability) is what I call it. Of course, I'm not at work right now, so I'm a little more mellow about it. [Chris Saunderson in the SDM]
Hallo, * David Haller -- Monday 29 January 2001 20:19: [...]
SCNR dito, aber mit 2(!) Ausrufezeichen
CU David, millisekunden zaehlend :)) ^^^^^^^^^^^^^^^^^^^^^^
Hihi, seit wann denn das? Am letzten Dienstag war Dir das aber nicht so wichtig ... $ z_bench real 0m16.739s user 0m7.570s sys 0m7.940s real 0m4.267s user 0m1.300s sys 0m2.670s $ cat z_bench time for i in `seq 99`; do test $(ps ax | grep -ci 'squid') -le 1 ; done time for i in `seq 99`; do test -z "$(/sbin/pidof squid)"; done Verhaeltnis: 1 zu 0.255 ... auch nicht schlecht, oder? SCNR (mit 3 Ausrufezeichen ;-) m. PS: Die schnelle Loesung stammte von mir, gleicher Thread ("Re: shell skript zur über prüfung von prozessen"), gleicher Tag, etwas frueher: 17:17:50.
Hallo, On Mon, 29 Jan 2001, Melchior FRANZ wrote:
* David Haller -- Monday 29 January 2001 20:19: [...]
SCNR dito, aber mit 2(!) Ausrufezeichen
CU David, millisekunden zaehlend :)) ^^^^^^^^^^^^^^^^^^^^^^
Hihi, seit wann denn das? Am letzten Dienstag war Dir das aber nicht so wichtig ... [..] $ cat z_bench time for i in `seq 99`; do test $(ps ax | grep -ci 'squid') -le 1 ; done time for i in `seq 99`; do test -z "$(/sbin/pidof squid)"; done
Verhaeltnis: 1 zu 0.255 ... auch nicht schlecht, oder?
Ja. Stuempt. Nur: $ /sbin/pidof squid bash: /sbin/pidof: Keine Berechtigung SCNR. Ansonsten natuerlich Ack.
SCNR (mit 3 Ausrufezeichen ;-)
*bg* f'up2poster CU David --
Trolle sind die Ratten des Usernetzes. Weil sie alles fressen und die Krankheit der Dummheit verbreiten. Dich siggt hier keiner mehr. [Hilko Bengen zu Woko° in dag°]
On Mon, 29 Jan 2001, Christian Schmidt wrote:
Verständlicherweise möchte ich nicht ständig in /var/log/messages nach Wörtern wie 'DENY' oder 'scanlogd' greppen sondern den Vorgang weitestgehend automatisieren. Mein Ziel ist folgendes: Meldet beispielsweise der scanlogd einen Portscan, so möchte ich möglichst schnell per eMail oder SMS davon unterrichtet werden.
Das Tool der Wahl ist wohl der logsurfer. Allerdings habe ich beim Durchstöbern der Man-Page noch keinen Hinweis dazu gefunden, ob und wie ich das Programm in einer Art "daemon mode" laufen lassen kann, so daß die Logfiles quasi ständig ausgewertet werden.
Oder gibt es sinnvollere Lösungsansätze, z.B. mit cron? Sicherlich hat doch jemand eine solche Lösung am Laufen...
Für Tips, Anregungen, RTFMs und URLs bin ich wie immer dankbar.
In der "smtp-after-pop"-Lösung wird das über eine FIFO-Schnittstelle gemacht, die hier eben das mail.log überwacht ... in der Form könnte ich mir auch ein Lösungs-Ansatz für dein Problem vorstellen... Mit freundlichen Grüßen, Joerg Henner. -- LinuxHaus Stuttgart | Tel.: +49 (7 11) 2 85 19 05 J. Henner & A. Reyer, Datentechnik GbR | D2: +49 (1 72) 7 35 31 09 | Fax: +49 (7 11) 5 78 06 92 Linux, Netzwerke, Consulting & Support | http://linuxhaus.de
participants (5)
-
Christian Schmidt
-
David Haller
-
Joerg Henner
-
Melchior FRANZ
-
Ralf Freisinger