Skip to content

Commit

Permalink
Updated the system uptime plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Apr 6, 2015
1 parent 87669ee commit 6580fa3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Source/Samples/SampleConsole/Plugins/SystemUptimePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down

0 comments on commit 6580fa3

Please sign in to comment.