You are not logged in.

#1 2020-02-17 17:30:12

Sector11
Conky 1.9er Mod Squid
From: Upstairs
Registered: 2015-08-20
Posts: 6,046

CLI Network monitoring - here as "& Tips"

Had this little text file for a while.  Hope it helps someone.
=====================

Network monitoring on Linux:

 1. nload        - AWESOME ASCII nload
 2. iftop        - sudo iftop
 3. iptraf       - sudo iptraf
 4. nethogs      - sudo nethogs
 5. bmon         - AWESOME Love it - ASCII - bmon
 6. slurm        - slurm -s -i enp5s0 = Very Nice! Love it!
 7. tcptrack     - read man requires = SUDO =
 8. vnstat       - this I know this I like
 9. bwm-ng       - NICE! simple - looks like a "live" vnstat
10. cbm          - Color Bandwidth Meter - must play with this
11. speedometer  - alias = speed (speedometer -r enp5s0 -t enp5s0) AWESOME
12. pktstat      - sudo pkstat
13. trafshow     - sudo trafshow - it's OK
14. ifstat       - simple list nice
15. dstat        - NICE - in colour - CPU | Disk | Net | Paging | System
16. collectl     - ASCII - CPU | Disks | Network - Nice one.
17. netdiag
     netwatch    - REQUIRES: netdiag - usage: sudo trafshow -i enp5s0 tcp
     netload     - REQUIRES: netdiag - usage: netload enp5s0
     netwatch    - REQUIRES: netdiag - usage: sudo trafshow -i enp5s0 tcp
18 speedtest-cli - Love it - I discovered it via corenominal over at Crunchbang.
 17 Feb 20 @ 13:01:30 ~
   $ speedtest-cli
Retrieving speedtest.net configuration...
Testing from Cablevision Argentina (xxx.xxx.xxx.xxx)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Telefonica De Argentina SA (EMPRESAS) (Buenos Aires) [0.31 km]: 14.756 ms
Testing download speed... {snip lottsa dots}
Download: 54.79 Mbit/s
Testing upload speed... {snip lottsa dots}
Upload: 2.59 Mbit/s

 17 Feb 20 @ 13:02:56 ~
   $ 

=-=-==-=-=
Here is a list of the commands, sorted by their features.

1. Overall bandwidth - nload, bmon, slurm, bwm-ng, cbm, speedometer, netload

2. Overall bandwidth (batch style output) - vnstat, ifstat, dstat, collectl

2. Bandwidth per socket connection - iftop, iptraf, tcptrack, pktstat, netwatch, trafshow

3. Bandwidth per process - nethogs
=-=-= NOTE Some may be missing =-=-=
1. nload

Nload is a commandline tool that allows users to monitor the incoming and outgoing traffic separately. It also draws out a graph to indicate the same, the scale of which can be adjusted. Easy and simple to use, and does not support many options.

So if you just need to take a quick look at the total bandwidth usage without details of individual processes, then nload will be handy.

$ nload

=-=-==-=-==-=-==-=-=
2. iftop

Iftop measures the data flowing through individual socket connections, and it works in a manner that is different from Nload. Iftop uses the pcap library to capture the packets moving in and out of the network adapter, and then sums up the size and count to find the total bandwidth under use.

Although iftop reports the bandwidth used by individual connections, it cannot report the process name/id involved in the particular socket connection. But being based on the pcap library, iftop is able to filter the traffic and report bandwidth usage over selected host connections as specified by the filter.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3. iptraf

Iptraf is an interactive and colorful IP Lan monitor. It shows individual connections and the amount of data flowing between the hosts.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
4. nethogs

Nethogs is a small 'net top' tool that shows the bandwidth used by individual processes and sorts the list putting the most intensive processes on top. In the event of a sudden bandwidth spike, quickly open nethogs and find the process responsible. Nethogs reports the PID, user and the path of the program.

$ sudo nethogs

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
5. bmon

Bmon (Bandwidth Monitor) is a tool similar to nload that shows the traffic load over all the network interfaces on the system. The output also consists of a graph and a section with packet level details.

Bmon supports many options and is capable of producing reports in html format. Check the man page for more information

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6. slurm

Slurm is 'yet' another network load monitor that shows device statistics along with an ascii graph. It supports 3 different styles of graphs each of which can be activated using the c, s and l keys. Simple in features, slurm does not display any further details about the network load.

$ slurm -s -i enp5s0

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7. tcptrack

