Newer
Older
Nikolay Stanchev
committed
#!/bin/bash
Nikolay Stanchev
committed
CLMC_IP="172.40.231.51"
Nikolay Stanchev
committed
sfc="fms-sfc"
sfci="fms-sfc-1"
service_function="fms-storage"
measurement="tomcat_connector"
response_time_field="(max(processing_time) - min(processing_time)) / ((count(processing_time) - 1)*1000)"
request_size_field="(max(bytes_received) - min(bytes_received)) / (count(bytes_received) - 1)"
response_size_field="(max(bytes_sent) - min(bytes_sent)) / (count(bytes_sent) - 1)"
rtt_measurement="graph_measurement"
Nikolay Stanchev
committed
query_period=30
ues=("ue20" "ue22" "ue23" "ue24")
endpoints=("fms-storage-endpoint" "fms-storage-second-endpoint")
Nikolay Stanchev
committed
Nikolay Stanchev
committed
echo "Building network subgraph..."
response=$(curl -s -X POST http://${CLMC_IP}/clmc-service/graph/network)
echo ${response}
Nikolay Stanchev
committed
while true
do
echo "Building temporal graph..."
end=$(date +%s)
start=$((${end}-${query_period}))
echo "Start - ${start}, End - ${end}"
JSON_STRING=$( jq -n \
--arg sfc "${sfc}" \
--arg sfci "${sfci}" \
--arg sf "${service_function}" \
--arg measurement "${measurement}"\
--arg response_time "${response_time_field}"\
--arg request_size "${request_size_field}"\
--arg response_size "${response_size_field}"\
--argjson from ${start}\
--argjson to ${end}\
'{from: $from, to: $to, service_function_chain: $sfc, service_function_chain_instance: $sfci, service_functions: {($sf): {measurement_name: $measurement, response_time_field: $response_time, request_size_field: $request_size, response_size_field: $response_size}}}' )
echo "Sending build request to CLMC"
Nikolay Stanchev
committed
response=$(curl -s -X POST -d "${JSON_STRING}" http://${CLMC_IP}/clmc-service/graph/temporal)
fields=$(echo ${response} | jq -r '. | "\(.graph.time_range.to) \(.graph.uuid)"')
read timestamp graph_uuid <<< ${fields}
echo "Received request uuid ${graph_uuid}"
echo "Timestamp to use for measurement ${timestamp}"
Nikolay Stanchev
committed
for endpoint in ${endpoints[@]}; do
for ue in ${ues[@]}; do
echo "Querying for round-trip time..."
Nikolay Stanchev
committed
response=$(curl -s -X GET "http://${CLMC_IP}/clmc-service/graph/temporal/${graph_uuid}/round-trip-time?startpoint=${ue}&endpoint=${endpoint}")
global_tags=$(echo ${response} | jq -r '.global_tags | to_entries | map("\(.key)=\(.value|tostring)") | join(",")')
echo "Global tags: ${global_tags}"
local_tags=$(echo ${response} | jq -r '.local_tags | to_entries | map("\(.key)=\(.value|tostring)") | join (",")')
echo "Local tags: ${local_tags}"
Nikolay Stanchev
committed
fields=$(echo ${response} | jq -r '. | "\(.round_trip_time) \(.response_time) \(.total_forward_latency)"')
read rtt service_delay network_delay <<< ${fields}
measurement_line="${rtt_measurement},${global_tags},${local_tags} round_trip_time=${rtt},service_delay=${service_delay},network_delay=${network_delay} ${timestamp}"
echo "Measurement line: ${measurement_line}"
response=$(curl -si -X POST "http://${CLMC_IP}/influxdb/write?db=${sfc}" --data-binary "${measurement_line}")
echo "InfluxDB response: ${response}"
done
done
Nikolay Stanchev
committed
echo "Deleting temporal graph..."
Nikolay Stanchev
committed
response=$(curl -s -X DELETE "http://${CLMC_IP}/clmc-service/graph/temporal/${graph_uuid}")
Nikolay Stanchev
committed
echo "Sleeping ${query_period} seconds"
Nikolay Stanchev
committed
sleep ${query_period}
done