Skip to content
Snippets Groups Projects
Commit bce4a2e7 authored by karamchandan's avatar karamchandan
Browse files

Removed unused scripts and restored my_deploy.sh

parent c2efe959
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!128Fixes on L3 Cybersecurity components
This diff is collapsed.
timestamp_first_req,timestamp_last_req,total_time,batch_size
1684439500.7262454,1684439518.696577,17.97033166885376,256
1684439518.7009058,1684439536.8979518,18.197046041488647,256
1684439536.9033403,1684439573.1907332,36.28739285469055,256
1684439573.1981168,1684439591.7938573,18.59574055671692,256
1684439591.801213,1684439626.0076125,34.20639944076538,256
1684439626.0122116,1684439660.0969336,34.08472204208374,256
1684439660.1023145,1684439694.6814883,34.57917380332947,256
1684439694.6866412,1684439713.177154,18.49051284790039,256
1684439713.183632,1684439748.8026614,35.61902952194214,256
1684439748.8648906,1684439768.0725336,19.207643032073975,256
1684439768.0773811,1684439786.7156172,18.638236045837402,256
1684439786.7640705,1684439805.4091456,18.64507508277893,256
1684439805.4138126,1684439841.2038834,35.79007077217102,256
1684439841.2108314,1684439860.10726,18.89642858505249,256
1684439860.1131806,1684439878.264643,18.15146231651306,256
1684439878.2704298,1684439896.9845712,18.714141368865967,256
1684439897.0112722,1684439915.293344,18.282071828842163,256
1684439915.2984266,1684439934.505506,19.20707941055298,256
1684439934.5113277,1684439952.389038,17.877710342407227,256
folder_name="exp1_results"
echo "Output folder: $folder_name"
if [ -d "$folder_name" ]; then
echo "Output folder '$folder_name' already exists."
echo "Removing all files in '$folder_name'..."
rm -r "$folder_name"/*
else
echo "Creating output folder '$folder_name'..."
mkdir "$folder_name"
fi
# Write column names to csv file
echo "number_active_pods,cpu_usage" > $folder_name/pod_info.csv
echo "Starting collection of CAD metrics..."
while true; do
list=($(kubectl get pods --namespace tfs | grep l3-centralized | awk '{print $1}'))
#kubectl -n "tfs" cp $pod_name:exp_1.csv $folder_name/$pod_name.csv -c server
echo "Currently running pods:"
for item in "${list[@]}"; do
echo "Pod: $item"
echo "Copying CAD metrics csv file to $folder_name/response_times_$item.csv"
kubectl -n "tfs" cp $item:response_times.csv $folder_name/response_times_$item.csv -c server
done
echo "Getting number of currently active pods and CPU usage..."
number_pods=$(kubectl get pods --namespace tfs | grep l3-centralized | wc -l)
cpu_usage=$(kubectl --namespace tfs get all | grep autoscaling/l3-centralizedattackdetectorservice-hpa | awk '{print $3}')
# check that cpu_usage does not contain "unknown"
if [[ $cpu_usage == *"unknown"* ]]; then
cpu_usage=0
fi
echo
echo "Number of currently active pods: $number_pods"
echo "CPU usage: $cpu_usage"
echo
echo "Writing number of currently active pods and CPU usage to $folder_name/pod_info.csv"
echo "$number_pods,$cpu_usage" >> $folder_name/pod_info.csv
sleep 1
# check if file "stop_exp1" exists
if [ -f "stop_exp1" ]; then
echo "File 'stop_exp1' found. Stopping experiment."
break
fi
done
echo "Collection of CAD metrics stopped."
rm stop_exp1
#!/bin/bash
export BATCH_SIZE=${1:-10}
export TARGET_CPU_UTIL=${2:-80}
echo "exp1 parameters set to:"
echo "BATCH_SIZE: $BATCH_SIZE"
echo "TARGET_CPU_UTIL: $TARGET_CPU_UTIL"
CAD_manifest="./manifests/l3_centralizedattackdetectorservice.yaml"
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# apiVersion: apps/v1
# kind: Deployment
# metadata:
# name: l3-centralizedattackdetectorservice
# spec:
# selector:
# matchLabels:
# app: l3-centralizedattackdetectorservice
# template:
# metadata:
# labels:
# app: l3-centralizedattackdetectorservice
# spec:
# terminationGracePeriodSeconds: 5
# containers:
# - name: server
# image: labs.etsi.org:5050/tfs/controller/l3_centralizedattackdetector:latest
# imagePullPolicy: Always
# ports:
# - containerPort: 10001
# - containerPort: 9192
# env:
# - name: LOG_LEVEL
# value: "DEBUG"
# - name: BATCH_SIZE
# value: "10"
# - name: CAD_CLASSIFICATION_THRESHOLD
# Update BATCH_SIZE value in the CAD manifest
echo "Updating BATCH_SIZE value in the CAD manifest to $BATCH_SIZE"
found=0
line_num=0
while read line; do
line_num=$((line_num+1))
if [[ $line == *"name: BATCH_SIZE"* ]]; then
found=1
fi
if [[ $found == 1 ]]; then
if [[ $line == *"value"* ]]; then
echo "Found BATCH_SIZE value in the CAD manifest at line $line_num"
sed -i "${line_num}s/\(value: \).*/\1\"$BATCH_SIZE\"/" $CAD_manifest
break
fi
fi
done < $CAD_manifest
# Update averageUtilization value in the CAD manifest to TARGET_CPU_UTIL
echo "Updating averageUtilization value in the CAD manifest to $TARGET_CPU_UTIL"
sed -i "s/\(averageUtilization: \).*/\1$TARGET_CPU_UTIL/" $CAD_manifest
\ No newline at end of file
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
component=$1
source "my_deploy.sh"
echo "Deploying $component..."
# check if component == "CAD"
if [ $component == "CAD" ]; then
# find kubernetes pod that contains "centralizedattackdetectorservice"
pod=$(kubectl --namespace $TFS_K8S_NAMESPACE get pods | grep l3-centralizedattackdetectorservice | awk '{print $1}')
# delete pod
kubectl --namespace $TFS_K8S_NAMESPACE delete pod $pod --force --grace-period=0
# # wait for pod to be deleted
# while [ $(kubectl --namespace $TFS_K8S_NAMESPACE get pods | grep l3-centralizedattackdetectorservice | wc -l) -gt 0 ]; do
# sleep 1
# done
# deploy l3_centralizedattackdetector component
./deploy_component.sh "l3_centralizedattackdetector"
fi
# check if component == "AM"
if [ $component == "AM" ]; then
# find kubernetes pod that contains "l3-attackmitigatorservice"
pod=$(kubectl --namespace $TFS_K8S_NAMESPACE get pods | grep l3-attackmitigatorservice | awk '{print $1}')
# delete pod
kubectl --namespace $TFS_K8S_NAMESPACE delete pod $pod --force --grace-period=0
# # wait for pod to be deleted
# while [ $(kubectl --namespace $TFS_K8S_NAMESPACE get pods | grep l3-attackmitigatorservice | wc -l) -gt 0 ]; do
# sleep 1
# done
# deploy l3_attackmitigator component
./deploy_component.sh "l3_attackmitigator"
fi
echo "Component $component deployed"
echo "Restarting DAD..."
sshpass -p "ubuntu" ssh -o StrictHostKeyChecking=no -n -f ubuntu@192.168.165.73 "sh -c 'nohup /home/ubuntu/TeraflowDockerDistributed/restart.sh > /dev/null 2>&1 &'"
echo "DAD restarted"
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ssh -L 12345:localhost:80 ubuntu@192.168.165.78
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment