Архив

Публикации с меткой ‘FreeBSD 7’

Update to 8.0

15 января 2010

Произвел незапланированный апдейт до FreeBSD 8.
Доигрался блин с настройками =)
Удалось спасти все базы и сайты.
Но скорее всего большинство из них не использовались.
Так что пока включил только блог

Егор Другое, Жизнь , , ,

php-syslog-ng silvernet edition

8 апреля 2009

Установка базы

Все заточено под FreeBSD 7

Свободно распостраняемые продукты syslog-ng и php-syslog-ng позволяют мониторить состояние сети практически сразу, разумеется необходимо слегка подредактировать конфиги.

Silvernet mod расчитан под DES-3526, DES-3026 которые очень часто используются для строительства сетей

Первым советую установить php-syslog-ng

syslog-ng установлен из портов (/usr/ports/sysutils/syslog-ng), вот его конфиг заточеный под php-syslog-ng:

one# cat /usr/local/etc/syslog-ng/syslog-ng.conf
# options
options { long_hostnames(off); sync(0); };

# sources
source src { unix-dgram(”/var/run/log”);
unix-dgram(”/var/run/logpriv” perm(0600));
internal(); file(”/dev/klog”); };
source net {
udp();
};

# destinations
destination messages { file(”/var/log/messages”); };
destination security { file(”/var/log/security”); };
destination authlog { file(”/var/log/auth.log”); };
destination maillog { file(”/var/log/maillog”); };
destination lpd-errs { file(”/var/log/lpd-errs”); };
destination xferlog { file(”/var/log/xferlog”); };
destination cron { file(”/var/log/cron”); };
destination debuglog { file(”/var/log/debug.log”); };
destination consolelog { file(”/var/log/console.log”); };
destination all { file(”/var/log/all.log”); };
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 slip { file(”/var/log/slip.log”); };
destination ppp { file(”/var/log/ppp.log”); };
destination console { file(”/dev/console”); };
destination allusers { usertty(”*”); };
destination remote {
file(”/var/log/remote/$YEAR/$MONTH/$DAY/$HOST.log”
owner(root) group(root) perm(0600) dir_perm(0700) create_dirs(yes));
};
destination d_mysql {
pipe(”/var/log/mysql.pipe”
template(”
INSERT INTO logs
(host, facility, priority, level, tag, datetime, program, msg)
VALUES ( ‘$HOST’, ‘$FACILITY’, ‘$PRIORITY’, ‘$LEVEL’, ‘$TAG’, CURRENT_TIMESTAMP,
‘$PROGRAM’, ‘$MSG’ );\n”) template-escape(yes));
};
destination swatch {
program(”/usr/local/bin/swatch –read-pipe=\”cat /dev/fd/0\”");
};

# log facility filters
filter f_auth { facility(auth); };
filter f_authpriv { facility(authpriv); };
filter f_not_authpriv { not facility(authpriv); };
filter f_console { facility(console); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon); };
filter f_ftp { facility(ftp); };
filter f_kern { facility(kern); };
filter f_lpr { facility(lpr); };
filter f_mail { facility(mail); };
filter f_news { facility(news); };
filter f_security { facility(security); };
filter f_user { facility(user); };
filter f_uucp { facility(uucp); };
filter f_local0 { facility(local0); };
filter f_local1 { facility(local1); };
filter f_local2 { facility(local2); };
filter f_local3 { facility(local3); };
filter f_local4 { facility(local4); };
filter f_local5 { facility(local5); };
filter f_local6 { facility(local6); };
filter f_local7 { facility(local7); };
filter f_topology { match(”Topology “); };
filter f_not_topology {not filter(f_topology);};

# log level filters
filter f_emerg { level(emerg); };
filter f_alert { level(alert..emerg); };
filter f_crit { level(crit..emerg); };
filter f_err { level(err..emerg); };
filter f_warning { level(warning..emerg); };
filter f_notice { level(notice..emerg); };
filter f_info { level(info..emerg); };
filter f_debug { level(debug..emerg); };
filter f_is_debug { level(debug); };

#######################
### Local Machine #####
#######################

# *.err;kern.warning;auth.notice;mail.crit              /dev/console
log { source(src); filter(f_err); destination(console); };
log { source(src); filter(f_kern); filter(f_warning); destination(console); };
log { source(src); filter(f_auth); filter(f_notice); destination(console); };
log { source(src); filter(f_mail); filter(f_crit); destination(console); };

# *.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
log { source(src); filter(f_notice); filter(f_not_authpriv); destination(messages); };
log { source(src); filter(f_kern); filter(f_debug); destination(messages); };
log { source(src); filter(f_lpr); filter(f_info); destination(messages); };
log { source(src); filter(f_mail); filter(f_crit); destination(messages); };
log { source(src); filter(f_news); filter(f_err); destination(messages); };

# security.*                                            /var/log/security
log { source(src); filter(f_security); destination(security); };

# auth.info;authpriv.info                               /var/log/auth.log
log { source(src); filter(f_auth); filter(f_info); destination(authlog); };
log { source(src); filter(f_authpriv); filter(f_info); destination(authlog); };

# mail.info                                             /var/log/maillog
log { source(src); filter(f_mail); filter(f_info); destination(maillog); };

# cron.*                                                /var/log/cron
log { source(src); filter(f_cron); destination(cron); };

# *.=debug                                              /var/log/debug.log
log { source(src); filter(f_is_debug); destination(debuglog); };

# *.emerg                                               *
log { source(src); filter(f_emerg); destination(allusers); };

#######################
### Remote Hosts ######
#######################