Tcptrack is similar to iftop, and uses the pcap library to capture packets and calculate various statistics like the bandwidth used in each connection. It also supports the standard pcap filters that can be used to monitor specific connections.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8. Vnstat

Vnstat is bit different from most of the other tools. It actually runs a background service/daemon and keeps recording the size of data transfer all the time. Next it can be used to generate a report of the history of network usage.

$ vnstat
Database updated: Mon Mar 17 15:26:59 2014

   enp5s0 since 06/12/13

          rx:  135.14 GiB      tx:  35.76 GiB      total:  170.90 GiB

   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       Feb '14      8.19 GiB |    2.08 GiB |   10.27 GiB |   35.60 kbit/s
       Mar '14      4.98 GiB |    1.52 GiB |    6.50 GiB |   37.93 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated      9.28 GiB |    2.83 GiB |   12.11 GiB |

   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     yesterday    236.11 MiB |   98.61 MiB |  334.72 MiB |   31.74 kbit/s
         today    128.55 MiB |   41.00 MiB |  169.56 MiB |   24.97 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated       199 MiB |      63 MiB |     262 MiB |

To monitor the bandwidth usage in realtime, use the '-l' option (live mode). It would then show the total bandwidth used by incoming and outgoing data, but in a very precise manner without any internal details about host connections or processes.

$ vnstat -l -i enp5s0
Monitoring enp5s0...    (press CTRL-C to stop)

   rx:       12 kbit/s    10 p/s          tx:       12 kbit/s    11 p/s

Vnstat is more like a tool to get historic reports of how much bandwidth is used everyday or over the past month. It is not strictly a tool for monitoring the network in real time.

Vnstat supports many options, details about which can be found in the man page.

I have it in a conky.  System is new so not filled in yet, gimme time.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
9. bwm-ng

Bwm-ng (Bandwidth Monitor Next Generation) is another very simple real time network load monitor that reports a summary of the speed at which data is being transferred in and out of all available network interfaces on the system.

$ bwm-ng

bwm-ng v0.6 (probing every 0.500s), press 'h' for help
  input: /proc/net/dev type: rate
  /iface           Rx              Tx            Tot
============================================================================
   enp5s0:           0.53 KB/s       1.31 KB/s     1.84KB
   lo:             0.00 KB/s       0.00 KB/s     0.00KB
----------------------------------------------------------------------------
   total:          0.53 KB/s       1.31 KB/s     1.84KB/s

If the console size is sufficiently large, bwm-ng can also draw bar graphs for the traffic using the curses2 output mode.

$ bwm-ng -o curses2

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
10. cbm - Color Bandwidth Meter

A tiny little simple bandwidth monitor that displays the traffic volume through network interfaces. No further options, just the traffic stats are display and updated in real-time.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
11. speedometer

Another small and simple tool that just draws out good looking graphs of incoming and outgoing traffic through a given interface.

$ speedometer -r enp5s0 -t enp5s0

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
12. Pktstat

Pktstat displays all the active connections in real time, and the speed at which data is being transferred through them. It also displays the type of the connection, i.e. tcp or udp and also details about http requests if involved.

$ sudo pktstat -i enp5s0 -nt

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
13. netwatch Requires = SUDO =

Netwatch is part of the netdiag collection of tools, and it too displays the connections between local host and other remote hosts, and the speed at which data is transferring on each connection.

$ = sudo netwatch -e enp5s0 -nt

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
14. trafshow

Like netwatch and pktstat, trafshow reports the current active connections, their protocol and the data transfer speed on each connection. It can filter out connections using pcap type filters.

Monitor only tcp connections

$ sudo trafshow -i enp5s0 tcp

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
15. netload

The netload command just displays a small report on the current traffic load, and the total number of bytes transferred since the program start. No more features are there. Its part of the netdiag.

$ netload enp5s0

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
16. ifstat

The ifstat reports the network bandwidth in a batch style mode. The output is in a format that is easy to log and parse using other programs or utilities.

$ ifstat -t -i enp5s0 0.5
  Time           enp5s0
HH:MM:SS   KB/s in  KB/s out
09:59:21      2.62      2.80
09:59:22      2.10      1.78
09:59:22      2.67      1.84
09:59:23      2.06      1.98
09:59:23      1.73      1.79

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
17. dstat

Dstat is a versatile tool (written in python) that can monitor different system statistics and report them in a batch style mode or log the data to a csv or similar file. This example shows how to use dstat to report network bandwidth

