Skip to content
Snippets Groups Projects
Commit f56d62ef authored by MJB's avatar MJB
Browse files

fixed simulation error as the timestamps where converted incorrectly to mS...

fixed simulation error as the timestamps where converted incorrectly to mS when the precision in influx expects nS, the queries now() - <time> work in Chronograf
parent f5ecc0c6
Branches
Tags
No related merge requests found
...@@ -83,7 +83,9 @@ def quote_wrap(str): ...@@ -83,7 +83,9 @@ def quote_wrap(str):
# InfluxDB likes to have time-stamps in nanoseconds # InfluxDB likes to have time-stamps in nanoseconds
def _getNSTime(time): def _getNSTime(time):
# Convert to nano-seconds # Convert to nano-seconds
return 1000000 * time timestamp = int(1000000000*time)
print("timestamp", timestamp)
return timestamp
# DEPRICATED # DEPRICATED
# ____________________________________________________________________________ # ____________________________________________________________________________
......
...@@ -8,7 +8,7 @@ import random ...@@ -8,7 +8,7 @@ import random
# Simulation parameters # Simulation parameters
TICK_TIME = 1 TICK_TIME = 1
DEFAULT_REQUEST_RATE_INCREMENT = 5 DEFAULT_REQUEST_RATE_INCREMENT = 5
SIMULATION_TIME_SEC = 10 SIMULATION_TIME_SEC = 180
# CLMC parameters # CLMC parameters
INFLUX_DB_URL = 'http://192.168.50.10:8086' INFLUX_DB_URL = 'http://192.168.50.10:8086'
...@@ -25,8 +25,8 @@ class sim: ...@@ -25,8 +25,8 @@ class sim:
def run(self, simulation_length_seconds): def run(self, simulation_length_seconds):
start_time = time.time() start_time = time.time()-SIMULATION_TIME_SEC
current_time = int(time.time()) sim_time = start_time
ip_endpoints = [{'agent_url': 'http://192.168.50.11:8186', 'location': 'DC1', 'cpu': 16, ip_endpoints = [{'agent_url': 'http://192.168.50.11:8186', 'location': 'DC1', 'cpu': 16,
'mem': '8GB', 'storage': '1TB', 'request_queue': 0, 'request_arrival_rate': 0}, 'mem': '8GB', 'storage': '1TB', 'request_queue': 0, 'request_arrival_rate': 0},
...@@ -35,36 +35,44 @@ class sim: ...@@ -35,36 +35,44 @@ class sim:
] ]
# Simulate configuration of the ipendpoints # Simulate configuration of the ipendpoints
# endpoint state->mu, sigma, mS normal distribution # endpoint state->mu, sigma, secs normal distribution
config_delay_dist = {"placed": [5000, 0.68], "booted": [10000, 0.68],"connected": [1000, 0.68]} config_delay_dist = {"placed": [5, 0.68], "booted": [10, 0.68],"connected": [10, 0.68]}
# Place the endpoints # Place the endpoints
max_delay = 0 max_delay = 0
for ip_endpoint in ip_endpoints: for ip_endpoint in ip_endpoints:
delay_time = int(random.normalvariate(config_delay_dist['placed'][0], config_delay_dist['placed'][0]*config_delay_dist['placed'][1])) delay_time = random.normalvariate(config_delay_dist['placed'][0], config_delay_dist['placed'][0]*config_delay_dist['placed'][1])
self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_vm_config('placed', ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], current_time+delay_time))
# print('sim_time: ', sim_time)
# print('delay_time: ', delay_time)
# timestamp = sim_time+delay_time
# print('timestamp: ', timestamp)
# ns_time = int(timestamp*1000000)
# print('ns_time: ', ns_time)
self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_vm_config('placed', ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], sim_time+delay_time))
if delay_time > max_delay: if delay_time > max_delay:
max_delay = delay_time max_delay = delay_time
current_time +=max_delay sim_time +=max_delay
max_delay = 0 max_delay = 0
# Boot the endpoints # Boot the endpoints
for ip_endpoint in ip_endpoints: for ip_endpoint in ip_endpoints:
delay_time = int(random.normalvariate(config_delay_dist['booted'][0], config_delay_dist['booted'][0]*config_delay_dist['booted'][1])) delay_time = random.normalvariate(config_delay_dist['booted'][0], config_delay_dist['booted'][0]*config_delay_dist['booted'][1])
self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_vm_config('booted', ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], current_time+delay_time)) self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_vm_config('booted', ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], sim_time+delay_time))
if delay_time > max_delay: if delay_time > max_delay:
max_delay = delay_time max_delay = delay_time
current_time +=max_delay sim_time +=max_delay
max_delay = 0 max_delay = 0
# Connect the endpoints # Connect the endpoints
for ip_endpoint in ip_endpoints: for ip_endpoint in ip_endpoints:
delay_time = int(random.normalvariate(config_delay_dist['connected'][0], config_delay_dist['connected'][0]*config_delay_dist['connected'][1])) delay_time = random.normalvariate(config_delay_dist['connected'][0], config_delay_dist['connected'][0]*config_delay_dist['connected'][1])
self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_vm_config('connected', ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], current_time+delay_time)) self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_vm_config('connected', ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], sim_time+delay_time))
if delay_time > max_delay: if delay_time > max_delay:
max_delay = delay_time max_delay = delay_time
current_time +=max_delay sim_time +=max_delay
request_arrival_rate_inc = DEFAULT_REQUEST_RATE_INCREMENT request_arrival_rate_inc = DEFAULT_REQUEST_RATE_INCREMENT
request_queue = 0 request_queue = 0
...@@ -104,24 +112,24 @@ class sim: ...@@ -104,24 +112,24 @@ class sim:
cpu_active_time = int(requests_processed*request_processing_time) cpu_active_time = int(requests_processed*request_processing_time)
cpu_idle_time = int(cpu_time_available-cpu_active_time) cpu_idle_time = int(cpu_time_available-cpu_active_time)
cpu_usage = cpu_active_time/cpu_time_available cpu_usage = cpu_active_time/cpu_time_available
self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_cpu_report(cpu_usage, cpu_active_time, cpu_idle_time, current_time)) self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_cpu_report(cpu_usage, cpu_active_time, cpu_idle_time, sim_time))
# calc network usage metrics with no constraints. # calc network usage metrics with no constraints.
bytes_sent = 1024*requests_processed bytes_sent = 1024*requests_processed
bytes_rec = 32*requests_processed bytes_rec = 32*requests_processed
self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_network_report(bytes_rec, bytes_sent, current_time)) self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_network_report(bytes_rec, bytes_sent, sim_time))
# time to process all of the requests in the queue # time to process all of the requests in the queue
peak_response_time = ip_endpoint['request_queue']*request_processing_time/ip_endpoint['cpu'] peak_response_time = ip_endpoint['request_queue']*request_processing_time/ip_endpoint['cpu']
# mid-range # mid-range
avg_response_time = (peak_response_time+request_processing_time)/2 avg_response_time = (peak_response_time+request_processing_time)/2
self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_mpegdash_report('https://Netflix.com/scream', ip_endpoint['request_arrival_rate'], avg_response_time, peak_response_time, current_time)) self._sendInfluxData(ip_endpoint['agent_url'], lp.generate_mpegdash_report('https://Netflix.com/scream', ip_endpoint['request_arrival_rate'], avg_response_time, peak_response_time, sim_time))
# remove requests processed off the queue # remove requests processed off the queue
ip_endpoint['request_queue'] -= int(requests_processed) ip_endpoint['request_queue'] -= int(requests_processed)
current_time += TICK_TIME*1000 sim_time += TICK_TIME
end_time = time.time() end_time = sim_time
print("Simulation Finished. Start time {0}. End time {1}. Total time {2}".format(start_time,end_time,end_time-start_time)) print("Simulation Finished. Start time {0}. End time {1}. Total time {2}".format(start_time,end_time,end_time-start_time))
def _createDB(self): def _createDB(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment