Skip to content

Commit 6580fa3

Browse files
committed
Updated the system uptime plugin
1 parent 87669ee commit 6580fa3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Source/Samples/SampleConsole/Plugins/SystemUptimePlugin.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ public void Run(EventPluginContext context) {
1212
return;
1313

1414
// Get the system uptime
15-
using (var uptime = new PerformanceCounter("System", "System Up Time")) {
16-
uptime.NextValue();
15+
using (var pc = new PerformanceCounter("System", "System Up Time")) {
16+
pc.NextValue();
17+
18+
var uptime = TimeSpan.FromSeconds(pc.NextValue());
1719

1820
// Store the system uptime as an extended property.
19-
context.Event.SetProperty("System Uptime", DateTimeOffset.Now.Subtract(TimeSpan.FromSeconds(uptime.NextValue())).ToString("F"));
21+
context.Event.SetProperty("System Uptime", String.Format("{0} Days {1} Hours {2} Minutes {3} Seconds", uptime.Days, uptime.Hours, uptime.Minutes, uptime.Seconds));
2022
}
2123
}
2224
}

0 commit comments

Comments
 (0)