This commit is contained in:
José Henrique Ivanchechen 2023-08-31 20:07:14 -03:00
parent 209275cce0
commit 51d09be512
2 changed files with 5 additions and 3 deletions

View File

@ -9,6 +9,7 @@ def plot_graph(x, y, title, x_label, y_label, filename):
plt.savefig(f'{filename}.png')
plt.clf()
plt.close('all')
def plot_resource_graph(x_data, y_data, title, x_label, y_label, filename):
requests = x_data
@ -36,11 +37,12 @@ def plot_resource_graph(x_data, y_data, title, x_label, y_label, filename):
ax.set_title(title)
ax.set_xticks(x + width, requests)
ax.legend(loc='upper left', ncols=len(resource.items()))
ax.set_ylim(0, 250)
ax.set_ylim(0, 100)
plt.savefig(f'resources_{filename}.png')
plt.clf()
plt.close('all')
def get_data(filename):
lines = []

View File

@ -120,14 +120,14 @@ def get_cpu_usage(stats):
UsageDelta = stats['cpu_stats']['cpu_usage']['total_usage'] - stats['precpu_stats']['cpu_usage']['total_usage']
SystemDelta = stats['cpu_stats']['system_cpu_usage'] - stats['precpu_stats']['system_cpu_usage']
len_cpu = stats['cpu_stats']['online_cpus']
percentage = (UsageDelta / SystemDelta) * len_cpu * 100
percentage = (UsageDelta / SystemDelta) * len_cpu
return f"{percentage:.2f}"
def get_ram_usage(stats):
usage = stats['memory_stats']['usage']
limit = stats['memory_stats']['limit']
percentage = (usage / limit) * 100
percentage = (usage / limit)
# percent = round(percentage, 2)
return f"{percentage:.2f}"