This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
регистрация_событий_в_системе [2009/03/30 13:27] val |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Регистрация событий в системе ====== | ||
- | |||
- | ===== Пример использования syslogd ===== | ||
- | <code> | ||
- | [gX:~] # cat syslog.conf | ||
- | ... | ||
- | local7.info /var/log/dhcpd.log | ||
- | ... | ||
- | |||
- | [gX:~] # touch /var/log/dhcpd.log | ||
- | |||
- | [gX:~] # /etc/rc.d/syslogd reload | ||
- | |||
- | [gX:~] # logger -t dhcpd -p local7.info "Starting dhcpd..." | ||
- | </code> | ||
- | |||
- | ===== Ротация файлов регистрации ===== | ||
- | <code> | ||
- | [gX:~] # cat /etc/newsyslog.conf | ||
- | ... | ||
- | /var/log/dhcpd.log 600 7 10 * J | ||
- | |||
- | [gX:~] # cat logger.sh | ||
- | logger -t dhcpd -p local7.info "Message 1" | ||
- | logger -t dhcpd -p local7.info "Message 2" | ||
- | |||
- | [gX:~] # sh logger.sh | ||
- | ... | ||
- | <Ctrl>-C | ||
- | |||
- | [gX:~] # tail -f /var/log/dhcpd.log | ||
- | ... | ||
- | <Ctrl>-C | ||
- | |||
- | [gX:~] # newsyslog | ||
- | |||
- | [gX:~] # ls -l /var/log/dhcpd* | ||
- | </code> | ||
- | |||
- | ===== Использование syslogd в сети===== | ||
- | |||
- | ==== Настройка сервера ==== | ||
- | <code> | ||
- | [gX:~] # cat /etc/rc.conf | ||
- | ... | ||
- | syslogd_flags="-a 192.168.X.0/24" | ||
- | </code> | ||
- | |||
- | Сокращенная форма 192.168.X/24 не распознается! | ||
- | <code> | ||
- | [gX:~] # /etc/rc.d/syslogd restart | ||
- | </code> | ||
- | |||
- | ==== Настройка клиента ==== | ||
- | <code> | ||
- | [g50:~] # cat /etc/syslog.conf | ||
- | *.* @gX | ||
- | ... | ||
- | |||
- | [g50:~] # /etc/rc.d/syslogd restart | ||
- | </code> | ||
- | |||
- | ===== Передача сообщений syslogd в программу ===== | ||
- | <code> | ||
- | [gX:~] # cat syslog.sh | ||
- | #!/bin/sh | ||
- | while read m | ||
- | do | ||
- | if expr "$m" : '.*login.*' > /dev/null | ||
- | then | ||
- | echo $m | mail -s login root | ||
- | fi | ||
- | done | ||
- | |||
- | [gX:~] # chmod +x syslog.sh | ||
- | |||
- | [gX:~] # cat /etc/syslog.conf | ||
- | ... | ||
- | auth.* | /root/syslog.sh | ||
- | ... | ||
- | </code> | ||
- | |||