From fa9d06192de3aa5368f975ce46d9194bea985feb Mon Sep 17 00:00:00 2001 From: Kim Date: Thu, 11 May 2023 10:20:47 +0200 Subject: [PATCH] added Grafana --- csharp/App/Backend/Backend.csproj | 4 ++++ csharp/App/BmsTunnel/BmsTunnel.csproj | 4 ++++ csharp/App/Collector/Collector.csproj | 4 ++++ .../App/EmuMeterDriver/EmuMeterDriver.csproj | 4 ++++ csharp/App/InnovEnergy.App.props | 2 +- .../OpenVpnCertificatesServer.csproj | 2 ++ .../RemoteSupportConsole.csproj | 4 ++++ csharp/App/SaliMax/SaliMax.csproj | 4 ++++ csharp/App/VrmGrabber/Controller.cs | 22 ++++++++---------- csharp/App/VrmGrabber/VrmGrabber.csproj | 18 ++++---------- .../__pycache__/server.cpython-310.pyc | Bin 0 -> 626 bytes csharp/InnovEnergy.sln | 4 ++-- csharp/Lib/Channels/Channels.csproj | 5 ++++ csharp/Lib/Devices/AMPT/Ampt.csproj | 4 ++++ csharp/Lib/Devices/Adam6060/Adam6060.csproj | 4 ++++ .../Devices/Battery48TL/Battery48TL.csproj | 4 ++++ csharp/Lib/Devices/EmuMeter/EmuMeter.csproj | 4 ++++ .../Trumpf/SystemControl/SystemControl.csproj | 4 ++++ .../Trumpf/TruConvert/TruConvert.csproj | 4 ++++ .../Trumpf/TruConvertAc/TruConvertAc.csproj | 4 ++++ .../Trumpf/TruConvertDc/TruConvertDc.csproj | 4 ++++ csharp/Lib/Protocols/DBus/DBus.csproj | 2 ++ csharp/Lib/Protocols/Modbus/Modbus.csproj | 4 ++++ csharp/Lib/StatusApi/StatusApi.csproj | 4 ++++ csharp/Lib/SysTools/SysTools.csproj | 4 ++++ csharp/Lib/Time/Time.csproj | 4 ++++ csharp/Lib/Units/Units.csproj | 4 ++++ csharp/Lib/Utils/JsonNodeAccessors.cs | 15 +++++++++++- csharp/Lib/Utils/Utils.csproj | 4 ++++ csharp/Lib/Victron/VeDBus/VeDBus.csproj | 5 ++++ csharp/Lib/Victron/VictronVRM/Installation.cs | 2 +- .../Lib/Victron/VictronVRM/VictronVRM.csproj | 5 ++++ csharp/Lib/WebServer/WebServer.csproj | 3 ++- 33 files changed, 134 insertions(+), 31 deletions(-) create mode 100644 csharp/App/VrmGrabber/__pycache__/server.cpython-310.pyc diff --git a/csharp/App/Backend/Backend.csproj b/csharp/App/Backend/Backend.csproj index ef4777f93..88adde6d6 100644 --- a/csharp/App/Backend/Backend.csproj +++ b/csharp/App/Backend/Backend.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/BmsTunnel/BmsTunnel.csproj b/csharp/App/BmsTunnel/BmsTunnel.csproj index 0466a4173..1732d02f8 100644 --- a/csharp/App/BmsTunnel/BmsTunnel.csproj +++ b/csharp/App/BmsTunnel/BmsTunnel.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/Collector/Collector.csproj b/csharp/App/Collector/Collector.csproj index 27b560c8d..9d08f7253 100644 --- a/csharp/App/Collector/Collector.csproj +++ b/csharp/App/Collector/Collector.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/EmuMeterDriver/EmuMeterDriver.csproj b/csharp/App/EmuMeterDriver/EmuMeterDriver.csproj index b2f8696ed..f89f90434 100644 --- a/csharp/App/EmuMeterDriver/EmuMeterDriver.csproj +++ b/csharp/App/EmuMeterDriver/EmuMeterDriver.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/InnovEnergy.App.props b/csharp/App/InnovEnergy.App.props index fe6d1e334..0cf09ae83 100644 --- a/csharp/App/InnovEnergy.App.props +++ b/csharp/App/InnovEnergy.App.props @@ -4,7 +4,7 @@ - + linux-x64 true true false diff --git a/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj b/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj index de611520f..9ae0cd90a 100644 --- a/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj +++ b/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj @@ -21,6 +21,8 @@ false + Debug;Release;Release-Server + AnyCPU;linux-arm diff --git a/csharp/App/RemoteSupportConsole/RemoteSupportConsole.csproj b/csharp/App/RemoteSupportConsole/RemoteSupportConsole.csproj index 1f571c26d..81deeb7c1 100644 --- a/csharp/App/RemoteSupportConsole/RemoteSupportConsole.csproj +++ b/csharp/App/RemoteSupportConsole/RemoteSupportConsole.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/SaliMax/SaliMax.csproj b/csharp/App/SaliMax/SaliMax.csproj index 6802aca05..ba80db36b 100644 --- a/csharp/App/SaliMax/SaliMax.csproj +++ b/csharp/App/SaliMax/SaliMax.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/VrmGrabber/Controller.cs b/csharp/App/VrmGrabber/Controller.cs index 8ce112351..653aede9b 100644 --- a/csharp/App/VrmGrabber/Controller.cs +++ b/csharp/App/VrmGrabber/Controller.cs @@ -1,4 +1,6 @@ +using System.Web; using HandlebarsDotNet; +using InnovEnergy.App.RemoteSupportConsole; using InnovEnergy.App.VrmGrabber.Database; using InnovEnergy.Lib.Victron.VictronVRM; using Microsoft.AspNetCore.Mvc; @@ -11,7 +13,8 @@ public record Install( String Ip, UInt64 Vrm, String Identifier, - String Serial + String Serial, + String EscapedName ); [Controller] @@ -64,23 +67,17 @@ td { String partialSource = @"{{Name}} - {{Ip}} + {{Ip}} VRM {{Identifier}} - {{Serial}}"; + {{Serial}} + Grafana"; Handlebars.RegisterTemplate("installations", partialSource); var template = Handlebars.Compile(source); var insts = instList.Select(i => { - try - { - return new Install(i.Name, Ip(i), i.IdSite, i.Identifier, Serial(i)); - } - catch (Exception) - { - return new Install(i.Name, Ip(i), i.IdSite, "0", Serial(i)); - } + return new Install(i.Name, Ip(i), i.IdSite, i.Identifier, Serial(i), HttpUtility.UrlEncode(i.Name)); }); @@ -100,7 +97,8 @@ td { private String Ip(Installation installation) { - return Db.InstallationsAndDetails[installation].RemoteSupportIp() ?? "Unknown"; + + return VpnInfo.LookUpIp(installation.Identifier, Serial(installation)).Result ?? "Unknown"; } private String Serial(Installation installation) diff --git a/csharp/App/VrmGrabber/VrmGrabber.csproj b/csharp/App/VrmGrabber/VrmGrabber.csproj index 45e814a59..92c7a0262 100644 --- a/csharp/App/VrmGrabber/VrmGrabber.csproj +++ b/csharp/App/VrmGrabber/VrmGrabber.csproj @@ -1,4 +1,7 @@ + + false + @@ -28,20 +31,9 @@ + - - - - PreserveNewest - - - - - - Never - - - + <_ContentIncludedByDefault Remove="wwwroot\index.html" /> diff --git a/csharp/App/VrmGrabber/__pycache__/server.cpython-310.pyc b/csharp/App/VrmGrabber/__pycache__/server.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a276f3c5db6091dd1fc14c802ac9a76084baeba3 GIT binary patch literal 626 zcmYjOJ8u**5VpO~3rUC~BqV6kUK3xgITRtpLrR1cr8z;d&1$or-0hv$UTj~`ok9ho z%YR53B>s|HDro6aF}?`t#+t|H@yvX-_0G-~LHYB2EPhZzeg&{85rWsK_AMGg1eK%+ zo=MuWg3%C1GHRnDq68SkUultuxJV(n%|voXMJlpy1b1^m$E2VC#y;e{PknMCD?7)a zH?vv|r>>Q&XH(}od(8RKaCA7pb#y!$ycqGSYwjtpL+O7(vLr@*hiZpt9GOwa1bvF+ zM0CTxkZUrFL_B9^Pb6dF;#qP{ZqvJvPj48K$<9|#_$j#e%DPI*$~9V@HP)RVtMm#? zbGiH*<_uQP$F7m`K-b00o|@|70t|ncd)O^~G6gAhj*V?F`)rHFbf22NFt}%W=zMY+e#9`0 zAL!*}sj3#r(nnR-nMdnGMlT$!>()Fs%;S*HU$$B-B)kd_XTwc$vQ4*Xj`MQ1OaB2d C-koXy literal 0 HcmV?d00001 diff --git a/csharp/InnovEnergy.sln b/csharp/InnovEnergy.sln index 90de295af..3a0401858 100644 --- a/csharp/InnovEnergy.sln +++ b/csharp/InnovEnergy.sln @@ -186,10 +186,10 @@ Global {B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Debug|Any CPU.Build.0 = Debug|Any CPU {B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Release|Any CPU.ActiveCfg = Release|Any CPU {B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Release|Any CPU.Build.0 = Release|Any CPU - {4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.Build.0 = Debug|Any CPU {4F9BB20B-8030-48AB-A37B-23796459D516}.Release|Any CPU.ActiveCfg = Release|Any CPU {4F9BB20B-8030-48AB-A37B-23796459D516}.Release|Any CPU.Build.0 = Release|Any CPU + {4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.ActiveCfg = Release-Server|linux-arm + {4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.Build.0 = Release-Server|linux-arm EndGlobalSection GlobalSection(NestedProjects) = preSolution {CF4834CB-91B7-4172-AC13-ECDA8613CD17} = {145597B4-3E30-45E6-9F72-4DD43194539A} diff --git a/csharp/Lib/Channels/Channels.csproj b/csharp/Lib/Channels/Channels.csproj index 9eb898d4e..db7ad1473 100644 --- a/csharp/Lib/Channels/Channels.csproj +++ b/csharp/Lib/Channels/Channels.csproj @@ -1,5 +1,10 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + + diff --git a/csharp/Lib/Devices/AMPT/Ampt.csproj b/csharp/Lib/Devices/AMPT/Ampt.csproj index ea8cbf21c..d5340e3ca 100644 --- a/csharp/Lib/Devices/AMPT/Ampt.csproj +++ b/csharp/Lib/Devices/AMPT/Ampt.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Adam6060/Adam6060.csproj b/csharp/Lib/Devices/Adam6060/Adam6060.csproj index 1a36e43e1..9c65e0cb7 100644 --- a/csharp/Lib/Devices/Adam6060/Adam6060.csproj +++ b/csharp/Lib/Devices/Adam6060/Adam6060.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Battery48TL/Battery48TL.csproj b/csharp/Lib/Devices/Battery48TL/Battery48TL.csproj index ce3b83de6..92dd034ad 100644 --- a/csharp/Lib/Devices/Battery48TL/Battery48TL.csproj +++ b/csharp/Lib/Devices/Battery48TL/Battery48TL.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/EmuMeter/EmuMeter.csproj b/csharp/Lib/Devices/EmuMeter/EmuMeter.csproj index ce3b83de6..92dd034ad 100644 --- a/csharp/Lib/Devices/EmuMeter/EmuMeter.csproj +++ b/csharp/Lib/Devices/EmuMeter/EmuMeter.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Trumpf/SystemControl/SystemControl.csproj b/csharp/Lib/Devices/Trumpf/SystemControl/SystemControl.csproj index be34f2198..2197231aa 100644 --- a/csharp/Lib/Devices/Trumpf/SystemControl/SystemControl.csproj +++ b/csharp/Lib/Devices/Trumpf/SystemControl/SystemControl.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Trumpf/TruConvert/TruConvert.csproj b/csharp/Lib/Devices/Trumpf/TruConvert/TruConvert.csproj index ca3eb7a2a..a4f729801 100644 --- a/csharp/Lib/Devices/Trumpf/TruConvert/TruConvert.csproj +++ b/csharp/Lib/Devices/Trumpf/TruConvert/TruConvert.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Trumpf/TruConvertAc/TruConvertAc.csproj b/csharp/Lib/Devices/Trumpf/TruConvertAc/TruConvertAc.csproj index 36322cc01..34e08f495 100644 --- a/csharp/Lib/Devices/Trumpf/TruConvertAc/TruConvertAc.csproj +++ b/csharp/Lib/Devices/Trumpf/TruConvertAc/TruConvertAc.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDc.csproj b/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDc.csproj index 1628a2b19..f640e856c 100644 --- a/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDc.csproj +++ b/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDc.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Protocols/DBus/DBus.csproj b/csharp/Lib/Protocols/DBus/DBus.csproj index 01a9e0400..ba9da4823 100644 --- a/csharp/Lib/Protocols/DBus/DBus.csproj +++ b/csharp/Lib/Protocols/DBus/DBus.csproj @@ -4,6 +4,8 @@ DBus Library true + Debug;Release;Release-Server + AnyCPU;linux-arm diff --git a/csharp/Lib/Protocols/Modbus/Modbus.csproj b/csharp/Lib/Protocols/Modbus/Modbus.csproj index 460195f09..70b28e699 100644 --- a/csharp/Lib/Protocols/Modbus/Modbus.csproj +++ b/csharp/Lib/Protocols/Modbus/Modbus.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/StatusApi/StatusApi.csproj b/csharp/Lib/StatusApi/StatusApi.csproj index a1e52bb50..d30b8534e 100644 --- a/csharp/Lib/StatusApi/StatusApi.csproj +++ b/csharp/Lib/StatusApi/StatusApi.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/SysTools/SysTools.csproj b/csharp/Lib/SysTools/SysTools.csproj index 72e17cc9b..fe718d694 100644 --- a/csharp/Lib/SysTools/SysTools.csproj +++ b/csharp/Lib/SysTools/SysTools.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Time/Time.csproj b/csharp/Lib/Time/Time.csproj index e971a1f7d..4e4793547 100644 --- a/csharp/Lib/Time/Time.csproj +++ b/csharp/Lib/Time/Time.csproj @@ -1,3 +1,7 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Units/Units.csproj b/csharp/Lib/Units/Units.csproj index 422120d58..257b04c56 100644 --- a/csharp/Lib/Units/Units.csproj +++ b/csharp/Lib/Units/Units.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Utils/JsonNodeAccessors.cs b/csharp/Lib/Utils/JsonNodeAccessors.cs index 4b2ecfe0c..723673111 100644 --- a/csharp/Lib/Utils/JsonNodeAccessors.cs +++ b/csharp/Lib/Utils/JsonNodeAccessors.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json.Nodes; +using System.Text.Json.Serialization; namespace InnovEnergy.Lib.Utils; @@ -38,7 +39,19 @@ public static class JsonNodeAccessors } } - public static String? TryGetString(this JsonNode n, String propName) => n.TryGet(propName); + public static String? TryGetString(this JsonNode n, String propName) + { + try + { + return n.TryGet(propName); + } + catch (Exception e) + { + Console.WriteLine(e); + return n.TryGet(propName).ToString(); + } + } + public static Boolean? TryGetBoolean(this JsonNode n, String propName) => n.TryGet(propName); public static UInt32? TryGetUInt32(this JsonNode n, String propName) => n.TryGet(propName); diff --git a/csharp/Lib/Utils/Utils.csproj b/csharp/Lib/Utils/Utils.csproj index 3ace16dcb..85d63a90e 100644 --- a/csharp/Lib/Utils/Utils.csproj +++ b/csharp/Lib/Utils/Utils.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Victron/VeDBus/VeDBus.csproj b/csharp/Lib/Victron/VeDBus/VeDBus.csproj index c7d6bf0a9..23827110a 100644 --- a/csharp/Lib/Victron/VeDBus/VeDBus.csproj +++ b/csharp/Lib/Victron/VeDBus/VeDBus.csproj @@ -1,5 +1,10 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + + diff --git a/csharp/Lib/Victron/VictronVRM/Installation.cs b/csharp/Lib/Victron/VictronVRM/Installation.cs index 269289fe1..82fcd85ce 100644 --- a/csharp/Lib/Victron/VictronVRM/Installation.cs +++ b/csharp/Lib/Victron/VictronVRM/Installation.cs @@ -16,7 +16,7 @@ public readonly partial record struct Installation(VrmAccount VrmAccount, JsonNo public String Name => Json.GetString("name"); public String Notes => Json.GetString("notes"); public String PhoneNumber => Json.GetString("phonenumber"); - public String Identifier => Json.GetString("identifier"); + public String Identifier => Json.TryGetString("identifier"); // TODO: alternative way to handle settings? make them writeable here and have an UpdateInstallation function? // public String Name // { diff --git a/csharp/Lib/Victron/VictronVRM/VictronVRM.csproj b/csharp/Lib/Victron/VictronVRM/VictronVRM.csproj index c5a94a419..57128f448 100644 --- a/csharp/Lib/Victron/VictronVRM/VictronVRM.csproj +++ b/csharp/Lib/Victron/VictronVRM/VictronVRM.csproj @@ -5,6 +5,11 @@ full + + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/WebServer/WebServer.csproj b/csharp/Lib/WebServer/WebServer.csproj index 00c76841c..a13aec7a9 100644 --- a/csharp/Lib/WebServer/WebServer.csproj +++ b/csharp/Lib/WebServer/WebServer.csproj @@ -3,7 +3,8 @@ - + Debug;Release;Release-Server + AnyCPU;linux-arm