sid1333 Posted August 6, 2009 Всем доброго времени суток! Возникла проблема сбора статистики через ng_netflow. Топология: L3 сеть <-> em0:Router:em1 <-> DGS-3100-24TG <-> ВОЛС <-> DES-3526 <-> Абонент по vlan per user. Операционка FreeBSD 7.2. Cобираюсь считать трафик через ng_netflow, прикрепляя его к ng_ether который от em1: ngctl mkpeer em1: netflow lower iface0 ngctl name em1:lower netflow ngctl connect em1: netflow: upper out0 ngctl msg netflow: setconfig { iface = 0 conf = 3 } <- тут учитываем проходящие в обе стороны пакеты ngctl mkpeer netflow: ksocket export inet/dgram/udp ngctl msg netflow:export connect inet/xxx.xxx.147.26:1670 По каким-то причинам трафик считается только в одну сторону - только пакеты, приходящие из em1 Знает ли кто способ сбора статистики таким образом? Очень не хочется прикручивать к netgraph ipfw и заворачивать трафик через ngtee. P.S. снимать статистику с внешнего интерфейса em0 не удастся, ибо на нем висит pfnat. Всем заранее спасибо :) Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
XeonVs Posted August 7, 2009 У меня сделано так: mkpeer vlan5: netflow lower iface0 name vlan5:lower netflow connect vlan5: netflow: upper iface1 connect netflow: netflow: out0 out1 msg netflow: settimeouts { inactive=150 active=3600 } все обсчитывается в обе стороны. Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
Dm1try Posted August 7, 2009 У меня сделано так: mkpeer vlan5: netflow lower iface0 name vlan5:lower netflow connect vlan5: netflow: upper iface1 connect netflow: netflow: out0 out1 msg netflow: settimeouts { inactive=150 active=3600 } все обсчитывается в обе стороны. На 7.2 такой огород можно не городить, а задать конигурацию iface-ов и все будет считаться в обе стороны: У меня работает вот так: #!/bin/sh . /etc/rc.subr # 1. Name of start script used in rc.conf name=flow_export rcvar=`set_rcvar` # 2. Functions of script (start/stop) start_cmd="nfsensor_start" stop_cmd="nfsensor_stop" # 3. Read configuration from rc.conf & setting defaults # 3.1 Collectors: new collector used by default. load_rc_config $name : ${flow_export_enable="NO"} : ${flow_export_interfaces=""} : ${flow_export_collectors="192.168.26.58:9995"} # 3.2 Executables # 3.2.1 Netgraph executable ngctl=/usr/sbin/ngctl # 3.2.2 Kldstat executable kldstat=/sbin/kldstat # 3.2.3 Number of netflow hooks nodes num_iface=0 # 3.2.4 Number of virtual hub ports connected to collectors num_port=1 # 3.2.5 List of modules module_list="ng_ether ng_ksocket ng_netflow ng_hub" # 4. Functions nfsensor_start() { # Sanity check echo "Starting flow_export netgraph structure." # Checking if "export" interface specified. if [ -z "$flow_export_interfaces" ] then echo "[ERR]: You must specify at least one iface." exit fi # Checking if require modules are loaded for module in $module_list; do check=`$kldstat -v |grep ${module}` if [ -z "$check" ] then echo "[ERR]: Module ${module} is not loaded." exit fi done # Creating nodes for iface in $flow_export_interfaces; do # Checkng if netflow node is created if [ $num_iface -eq 0 ] then # Creating neflow node for given iface $ngctl mkpeer $iface: netflow lower iface${num_iface} $ngctl name $iface:lower nfsr-node $ngctl connect $iface: nfsr-node: upper out${num_iface} # Configuring current netflow node $ngctl msg nfsr-node: setdlt { iface=${num_iface} dlt=1 } $ngctl msg nfsr-node: settimeouts { inactive=10 active=30 } # Collecting ingress & egress flows (require FreeBSD 7.2 and above) $ngctl msg nfsr-node: setconfig { iface=${num_iface} conf=11 } else # Connecting given iface to netflow node $ngctl connect $iface: nfsr-node: lower iface${num_iface} $ngctl connect $iface: nfsr-node: upper out${num_iface} # Collecting ingress & egress flows (require FreeBSD 7.2 and above) $ngctl msg nfsr-node: setconfig { iface=${num_iface} conf=11 } fi # Using next node num_iface=`expr $num_iface + 1` done # Connecting export hook of netflow node to virtual hub $ngctl mkpeer nfsr-node: hub export hubtmp $ngctl name nfsr-node:export nfex-hub # Connecting export flows to collectors to hub ports num_port=1 for collector in $flow_export_collectors; do $ngctl mkpeer nfex-hub: ksocket p${num_port} inet/dgram/udp $ngctl name nfex-hub:p${num_port} nfex-hub-p${num_port} $ngctl msg nfex-hub:p${num_port} connect inet/$collector num_port=`expr $num_port + 1` done } nfsensor_stop() { echo "Stoping flow_export netgraph structure." # Killing virtual hub node $ngctl shutdown nfex-hub: > /dev/null 2>&1 # Killing netflow node $ngctl shutdown nfsr-node: > /dev/null 2>&1 } run_rc_command "$1" Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
sid1333 Posted August 7, 2009 У меня сделано так: mkpeer vlan5: netflow lower iface0 name vlan5:lower netflow connect vlan5: netflow: upper iface1 connect netflow: netflow: out0 out1 msg netflow: settimeouts { inactive=150 active=3600 } все обсчитывается в обе стороны. На 7.2 такой огород можно не городить, а задать конигурацию iface-ов и все будет считаться в обе стороны: У меня работает вот так: #!/bin/sh . /etc/rc.subr # 1. Name of start script used in rc.conf name=flow_export rcvar=`set_rcvar` # 2. Functions of script (start/stop) start_cmd="nfsensor_start" stop_cmd="nfsensor_stop" # 3. Read configuration from rc.conf & setting defaults # 3.1 Collectors: new collector used by default. load_rc_config $name : ${flow_export_enable="NO"} : ${flow_export_interfaces=""} : ${flow_export_collectors="192.168.26.58:9995"} # 3.2 Executables # 3.2.1 Netgraph executable ngctl=/usr/sbin/ngctl # 3.2.2 Kldstat executable kldstat=/sbin/kldstat # 3.2.3 Number of netflow hooks nodes num_iface=0 # 3.2.4 Number of virtual hub ports connected to collectors num_port=1 # 3.2.5 List of modules module_list="ng_ether ng_ksocket ng_netflow ng_hub" # 4. Functions nfsensor_start() { # Sanity check echo "Starting flow_export netgraph structure." # Checking if "export" interface specified. if [ -z "$flow_export_interfaces" ] then echo "[ERR]: You must specify at least one iface." exit fi # Checking if require modules are loaded for module in $module_list; do check=`$kldstat -v |grep ${module}` if [ -z "$check" ] then echo "[ERR]: Module ${module} is not loaded." exit fi done # Creating nodes for iface in $flow_export_interfaces; do # Checkng if netflow node is created if [ $num_iface -eq 0 ] then # Creating neflow node for given iface $ngctl mkpeer $iface: netflow lower iface${num_iface} $ngctl name $iface:lower nfsr-node $ngctl connect $iface: nfsr-node: upper out${num_iface} # Configuring current netflow node $ngctl msg nfsr-node: setdlt { iface=${num_iface} dlt=1 } $ngctl msg nfsr-node: settimeouts { inactive=10 active=30 } # Collecting ingress & egress flows (require FreeBSD 7.2 and above) $ngctl msg nfsr-node: setconfig { iface=${num_iface} conf=11 } else # Connecting given iface to netflow node $ngctl connect $iface: nfsr-node: lower iface${num_iface} $ngctl connect $iface: nfsr-node: upper out${num_iface} # Collecting ingress & egress flows (require FreeBSD 7.2 and above) $ngctl msg nfsr-node: setconfig { iface=${num_iface} conf=11 } fi # Using next node num_iface=`expr $num_iface + 1` done # Connecting export hook of netflow node to virtual hub $ngctl mkpeer nfsr-node: hub export hubtmp $ngctl name nfsr-node:export nfex-hub # Connecting export flows to collectors to hub ports num_port=1 for collector in $flow_export_collectors; do $ngctl mkpeer nfex-hub: ksocket p${num_port} inet/dgram/udp $ngctl name nfex-hub:p${num_port} nfex-hub-p${num_port} $ngctl msg nfex-hub:p${num_port} connect inet/$collector num_port=`expr $num_port + 1` done } nfsensor_stop() { echo "Stoping flow_export netgraph structure." # Killing virtual hub node $ngctl shutdown nfex-hub: > /dev/null 2>&1 # Killing netflow node $ngctl shutdown nfsr-node: > /dev/null 2>&1 } run_rc_command "$1" Ну собсно аналогичный вашему скриптовый костыль быль прикручен перед созданием темы на форуме =) Только не с 11, а с 3 конфигом для ng_netflow. Надеялся просто, как всегда сделать проще, да видать не судьба =) Dm1try, у вас судя по скрипту создаётся по ноде ng_netflow для каждого vlan? Позвольте спросить: а зачем? Можно же обойтись всего одной :) Или я просто немного не разобрался в принципе функционирования вашего скрипта? Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
Dm1try Posted August 9, 2009 Ну собсно аналогичный вашему скриптовый костыль быль прикручен перед созданием темы на форуме =)Только не с 11, а с 3 конфигом для ng_netflow. Насколько я помню у вас считается только в одном направлении, у меня в и входящий и исходящий через vlan. Dm1try, у вас судя по скрипту создаётся по ноде ng_netflow для каждого vlan? Позвольте спросить: а зачем? Можно же обойтись всего одной :)Или я просто немного не разобрался в принципе функционирования вашего скрипта? Не разобрались - нода (сенсор) одна, к ней подключено соответ. число ifaceX и outX, по паре на один vlan. Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
Dm1try Posted August 9, 2009 Да, все конечно здорово, но кто-нибудь льет netflow c потока 1Gbit/s (суммарно и входящий и исходящий) или только я один такой идиот, и нужно менять схему учета? Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
sid1333 Posted August 9, 2009 Ну собсно аналогичный вашему скриптовый костыль быль прикручен перед созданием темы на форуме =)Только не с 11, а с 3 конфигом для ng_netflow. Насколько я помню у вас считается только в одном направлении, у меня в и входящий и исходящий через vlan. На vlan считает оба направления с 3 конфигом. Да, все конечно здорово, но кто-нибудь льет netflow c потока 1Gbit/s (суммарно и входящий и исходящий) или только я один такой идиот, и нужно менять схему учета?На данный момент 3000 абонентов генерируют 950 Мбит суммарно вход/выход, uplink и downlink. Но на той машине схема другая немного - em0 вход/em1 выход без всяких vlan и т.п.На нём поднят шейп, нат, netflow - роутер на 30% нагружен. Оптимизировать схему всё руки никак не дойдут. Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
Dm1try Posted August 9, 2009 На данный момент 3000 абонентов генерируют 950 Мбит суммарно вход/выход, uplink и downlink. Но на той машине схема другая немного - em0 вход/em1 выход без всяких vlan и т.п.На нём поднят шейп, нат, netflow - роутер на 30% нагружен. Оптимизировать схему всё руки никак не дойдут. Т.о. ng_netflow у Вас привязана в физическим интерфейсам без какой-либо хитрой конфигурации (сливаюся только входящие потоки на интерфейс), я правильно понимаю? Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
sid1333 Posted August 9, 2009 На данный момент 3000 абонентов генерируют 950 Мбит суммарно вход/выход, uplink и downlink. Но на той машине схема другая немного - em0 вход/em1 выход без всяких vlan и т.п.На нём поднят шейп, нат, netflow - роутер на 30% нагружен. Оптимизировать схему всё руки никак не дойдут. Т.о. ng_netflow у Вас привязана в физическим интерфейсам без какой-либо хитрой конфигурации (сливаюся только входящие потоки на интерфейс), я правильно понимаю? В схеме с vlan per user так сделать не получилось (считался только исходящий), и сделал как вы - по iface с 3 конфигом ng_netflow на каждый vlan - считается и входящий и исходящий.А в схеме em0/em1 - вход/выход - сделано именно так - iface0 тупо к em1 - также считаются оба направления трафика. Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
Dm1try Posted August 9, 2009 В схеме с vlan per user так сделать не получилось (считался только исходящий), и сделал как вы - по iface с 3 конфигом ng_netflow на каждый vlan - считается и входящий и исходящий.А в схеме em0/em1 - вход/выход - сделано именно так - iface0 тупо к em1 - также считаются оба направления трафика. А мне что-то тяжко сливать: last pid: 78727; load averages: 1.61, 1.74, 1.80 up 60+02:25:12 23:44:04 93 processes: 8 running, 71 sleeping, 14 waiting CPU: 0.0% user, 0.0% nice, 48.3% system, 3.5% interrupt, 48.3% idle Mem: 443M Active, 422M Inact, 547M Wired, 160K Cache, 399M Buf, 2503M Free Swap: 1024M Total, 1024M Free PID USERNAME PRI NICE SIZE RES STATE C TIME WCPU COMMAND 31 root -68 - 0K 16K CPU2 2 479.4H 77.78% em2 taskq 11 root 171 ki31 0K 16K RUN 3 1239.0 76.95% idle: cpu3 13 root 171 ki31 0K 16K RUN 1 1216.9 71.39% idle: cpu1 14 root 171 ki31 0K 16K RUN 0 1196.3 57.47% idle: cpu0 33 root -68 - 0K 16K CPU0 0 228.3H 47.46% em4 taskq 34 root -68 - 0K 16K CPU1 1 209.9H 32.76% em5 taskq 12 root 171 ki31 0K 16K RUN 2 954.1H 22.75% idle: cpu2 32 root -68 - 0K 16K - 3 182.4H 19.97% em3 taskq 15 root -32 - 0K 16K WAIT 3 23.2H 2.39% swi4: clock sio По em2 - идут два vlan-на на uplink-и, по всем остальным абоненты. Ну и как-то так: # netstat -w 1 input (Total) output packets errs bytes packets errs bytes colls 348380 0 226868136 349787 0 228639090 0 353217 0 227152554 353569 0 228314190 0 349740 0 224858322 350983 0 226352456 0 353370 0 227282344 354927 0 229131842 0 357198 0 231921978 357971 0 233142260 0 340989 0 219560880 341816 0 221137332 0 366781 0 236841500 367752 0 238151876 0 343344 0 221757348 343249 0 221490814 0 351631 0 227192944 352004 0 228304120 0 347605 0 220009330 349385 0 222528814 0 346344 0 222624166 347474 0 224249284 0 352724 0 227594854 353103 0 228484070 0 356246 0 229826106 357192 0 231372864 0 350573 0 227996614 351992 0 229736574 0 359184 0 231357154 359887 0 232571486 0 347838 0 224533924 349080 0 226132868 0 Ладно понял, надо разделять uplink-и по разным физическим интерфесам. Кстати значениями timeout-ов не поделитесь? Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
sid1333 Posted August 10, 2009 Кстати значениями timeout-ов не поделитесь?Для ng_netflow таймауты стандартные.Но трафика мне кажется у вас ощутимо больше, чем у меня. Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
hizel Posted August 13, 2009 кстати да такая же схема подключения и не хотелось бы вешать пачки нод на каждый инетрфес особенно в связи с этим: http://www.slashtmp.ru/2009/05/06/tag-ng_netflow/ Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...