syntax = "proto3";
option go_package = "./pb";

package pb;

import "models/rpc_messages.proto";
import "models/model_node_value.proto";

// 节点指标数据服务
service NodeValueService {
	// 记录数据
	rpc createNodeValue (CreateNodeValueRequest) returns (RPCSuccess);

	// 读取数据
	rpc listNodeValues (ListNodeValuesRequest) returns (ListNodeValuesResponse);

	// 读取所有节点的最新数据
	rpc sumAllNodeValueStats(SumAllNodeValueStatsRequest) returns (SumAllNodeValueStatsResponse);
}

// 记录数据
message CreateNodeValueRequest {
	string item = 1;
	bytes valueJSON = 2;
	int64 createdAt = 3;
}

// 读取数据
message ListNodeValuesRequest {
	string role = 1;
	int64 nodeId = 2;
	string item = 3;

	string range = 10;
}

message ListNodeValuesResponse {
	repeated NodeValue nodeValues = 1;
}

// 读取所有节点的最新数据
message SumAllNodeValueStatsRequest {

}

message SumAllNodeValueStatsResponse {
	int64 totalTrafficBytesPerSecond = 1;
	float avgCPUUsage = 2;
	float maxCPUUsage = 3;
	int32 totalCPUCores = 4;
	float avgMemoryUsage = 5;
	float maxMemoryUsage = 6;
	int64 totalMemoryBytes = 7;
	float avgLoad1min = 8;
	float maxLoad1min = 9;
	float avgLoad5min = 10;
}