scripts: add scripts for starting/stopping bandwidth limitation
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Thu, 21 Apr 2011 20:09:26 +0000 (23:09 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Thu, 21 Apr 2011 20:32:38 +0000 (23:32 +0300)
scripts/kvm/mcreate-bw-limit [new file with mode: 0755]
scripts/kvm/mreset-bw-limit [new file with mode: 0755]

diff --git a/scripts/kvm/mcreate-bw-limit b/scripts/kvm/mcreate-bw-limit
new file mode 100755 (executable)
index 0000000..e2c7fdf
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+#
+# Run remote tc script enabling bandwidth limitation.
+#
+# Use the same traffic limitation for all systems
+#
+
+#
+# 2011, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
+#
+
+default_config=destinations.default.conf
+
+if test $# -ge 2; then
+    echo "Usage: $0 [config]" 1>&2
+    exit 1
+elif test $# -eq 1; then
+    config="$1"
+else
+    config=${default_config}
+fi
+
+# 1 - debug enabled
+# 0 or none - debug disabled
+_DEBUG_=1
+
+DEBUG()
+{
+    if test "x${_DEBUG_}" == "x1"; then
+        echo $@ 1>&2
+    fi
+}
+
+dw_speed=128kbps
+while read local_port destination; do
+    DEBUG "Running limitation on ${destination} through local port ${local_port} ..."
+    ssh -n -f -l root localhost -p ${local_port} "/home/p2p/traffic_shape.sh start --down=${dw_speed}"
+done < <(grep -v '^[ \t]*#' ${config} | grep -v '^[ \t]*$')
diff --git a/scripts/kvm/mreset-bw-limit b/scripts/kvm/mreset-bw-limit
new file mode 100755 (executable)
index 0000000..577e92b
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+#
+# Run remote tc script enabling bandwidth limitation.
+#
+# Use the same traffic limitation for all systems
+#
+
+#
+# 2011, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
+#
+
+default_config=destinations.default.conf
+
+if test $# -ge 2; then
+    echo "Usage: $0 [config]" 1>&2
+    exit 1
+elif test $# -eq 1; then
+    config="$1"
+else
+    config=${default_config}
+fi
+
+# 1 - debug enabled
+# 0 or none - debug disabled
+_DEBUG_=1
+
+DEBUG()
+{
+    if test "x${_DEBUG_}" == "x1"; then
+        echo $@ 1>&2
+    fi
+}
+
+dw_speed=128kbps
+while read local_port destination; do
+    DEBUG "Running limitation on ${destination} through local port ${local_port} ..."
+    ssh -n -f -l root localhost -p ${local_port} "/home/p2p/traffic_shape.sh stop"
+done < <(grep -v '^[ \t]*#' ${config} | grep -v '^[ \t]*$')