Writing a Network Traffic module (No Lame Dependencies)

preview_player
Показать описание
Classic video of me milking random statusbar modules I've written for educational notes about the Linux file system and the command line. I write a very terse module that checks your current cumulative network traffic (upload and download) and determines your download and upload rates per second or any time interval you give it. NO STUPID DEPENDENCIES!

Check out the script below. Tell me what obvious inefficiencies I missed.

You'll learn about RX/TX bytes, how to monitor network status, string operations on the command line, paste, and shell arithmetic. I go over some things quickly because there's a lot to talk about even in this minimalist script, but I might cover some of these topics in videos in the future because they're worth it.

Рекомендации по теме
Комментарии
Автор

"I'm not a programmer" - Vim "The programmer" Diesel

joseagustinrios
Автор

You can write files in shared memory at /dev/shm. No need to use the disk.

logfile=/dev/shm/netlog

nikosful
Автор

Somebody tell him that only soy devs use cat to print the content of a file

StrangeIndeed
Автор

“lo” is the loop back device which is just traffic on your local machine. If you’re just looking for internet traffic, It should be ignored.

Euphorya
Автор

Paste can read kernel file entries. You can skip the cat process and just use
"paste -d'+'

Although maybe I would use libudev instead of the script, depending on how fast you make it update. Otherwise, good script.

ertwro
Автор

4 days in a roll, you are on fire luke

paulo
Автор

Paste admits files as params, so you can skip the cats. Also without the -s option it reads in parallel, so may that be a possible optimization?

_foldr
Автор

I like those bash "tutorial" they are short, easy to grasp, and show hows to do useful scripts. Keep doing these videos!

Vsioul
Автор

I do recommend storing the logfile on a mounted RAM disk as it speeds things up, especially if you're checking often in a loop with little delay.

unhlysda
Автор

Luke "I'm not a programmer" Smith creates advanced shell scripting tutorial series, now available on Udemy for $199

Klayperson
Автор

*does subtraction*
Very dense stuff, man!
For real though, nice video. I love keeping up with these to keep my bash skills growing.

gavinridley
Автор

use 'numfmt' to format the size

chu-kuanchang
Автор

Last time I was this early Vim Diesel was Vim Petrol

Supertimegamingify
Автор

Sorry Luke you don't get to choose, you're a programmer now

lovely-shrubbery
Автор

You could do this with dc
cat | dc -f - -e '+ 1024 / p'

Not really better, just nice to finally see a use for the reverse polish notation dc uses

Автор

Hey luke, I subscribed to you a few months back. Really liking your mindset and the way you do things. Could you make a tutorial on Keyboard shortcuts and traversing the web i.e entering the address bar, quickly selecting search results and doing other things without touching the mouse? Thanks

nswayze
Автор

Thank Luke for your videos, i'm a computer engineer and ejoy all of your content. They are very useful.

GonzaloOviedoLambert
Автор

You should make it so that if you're recording all terminal emulators start pre-zoomed in.

axelforsman
Автор

I would love to see a video on consumer-grade firewalls! Rather than having your desktop or laptop running a VPN, an OpenWRT or pfSense device can do all that and more. It can block ads, block data sent to Microsoft/Google/etc, and it will work for any device on your network, not just one device with your VPN installed.

You can easily set up one of these boxes for under $50 if you buy the right gear used. Check out Open Source Intelligence Techniques by Michael Bazzel if this sounds interesting

travishopkins
Автор

Shell script is some thing i really have to work on. The first time was easier. It would be nice to print out Unix ports that the Bits are coming in. would sort it by < to > . I would call it nemesis to hubris lol.

shooksnc
join shbcf.ru