fi
# convert host_id and veid to veth IP address in 10.0.0.0/8 network
-host_veid_to_eth_ip()
-{
- host_id=$1
- veid=$2
- ip_part1=$(($veid / 100))
- ip_part2=$(($veid % 100))
- id=$(echo "$host_id" | awk '{printf "%d", $1;}')
- echo "10.$ip_part1.$id.$ip_part2"
-}
-
-# convert p2p-next-${host_id}-${veid} hostname to veth IP address
-hostname_to_ip()
-{
- hostname=$1
-
- veid=${hostname##*-}
-tmp=${hostname%-*}
- host_id=${tmp##*-}
-
- host_veid_to_eth_ip $host_id $veid
-}
-
-OWN_IP=$(hostname_to_ip $(hostname))
+#host_veid_to_eth_ip()
+#{
+# host_id=$1
+# veid=$2
+# ip_part1=$(($veid / 100))
+# ip_part2=$(($veid % 100))
+# id=$(echo "$host_id" | awk '{printf "%d", $1;}')
+# echo "10.$ip_part1.$id.$ip_part2"
+#}
+#
+## convert p2p-next-${host_id}-${veid} hostname to veth IP address
+#hostname_to_ip()
+#{
+# hostname=$1
+#
+# veid=${hostname##*-}
+#tmp=${hostname%-*}
+# host_id=${tmp##*-}
+#
+# host_veid_to_eth_ip $host_id $veid
+#}
+#
+#OWN_IP=$(hostname_to_ip $(hostname))
+OWN_IP="0.0.0.0" #"10.42.5.225"
cd "$WORKING_FOLDER_REL_PATH"/TorrentsAndData
DATA_PATH=$(pwd)
cd $SWIFT_ABS_PATH
#echo ./swift -f "${DATA_PATH}"/"${TORRENT_FILE}" -l ${OWN_IP}:6881 -p > ~/deb
-./swift -f "${DATA_PATH}"/"${TORRENT_FILE}" -l ${OWN_IP}:6881 -p
+echo "***!@"
+echo ./swift -f "${DATA_PATH}"/"${TORRENT_FILE}" -l ${OWN_IP}:6882 -p
+./swift -f "${DATA_PATH}"/"${TORRENT_FILE}" -l ${OWN_IP}:6882 -p
--- /dev/null
+#!/bin/bash
+
+#
+# monitor process resources using systat (/proc), free, iptables and /sys
+#
+# 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
+#
+
+# command line argument must be a process id
+if test $# -ne 1; then
+ echo "Usage: $0 <pid>" 1>&2
+ exit 1
+fi
+
+pid=$1
+
+# check if pid exists
+kill -0 $pid > /dev/null 2>&1
+if test $? -ne 0; then
+ ps -ef
+ echo -e "PID $pid does not exists.\nUsage: $0 <pid>" 1>&2
+ exit 1
+fi
+
+# use _DEBUG="off" to turn off debug printing
+_DEBUG="off"
+
+# Read the global configuration file
+# Check if the global configuration file exists
+if [ ! -e globalconfig ]; then
+ echo "Warning: The global config file globalconfig does not exist."
+else
+ source globalconfig
+fi
+
+# cleanup code (run as signal handler)
+cleanup()
+{
+ kill -TERM $pidstat_pid
+ kill -TERM $iostat_pid
+ kill -TERM $free_pid
+ kill -TERM $timer_callback_pid
+}
+
+# function acting like a periodic callback
+timer_callback()
+{
+ while true; do
+ date +%F-%X
+ sudo iptables -t filter -L -n -v
+ cat /sys/class/net/eth0/statistics/rx_bytes /sys/class/net/eth0/statistics/tx_bytes
+ sleep 1
+ done
+}
+
+# run cleanup on signal receive
+trap cleanup 0 1 2 3 15
+
+# per-process processor (-u), disk (-d) and memory usage (-r)
+pidstat -u -d -r -p $pid 1 &
+pidstat_pid=$!
+
+# per-system (iostat and free)
+iostat -d -c 1 &
+iostat_pid=$!
+free -s 1 &
+free_pid=$!
+
+# per-process network bandwidth usage (iptables)
+# /sys/class/net/$iface/statistics/{tx,rx}_bytes (per system)
+
+# remove old iptables rules/chains
+sudo iptables -t filter -F cout > /dev/null 2>&1
+sudo iptables -t filter -F cin > /dev/null 2>&1
+sudo iptables -t filter -X cout > /dev/null 2>&1
+sudo iptables -t filter -X cin > /dev/null 2>&1
+sudo iptables -t filter -F OUTPUT > /dev/null 2>&1
+
+# add iptables rule
+sudo iptables -t filter -N cout
+sudo iptables -t filter -N cin
+sudo iptables -t filter -A OUTPUT -j cout
+sudo iptables -t filter -A cout -j ACCEPT
+sudo iptables -t filter -A OUTPUT -j cin
+sudo iptables -t filter -A cin -j ACCEPT
+
+timer_callback &
+timer_callback_pid=$!
+
+# wait for child processes to end (shouldn't happen)
+wait