dodana podpora za temperaturni senzor addon, pm1

dodan nlog
pinganje devicov
This commit is contained in:
David
2025-01-10 20:52:29 +01:00
parent 98bb0ae882
commit 8892044e51
7 changed files with 259 additions and 36 deletions

View File

@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Hosting;
using ShellyExporter;
using System.Xml.Linq;
using NLog.Web;
var builder = WebApplication.CreateBuilder(args);
@@ -19,6 +20,12 @@ if (!builder.Environment.IsDevelopment())
builder.WebHost.UseUrls(builder.Configuration["Kst:Url"]);
}
//Nlog
builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Host.UseNLog();
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -39,10 +46,15 @@ app.Map("/metrics", () =>
foreach (var host in builder.Configuration.GetSection("Hosts").GetChildren())
{
sb.Append(Metrics.Get($"http://{host["ip"]}",
var id = "0";
if (host["id"] != "")
id = host["id"];
sb.Append(Metrics.Get(host["ip"],
host.Path.Replace("Hosts:", ""),
(Metrics.Version)Convert.ToInt16(host["version"]),
(Metrics.Type)Convert.ToInt16(host["type"])).Result);
(Metrics.Type)Convert.ToInt16(host["type"]),
id).Result);
}
return sb.ToString();