# *.err;kern.warning;auth.notice;mail.crit
log { source(net); filter(f_not_topology); destination( d_mysql); };
#log { source(net); filter(f_kern); filter(f_warning); destination(remote); };
#log { source(net); filter(f_auth); filter(f_notice); destination(remote); };
#log { source(net); filter(f_mail); filter(f_crit); destination(remote); };

# *.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err
log { source(net); filter(f_notice); filter(f_not_authpriv); destination(remote); };
log { source(net); filter(f_kern); filter(f_debug); destination(remote); };
log { source(net); filter(f_lpr); filter(f_info); destination(remote); };
log { source(net); filter(f_mail); filter(f_crit); destination(remote); };
log { source(net); filter(f_news); filter(f_err); destination(remote); };

# security.*
log { source(net); filter(f_security); destination(remote); };

# auth.info;authpriv.info
log { source(net); filter(f_auth); filter(f_info); destination(remote); };
log { source(net); filter(f_authpriv); filter(f_info); destination(remote); };

# mail.info
log { source(net); filter(f_mail); filter(f_info); destination(remote); };

# cron.*
log { source(net); filter(f_cron); destination(remote); };

# *.=debug
log { source(net); filter(f_is_debug); destination(remote); };

# *.emerg
log { source(net); filter(f_emerg); destination(remote); };

# local.*
log { source(net); filter(f_local0);  destination(remote); };
log { source(net); filter(f_local1);  destination(remote); };
log { source(net); filter(f_local2);  destination(remote); };
log { source(net); filter(f_local3);  destination(remote); };
log { source(net); filter(f_local4);  destination(remote); };
log { source(net); filter(f_local5);  destination(remote); };
log { source(net); filter(f_local6);  destination(remote); };
log { source(net); filter(f_local7);  destination(remote); };

# Run everything through swatch
log { source(net); destination(swatch); };
log { source(src); destination(swatch); };

Советую использовать в этой конструкции именно :

VALUES ( ‘$HOST’, ‘$FACILITY’, ‘$PRIORITY’, ‘$LEVEL’, ‘$TAG’, CURRENT_TIMESTAMP,  ‘$PROGRAM’, ‘$MSG’ );\n”)

а не переменные syslog-ng которые он получает с свитча, хоть в сети везде настроена синхронизация с ntp сервером - все же могут быть проблемы с переходом на летнее-зимнее время, так же я фильтрами (выделено)  убираю все события Topology * которых будет просто забьют бд.

так же необходимо запускать демон:

#!/bin/sh

if [ ! -e /var/log/mysql.pipe ]
then
mkfifo /var/log/mysql.pipe
fi
while [ -e /var/log/mysql.pipe ]
do
mysql -u username–password=password syslog < /var/log/mysql.pipe >/dev/null
done

скрипт я назвал syslog2mysql подобран он где то в рунете, запуск sh syslog2mysql &

& - фоновое выполнение.

Во время обкатки я не стал его запихивать в rc.d,  почему то во время отпуска он отвалился - почему не знаю.

Сейчас  добавил в rc.d:

cat /usr/local/etc/rc.d/syslog2mysql

#!/bin/sh

. /etc/rc.subr

name=”syslog2mysql”
start_cmd=”${name}_start”
stop_cmd=”:”

syslog2mysql_start()
{

/bin/sh /home/egor/syslog2mysql.sh  &

}
load_rc_config $name
run_rc_command “$1″

и в rc.conf

syslog2mysql_enable=”YES”

На этом часть связки закончена.

Теперь о фитчах которые реализованы в связке с биллингом  SilverNet Billing v.4.4.0 .

База silverbill необходима для:

  • учета оборудования (по ней мод определяет кто куда включен)
  • определения snmp community

Условия работы:

  • На всех свитчах присутсвует rw community
  • Все свитчи настроены посылать свои логи на syslog сервер =)

Switch info

Стоит признать что php-syslog-ng очень сильный продукт, очень много нового можно узнать о сети =). Очень много полезной информации. Но перед глазами одни ip, сразу захотелось связать эту информацию с домом, так появилась кнопка link , нажав на неё открывается страница в биллинге, теперь есть оперативное средство для мониторинга, сразу же появилась кнопка telnet, нажав на нее сразу можно попасть на свитч.

User Info

После того как появлась запись о броадкаст шторме стало интерестно откуда же он, конечно же запись есть об этом (на свитчах установлены лимиты storm control) есть “INFO: Broadcast storm has cleared (port: 17) ” да же порт указан, можно зайти на свитч и посмотреть кто на порту, но ведь можно и проще, написав небольшой парсер, который вырывал номер порта из различных сообщений я сопоставлял id user в биллинге, осталось добавить только ссылку на него, что я и сделал.

ExpressTest

Самое интерестно, что я буду далее развивать это экспресс тест порта. Тут пригодился парсер, с помощью него я теперь знаю ip и порт который надо проанализировать, остается только snmp community.

demo1

Использован Ajax - для более оперативной работы, увы окошки не очень удобны.

Как видно из картинки есть вся полезная информация - модель, прошивка, скорость соединения, аптайм свитча, состояния портов, ошибки, не везде доступны длинны линков, только если свитч DES-3526 c прошивкой от 5.01.b52 и выше (не всегда работает верно), так же доступна возможность ребута порта, что иногда помогает.

Нажав на кнопку получить таблицу MAC - оператор увидит маки на порту которые будут связаны с юзерами (данные silverbill) так же оператор увидит верен ли мак для этого порта. Получение таблицы основано на ajax, так что перезагрузки страницы не будет

upd

Сделать в ExpressTest историю порта и свитча (10 + 5 записей)

Пофиксить db_open

Егор Silvernet , , , , ,