Created
March 21, 2016 19:44
-
-
Save alistairncoles/cba6a7953748d054f5df to your computer and use it in GitHub Desktop.
Monitoring swift container sync traffic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# could be smarter and read these ports from the server conf files... | |
OBJ_SERVER_PORTS="6010 6020 6030 6040" | |
PROXY_SERVER_PORT=8080 | |
setup_rules() { | |
# $1 should be -A to set, -D to unset | |
OP=$1 | |
# the order we set the rules dictates the order they are displayed. | |
# bytes from obj servers... | |
for PORT in $OBJ_SERVER_PORTS | |
do | |
iptables $OP INPUT -p tcp --sport $PORT | |
done | |
# bytes to proxy server ... | |
iptables $OP INPUT -p tcp --dport $PROXY_SERVER_PORT | |
# bytes to object servers... | |
for PORT in $OBJ_SERVER_PORTS | |
do | |
iptables $OP INPUT -p tcp --dport $PORT | |
done | |
} | |
set() { | |
setup_rules -A | |
} | |
unset() { | |
setup_rules -D | |
} | |
show() { | |
iptables -nvxL INPUT | |
} | |
reset() { | |
iptables -Z INPUT | |
} | |
cmd=$0 | |
if [[ -z $1 ]]; | |
then | |
echo "$cmd [set|unset|reset|show]" | |
exit | |
fi | |
$1 | |
echo "$1 rules on ports $PROXY_SERVER_PORT $OBJ_SERVER_PORTS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewing https://review.openstack.org/#/c/270961/