@@ -0,0 +1,1057 @@
+## Outbound Traffic Monitor v0.1 - Jan 2014%0A## Shutdown the server if the maximum outbound speed is reached.%0A%0A# Set the interface you wish to monitor, eg: eth0, wlan0, usb0%0AINTERFACE = %22eth0%22%0A%0A# Set the maximum out speed in KB/s, shutdown the server if reached.%0AMAXIMUM_SPEED = 15%0A%0A# Set the number of retries to test for the average maximum speed. If the average speed is greater%0A# than the maximum speed for x number of retries, then shutdown.%0ARETRIES = 5%0A%0A# Set the interval (in seconds), between retries to test for the maximum speed.%0AINTERVAL = 5%0A%0A%0Aimport os, time%0Afrom commands import getoutput%0A%0Adef worker ():%0A    RETRIES_COUNT = RETRIES%0A    while True:%0A        SPEED = int(float(getoutput(%22ifstat -i %25s 1 1 %7C awk '%7Bprint $1%7D' %7C sed -n '3p'%22 %25 INTERFACE)))%0A        if (SPEED %3C MAXIMUM_SPEED and RETRIES_COUNT %3C= 0):%0A            os.system(%22shutdown -h now%22)%0A        elif SPEED %3C MINIMUM_SPEED:%0A            RETRIES_COUNT -= 1%0A            time.sleep(INTERVAL)%0A        else:%0A            RETRIES_COUNT = RETRIES%0A            time.sleep(INTERVAL)%0A%0Aworker()%0A

Create server_shutdown_based_on_network_speed.py