import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv(r'D:实验数据记录kcss2次monitor.csv')
# nodeIp = "192.168.1.27"
# nodeIp = "192.168.1.90"
# nodeIp = "192.168.1.100"
# nodeIp = "192.168.1.127"
nodeIp = "192.168.1.187"
df = data.loc[data['node_ip'] == nodeIp, :]
print(df)
# 分别拿到时间戳与值
values = df['cpu_util'].values
timestamps = df['record_time'].values
# 为了避免数据太多可以考虑展现其中一部分
pieceSize = 4
showPiece = 1 # [1,pieceSize]
# 开始准备绘制
plt.figure(num='cpu4', figsize=(16, 7))
# plt.title('cpu4-'+str(showPiece))
# start = int(len(timestamps)*(showPiece/pieceSize))
# end = int(len(timestamps)*((showPiece+1)/pieceSize))
start = 0
end = len(timestamps)
plt.plot(timestamps[start:end], values[start:end], color="BLACK")
plt.show()
# 如果不展示而是导出为 eps 文件,非常简单
#plt.savefig(nodeIp + str(showPiece) + '.eps', format='eps', bbox_inches='tight')
plt.savefig(nodeIp + '.eps', format='eps', bbox_inches='tight')