Bu yazımızda sizlere Linux (Debian GNU/Linux ve Ubuntu) tabanlı sunucularda network izleme/takip programı olan VNStat programı kurulumu ve ayarlarından bahsedeğim.
VNStat Kurulumu
apt-get ile Debian GNU/Linux ve(ya) Ubuntu için VNStat programını kuralım.
apt-get install vnstat
Kurulum sonunda buna benzer bir mesaj ile karşılaşacaksınız
Setting up vnstat (1.11-1) ... Starting vnStat daemon: vnstatdZero database found, adding available interfaces... "eth0" added, 100 Mbit bandwidth limit. -> 1 interface added. Limits can be modified using the configuration file.
/etc/vnstat.conf dosyasını nano/pi/vi veya herhangi bir metin editörü ile açalım.
nano /etc/vnstat.conf
MaxBandwidth 100 kısmını kendi sunucu port hızınıza göre değiştirin.
(Herhangi bir limit belirlememek için “0” değerini atayabilirsiniz)
Şimdi ifconfig komutu ile aktif olan internet arayüzüne bakalım.
[email protected]:~# ifconfig eth0 Link encap:Ethernet HWaddr fa:16:3e:ef:3a:f6 inet addr:92.222.73.168 Bcast:92.222.73.168 Mask:255.255.255.255 inet6 addr: fe80::f816:3eff:feef:3af6/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:550 errors:0 dropped:0 overruns:0 frame:0 TX packets:553 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:142635 (139.2 KiB) TX bytes:69605 (67.9 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:6 errors:0 dropped:0 overruns:0 frame:0 TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:300 (300.0 B) TX bytes:300 (300.0 B) [email protected]:~#
Görüldüğü üzere aktif olarak, internete çıkış yapan arayüzümüz eth0.
Şimdi ise, VNStat programını eth0 üzerinden geçen trafiği izlemesi için ayarlayalım.
vnstat -u -i eth0
Bu komuyu çalıştırdıktan sonra, VNStat sunucumuzdaki trafiği izlemeye başladı.
Şimdi de, crontab ile VNStat istatistiklerimizin güncellemnesini ayarlayalım.
/etc/crontab dosyasını metin editörü ile açalım.
nano /etc/crontab
Dosyanın en alt satırına aşağıdaki kodları ekleyin.
*/5 * * * * root /usr/bin/vnstat -u
crond’u yeniden başlatalım.
[email protected]:~# service cron restart [ ok ] Restarting periodic command scheduler: cron[....] Stopping periodic command scheduler: cron. [ ok ] Starting periodic command scheduler: cron. [email protected]:~#
Böylelikle VNStat‘ın her beş dakikada bir güncellenmesine ayarlamış olduk.
VNStat Kullanımı
En basit istatistikleri görüntülemek için vnstat komutunu kullanıyoruz.
[email protected]:~# vnstat rx / tx / total / estimated eth0: Jan '15 221.64 GB / 2.06 TB / 2.27 TB / 6.51 TB yesterday 45.95 GB / 445.28 GB / 491.23 GB today 15.51 GB / 334.49 GB / 350.00 GB / 425.32 GB eth1: Not enough data available yet. [email protected]:~#
Saatlik istatistikleri görüntülemek için vnstat -h
[email protected]:~# vnstat -h eth0 19:50 ^ t | t | t t t | t t t t t t | t t t t t t t | t t t t t t t t t | t t t t t t t t t t t t t t t t t t t | t t t t t t t t t t t t t t t t t t t t t | t t t t t t t t t t t t t t t t t t t t t t t t | t t t t rt t t t t t t t t t t t t t t t t t t t -+---------------------------------------------------------------------------> | 20 21 22 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 h rx (KB) tx (KB) h rx (KB) tx (KB) h rx (KB) tx (KB) 20 651966 31140771 04 380109 17153305 12 487243 16638475 21 618975 31503009 05 307281 12422781 13 449948 15290067 22 562475 29334556 06 320481 12262502 14 2053628 18260318 23 572436 27924527 07 397797 15748914 15 1801985 24042035 00 3965887 37899573 08 228335 8404701 16 529588 20533635 01 1027248 30312565 09 1267366 10319412 17 434089 16700083 02 441301 19047997 10 443633 11162232 18 419895 16029498 03 429304 18104608 11 495418 15874254 19 427032 16107699 [email protected]:~#
Günlük istatistikler için vnstat -d
[email protected]:~# vnstat -d eth0 / daily day rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- 07/01/2015 6.91 GB | 99.98 GB | 106.89 GB | 10.38 Mbit/s 08/01/2015 83.66 GB | 701.32 GB | 784.98 GB | 76.21 Mbit/s 09/01/2015 69.61 GB | 525.25 GB | 594.85 GB | 57.75 Mbit/s 10/01/2015 45.95 GB | 445.28 GB | 491.23 GB | 47.69 Mbit/s 11/01/2015 15.55 GB | 335.99 GB | 351.55 GB | 41.30 Mbit/s ------------------------+-------------+-------------+--------------- estimated 18.82 GB | 406.58 GB | 425.40 GB | [email protected]:~#
Aylık istatistikler için vnstat -m
[email protected]:~# vnstat -m eth0 / monthly month rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Jan '15 221.68 GB | 2.06 TB | 2.27 TB | 20.89 Mbit/s ------------------------+-------------+-------------+--------------- estimated 634.75 GB | 5.89 TB | 6.51 TB | [email protected]:~#
Haftalık istatistikler için vnstat -w
[email protected]:~# vnstat -w eth0 / weekly rx | tx | total | avg. rate ---------------------------+-------------+-------------+--------------- last 7 days 221.68 GB | 2.06 TB | 2.27 TB | 33.13 Mbit/s current week 221.68 GB | 2.06 TB | 2.27 TB | 33.13 Mbit/s ---------------------------+-------------+-------------+--------------- estimated 228.48 GB | 2.12 TB | 2.34 TB | [email protected]:~#
Top10 istatistikler için ise vnstat -t
[email protected]:~# vnstat -t eth0 / top 10 # day rx | tx | total | avg. rate -----------------------------+-------------+-------------+--------------- 1 08/01/2015 83.66 GB | 701.32 GB | 784.98 GB | 76.21 Mbit/s 2 09/01/2015 69.61 GB | 525.25 GB | 594.85 GB | 57.75 Mbit/s 3 10/01/2015 45.95 GB | 445.28 GB | 491.23 GB | 47.69 Mbit/s 4 07/01/2015 6.91 GB | 99.98 GB | 106.89 GB | 10.38 Mbit/s -----------------------------+-------------+-------------+--------------- [email protected]:~#
Ve son olarak anlık istatistikler için kullanacağınız komut vnstat -l
[email protected]:~# vnstat -l Monitoring eth0... (press CTRL-C to stop) rx: 1.12 Mbit/s 2077 p/s tx: 44.56 Mbit/s 3849 p/s
Anlık istatistikler ekranından çıkmak için Ctrl+C tuş kombinasyonunu kullanıyoruz.
Gelecek yazımızda, VNStat istatisklerini web sayfanızda yayımlamak için kullanabileceğimiz vnStat PHP frontend adlı scriptten bahsedeceğim.
Bu scriptin hali hazırda çalışan, ve üzerinde benim birkaç düzenleme yaptığım halini http://status.netkolik.org adresinden inceleyebilirsiniz.
Her türlü soru ve sorununuzla ilgili yorumlarınızı bekliyorum arkadaşlar.