راه اندازی و تنظیمات syslog-ng
راه اندازی و تنظیمات syslog-ng
ورژن نصب شده: syslog-ng-1.6.10-1.el4.kb.i386.rpm
بررسی اجمالی:
Syslog-ng رخدادهای ورودی از منابع تعریف شده را به مقصد مناسب فیلتر کرده و ارسال می نماید. در حالت ساده نصب syslog-ng رخداد ها از سه منبع خوانده می شود:
1. the default /dev/log device, where most logs are sent
2. syslog-ng "internal" log messages
3. /proc/kmsg kernel messages
منابع با استفاده از دستور “surce” تعریف می شوند.
رخدادها دریافت شده و با توجه به تعریف کلمات کلیدی فیلتر شده و سطح رخداد به مقصد مناسب فرستاده می شود.
· تنظیمات مربوطه در فایل syslog-ng.conf صورت میگیرد.(مسیر فایل /etc/syslog-ng/syslog-ng.conf)
دستورات: .....
مشخص کردن منبع:
source
eg: source src { unix-stream("/dev/log"); internal(); };
eg(kernel): source kernsrc { file("/proc/kmsg"); };
تنظیمات پیش فرض برای ادغام رخدادها:
Eg: source src { unix-stream("/dev/log"); internal(); pipe("/proc/kmsg"); };
باز نمودن یک پورت برای خواندن اطلاعات از سرور راه دور مبدا:
Eg: (UDP port): source s_net{udp();};
Eg: (TCP port): source s_net{tcp();};
Eg: destination d_askapacheloghost {
tcp("askapacheloghost.dyndns.org" port(65514));
udp("askapacheloghost.dyndns.org" port(65514));
udp("askapacheloghost.dyndns.org" port(514));
};
تعریف مقصد برای ارسال رخدادهای انتخابی به فایل:
destination
مثال ها:
destination d_authlog { file("/var/log/auth.log"); };
destination d_cron { file("/var/log/cron.log"); };
destination d_daemon { file("/var/log/daemon.log"); };
destination d_kern { file("/var/log/kern.log"); };
destination d_lpr { file("/var/log/lpr.log"); };
destination d_user { file("/var/log/user.log"); };
destination d_uucp { file("/var/log/uucp.log"); };
destination d_ppp { file("/var/log/ppp.log"); };
destination d_mail { file("/var/log/mail.log"); };
destination d_mailinfo { file("/var/log/mail.info"); };
destination d_mailwarn { file("/var/log/mail.warn"); };
destination d_mailerr { file("/var/log/mail.err"); };
destination d_newscrit { file("/var/log/news/news.crit"); };
destination d_newserr { file("/var/log/news/news.err"); };
destination d_newsnotice { file("/var/log/news/news.notice"); };
destination d_debug { file("/var/log/debug"); };
destination d_messages { file("/var/log/messages"); };
destination d_everything { file("/var/log/everything"); };
destination d_console { usertty("root"); };
destination d_console_all { file("/dev/tty12"); };
destination d_loghost { udp("loghost" port(999)); };
destination d_xconsole { pipe("/dev/xconsole"); };
تعریف فیلتر برای رخدادها:
filter
مثال ها:
filter f_auth { facility(auth); };
filter f_authpriv { facility(auth, authpriv); };
filter f_syslog { program(syslog-ng); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon); };
filter f_kernel { facility(kern) and not filter(f_iptables); };
filter f_lpr { facility(lpr); };
filter f_mail { facility(mail); };
filter f_news { facility(news); };
filter f_user { facility(user); };
filter f_uucp { facility(cron); };
filter f_news { facility(news); };
filter f_ppp { facility(local2); };
filter f_debug { not facility(auth, authpriv, news, mail); };
filter f_messages { level(info..warn) and not facility(auth, authpriv, mail, news, cron) and not program(syslog-ng) and not filter(f_iptables); };
filter f_everything { level(debug..emerg); };
filter f_emergency { level(emerg); };
filter f_info { level(info); };
filter f_notice { level(notice); };
filter f_warn { level(warn); };
filter f_crit { level(crit); };
filter f_err { level(err); };
filter f_iptables { match("IN=" value("MESSAGE")) and match("OUT=" value("MESSAGE")); };
filter f_acpid { program("acpid"); };
filter f_failed { match("failed" value(MESSAGE)); };
filter f_denied { match("denied" value(MESSAGE)); };
filter f_noshorewall { not match("Shorewall" value(MESSAGE)); }; # Filter everything except regex keyword Shorewall
filter f_shorewall { match("Shorewall" value(MESSAGE)); }; # Filter regex keyword Shorewall
مسیر logها
log {source(s1); source(s2); ...
filter(f1); filter(f2); ...
destination(d1); destination(d2); ...
flags(flag1[, flag2...]); };
eg:
log { source(src); filter(f_mail); filter(f_info); destination(mailinfo); };
شما میتوانید سوالات خود را از طریق ایمیل مطرح کنید:
MGR9500@GMAIL.com