免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1876 | 回复: 1
打印 上一主题 下一主题

[服务应用] syslog-ng日志 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-10-15 17:46 |只看该作者 |倒序浏览
小弟现在在做一个项目,里面需要用到将交换机、路由器等网络设备的日志发送到服务器上,并且分类储存;
于是在这种情况下我想到了使用syslog-ng这个免费的日志工具,
想把设备发送过来的日志信息,通过syslog-ng的转储,保存到/var/log/这个目录下(配置文件中先用两台服务器做测试,验证配置是否正确)
但是配置的时候遇到问题,重启syslog-ng服务后,老是报错,请各位高手帮我看看究竟问题是出在哪里,谢谢了!
错误信息:Error binding socket; addr='AF_INET(192.168.0.1:514)', error='Cannot assign requested address (99)'

配置文件如下一些无关的作了删减,如果有问题我可以把完整的配置文件发上来)

options {
    sync (0);
    time_reopen (10);
    log_fifo_size (1000);
    long_hostnames (off);
    use_dns (no);
    use_fqdn (no);
    create_dirs (no);
    keep_hostname (no);
};

#----
source s_esx1 { udp(ip(192.168.0.1) port(514) ); };
source s_esx2 { udp(ip(192.168.0.2) port(514) ); };
#----

destination d_cons { file("/dev/console"; };
destination d_mesg { file("/var/log/messages"; };
destination d_auth { file("/var/log/secure"; };
destination d_mail { file("/var/log/maillog" sync(10)); };
destination d_spol { file("/var/log/spooler"; };
destination d_boot { file("/var/log/boot.log"; };
destination d_cron { file("/var/log/cron"; };
#----
destination d_esx1 { file("/var/log/esx-1.log"; };
destination d_esx2 { file("/var/log/esx-2.log"; };
#----
destination d_mlal { usertty("*"; };

#filter f_filter1  { facility(kern); };
filter f_mesg      { level(info..emerg) and not facility(mail,authpriv,cron); };
filter f_auth      { facility(authpriv); };
filter f_mail      { facility(mail); };
filter f_mlal      { level(emerg); };
filter f_spol      { facility(uucp) or (facility(news) and level(crit..emerg)); };
filter f_boot      { facility(local7); };
filter f_cron      { facility(cron); };

#----
log { source(s_esx1); filter(f_mesg); destination(d_esx1);};
log { source(s_esx2); filter(f_mesg); destination(d_esx2);};
#----

论坛徽章:
0
2 [报告]
发表于 2013-10-16 10:09 |只看该作者
经过百度和谷歌,找到了解决办法,可以通过syslog-ng的设置,将各不同主机、网络设备传来的日志信息在syslog-ng服务端根据IP和facility分类存储

--------
syslog-ng可以解决syslog接受时无法把各机器发送过来的log分开的问题。适用于较多设备日志记录。
很多linux系统自带syslog-ng这里就不说安装了。

服务器配置:
#cat /etc/syslog-ng/syslog-ng.conf
添加如下内容
source s_remote {
   udp(ip(0.0.0.0) port(514));
};
destination d_separatedbyhosts {  file("/var/log/syslog-ng/$HOST/$FACILITY.log" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));};

log { source(s_remote); destination(d_separatedbyhosts); };
使记录的设备日志按设备IP和设备号分别保存。

参考网址:http://blog.chinaunix.net/uid-261392-id-3044068.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP