RSS구독하기:SUBSCRIBE TO RSS FEED
즐겨찾기추가:ADD FAVORITE
글쓰기:POST
관리자:ADMINISTRATOR

# Syslog-Host with Syslog-NG and MySQL


When administrating a larger farm of servers, not only the security gain gives enough reasons to archive syslog messages at a central location: after a remote server has been compromised those logs may not be altered by the attacker. Additionally, logs may be analyzed over all hosts at the same time.

 

To achieve this goal, I rely on Syslog-NG. There are alternatives like rsyslog, but those do not offer the same level of comfort.

With Debian Wheezy, which has been released on May 4th (pun intended, I think), the setup and administration of such a central loghost has been simplified.

Syslog-NG now utilizes, amongst other packages, a new configuration layout, which includes all files in the directory /etc/syslog-ng/conf.d/ in the main configuration file. The main config file doesn’t have to be altered any more.

On every system, which has to send its syslog messages to our new central loghost, we install the package “syslog-ng-core” and create the file  /etc/syslog-ng/conf.d/10syslognet.conf with the following contents (change the IP address!):
1.destination d_net { udp("62.146.15.2" port(514) log_fifo_size(1000)); };
2.log { source(s_src); destination(d_net); };


This defines a new “destination” for sending messages to a remote IP address. Instead of an IPv4 address, one may also use “udp6()” and an IPv6 address. Additionally, the command “log()” instructs Syslog-NG to send all messages received by the source “s_src” to the destination “d_net“, which is the target central loghost.

After a restart of the service, Syslog-NG tries to send the messages over the network. Now we have to configure the destination itself.

Beforehand, we install Syslog-NG with the following module:
1.aptitude install syslog-ng-core syslog-ng-mod-sql


Afterwards, we create /etc/syslog-ng/conf.d/05loghost.conf with the specified content:
1.source s_net { udp( ip("62.146.15.2") port(514)); );
2.destination hosts_syslog { file("/var/logs/$HOST/$YEAR/$MONTH/$DAY/syslog" owner(root) group(root) perm(0644) dir_perm(0700) create_dirs(yes)); };
3.log {source(s_net); source(s_src); destination(hosts_syslog); };


Again, to achieve best results, the IP-address has to be changed and possibly the full path to the new log directory as well.

After the service restart, Syslog-NG now accepts syslog messages at the specified IP address and saves them in our predefined folder structure: each source IP / hostname, year, month and day we will have a single folder. This allows us an easy search as well as an easy archive of the data.

As you probably have noticed, Syslog-NG only creates a folder for each remote IP address sending syslog messages. This may get a bit confusing, so we tell Syslog-NG to perform a ReverseDNS query and use the resulting DNS name as the folder name. Edit /etc/syslog-ng/syslog-ng.conf (yes, this is main configuration file, contrary to the initial statement) and change the following paramaters in the section options{} from no to yes:
1.use_dns(no); use_fqdn(no);


To simplify the search, storing messages in the database is an option as well. A new destination is required as well as a filter, which reduces the size of our database:
1.filter f_no_debug { not level(debug); };
2.destination d_mysql {
3.sql(
4.type(mysql)
5.username("logs")
6.password("SECUREPASSWORD")
7.database("logs")
8.host("localhost")
9.table("logs")
10.columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg")
11.values("$HOST", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG","$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC","$PROGRAM", "$MSG")
12.indexes("datetime", "host", "program", "pid", "message")
13.);
14.};
15.log {source(s_net); source(s_src); filter(f_no_debug); destination(d_mysql); };


How to insert and create the appropriate MySQL username and password should be clear – or is at least not part of this tutorial :)

The required MySQL table looks the following:
1.CREATE TABLE `logs` (
2.`host` varchar(32) DEFAULT NULL,
3.`facility` varchar(10) DEFAULT NULL,
4.`priority` varchar(10) DEFAULT NULL,
5.`level` varchar(10) DEFAULT NULL,
6.`tag` varchar(10) DEFAULT NULL,
7.`datetime` datetime DEFAULT NULL,
8.`program` varchar(15) DEFAULT NULL,
9.`msg` text,
10.`seq` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
11.PRIMARY KEY (`seq`),
12.KEY `host` (`host`),
13.KEY `program` (`program`),
14.KEY `datetime` (`datetime`),
15.KEY `priority` (`priority`),
16.KEY `facility` (`facility`)
17.) ENGINE=InnoDB DEFAULT CHARSET=utf8;