$ dstat -nt
-net/total- ----system----
 recv  send|     time
   0     0 |23-03 10:27:13
1738B 1810B|23-03 10:27:14
2937B 2610B|23-03 10:27:15
2319B 2232B|23-03 10:27:16
2738B 2508B|23-03 10:27:17

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
18. collectl

Collectl reports system statistics in a style that is similar to dstat, and like dstat it is gathers statistics about various different system resources like cpu, memory, network etc. Over here is a simple example of how to use it to report network usage/bandwidth.

$ collectl -sn -oT -i0.5
waiting for 0.5 second sample...
#         <----------Network---------->
#Time       KBIn  PktIn  KBOut  PktOut
10:32:01      40     58     43      66
10:32:01      27     58      3      32
10:32:02       3     28      9      44
10:32:02       5     42     96      96
10:32:03       5     48      3      28

Here's a few in action!


The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.

Offline

#2 2020-02-18 00:28:20

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,543
Website

Re: CLI Network monitoring - here as "& Tips"

Knockout! I know so little about networking - this will be copied out into a text file right away. Many thanks. smile


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

#3 2020-02-18 02:23:42

Sector11
Conky 1.9er Mod Squid
From: Upstairs
Registered: 2015-08-20
Posts: 6,046

Re: CLI Network monitoring - here as "& Tips"

S11 wrote:

Hope it helps someone.

Hi John ... well, thank you for being that "someone".

If you are interested I have a bash "function" for speedtest-cli

 17 Feb 20 @ 23:05:15 ~
   $ stest

 hfx  | mon  | mtl  | tor
 wpg  | reg  | calg | van
 lond | chin | lotr | ital
 luxe | swit | holl | nyc
 flor | mexi | gree | aust
 afri | germ | fran | denm
 ftel | star | tcen | plat
 
 17 Feb 20 @ 23:05:20 ~
   $ ftel
  Start time: 2020-02-17 @ 23:05:25 18732) Fibertel (Buenos Aires, Argentina) [0.31 km]
Ping: 13.746 ms
Download: 54.70 Mbit/s
Upload: 2.60 Mbit/s
 
 17 Feb 20 @ 23:05:52 ~
   $ swit
  Start time: 2020-02-17 @ 23:06:00 3228) SIG-Telecom (Geneva, Switzerland) [11063.01 km]
Ping: 338.638 ms
Download: 28.04 Mbit/s
Upload: 2.35 Mbit/s
 
 17 Feb 20 @ 23:06:31 ~
   $ 


bash function: stest

################################################################# Speedtests ###
### Every now and then you have to redo the servers
### speedtest-cli --list
### to: Display a list of speedtest.net servers sorted by distance
###
stest(){
echo ""
echo " hfx  | mon  | mtl  | tor"
echo " wpg  | reg  | calg | van"
echo " lond | chin | lotr | ital"
echo " luxe | swit | holl | nyc"
echo " flor | mexi | gree | aust"
echo " afri | germ | fran | denm"
echo " ftel | star | tcen | plat"
}

hfx(){
date +"  Start time: %x @ %T - 1658) Eastlink (Halifax, NS, Canada) [8830.43 km]"
speedtest-cli --server 1658 --simple
}

mon(){
date +"  Start time: %x @ %T 8810) Rogers (Moncton, NB, Canada) [9000.16 km]"
speedtest-cli --server 8810 --simple
}

mtl(){
date +"  Start time: %x @ %T 16754) Bell Mobility (Montreal, QC, Canada) [9037.14 km]"
speedtest-cli --server 16754 --simple
}

tor(){
date +"  Start time: %x @ %T 10393) Speedtest.net (Toronto, ON, Canada) [8957.92 km]"
speedtest-cli --server 10393 --simple
}

wpg(){
date +"  Start time: %x @ %T 4297) LES.NET (Winnipeg, MB, Canada) [10139.65 km]"
speedtest-cli --server 4297 --simple
}

reg(){
date +"  Start time: %x @ %T 4198) SaskTel (Regina, SK, Canada) [10487.84 km]"
speedtest-cli --server 4198 --simple
}

calg(){
date +"  Start time: %x @ %T 4637) Cybera (Calgary, AB, Canada) [10965.35 km]"
speedtest-cli --server 4637 --simple
}

