Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Write syslog ng logs to the MySQL (remote) database

2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Centos6.5

Syslog-ng 3.25

Mysql

1,yum install syslog-ng.x86_64

2Jing yum install mysql.x86_64 / / supports mysql command to run

3Mkfifo-m 777 / var/log/mysql.pipe / / create a channel and grant permissions

4, logsys-ng.conf / / modify the configuration file

/ / Source

Source s_sys {

File ("/ proc/kmsg" program_override ("kernel:"))

Unix-stream ("/ dev/log")

Internal ()

# udp (ip (0.0.0.0) port (514)

}

/ / use the default rules, or you can write them yourself

Filter f_default {level (info..emerg) and

Not (facility (mail))

Or facility (authpriv)

Or facility (cron);}

/ / Transmission destination

Destination mysql {

Program ("mysql-h20.10.10.10-uxxxxx-pxxxxx table < / var/log/mysql.pipe")

Pipe ("/ var/log/mysql.pipe"

Template ("INSERT INTO w_sys_logs (host, facility, priority, level, tag)

Datetime, program, msg) VALUES ('$HOST','$FACILITY','$PRIORITY'

'$LEVEL',' $TAG','$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC','$PRORAM'

'$MSG'); n ") template-escape (yes);}

/ / table is the database name

/ / message combination

Log {source (s_sys); filter (f_default); destination (mysql);}

/ / create a database

DROP TABLE IF EXISTS `wpragsys _ logs`

CREATE TABLE `wpragsys _ logs` (

`id` bigint (20) unsigned NOT NULL AUTO_INCREMENT

`host` varchar (32) DEFAULT NULL

`roomy` varchar (10) DEFAULT NULL

`priority` varchar (10) DEFAULT NULL

`level` varchar (10) DEFAULT NULL

`tag` varchar (10) DEFAULT NULL

`datetime` datetime DEFAULT NULL

`program` varchar (15) DEFAULT NULL

`msg` text

PRIMARY KEY (`id`)

KEY `host` (`host`)

KEY `program` (`program`)

KEY `datetime` (`datetime`)

KEY `priority` (`priority`)

KEY `roomy` (`roomy`)

) ENGINE=InnoDB AUTO_INCREMENT=81 DEFAULT CHARSET=utf8

For reprint, please indicate: http://8463390.blog.51cto.com/8453390/1911623

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report