From 6580fa3ab490cb55e3718a1d086ea1d9f31c3860 Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Mon, 6 Apr 2015 16:12:56 -0500 Subject: [PATCH] Updated the system uptime plugin --- .../Samples/SampleConsole/Plugins/SystemUptimePlugin.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Samples/SampleConsole/Plugins/SystemUptimePlugin.cs b/Source/Samples/SampleConsole/Plugins/SystemUptimePlugin.cs index 9343ce83..d1dc1746 100644 --- a/Source/Samples/SampleConsole/Plugins/SystemUptimePlugin.cs +++ b/Source/Samples/SampleConsole/Plugins/SystemUptimePlugin.cs @@ -12,11 +12,13 @@ public void Run(EventPluginContext context) { return; // Get the system uptime - using (var uptime = new PerformanceCounter("System", "System Up Time")) { - uptime.NextValue(); + using (var pc = new PerformanceCounter("System", "System Up Time")) { + pc.NextValue(); + + var uptime = TimeSpan.FromSeconds(pc.NextValue()); // Store the system uptime as an extended property. - context.Event.SetProperty("System Uptime", DateTimeOffset.Now.Subtract(TimeSpan.FromSeconds(uptime.NextValue())).ToString("F")); + context.Event.SetProperty("System Uptime", String.Format("{0} Days {1} Hours {2} Minutes {3} Seconds", uptime.Days, uptime.Hours, uptime.Minutes, uptime.Seconds)); } } }