def plot_sync_gateway_expvars(cluster_config, figure, json_file_name): print("Plotting sync_gateway expvars ...") # Get writer hostnames for provisioning_config sg_writers = hosts_for_tag(cluster_config, "sg_accels") sg_writer_hostnames = [ sg_writer["ansible_host"] for sg_writer in sg_writers ] with open(json_file_name, "r") as f: obj = json.loads(f.read(), object_pairs_hook=OrderedDict) datetimes = [] memstats_alloc = [] memstats_sys = [] writer_datetimes = [] writer_memstats_alloc = [] writer_memstats_sys = [] for timestamp in obj: endpoint = obj[timestamp]["endpoint"] hostname = endpoint.split(":")[0] if hostname in sg_writer_hostnames: writer_datetimes.append( datetime.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S.%f")) writer_memstats_alloc.append( obj[timestamp]["expvars"]["memstats"]["Alloc"]) writer_memstats_sys.append( obj[timestamp]["expvars"]["memstats"]["Sys"]) else: datetimes.append( datetime.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S.%f")) memstats_alloc.append( obj[timestamp]["expvars"]["memstats"]["Alloc"]) memstats_sys.append(obj[timestamp]["expvars"]["memstats"]["Sys"]) # Plot Alloc / Sys ax1 = figure.add_subplot(111) ax1.set_title( "(writers=blue, readers=green) memstats.Alloc (square) / memstats.Sys (triangle)" ) ax1.plot(datetimes, memstats_alloc, "gs", datetimes, memstats_sys, "g^") ax1.plot(writer_datetimes, writer_memstats_alloc, "bs", writer_datetimes, writer_memstats_sys, "b^") figure.autofmt_xdate()
def plot_machine_stats(cluster_config, figure, folder_path): print("Plotting machine stats ...") folders = [x[0] for x in os.walk(folder_path)] machine_stats = dict() # entry at one is the first subdirect for subfolder in folders[1:]: # Get name of sg path_components = os.path.split(subfolder) name = path_components[len(path_components) - 1] # Get CPU stats dict for sg with open("{}/cpu_stats.json".format(subfolder), "r") as f: obj = json.loads(f.read()) machine_stats[name] = obj ax3 = figure.add_subplot(111) ax3.set_title("CPU percent (writers=blue, readers=green") # Get writer hostnames for provisioning_config sg_writers = hosts_for_tag(cluster_config, "sg_accels") sg_writer_hostnames = [ sg_writer["inventory_hostname"] for sg_writer in sg_writers ] for machine in machine_stats: entity = machine_stats[machine] datetimes = [] cpu_percents = [] # create a list of timestamps with the corresponding CPU percent for timestamp in entity.keys(): datetimes.append( datetime.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S.%f")) cpu_percents.append(entity[timestamp]["cpu_percent"]) # Plot blue if writer, green if reader if machine in sg_writer_hostnames: ax3.plot(datetimes, cpu_percents, "bo") else: ax3.plot(datetimes, cpu_percents, "go") figure.autofmt_xdate()
def plot_machine_stats(cluster_config, figure, folder_path): print("Plotting machine stats ...") folders = [x[0] for x in os.walk(folder_path)] machine_stats = dict() # entry at one is the first subdirect for subfolder in folders[1:]: # Get name of sg path_components = os.path.split(subfolder) name = path_components[len(path_components) - 1] # Get CPU stats dict for sg with open("{}/cpu_stats.json".format(subfolder), "r") as f: obj = json.loads(f.read()) machine_stats[name] = obj ax3 = figure.add_subplot(111) ax3.set_title("CPU percent (writers=blue, readers=green") # Get writer hostnames for provisioning_config sg_writers = hosts_for_tag(cluster_config, "sg_accels") sg_writer_hostnames = [sg_writer["inventory_hostname"] for sg_writer in sg_writers] for machine in machine_stats: entity = machine_stats[machine] datetimes = [] cpu_percents = [] # create a list of timestamps with the corresponding CPU percent for timestamp in entity.keys(): datetimes.append(datetime.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S.%f")) cpu_percents.append(entity[timestamp]["cpu_percent"]) # Plot blue if writer, green if reader if machine in sg_writer_hostnames: ax3.plot(datetimes, cpu_percents, "bo") else: ax3.plot(datetimes, cpu_percents, "go") figure.autofmt_xdate()
def plot_sync_gateway_expvars(cluster_config, figure, json_file_name): print("Plotting sync_gateway expvars ...") # Get writer hostnames for provisioning_config sg_writers = hosts_for_tag(cluster_config, "sg_accels") sg_writer_hostnames = [sg_writer["ansible_host"] for sg_writer in sg_writers] with open(json_file_name, "r") as f: obj = json.loads(f.read(), object_pairs_hook=OrderedDict) datetimes = [] memstats_alloc = [] memstats_sys = [] writer_datetimes = [] writer_memstats_alloc = [] writer_memstats_sys = [] for timestamp in obj: endpoint = obj[timestamp]["endpoint"] hostname = endpoint.split(":")[0] if hostname in sg_writer_hostnames: writer_datetimes.append(datetime.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S.%f")) writer_memstats_alloc.append(obj[timestamp]["expvars"]["memstats"]["Alloc"]) writer_memstats_sys.append(obj[timestamp]["expvars"]["memstats"]["Sys"]) else: datetimes.append(datetime.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S.%f")) memstats_alloc.append(obj[timestamp]["expvars"]["memstats"]["Alloc"]) memstats_sys.append(obj[timestamp]["expvars"]["memstats"]["Sys"]) # Plot Alloc / Sys ax1 = figure.add_subplot(111) ax1.set_title("(writers=blue, readers=green) memstats.Alloc (square) / memstats.Sys (triangle)") ax1.plot(datetimes, memstats_alloc, "gs", datetimes, memstats_sys, "g^") ax1.plot(writer_datetimes, writer_memstats_alloc, "bs", writer_datetimes, writer_memstats_sys, "b^") figure.autofmt_xdate()
def get_hosts_by_type(cluster_config, host_type="load_generators"): lgs_hosts = hosts_for_tag(cluster_config, host_type) lgs = [lg["ansible_host"] for lg in lgs_hosts] return lgs
def get_hosts_by_type(cluster_config, host_type="load_generators"): lgs_hosts = hosts_for_tag(cluster_config, host_type) lgs = [lg["ansible_host"] for lg in lgs_hosts] return lgs