forked from trimble-oss/dba-dash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerformanceCounters.cs
49 lines (44 loc) · 1.67 KB
/
PerformanceCounters.cs
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
using Serilog;
using System;
using System.IO;
namespace DBADash
{
static class PerformanceCounters
{
static string countersXML;
static readonly string defaultFileName = "PerformanceCounters.xml";
static readonly string userFileName = "PerformanceCountersCustom.xml";
public static string PerformanceCountersXML
{
get
{
if (countersXML != null) return countersXML;
try
{
if (File.Exists(userFileName))
{
Log.Information("Read performance counters from {filename} (user)", userFileName);
countersXML = File.ReadAllText(userFileName);
}
else if (File.Exists(defaultFileName))
{
Log.Information("Read performance counters from {filename} (default)", defaultFileName);
countersXML = File.ReadAllText(defaultFileName);
}
else
{
Log.Warning("Performance counters file '{filename}' not found. Performance counter collection disabled", defaultFileName);
countersXML = "";
return countersXML;
}
}
catch (Exception ex)
{
Log.Error(ex, "Error reading performance counters file '{filename}'. Performance counter collection disabled", defaultFileName);
countersXML = "";
}
return countersXML;
}
}
}
}