File: az-network-corrupter.sh

package info (click to toggle)
mpich 4.3.0%2Breally4.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 419,120 kB
  • sloc: ansic: 1,215,557; cpp: 74,755; javascript: 40,763; f90: 20,649; sh: 18,463; xml: 14,418; python: 14,397; perl: 13,772; makefile: 9,279; fortran: 8,063; java: 4,553; asm: 324; ruby: 176; lisp: 19; php: 8; sed: 4
file content (40 lines) | stat: -rwxr-xr-x 1,169 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash -eE

echo "Running $0 $*..."
eval "$*"
initial_delay=${initial_delay:=10}
interfaces=${interfaces:=bond0}
cycles=${cycles:=1000}
downtime=${downtime:=5}
uptime=${uptime:=20}
reset=${reset:="no"}


manager_script_dir=/hpc/noarch/git_projects/hpc-mtt-conf/scripts
manager_script=${manager_script_dir}/switch_port_on_off.py

if [ "x$reset" = "xyes" ]; then
    for interface in ${interfaces} ; do
        echo "Resetting interface ${interface} on $(hostname) interface ..."
        ${manager_script} -d ${manager_script_dir}/hosts --host $(hostname) -a on -i ${interface}
    done
    sleep "$uptime"
    exit $?
fi

echo "Initial delay ${initial_delay} sec"
sleep ${initial_delay}

for i in $(seq 1 ${cycles}); do
    echo "#$i Put it down! And sleep ${downtime}"
    for interface in ${interfaces} ; do
        ${manager_script} --one -d ${manager_script_dir}/hosts --host $(hostname) -a off -i ${interface}
    done
    sleep "$downtime"

    echo "#$i Put it up! And sleep ${uptime}"
    for interface in ${interfaces} ; do
        ${manager_script} -d ${manager_script_dir}/hosts --host $(hostname) -a on -i ${interface}
    done
    sleep "$uptime"
done