summaryrefslogtreecommitdiffstats
path: root/Monitoring/MonitoringTool/PacketTracking/scripts/packet_tracking.sh
blob: b160c8f0f6ee05eeffc8f63a121551f38bf8de1b (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash

# PacketTracking in NOVI
# Copyright (C) 2011 Fokus Fraunhofer <Julian.Vetter@fokus.fraunhofer.de>
#

stop_probe()
{
    for NODE in $NODES; do
        echo "Stopping probe on ${NODE} (${!NODE})"
	ssh ${SSH_PARAMS} novi_novi@${!NODE} "sudo ${IMPD_STOP}"
    done
    exit 0
}

start_probe()
{
    for NODE in $NODES; do
        echo "Starting probe on ${NODE} (${!NODE})"
        PARAMS=${NODE}_PARAMS
        PARAMS=${!PARAMS}
        #echo "ssh ${SSH_PARAMS} novi_novi@${!NODE} 'sudo ${IMPD_START} $PARAMS'"
        ssh ${SSH_PARAMS} novi_novi@${!NODE} "sudo ${IMPD_START} $PARAMS"
    done
}

transfer()
{
    for NODE in $NODES; do
        echo "Removing old dir from ${NODE} (${!NODE})"
        ssh ${SSH_PARAMS} novi_novi@${!NODE} "rm -rf ${WDIR}"
	ssh ${SSH_PARAMS} novi_novi@${!NODE} "mkdir -p /home/novi_novi/pt/packet"
        echo "Transfering data to ${NODE} (${!NODE})"

        #Copying all necessary files to the 'packet' directory
        scp -r ${SSH_PARAMS} /home/novi_novi/pt/impd4e novi_novi@${!NODE}:${WDIR} 1> /dev/null
        scp -r ${SSH_PARAMS} /home/novi_novi/pt/libipfix novi_novi@${!NODE}:${WDIR} 1> /dev/null
	scp -r ${SSH_PARAMS} /home/novi_novi/pt/scripts/start_probe.sh novi_novi@${!NODE}:${WDIR} 1> /dev/null
    done
}

helper()
{
    echo "usage: openepc-pt CONFIGURATION (start|stop|transfer|transfer_keys)"
    echo "  transfer        Transfers the whole 'pt' directory to the target nodes"
    echo "  start           Starts all probes on the devices"
    echo "  stop            Stops all probes"
    echo "  help            Show this help"
    
}

[ \! -z "$1" ] && [ -f "$1" ] && . "$1" || (echo "couldn't read configuration file"; exit 1)

case $2 in
"transfer")
    transfer;;
"start")
    start_probe;;
"stop")
    stop_probe;;
"help")
    helper;;
*)
    helper;;
esac