|
@@ -6,6 +6,7 @@ using System.Net.Sockets;
|
|
using System.Timers;
|
|
using System.Timers;
|
|
using NLog;
|
|
using NLog;
|
|
using OpenHardwareMonitor.Hardware;
|
|
using OpenHardwareMonitor.Hardware;
|
|
|
|
+using static System.FormattableString;
|
|
|
|
|
|
namespace OhmGraphite
|
|
namespace OhmGraphite
|
|
{
|
|
{
|
|
@@ -85,7 +86,7 @@ namespace OhmGraphite
|
|
|
|
|
|
// Graphite API wants <metric> <value> <timestamp>. We prefix the metric
|
|
// Graphite API wants <metric> <value> <timestamp>. We prefix the metric
|
|
// with `ohm` as to not overwrite potentially existing metrics
|
|
// with `ohm` as to not overwrite potentially existing metrics
|
|
- writer.WriteLine($"ohm.{host}.{data.Identifier}.{data.Name} {data.Value} {epoch:d}");
|
|
|
|
|
|
+ writer.WriteLine(FormatGraphiteData(host, epoch, data));
|
|
|
|
|
|
sensorCount++;
|
|
sensorCount++;
|
|
}
|
|
}
|
|
@@ -95,6 +96,11 @@ namespace OhmGraphite
|
|
Logger.Info($"Sent {sensorCount} metrics in {stopwatch.Elapsed.TotalMilliseconds}ms");
|
|
Logger.Info($"Sent {sensorCount} metrics in {stopwatch.Elapsed.TotalMilliseconds}ms");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static string FormatGraphiteData(string host, long epoch, Sensor data)
|
|
|
|
+ {
|
|
|
|
+ return Invariant($"ohm.{host}.{data.Identifier}.{data.Name} {data.Value} {epoch:d}");
|
|
|
|
+ }
|
|
|
|
+
|
|
private static Sensor Normalize(Sensor sensor)
|
|
private static Sensor Normalize(Sensor sensor)
|
|
{
|
|
{
|
|
// Take the sensor's identifier (eg. /nvidiagpu/0/load/0)
|
|
// Take the sensor's identifier (eg. /nvidiagpu/0/load/0)
|