After a restart of Syslog-NG, new messages will appear not only in the file system, but the database as well.

If Syslog-NG exits (or logs in /var/log/syslog) an error message like “no such file“, it is missing the DBI database drivers. For Debian Wheezy, we install them with the following command:
1.aptitude install libdbi1 libdbd-mysql


At the end, an additional remark: I found a lot of tutorials or how-tos how to write log messages to a MySQL database using Syslog-NG. None (none I found!) relied on the native solution, but used either a pipe (Syslog-NG writes messages to a FIFO-pipe, where a second daemon reads the contents and performs the actual MySQL insertion) or – worse – use the MySQL client binary. With the MySQL client, Syslog-NG starts the binary for each received syslog message, resulting in a start of the binary, which has to connect to the database, perform the insert query, disconnect and exit the program. This overhead of starting, connecting, disconnecting and exiting is prevented with the native solution, resulting in a better performance and a lower system load :)

Actually, I still miss the “perfect” GUI to display the logs in the database. Currently we are using LogAnalyzer, but this solution does not work that great (e.g., search in 7 days of logs take more than 30 seconds, so the LogAnalyzer cancels the query without any result). Creating a new solution just for accessing the stored logs is achievable.
 

 

Post navigation

← Nginx für alle! the language of the target audience →
 

2 thoughts on “Syslog-Host with Syslog-NG and MySQL”

 

@Tacioandrade_  
 
 January 10, 2014 at 3:14 pm  
 

Good day friend, I managed to install syslog-ng to your tutorial and am using LogAnalyzer also for viewing, it is not perfect, more should initially serve my purpose.
 Curious customers in how to proceed in the configuration so they send their logs to the server? I have to install syslog-ng them as well?

Thank you in advance for help.
 
Reply 
 


Anton Dollmaier  
 
 January 10, 2014 at 9:04 pm  
 

Yes, each server sending the logs to your new central loghost has to be configured to forward its local messages.

See the section with “destination d_net” in the tutorial. Instead of syslog-ng, rsyslog works as well with the following directive:
1.*.* @1.2.3.4

