PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : mit syslog-ng logs in mysql Datenbank



urias
17.01.06, 07:49
Hi,

ich bin auf durch ein Programm auf die Idee gekommen die syslog-ng logs in mysql Datenbank zu schreiben, und habe dazu im Netz auch ein nettes kleines howto gefunden, welches mit dem Programm (http://freshmeat.net/projects/php-syslog-ng/)



To setup syslog-ng to log to a mysql database. This assumes that you have installed and setup syslog-ng and mysql.

Edit the syslog-ng.conf file
This tells syslog-ng to pipe to a fifo template

Add the following lines --

## Log syslog-ng to mysql database
##
destination d_mysql {pipe("/tmp/mysql.pipe" template("INSERT INTO logs (host, facility, priority, level, tag, date, time, program, msg) VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY', '$HOUR:$MIN:$SEC', '$PROGRAM', '$MSG' );\n") template-escape(yes));
};
log { source(net); destination(d_mysql);
};


Then comment out this line --

# This is the default behavior of sysklogd package
# Logs may come from unix stream, but not from another machine.
#
#source src { unix-dgram("/dev/log"); internal(); };


# If you wish to get logs from remote machine you should uncomment
# this and comment the above source line.
#
source src { unix-dgram("/etc/log/log"); internal(); };
source net { udp(); };


[Datenbankstruktur]



Create a fifo pipe file --
This is the file that syslog-ng will store records before writing to the database.

mkfifo /tmp/mysql.pipe

You need to restart syslog-ng --

/etc/init.d/syslog-ng stop # Stop syslog-ng
/etc/ini.d/syslog-ng start # Start syslog-ng

Run this command to pipe the file mysql.pipe to mysql database

You need to create a script that will check to make sure this command is running and restart if stopped.
Syslog-ng/Pipe scripts

When this file is started it will hang, You need to create a script and have it run on startup.

mysql -u root --password=passwd syslog < /tmp/mysql.pipe


vorab zum Verständis:


Then comment out this line --

# This is the default behavior of sysklogd package
# Logs may come from unix stream, but not from another machine.
#
#source src { unix-dgram("/dev/log"); internal(); };


# If you wish to get logs from remote machine you should uncomment
# this and comment the above source line.
#
source src { unix-dgram("/etc/log/log"); internal(); };
source net { udp(); };

:?:

mache ich das nun, kriege ich leider nur ein



router:/var/www/syslog/docs# /etc/init.d/syslog-ng restart
CONSOLE_LOG_LEVEL is of unaccepted value.
KERNEL_RINGBUF_SIZE is of unaccepted value.
Stopping system logging: syslog-ng not running.
Starting system logging: syslog-ngunresolved reference: net
Error initializing configuration, exiting.
start failed.
:(

weitere howtos konnte ich nicht finden, und in der Doku zum syslog-ng wurde ich bisher auch nicht so recht fündig.
Hat wer sowas schonmal gemacht und gelöst und könnte mir weiterhelfen?
Oder hat eine Idee, was mich weiterbringen könnte?

danke
urias

marce
17.01.06, 08:19
was steht denn bei den angemeckerten Parametern in der Config vom Syslog-NG?

urias
17.01.06, 08:37
was steht denn bei den angemeckerten Parametern in der Config vom Syslog-NG?

Du meinst


CONSOLE_LOG_LEVEL is of unaccepted value.
KERNEL_RINGBUF_SIZE is of unaccepted value.


leider garnichts, sie kommen in der config nicht vor.
Der Fehler tritt auch nur auf, wenn ich den oben beschriebenen mysql krams einfüge, kommentiere ich den wieder aus, rennt der syslog wieder.

und


unresolved reference: net

denke ich mal bezieht sich auf

log {
source(net); destination(d_mysql);
};

am Ende der config.

edit 2.3.2007:
Die Links sind ungültig!
ich werde versuchen in nächster Zeit die neuen zu posten(sobald es welche gibt)

Wenn wer Interesse hatte, ist hier http://gaudystr.homeip.net/syslog/syslog-ng.conf die ganze config hinterlegt.

edit
unter http://gaudystr.homeip.net/syslog/docs/SYSLOG-NG-MYSQL liegt da auch die Doku nach der ich vorgehe.
/edit

urias
17.01.06, 10:25
google brachte mich auch heute morgen nicht weiter, wohl aber die manuelle Suche in einigen Foren.
Werde wenn ich wieder daheim bin mir mal folgendes anschauen

http://forums.gentoo.org/viewtopic-t-422805-highlight-syslog+mysql.html
(auf gentoo bezogen...)

rex6969
27.02.07, 01:29
Hallo Leute !

Also meine Frage zum Thema ist:

Wie schaut die Sache in der Praxis auS ? - Sprich der SQL Server ist auf einem anderen Server ... keine pipes usw ...

lg,
Rex

urias
02.03.07, 11:21
Das kannst Du machen wie Du willst.

Wenn Du sql über ein öffentliches Netz auf einen remote-Rechner loggst, würde ich Dir empfehlen, das ganze zu verschlüsseln.
Wie es da mit syslog-ng von Haus aus aussieht, weiß ich jedoch nicht.

Mein "Plan" war es, neben den logdateien, lokal auf einem mysql zu loggen, und die Daten dann von da weiterzusenden, alternativ über vpn direkt auf einen remote zu loggen.

Leider kam ich in den letzten Monaten nicht dazu, mich weiter mit dem Thema auseinanderzusetzen.

PS: ich habe die Links die inzwischen ungültig geworden sind per edit in meinem obigeb Beitrag entsprechend markiert

newbie2007
20.08.08, 19:19
Hallo @ll,
hat jemand eine Idee, wie man das ohne pipe realisieren kann, als Vorlage dachte ich an den Post von ( Gunnar Grimm vom 26.10.2007 ) unter folgendem Link: http://www.vertical-visions.de/2007/09/28/syslog-ng-phpsyslog-ng-mysql/
Doch leider funkt das so nicht, villeicht kann mir jemand von euch der das schon so realisiert hat weiterhelfen.

danke newbie2007

Roger Wilco
21.08.08, 01:06
Warum unbedingt syslog-ng? Es gibt doch schon einige Syslog-Daemons, die von Haus aus in eine relationale Datenbank schreiben können, etwa rsyslog (http://www.rsyslog.com/).

Jigsore
21.08.08, 10:00
rsyslog (http://www.rsyslog.com/).
Danke für den Link. Sieht sehr interessant aus.