1
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: nas_robot
|
container_name: nas_robot
|
||||||
restart: always
|
restart: always
|
||||||
|
networks:
|
||||||
|
- all_in
|
||||||
environment:
|
environment:
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
volumes:
|
volumes:
|
||||||
@@ -19,6 +21,8 @@
|
|||||||
image: beevelop/nginx-basic-auth:v2023.10.1
|
image: beevelop/nginx-basic-auth:v2023.10.1
|
||||||
container_name: nas_robot_proxy
|
container_name: nas_robot_proxy
|
||||||
restart: always
|
restart: always
|
||||||
|
networks:
|
||||||
|
- all_in
|
||||||
ports:
|
ports:
|
||||||
- 14902:80 # 开放端口
|
- 14902:80 # 开放端口
|
||||||
environment:
|
environment:
|
||||||
@@ -26,3 +30,7 @@
|
|||||||
- HTPASSWD=suncheng:$$apr1$$2QX32QHP$$HIGAbCuTt8jxdc4uDzNLI1
|
- HTPASSWD=suncheng:$$apr1$$2QX32QHP$$HIGAbCuTt8jxdc4uDzNLI1
|
||||||
- FORWARD_PORT=8080
|
- FORWARD_PORT=8080
|
||||||
- FORWARD_HOST=nas_robot
|
- FORWARD_HOST=nas_robot
|
||||||
|
|
||||||
|
networks:
|
||||||
|
all_in:
|
||||||
|
external: true
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
|
||||||
<PackageReference Include="FluentScheduler" Version="5.5.1"/>
|
<PackageReference Include="FluentScheduler" Version="5.5.1"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="InfluxDB.Client" Version="4.18.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using FluentScheduler;
|
using FluentScheduler;
|
||||||
|
using InfluxDB.Client;
|
||||||
|
using InfluxDB.Client.Api.Domain;
|
||||||
|
using InfluxDB.Client.Writes;
|
||||||
using Interface.Jobs;
|
using Interface.Jobs;
|
||||||
|
|
||||||
namespace Service.Jobs;
|
namespace Service.Jobs;
|
||||||
@@ -28,6 +31,9 @@ public class DiskMonitorRegistry : Registry, IDiskMonitorRegistry
|
|||||||
process.WaitForExit();
|
process.WaitForExit();
|
||||||
|
|
||||||
Console.WriteLine(FormatResult(result));
|
Console.WriteLine(FormatResult(result));
|
||||||
|
|
||||||
|
|
||||||
|
WriteToInfluxDB(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FormatResult(string result)
|
private string FormatResult(string result)
|
||||||
@@ -40,10 +46,45 @@ public class DiskMonitorRegistry : Registry, IDiskMonitorRegistry
|
|||||||
|
|
||||||
if (line.Contains("/host/wd/"))
|
if (line.Contains("/host/wd/"))
|
||||||
{
|
{
|
||||||
sb.AppendLine($"{cols[5].Substring("/host".Length)}, {cols[1]}, {cols[4].TrimEnd('%')}, {cols[3]}");
|
sb.AppendLine($"{cols[5].Substring("/host".Length)},{cols[1]},{cols[4].TrimEnd('%')},{cols[3]}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WriteToInfluxDB(string result)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
/wd/apps,916G,53,410G
|
||||||
|
/wd/volc,3.6T,69,1.1T
|
||||||
|
/wd/volb,3.6T,60,1.4T
|
||||||
|
/wd/vola,3.6T,88,440G
|
||||||
|
*/
|
||||||
|
|
||||||
|
var lines = result.Split("\n");
|
||||||
|
|
||||||
|
using var client = new InfluxDBClient("http://influxdb:8086", "BD4A71llb9_XbCA5mmKDbc_yTYwadPPLwyk4nAQ0l_yR_WJmw_-dMOWIs0KlS7-pZtHot_HrejY5GcOohKElmA==");
|
||||||
|
using var writeApi = client.GetWriteApi();
|
||||||
|
|
||||||
|
foreach (var line in lines)
|
||||||
|
{
|
||||||
|
var cols = line.Split(",", StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
var path = cols[0];
|
||||||
|
var totalSize = cols[1];
|
||||||
|
var usedPercent = cols[2];
|
||||||
|
var available = cols[3];
|
||||||
|
|
||||||
|
var point = PointData
|
||||||
|
.Measurement("disk_usage")
|
||||||
|
.Tag("path", path)
|
||||||
|
.Field("total_size", totalSize)
|
||||||
|
.Field("used_percent", double.Parse(usedPercent))
|
||||||
|
.Field("available", available)
|
||||||
|
.Timestamp(DateTime.UtcNow, WritePrecision.Ns);
|
||||||
|
|
||||||
|
writeApi.WritePoint(point, "def-bucket", "def-org");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user