Skip to content

Trigger a command when a process uses more or less than a specified bandwidth limit

Notifications You must be signed in to change notification settings

sudoroom/bw-trigger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple program that monitors the bandwidth usage of a specified process and triggers a command when the bandwidth moves above or below a custom setpoint.

compile libnethogs

git clone https://github.com/raboof/nethogs
cd nethogs/
git checkout 2acedff5d70db070c17772c7c4611cf742199607

sudo apt install build-essential libpcap-dev libncurses-dev
make libnethogs
cd src/
ln -s libnethogs.so.0.8.5-99-g2acedff libnethogs.so
cd ../../

compile bwtrigger

make

usage

Usage: ./trigger <pid> <bw> <cmd>
  <pid> is the process id of the process to monitor for bandwidth usage
  <bw> is the bandwidth at which to trigger the command in kilobits per second
  <cmd> is the command to run when the bandwidth usage of <pid> rises above
        or drops below <bw>. The argument 'above' or 'below' is given to <cmd>

Only the downstream bandwidth is monitored.

The command is run in a shell and the full path to the command must be specified as a single argument.

bwtrigger must be run as root.

example

sudo ./run.sh 2052 100 $(realpath ./test.sh)

ToDo

  • Add adjustable hysteresis

About

Trigger a command when a process uses more or less than a specified bandwidth limit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published