Skip to content
Snippets Groups Projects
Commit e054e810 authored by Rowan Powell's avatar Rowan Powell
Browse files

Added Port and SF config measurements, refactored all line protocol generation into new file

parent a3b7b74d
No related branches found
No related tags found
No related merge requests found
# line protocol
# Method to create a full InfluxDB request statement (based on partial statement from client)
import uuid
from random import random, randint
def _generateClientRequest(cReq, id, time):
# Tags first
result = 'sid="' + str(id) + '",' + cReq
# Fields
# No additional fields here yet
# Timestamp
result += ' ' + str(_getNSTime(time))
# Measurement
return 'request,' + result
# Method to create a full InfluxDB response statement
def _generateServerResponse(reqID, quality, time, cpuUsage, qualityDifference):
# Tags first
result = ' '
# Fields
result += 'quality=' + str(quality) + ','
result += 'cpuUsage=' + str(cpuUsage) + ','
result += 'qualityDifference=' + str(qualityDifference) + ','
result += 'requestID="' + str(reqID) + '",'
result += 'index="' + str(uuid.uuid4()) + '"'
# Timestamp
result += ' ' + str(_getNSTime(time))
# Measurement
# print('response'+result)
return 'response' + result
def _generateNetworkReport(sum_of_client_quality, time):
# Measurement
result = 'net_port_io'
# Tags
result += ',port_id=enps03 '
# Fields
result += 'RX_BYTES_PORT_M=' + str(sum_of_client_quality * 32) + ","
result += 'TX_BYTES_PORT_M=' + str(sum_of_client_quality * 1024)
# Timestamp
result += ' ' + str(_getNSTime(time))
# Measurement
# print('network'+result)
return result
def _generateMpegDashReport(resource, quality, time):
# Measurement
result = 'mpegdash_service '
# Tags
#None
# Fields
requests = randint(10, 30)
avg_response_time = 50 + randint(0, 100) + randint(0, 10 * quality)
peak_response_time = avg_response_time + randint(30, 60) + randint(5, 10) * quality
result += 'cont_nav=\"' + str(resource) + "\","
result += 'cont_rep=' + str(quality) + ','
result += 'requests=' + str(requests) + ','
result += 'avg_response_time=' + str(avg_response_time) + ','
result += 'peak_response_time=' + str(peak_response_time)
# Timestamp
result += ' ' + str(_getNSTime(time))
#print(result)
return result
def _generateServerConfig(ID, location, cpu, mem, storage, time):
# metric
result = 'host_resource'
# Tags
result += ',slide_id=' + quote_wrap(ID)
result += ',location=' + quote_wrap(location)
result += ' '
# Fields
result += 'cpu=' + str(cpu)
result += ',memory=' + quote_wrap(mem)
result += ',storage=' + quote_wrap(storage)
# Time
result += ' ' + str(_getNSTime(time))
print(result)
return result
def _generateVMConfig(state, cpu, mem, storage, time):
# metric
result = 'vm_res_alloc'
# Tags
result += ',vm_state=' + quote_wrap(state)
result += ' '
# Fields
result += 'cpu=' + str(cpu)
result += ',memory=' + quote_wrap(mem)
result += ',storage=' + quote_wrap(storage)
# Time
result += ' ' + str(_getNSTime(time))
print(result)
return result
def _configure_port(port_id, state, rate, time):
# metric
result = 'net_port_config '
# Fields
result += 'port_id=' + quote_wrap('enps' + port_id)
result += 'port_state=' + quote_wrap(state)
result += 'tx_constraint=' + quote_wrap(rate)
result += ' '
# Time
result += ' ' + str(_getNSTime(time))
print(result)
return result
def _configure_service_function(state, max_connected_clients):
# measurement
result = 'mpegdash_service_config'
# tags
result += ',running='+quote_wrap(state)
result += ' '
# fields
result += 'max_connected_clients='+max_connected_clients
return result
def quote_wrap(str):
return "\"" + str + "\""
# InfluxDB likes to have time-stamps in nanoseconds
def _getNSTime(time):
# Convert to nano-seconds
return 1000000 * time
File added
This diff is collapsed.
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