Category Archives: Bash

How to measure packets per second or throughput on high speed network interface – Xmodulo

There are many traffic monitoring tools available on Linux, which can monitor/classify network traffic, and report real-time traffic statistics in fancy user interfaces. Most of these tools (e.g., ntopng, iftop) are powered by libpcap, which is a packet capture library used to monitor network traffic in user space. Despite their versatility, however,libpcap-based network monitoring tools cannot scale to handle traffic on multi Gigabit rate network interfaces, due to the overhead associated with user-space packet capture.

In this tutorial, I will present simple shell scripts that can monitor network traffic on per-interface basis, without relying on slow libpcap library. These scripts are fast enough to support multi Gigabit rates, but only suitable if you are interested in “aggregate” network statistics on per interface basis.

The secret for the scripts lies in sysfs virtual filesystem which is used by the kernel to export device- or driver-related information to user space. Network interface related statistics are exported via /sys/class/net/<ethX>/statistics.

Read More

HowTo: Use Bash Parameter Substitution Like A Pro – nixCraft

Summary: String Manipulation and Expanding Variables For your ready references here are all your handy bash parameter substitution operators. Try them all; enhance your scripting skills like a pro: ${parameter:-defaultValue} Get default shell variables value ${parameter:=defaultValue} Set default shell variables value ${parameter:?”Error Message”} Display an error message if parameter is not set ${#var} Find the

Read More

Bad Behavior has blocked 56 access attempts in the last 7 days.