Beispiel #1
0
        public void ExportDataToGrafana(BaseCollectingServer server)
        {
            if (!server.GetSettings().InfluxOutput.Enabled)
            {
                return;
            }

            var influxDb = server.GetInfluxDbConnection();

            foreach (var hardware in Hardware)
            {
                foreach (var sensor in hardware.GetSensors())
                {
                    if (!sensor.IsAvaliable())
                    {
                        continue;
                    }

                    var influxData = new List <InfluxDataPair> {
                        new InfluxDataTag("vendor", hardware.Identify().GetVendor()),
                        new InfluxDataTag("hw_id", hardware.Identify().GetHardwareId()),
                        new InfluxDataTag("sensor", sensor.GetSystemName()),
                        new InfluxDataTag("sensor_type", sensor.GetSensorType().ToString().ToLower())
                    };

                    if (sensor is IMultiValueSensor multi)
                    {
                        foreach (var sensorElement in multi.GetElements())
                        {
                            influxData.Add(new InfluxDataPair(sensorElement.GetSystemTag(), $"{sensorElement.GetValue():F4}"));
                        }
                    }

                    if (sensor is ISingleValueSensor single)
                    {
                        var sensorElement = single.GetElement();
                        influxData.Add(new InfluxDataPair(sensorElement.GetSystemTag(), $"{sensorElement.GetValue():F4}"));
                    }

                    influxDb.Write(new InfluxWriteData(hardware.Identify().GetHardwareType().ToString().ToLower(), influxData.ToArray()));
                }
            }
        }
Beispiel #2
0
 public RhmsSettings GetSettings()
 {
     return(_server.GetSettings());
 }