-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSystemDiagnostics.cs
More file actions
53 lines (41 loc) · 2.22 KB
/
SystemDiagnostics.cs
File metadata and controls
53 lines (41 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
namespace SLZ.XRDoctor;
public static class SystemDiagnostics {
private static readonly Serilog.ILogger Log = Serilog.Log.ForContext(typeof(SystemDiagnostics));
private const string LogTag = "System";
public static void Check() {
CheckTime();
CheckSystem();
}
public static void CheckTime()
{
Log.Information(
"[{LogTag}] Timezone ID: {TimezoneID} DisplayName: {DisplayName} StandardName: {StandardName} " +
"DaylightName: {DaylightName} BaseUtcOffset: {BaseUtcOffset} " +
"SupportsDaylightSavingTime: {SupportsDaylightSavingTime} IsDaylightSavingTime: {IsDaylightSavingTime}",
LogTag,
TimeZoneInfo.Local.Id, TimeZoneInfo.Local.DisplayName, TimeZoneInfo.Local.StandardName,
TimeZoneInfo.Local.DaylightName, TimeZoneInfo.Local.BaseUtcOffset,
TimeZoneInfo.Local.SupportsDaylightSavingTime, TimeZoneInfo.Local.IsDaylightSavingTime(DateTime.Now));
}
public static void CheckSystem() {
Log.Information(
"[{LogTag}] OS Version: {OSVersion} ", LogTag, Environment.OSVersion);
foreach (var drive in DriveInfo.GetDrives()) {
if (!drive.IsReady) { continue; }
if (drive.DriveType != DriveType.Fixed) { continue; }
var availableFreeSpace = drive.AvailableFreeSpace;
var availableFreeSpaceGiB = drive.AvailableFreeSpace / (1024 * 1024 * 1024);
var totalFreeSpace = drive.TotalFreeSpace;
var totalFreeSpaceGiB = drive.TotalFreeSpace / (1024 * 1024 * 1024);
var totalSize = drive.TotalSize;
var totalSizeGiB = drive.TotalSize / (1024 * 1024 * 1024);
Log.Information(
"[{LogTag}] Drive Name={name} Filesystem={filesystem}, " +
"Available Space={availableFreeSpace}, ({availableFreeSpaceGiB} GiB) " +
"Total Free Space={totalFreeSpace} ({totalFreeSpaceGiB} GiB), " +
"Total Size={totalSize} ({totalSizeGiB} GiB)",
LogTag, drive.Name, drive.DriveFormat, availableFreeSpace, availableFreeSpaceGiB, totalFreeSpace,
totalFreeSpaceGiB, totalSize, totalSizeGiB);
}
}
}