billing:configuration:dhcp_logs

Настройка Сегмента - "Системные опции" | Логи dhcpd в mysql | Свойства Сегмента

Логи DHCP в MySQL

Для начала заменим стандартный syslogd на syslog-ng

Заходим по ссылкe на все ОС

Выбираем версию 3.1.1 Её нам будет достаточно "с головой".

далее качаем rpm для RedHat EL 5 или пакет для вашей OS

Качаем по ссылкам Sуslog-ng i386 и Sуslog-ng x86_64

ставится все в директорию

/opt

открываем файл

/opt/syslog-ng/etc/syslog-ng.conf

Удаляем все его содержимое и заново заполняем по примеру ниже.

@version: 3.0
# Copyright 2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-admin/syslog-ng/files/syslog-ng.conf.gentoo.hardened.3.0,v 1.1 2009/05/25 20:07:21 mr_bones_ Exp $

#
# Syslog-ng configuration file, compatible with default hardened installations.
#

options {
        chain_hostnames(no);
        stats_freq(43200);
};

source src {
    unix-stream("/dev/log");
    internal();
};
source kernsrc {
    file("/proc/kmsg");
};

#source net { udp(); };
#log { source(net); destination(net_logs); };
#destination net_logs { file("/var/log/HOSTS/$HOST/$YEAR$MONTH$DAY.log"); };

destination d_mysql_syslog_dhcp {
        sql(type(mysql)
        host("10.10.10.10") port("3306") username("mikbill") password("PASSWORD")
        database("mikbill")
        table("syslogs")
        columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg", "seq")
        values("$HOST_FROM", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG", "$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC", "$PROGRAM", "$MSG", "$SEQNUM")
        indexes("host", "facility", "priority", "datetime", "program", "seq"));
        };

#destination dhcpd { file("/var/log/dhcpd.log"); };
filter dhcpd { match("regexp" value("/dhcp/i")); };
#filter dhcpd { match("^dhcpd"); };

log { source(src); filter(dhcpd); destination(d_mysql_syslog_dhcp); };


destination authlog { file("/var/log/auth.log"); };
destination _syslog { file("/var/log/syslog"); };
destination cron { file("/var/log/cron.log"); };
destination daemon { file("/var/log/daemon.log"); };
destination kern { file("/var/log/kern.log"); file("/dev/tty12"); };
destination lpr { file("/var/log/lpr.log"); };
destination user { file("/var/log/user.log"); };
destination uucp { file("/var/log/uucp.log"); };
#destination ppp { file("/var/log/ppp.log"); };
destination mail { file("/var/log/mail.log"); };

destination avc { file("/var/log/avc.log"); };
destination audit { file("/var/log/audit.log"); };
destination pax { file("/var/log/pax.log"); };
destination grsec { file("/var/log/grsec.log"); };

destination mailinfo { file("/var/log/mail.info"); };
destination mailwarn { file("/var/log/mail.warn"); };
destination mailerr { file("/var/log/mail.err"); };

destination newscrit { file("/var/log/news/news.crit"); };
destination newserr { file("/var/log/news/news.err"); };
destination newsnotice { file("/var/log/news/news.notice"); };

destination debug { file("/var/log/debug"); };
destination messages { file("/var/log/messages"); };
destination console { usertty("root"); };
destination console_all { file("/dev/tty12"); };
#destination loghost { udp("loghost" port(999)); };

destination xconsole { pipe("/dev/xconsole"); };

filter f_auth { facility(auth); };
filter f_authpriv { facility(auth, authpriv); };
filter f_syslog { not facility(authpriv, mail); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon) and not match("regexp" value("nmbd")) and not match("regexp" value("smbd")) and not match("regexp" value("snmpd")); };
filter f_kern { facility(kern); };
filter f_lpr { facility(lpr); };
filter f_mail { facility(mail); };
filter f_user { facility(user); };
filter f_uucp { facility(uucp); };
#filter f_ppp { facility(ppp); };
filter f_news { facility(news); };
filter f_debug { not facility(auth, authpriv, news, mail) and not match("regexp" value("nmbd")) and not match("regexp" value("dhcpd")) and not match("regexp" value("smbd")) and not match("regexp" value("snmpd")); };
filter f_messages { level(info..warn)
        and not facility(auth, authpriv, mail, news) and not match("regexp" value("dhcpd")) and not match("regexp" value("nmbd")) and not match("regexp" value("smbd")) and not match("regexp" value("snmpd")); };
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_avc { match("regexp" value(".*avc: .*")); };
filter f_audit { match("regexp" value("^audit.*")) and not match("regexp" value(".*avc: .*")); };
filter f_pax { match("regexp" value("^PAX:.*")); };
filter f_grsec { match("regexp" value("^grsec:.*")); };

log { source(src); filter(f_authpriv); destination(authlog); };
log { source(src); filter(f_syslog); destination(_syslog); };
log { source(src); filter(f_cron); destination(cron); };
log { source(src); filter(f_daemon); destination(daemon); };
log { source(kernsrc); filter(f_kern); destination(kern); };
log { source(src); filter(f_lpr); destination(lpr); };
log { source(src); filter(f_mail); destination(mail); };
log { source(src); filter(f_user); destination(user); };
log { source(src); filter(f_uucp); destination(uucp); };
log { source(kernsrc); filter(f_pax); destination(pax); };
log { source(kernsrc); filter(f_grsec); destination(grsec); };
log { source(kernsrc); filter(f_audit); destination(audit); };
log { source(kernsrc); filter(f_avc); destination(avc); };
log { source(src); filter(f_mail); filter(f_info); destination(mailinfo); };
log { source(src); filter(f_mail); filter(f_warn); destination(mailwarn); };
log { source(src); filter(f_mail); filter(f_err); destination(mailerr); };
log { source(src); filter(f_news); filter(f_crit); destination(newscrit); };
log { source(src); filter(f_news); filter(f_err); destination(newserr); };
log { source(src); filter(f_news); filter(f_notice); destination(newsnotice); };
log { source(src); filter(f_debug); destination(debug); };
log { source(src); filter(f_messages); destination(messages); };
log { source(src); filter(f_emergency); destination(console); };
#log { source(src); filter(f_ppp); destination(ppp); };
log { source(src); destination(console_all); };

Не забываем поменять

PASSWORD - на пароль для доступа mikbill к базе данных.
и вместо 10.10.10.10 поставте IP сервера но не 127.0.0.1 и не localhost
И не забудте дать доступ на базу пользователю mikbill с того хоста на который будут идти запросы.

все осталось выполнить

/etc/init.d/syslog stop
/etc/init.d/syslog-ng start

Далее в биллинге.

Настройки – Системные опции –

поставте галочку во второй вкладке напротив - Логи DHCP

и в каждой учетке абонента будут видны обновляемые в реальном времени логи DHCP

Автозапуск в Centos

chkconfig --level 0123456 syslog off
chkconfig --level 35 syslog-ng on
  • billing/configuration/dhcp_logs.txt
  • Последнее изменение: 11 лет назад
  • ld