import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

# Load the data
df = pd.read_csv('../data/resources.txt', sep='\s+')

df['util'] = df['maxCPU']/df['CPU']*100
df = df[df['util'] <= 100]

counts, bins = np.histogram(df['util'], bins=30)

# Plot the histogram
plt.barh(bins[:-1], counts, height=(bins[1]-bins[0]), edgecolor='black')

# Add titles and labels
plt.title("Distribution of tenants based on max CPU utilization\nignore spikes > 100%")
plt.ylabel('Max CPU Utilization')
plt.xlabel('Number of Tenants')

# Save the plot as a PNG file
plt.savefig('../img/cpuMax.png')

# Show the plot
plt.show()
