分类: 网络与安全
2009-07-09 14:00:12
Code: |
$syslogdb_type = 'mysql'; $syslogdb_default = 'syslog'; $syslogdb_hostname = 'localhost'; $syslogdb_username = ' $syslogdb_password = ' |
Code: |
shell> mysqladmin --user=root create syslog shell> mysql syslog < |
Code: |
shell# mysql --user=root --password Enter password: ******** mysql> GRANT ALL ON mysql> flush privileges; mysql> exit |
Code: |
/sbin/syslogtomysql & |
Code: |
killall -9 syslogtomysql > /dev/null |
Code: |
#!/bin/bash if [ ! -e /tmp/mysql.pipe ]; then mkfifo /tmp/mysql.pipe fi while [ -e /tmp/mysql.pipe ] do mysql -u done |
Code: |
shell> chmod 755 /sbin/syslogtomysql shell> chown root:root /sbin/syslogtomysql |
Code: # syslog-ng configuration file. |
source net { udp(); }; destination d_mysql { pipe("/tmp/mysql.pipe" template("INSERT INTO syslog_incoming (host, facility, priority, date, time, message) VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$YEAR-$MONTH-$DAY', '$HOUR:$MIN:$SEC', '$MSG' );\n") template-escape(yes) ); }; log { source(net); destination(d_mysql); }; log { source(s_sys); destination(d_mysql); }; |
Code: |
shell> service syslog-ng restart |
Code: |
shell> kill -HUP syslog-ng |
Code: |
$plugins[] = 'syslog'; |
Code: |
shell> chown -R shell> chmod -R 644 |