Metrics Fixed #14
@@ -57,7 +57,7 @@ public class MetricDto
|
||||
|
||||
public double GPU_Vram_Size { get; set; } // Bytes
|
||||
|
||||
public double GPU_Vram_Usage { get; set; } // %
|
||||
public double GPU_Vram_Load { get; set; } // %
|
||||
|
||||
// RAM
|
||||
public double RAM_Size { get; set; } // Bytes
|
||||
@@ -178,19 +178,19 @@ public class MonitoringController : Controller
|
||||
{
|
||||
Timestamp = DateTime.UtcNow,
|
||||
ServerId = dto.ServerId,
|
||||
CPU_Load = sanitizeLoadInput(dto.CPU_Load),
|
||||
CPU_Temp = sanitizeDegreeInput(dto.CPU_Temp),
|
||||
GPU_Load = sanitizeLoadInput(dto.GPU_Load),
|
||||
GPU_Temp = sanitizeDegreeInput(dto.GPU_Temp),
|
||||
GPU_Vram_Size = sanitizeByteInput(dto.GPU_Vram_Size),
|
||||
GPU_Vram_Usage = sanitizeLoadInput(dto.GPU_Vram_Usage),
|
||||
RAM_Load = calculateRamUsage(sanitizeByteInput(dto.RAM_Load), sanitizeByteInput(dto.RAM_Size)),
|
||||
RAM_Size = sanitizeByteInput(dto.RAM_Size),
|
||||
DISK_Size = sanitizeByteInput(dto.DISK_Size),
|
||||
DISK_Usage = sanitizeByteInput(dto.DISK_Usage),
|
||||
DISK_Temp = sanitizeDegreeInput(dto.DISK_Temp),
|
||||
NET_In = sanitizeByteInput(dto.NET_In),
|
||||
NET_Out = sanitizeByteInput(dto.NET_Out)
|
||||
CPU_Load = sanitizeInput(dto.CPU_Load),
|
||||
CPU_Temp = sanitizeInput(dto.CPU_Temp),
|
||||
GPU_Load = sanitizeInput(dto.GPU_Load),
|
||||
GPU_Temp = sanitizeInput(dto.GPU_Temp),
|
||||
GPU_Vram_Size = calculateGigabyte(dto.GPU_Vram_Size),
|
||||
GPU_Vram_Usage = sanitizeInput(dto.GPU_Vram_Load),
|
||||
RAM_Load = sanitizeInput(dto.RAM_Load),
|
||||
RAM_Size = calculateGigabyte(dto.RAM_Size),
|
||||
DISK_Size = calculateGigabyte(dto.DISK_Size),
|
||||
DISK_Usage = calculateGigabyte(dto.DISK_Usage),
|
||||
DISK_Temp = sanitizeInput(dto.DISK_Temp),
|
||||
NET_In = calculateMegabit(dto.NET_In),
|
||||
NET_Out = calculateMegabit(dto.NET_Out)
|
||||
};
|
||||
try
|
||||
{
|
||||
@@ -285,38 +285,38 @@ public class MonitoringController : Controller
|
||||
}
|
||||
|
||||
// Metric Input Byte zu Gigabyte umwandeln
|
||||
public static double sanitizeByteInput(double metric_input)
|
||||
public static double calculateGigabyte(double metric_input)
|
||||
{
|
||||
// *10^-9 um auf Gigabyte zu kommen
|
||||
double sanitizedMetric = metric_input * Math.Pow(10, -9);
|
||||
double calculatedValue = metric_input * Math.Pow(10, -9);
|
||||
|
||||
// Auf 2 Nachkommastellen runden
|
||||
Math.Round(sanitizedMetric, 2);
|
||||
double calculatedValue_s = sanitizeInput(calculatedValue);
|
||||
|
||||
return sanitizedMetric;
|
||||
return calculatedValue_s;
|
||||
}
|
||||
|
||||
// Metric Input Byte/s zu Megabit/s umrechnen
|
||||
//TODO
|
||||
public static double calculateMegabit(double metric_input)
|
||||
{
|
||||
// *10^-9 um auf Gigabyte zu kommen
|
||||
double calculatedValue = metric_input * Math.Pow(10, -9);
|
||||
|
||||
// Auf 2 Nachkommastellen runden
|
||||
double calculatedValue_s = sanitizeInput(calculatedValue);
|
||||
|
||||
return calculatedValue_s;
|
||||
}
|
||||
|
||||
// Degree Input auf zwei Nachkommastellen runden
|
||||
public static double sanitizeDegreeInput(double metric_input)
|
||||
public static double sanitizeInput(double metric_input)
|
||||
{
|
||||
Math.Round(metric_input, 2);
|
||||
|
||||
return metric_input;
|
||||
}
|
||||
|
||||
// Load Input auf zwei Nachkommastellen runden
|
||||
public static double sanitizeLoadInput(double metric_input)
|
||||
{
|
||||
Math.Round(metric_input, 2);
|
||||
|
||||
return metric_input;
|
||||
}
|
||||
|
||||
public double calculateRamUsage(double RamSize, double RamUsage)
|
||||
{
|
||||
double usage = (RamUsage / RamSize) * 100;
|
||||
|
||||
return Math.Round(usage, 2);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user