Поздравляю с Новым Годом! :) Пусть новый год будет полон свершений, которые будет не стыдно добавить в резюме! :)
С Праздником! :)
С Праздником! :)
/opt/netsniff-ng/sbin/trafgen --cpp --dev eth1 --rand --num 0 -i udp_example01.trafgen --cpp --ring-size 500KiB --cpu 8В случае ошибки "Cannot allocate TX_RING" рекомендую убрать --ring-size вовсе.
1 [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%] 5 [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]
2 [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%] 6 [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]
3 [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%] 7 [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]
4 [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%] 8 [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]
Mem[||| 190/48400MB] Tasks: 32, 65 thr; 9 running
Swp[| 3/8190MB] Load average: 0.64 1.37 4.28
Uptime: 01:23:24
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
3728 root 20 0 13616 1760 1364 R 100. 0.0 0:09.22 /opt/trafgen --cpp --dev eth1 --rand --num 0 -i udp_example01.trafgen --cpp --ring-size
3732 root 20 0 13616 1780 1384 R 100. 0.0 0:09.22 /opt/trafgen --cpp --dev eth1 --rand --num 0 -i udp_example01.trafgen --cpp --ring-size
3721 root 20 0 13620 1780 1384 R 100. 0.0 0:09.22 /opt/trafgen --cpp --dev eth1 --rand --num 0 -i udp_example01.trafgen --cpp --ring-size
3722 root 20 0 13616 1764 1368 R 99.0 0.0 0:09.20 /opt/trafgen --cpp --dev eth1 --rand --num 0 -i udp_example01.trafgen --cpp --ring-size
3724 root 20 0 13616 1780 1384 R 99.0 0.0 0:09.21 /opt/trafgen --cpp --dev eth1 --rand --num 0 -i udp_example01.trafgen --cpp --ring-size
3723 root 20 0 13616 1768 1372 R 99.0 0.0 0:09.21 /opt/trafgen --cpp --dev eth1 --rand --num 0 -i udp_example01.trafgen --cpp --ring-size
3725 root 20 0 13616 1780 1384 R 99.0 0.0 0:09.20 /opt/trafgen --cpp --dev eth1 --rand --num 0 -i udp_example01.trafgen --cpp --ring-size
3730 root 20 0 13616 1768 1372 R 98.0 0.0 0:09.12 /opt/trafgen --cpp --dev eth1 --rand --num 0 -i udp_example01.trafgen --cpp --ring-size
sudo sysctl -w net.inet.ip.forwarding=1На внутреннем ифейсе задаем IP адрес (без этого не создаст, но потом почему-то поменяет на новый, очень странно он ведет себя):
sudo ifconfig en6 10.10.10.1Если внешний интерфейс (с интернетом) это en0, а внутренний, которому требуется дать интернет - en6, то сделать это так:
echo "nat on en0 from en6:network to any -> (en0)" > rules
sudo pfctl -f ./rules -e
sudo pfctl -dИсточник: https://roelant.net/2015/share-your-vpn-mac-el-capitan.html
cd /tmpIt's very useful toolkit for reading sFLOW dumps.
wget https://github.com/sflow/sflowtool/releases/download/v3.41/sflowtool-3.41.tar.gztar -xf sflowtool-3.41.tar.gz
cd sflowtool-3.41
./configure --prefix=/opt/sflowtool
make install
/opt/sflowtool/bin/sflowtool -r sflow.pcapOr you cal start it and it will listen on sFLOW port:
/opt/sflowtool/bin/sflowtoolHere you could find example of output:
startDatagram =================================
datagramSourceIP 127.0.0.1
datagramSize 696
unixSecondsUTC 1435146070
datagramVersion 5
agentSubId 100000
agent 192.168.122.162
packetSequenceNo 3175
sysUpTime 786000
samplesInPacket 1
startSample ----------------------
sampleType_tag 0:2
sampleType COUNTERSSAMPLE
sampleSequenceNo 27
sourceId 2:1
counterBlock_tag 0:2001
counterBlock_tag 0:2010
udpInDatagrams 5430
udpNoPorts 24321676
udpInErrors 0
udpOutDatagrams 8154
udpRcvbufErrors 0
udpSndbufErrors 0
udpInCsumErrors 0
counterBlock_tag 0:2009
tcpRtoAlgorithm 1
tcpRtoMin 200
tcpRtoMax 120000
tcpMaxConn 4294967295
tcpActiveOpens 119
tcpPassiveOpens 11
tcpAttemptFails 0
tcpEstabResets 10
tcpCurrEstab 2
tcpInSegs 225262
tcpOutSegs 263644
tcpRetransSegs 10
tcpInErrs 0
tcpOutRsts 1668
tcpInCsumErrors 0
counterBlock_tag 0:2008
icmpInMsgs 2694
icmpInErrors 0
icmpInDestUnreachs 0
icmpInTimeExcds 2690
icmpInParamProbs 0
icmpInSrcQuenchs 0
icmpInRedirects 0
icmpInEchos 0
icmpInEchoReps 4
icmpInTimestamps 0
icmpInAddrMasks 0
icmpInAddrMaskReps 0
icmpOutMsgs 0
icmpOutErrors 0
icmpOutDestUnreachs 12148804
icmpOutTimeExcds 247174
icmpOutParamProbs 12148797
icmpOutSrcQuenchs 0
icmpOutRedirects 0
icmpOutEchos 0
icmpOutEchoReps 0
icmpOutTimestamps 3
icmpOutTimestampReps 4
icmpOutAddrMasks 0
icmpOutAddrMaskReps 0
counterBlock_tag 0:2007
ipForwarding 2
ipDefaultTTL 64
ipInReceives 25451365
ipInHdrErrors 0
ipInAddrErrors 2
ipForwDatagrams 0
ipInUnknownProtos 0
ipInDiscards 0
ipInDelivers 24555065
ipOutRequests 12420612
ipOutDiscards 412852
ipOutNoRoutes 0
ipReasmTimeout 0
ipReasmReqds 0
ipReasmOKs 0
ipReasmFails 0
ipFragOKs 0
ipFragFails 0
ipFragCreates 0
counterBlock_tag 0:2005
disk_total 20091629568
disk_free 75268096
disk_partition_max_used 99.62
disk_reads 49609
disk_bytes_read 2410784768
disk_read_time 64008
disk_writes 71505
disk_bytes_written 2536456192
disk_write_time 1195352
counterBlock_tag 0:2004
mem_total 14447202304
mem_free 12821819392
mem_shared 0
mem_buffers 104521728
mem_cached 1174110208
swap_total 922742784
swap_free 922742784
page_in 1177603
page_out 1238504
swap_in 0
swap_out 0
counterBlock_tag 0:2003
cpu_load_one 0.130
cpu_load_five 0.350
cpu_load_fifteen 0.430
cpu_proc_run 0
cpu_proc_total 125
cpu_num 8
cpu_speed 3600
cpu_uptime 269214
cpu_user 923700
cpu_nice 0
cpu_system 308060
cpu_idle 2150608980
cpu_wio 307440
cpuintr 290
cpu_sintr 518020
cpuinterrupts 27964221
cpu_contexts 43373068
cpu_steal 15120
cpu_guest 0
cpu_guest_nice 0
counterBlock_tag 0:2006
nio_bytes_in 446691530
nio_pkts_in 7430121
nio_errs_in 0
nio_drops_in 0
nio_bytes_out 476011841
nio_pkts_out 6730531
nio_errs_out 0
nio_drops_out 0
counterBlock_tag 0:2000
hostname debian
UUID 5b-5a-d7-11-9e-5b-7c-48-bf-5b-cb-41-78-cd-a0-2b
machine_type 3
os_name 2
os_release 3.16.0-4-amd64
endSample ----------------------
endDatagram =================================
startDatagram =================================
datagramSourceIP 127.0.0.1
datagramSize 160
unixSecondsUTC 1435146073
datagramVersion 5
agentSubId 100000
agent 192.168.122.162
packetSequenceNo 3176
sysUpTime 789000
samplesInPacket 1
startSample ----------------------
sampleType_tag 0:2
sampleType COUNTERSSAMPLE
sampleSequenceNo 27
sourceId 0:14
counterBlock_tag 0:1005
ifName eth5
counterBlock_tag 0:1
ifIndex 14
networkType 6
ifSpeed 10000000000
ifDirection 1
ifStatus 3
ifInOctets 445441800
ifInUcastPkts 7424030
ifInMulticastPkts 4294967295
ifInBroadcastPkts 4294967295
ifInDiscards 0
ifInErrors 0
ifInUnknownProtos 4294967295
ifOutOctets 126
ifOutUcastPkts 3
ifOutMulticastPkts 4294967295
ifOutBroadcastPkts 4294967295
ifOutDiscards 0
ifOutErrors 0
ifPromiscuousMode 0
endSample ----------------------
endDatagram =================================
sudo apt-get install -y iptables-dev locate pkg-config make gcc git dkms libsnmp-dev snmpdСобираем:
cd /tmpЗапуск:
wget https://github.com/aabc/ipt-netflow/archive/v2.2.tar.gz
tar -xf v2.2.tar.gz
cd ipt-netflow-2.2/
./configure
make all
sudo make install
sudo dkms build ipt-netflow/2.2
sudo dkms install ipt-netflow/2.2
sudo modprobe ipt_NETFLOW protocol=9 destination=127.0.0.1:2055 inactive_timeout=10 hashsize=65535 maxflows=4000000 active_timeout=15И направляем трафик:
sudo iptables -I INPUT -i lo -j NETFLOW
sudo apt-get update
sudo apt-get install default-jre
sudo apt-get install zookeeperd
sudo vim /etc/zookeeper/conf/zoo.cfg
clientPortAddress=127.0.0.1
sudo service zookeeper restart
wget 'http://apache-mirror.rbc.ru/pub/apache/kafka/2.2.0/kafka_2.11-2.2.0.tgz' -Okafka_2.11-2.2.0.tgz
sudo tar -xf kafka_2.11-2.2.0.tgz -C /opt
cd /opt/kafka_2.11-2.2.0/
sudo useradd kafka -m
sudo chown -R kafka:kafka /opt/kafka_2.11-2.2.0/
sudo mkdir /tmp/kafka-logsMove configuration to proper place:
sudo chown kafka:kafka /tmp/kafka-logs
sudo mkdir /etc/kafka
sudo cp config/server.properties /etc/kafka
sudo vim /etc/init/kafka.conf
description "Kafka Broker"
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
respawn
respawn limit 2 5
env HOME=/etc/kafka
env KAFKA_HOME=/opt/kafka_2.11-2.2.0/
umask 007
kill timeout 300
pre-start script
#Sanity checks
[ -r $HOME/server.properties ]
end script
setuid kafka
setgid kafka
exec $KAFKA_HOME/bin/kafka-server-start.sh $HOME/server.properties
sudo service kafka startBased on: https://www.digitalocean.com/community/tutorials/how-to-install-apache-kafka-on-ubuntu-14-04 and https://github.com/wikimedia-incubator/kafka-debian/blob/master/kafka.upstart.conf