Skip to content

Commit

Permalink
Fix for case when instance is wildcarded but only one instance is ret…
Browse files Browse the repository at this point in the history
…urned. In this case do not use the instance alias
  • Loading branch information
andrewpaine committed Jul 29, 2015
1 parent 9b5c7c0 commit c6076bb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/CollectdWinService/WindowsPerformanceCounterPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,17 @@ public void Configure()
foreach (string instance in instances)
{
string instanceAlias = instance;

if (instances.Length == 1)
{
// If there is just one instance then replace the instance name with the CollectdInstanceName - i.e., alias the instance
instanceAlias = counter.CollectdPluginInstance;
// There is just one instance
// If this is because the regex was hardcoded then replace the instance name with the CollectdInstanceName - i.e., alias the instance
// But if the regex contains wildcards then it is a fluke that there was a single match
if (counter.Instance.IndexOf("?") < 0 && counter.Instance.IndexOf("*") < 0)
{
// No wildcards => this was hardcoded value.
instanceAlias = counter.CollectdPluginInstance;
}
}

// Replace collectd_plugin_instance with the Instance got from counter
Expand Down

0 comments on commit c6076bb

Please sign in to comment.