van(){
date +"  Start time: %x @ %T 2565) TekSavvy Solutions Inc (Toronto, ON, Canada) [8957.92 km]"
speedtest-cli --server 2565 --simple
}

lond(){
date +"  Start time: %x @ %T 24281) Vodafone UK (London, United Kingdom) [11129.61 km]"
speedtest-cli --server 24281 --simple
}

chin(){
date +"  Start time: %x @ %T 27100) ShanDong CMCC 5G (Qingdao, China) [19817.49 km]"
speedtest-cli --server 27100 --simple
}

lotr(){
date +"  Start time: %x @ %T 5749) Vocusgroup NZ (Auckland, New Zealand) [10353.56 km]"
speedtest-cli --server 5749 --simple
}

ital(){
date +"  Start time: %x @ %T 3676) Clouditalia S p A (Rome, Italy) [11151.65 km]"
speedtest-cli --server 3676 --simple
}

luxe(){
date +"  Start time: %x @ %T 1360) POST Luxembourg (Luxembourg, Luxembourg) [11310.28 km]"
speedtest-cli --server 1360 --simple
}

swit(){
date +"  Start time: %x @ %T 3228) SIG-Telecom (Geneva, Switzerland) [11063.01 km]"
speedtest-cli --server 3228 --simple
}

holl(){
date +"  Start time: %x @ %T 10389) Speedtest.net (Amsterdam, Netherlands) [11445.36 km]"
speedtest-cli --server 10389 --simple
}

nyc(){
date +"  Start time: %x @ %T 5029) AT&T (New York, NY, United States) [8525.95 km]"
speedtest-cli --server 5029 --simple
}

flor(){
date +"  Start time: %x @ %T 5030) AT&T (Miami, FL, United States) [7098.52 km]"
speedtest-cli --server 5030 --simple
}

mexi(){
date +"  Start time: %x @ %T 3345) Triara (Tuxtla Gutierrez, Mexico) [6788.09 km]"
speedtest-cli --server 3345 --simple
}

gree(){
date +"  Start time: %x @ %T 4201) OTE S.A. (Athens, Greece) [11685.94 km]"
speedtest-cli --server 4201 --simple
}

aust(){
date +"  Start time: %x @ %T 5666) Exetel (Sydney, Australia) [11801.93 km]"
speedtest-cli --server 5666 --simple
}

afri(){
date +"  Start time: %x @ %T 8894) AlwaysOn (Cape Town, South Africa) [6870.03 km]"
speedtest-cli --server 8894 --simple
}

germ(){
date +"  Start time: %x @ %T 4556) TNG Stadtnetz GmbH (Kiel, Germany) [11852.61 km]"
speedtest-cli --server 4556 --simple
}

fran(){
date +"  Start time: %x @ %T 12746) SFR SAS (Paris, France) [11051.19 km]"
speedtest-cli --server 12746 --simple
}

denm(){
date +"  Start time: %x @ %T 14902) Dansk Kabel TV A/S (Copenhagen, Denmark) [12066.09 km]"
speedtest-cli --server 14902 --simple
}

ftel(){
date +"  Start time: %x @ %T 18732) Fibertel (Buenos Aires, Argentina) [0.31 km]"
speedtest-cli --server 18732 --simple
}

star(){
date +"  Start time: %x @ %T 7696) Movistar Servidor Nacional (Buenos Aires, Argentina) [0.31 km]"
speedtest-cli --server 7696 --simple
}

tcen(){
date +"  Start time: %x @ %T 900) Telecentro (Buenos Aires, Argentina) [0.31 km]"
speedtest-cli --server 900 --simple
}

plat(){
date +"  Start time: %x @ %T 12878) Telecom Personal (La Plata, Argentina) [52.94 km]"
speedtest-cli --server 12878 --simple
}
############################################################# End Speedtests ###

BTW: speedtest-cli --list>sp-list.txt produced a list 9639 lines long.
So you have a good choice to choose from.


The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.

Offline

#4 2020-02-18 02:45:21

Sector11
Conky 1.9er Mod Squid
From: Upstairs
Registered: 2015-08-20
Posts: 6,046

Re: CLI Network monitoring - here as "& Tips"

Running bmon, "vnstat -l -i enp5s0" and "stest" at the same time = fun stuff!
2020-02-17-233737-S11.jpg


The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.

Offline

#5 2020-02-18 02:53:26

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,543
Website

Re: CLI Network monitoring - here as "& Tips"

Thanks! cool


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

Board footer

Powered by FluxBB