2014/07/17 14:09 2014/07/17 14:09
http://zosel.net/trackback/147
from.Ugg Brescia  2015/11/09 21:16
latest nike free run
from.モンクレール レディース アウトレット  2015/11/09 22:53
うわー、気難しい What is my IP address - determine or retrieve my IP address のおかげでそれを維持。
from.Ugg Non Originali  2015/11/09 23:47
where to buy cheap nike shoes online
from.Ugg Stivali Outlet  2015/11/10 03:53
cheap nike air max.com
from.buy birkenstocks  2015/11/10 05:54
buy birkenstocks online
from.Ugg Sito Ufficiale  2015/11/10 07:18
nike factory outlet near me
from.UGG コーディネート  2015/11/10 07:36
I was gone to inform my little brother, that he should also pay a quick visit this web site on regular basis to obtain updated from most up-to-date information ::: ZOSEL ::: :: .
from.Outlet Ugg  2015/11/10 08:27
price of nike air max 2014
from.Boots Ugg Online.Buy-Outlet  2015/11/10 08:27
nike air max 2014 wholesale
from.Vendo Ugg  2015/11/10 09:04
nike air max slip on
from.birkenstocks on sale  2015/11/10 09:39
http://birkenstockaustraliamalls.com/
from.birkenstock best price  2015/11/10 10:09
birkenstock sale clearance
from.Vendita Ugg Online  2015/11/10 16:30
women white nike air max
from.Imitazioni Ugg  2015/11/10 17:58
barefoot running shoes nike
from.Sneakers Ugg Australia  2015/11/10 18:43
nike shok
from.louis vuitton vesker  2015/11/10 19:34
What is my IP address - determine or retrieve my IP address
from.roger vivier shoes  2015/11/10 22:25
What is my IP address - determine or retrieve my IP address
from.parajumpers salg  2015/11/10 22:50
What is my IP address - determine or retrieve my IP address
from.Scarpe Tipo Ugg  2015/11/10 23:03
nike 5.0 running shoes
from.Outlet Ugg Online  2015/11/10 23:44
buy nike air max 2013 online
from.Ugg Mini Nero  2015/11/11 00:29
san leandro nike outlet store
from.parajumpers jakke  2015/11/11 02:12
What is my IP address - determine or retrieve my IP address
from.Apple+watch エルメス  2015/11/11 04:19
I always spent my half an hour to read this web site content What is my IP address - determine or retrieve my IP address every day along with a cup of coffee.
from.Mocassino Ugg  2015/11/11 06:56
nike 3.0
from.Ugg 38  2015/11/11 07:35
womens nike free run 3 cheap
from.Ugg Shop  2015/11/11 08:56
nike air max shox
from.バーバリーアウトレット  2015/11/12 04:27
One other method in support of advertising your weblog ::: ZOSEL ::: :: is posting comments on unique directories with your blog link.
from.crack photoshop cc  2016/05/08 19:15
I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…
from.Business news  2018/07/03 13:05
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.newborn baby sleeping bag  2019/11/17 11:13
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.biocides  2019/11/20 22:33
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.shop the north face womens vault backpack tnf black heather burnt  2019/11/24 08:49
<a href="http://www.conocerparasaber.com/bronx/men-christian-louboutin-sneakers-44-red-bottom-louis-black">men christian louboutin sneakers 44 red bottom louis black</a><a href="http://www.conocerparasaber.com/brookwood/laptop-backpacks-for-men-women-t...
from.joker cosplay girl  2019/12/01 23:16
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.black widow original costume  2019/12/03 18:37
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.batman arkham knight harley quinn costume  2019/12/04 13:08
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.real black panther costume  2019/12/05 04:11
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.harley quinn arkham knight  2019/12/05 13:04
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.the flash costume child  2019/12/05 13:06
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.espadrillas valencia alpargatas con suela de goma  2019/12/28 15:59
<a href="http://www.globaluniquenews.com/blackrock/precioso-gucci-bolsos-de-las-mujeres-verde-06c-acaba-de-comprar">precioso gucci bolsos de las mujeres verde 06c acaba de comprar</a><a href="http://www.globaluniquenews.com/bosco/ophidia-gg-shoulder-bo...
from.스포츠토토  2019/12/28 16:21
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.사다리사이트  2019/12/29 04:29
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.hawkeye and black widow costume  2020/01/14 04:19
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.spider-man costume  2020/01/14 11:39
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.deadpool costumes for  2020/01/16 16:47
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.lego dimensions ninjago zane fun pack  2020/01/17 00:13
<a href="http://www.chandnews.com/arrowhead/sdcc-2016-lego-exclusive-brickheadz-41490-superman-wonder-woman-sealed">sdcc 2016 lego exclusive brickheadz 41490 superman wonder woman sealed</a><a href="http://www.chandnews.com/atkinson/lego-new-lego-frien...
from.click the following webpage  2020/01/17 03:59
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.http://Audio-Component.com  2020/01/17 10:47
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.remy hair extensions  2020/01/17 18:28
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.scarlet witch costume child  2020/01/18 10:29
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.all spiderman suits  2020/01/19 05:20
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.the flash costume mens  2020/01/19 15:48
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.the flash costume mask  2020/01/19 16:09
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.talking to  2020/01/19 20:39
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.spiderman costumes  2020/01/19 22:22
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.just click the up coming post  2020/01/21 18:29
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.new joker suit  2020/01/23 15:45
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.spider-man costume  2020/01/24 09:42
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.watch this video  2020/01/25 18:46
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.ronald reagan bolo tie  2020/01/25 19:12
<a href="http://www.accuscanutah.com/luray/the-north-face-ua-old-skool-mte-dx-tr">the north face ua old skool mte dx tr</a><a href="http://www.accuscanutah.com/maeser/vans-online-summer-sandals-womens">vans online summer sandals womens</a><a href="http...
from.spider-man costumes  2020/01/26 14:02
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.tomy walkabout mini baby monitor for sale  2020/01/27 03:38
<a href="http://www.weduwin.com/ihlen/gucci-bamboo-black-velvet-velour-cosmetic-jewellery-makeup">gucci bamboo black velvet velour cosmetic jewellery makeup</a><a href="http://www.weduwin.com/indiantown/gucci-courrier-soft-gg-supreme-tote-474085-brown-...
from.patrol sunglasses  2020/01/28 04:15
<a href="http://www.dailicklink.com/hopkinton/fashion-photography-books-the-new-york-times">fashion photography books the new york times</a><a href="http://www.dailicklink.com/hughson/michael-kors-jet-set-travel-large-tote-saffiano-leather-brick-gold-n...
from.harley quinn arkham knight  2020/01/28 22:22
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.harley quinn arkham city boots  2020/01/28 23:07
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.spiderman suits  2020/01/29 08:09
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.custom rhinestone shoes for women puma super elevate  2020/01/29 09:19
<a href="http://www.df-news.com/trotwood/mens-cleats-spikes-under-armour-ua-corespeed-fg-black-phoenix-fire-a-hayes-photo">mens cleats spikes under armour ua corespeed fg black phoenix fire a hayes photo</a><a href="http://www.df-news.com/verobeach/und...
from.venice ii pewter gold leather espadrille  2020/01/29 14:39
<a href="http://www.namhacker.com/northvernon/spring-luna-moth-set">spring luna moth set</a><a href="http://www.namhacker.com/odessa/spectacular-deals-on-baseball-cap-red-balenciaga-hats">spectacular deals on baseball cap red balenciaga hats</a><a href...
from.click through the up coming website page  2020/01/29 20:34
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.harley quinn arkham city wig  2020/01/30 12:19
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.http://octhen.com/  2020/01/31 09:58
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/06/13 12:50
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/06/13 13:22
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/07/20 18:06
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/07/20 18:32
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/07/20 18:46
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/07/20 19:05
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/08/22 15:47
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/08/22 16:43
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/10/09 17:27
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/10/09 17:56
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/10/25 13:30
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/11/16 18:01
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/11/16 19:05
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/12/26 15:56
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/12/26 16:54
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/12/29 13:43
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2020/12/29 17:29
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2021/01/21 05:27
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2021/01/21 05:29
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
from.visit here  2021/01/21 12:36
::: ZOSEL ::: :: Syslog-Host with Syslog-NG and MySQL
ZOSEL:Too much is as bad as too little...!! 자공(子貢)이 공자에게 "사(師:子張의 이름)와 상(商:子夏의 이름)은 어느 쪽이 어집니까?" 하고 묻자, 공자는 "사는 지나치고 상은 미치지 못한다"고 대답하였다. "그럼 사가 낫단 말씀입니까?" 하고 반문하자, 공자는 "지나친 것은 미치지 못한 것과 같다(過猶不及)"고 말하였다.
Too much is as bad as too little...!! 자공(子貢)이 공자에게 "사(師:子張의 이름)와 상(商:子夏의 이름)은 어느 쪽이 어집니까?" 하고 묻자, 공자는 "사는 지나치고 상은 미치지 못한다"고 대답하였다. "그럼 사가 낫단 말씀입니까?" 하고 반문하자, 공자는 "지나친 것은 미치지 못한 것과 같다(過猶不及)"고 말하였다.
전체 (209)
리눅스시스템 (92)
윈도우시스템 (16)
프로그램 (7)
네트워크시스템 (7)
최근관심 (1)
«   2024/04   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        
  1. yeezyboost-350.co.uk  2021
    yeezyboost-350.co.uk
  2. 강남역 풀싸롱  2021
    강남역 풀싸롱
  3.   2021
  1. 2018/02 (1)
  2. 2017/03 (2)
  3. 2016/12 (2)