From 2e1559cb6b2efc846a41ea53a48aef6c05149e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=99=A0?= Date: Thu, 7 May 2015 23:46:03 +0300 Subject: [PATCH 1/2] Don't add empty MetricPath --- Functions/Start-StatsToGraphite.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Functions/Start-StatsToGraphite.ps1 b/Functions/Start-StatsToGraphite.ps1 index 97b8799..b248163 100644 --- a/Functions/Start-StatsToGraphite.ps1 +++ b/Functions/Start-StatsToGraphite.ps1 @@ -142,7 +142,11 @@ Function Start-StatsToGraphite $cleanNameOfSample = ConvertTo-GraphiteMetric -MetricToClean $sample.Path -HostName $Config.NodeHostName -MetricReplacementHash $Config.MetricReplace # Build the full metric path - $metricPath = $Config.MetricPath + '.' + $cleanNameOfSample + if (-not [string]::IsNullOrWhiteSpace($Config.MetricPath)) { + $metricPath = $Config.MetricPath + '.' + $cleanNameOfSample + } else { + $metricPath = $cleanNameOfSample + } $metricsToSend[$metricPath] = $sample.Cookedvalue } From 4a7009a18893b72c541e2a6ddab370e2cd053173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=99=A0?= Date: Fri, 8 May 2015 00:11:54 +0300 Subject: [PATCH 2/2] Add ConfigXMLPath parameter to Start-StatsToGraphite Allows to use a different config file other than the one inside the module directory --- Functions/Start-StatsToGraphite.ps1 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Functions/Start-StatsToGraphite.ps1 b/Functions/Start-StatsToGraphite.ps1 index b248163..6a00953 100644 --- a/Functions/Start-StatsToGraphite.ps1 +++ b/Functions/Start-StatsToGraphite.ps1 @@ -18,6 +18,9 @@ Function Start-StatsToGraphite .Parameter SqlMetrics Includes SQL Metrics defined in XML config + + .Parameter ConfigXMLPath + Uses this configuration file instead of the one inside the module folder .Example PS> Start-StatsToGraphite @@ -51,9 +54,19 @@ Function Start-StatsToGraphite [Parameter(Mandatory = $false)] [switch]$TestMode, [switch]$ExcludePerfCounters = $false, - [switch]$SqlMetrics = $false + [switch]$SqlMetrics = $false, + [string]$ConfigXMLPath ) + # Override the config path set in the module if one is provided explicitly + if (-not [string]::IsNullOrWhiteSpace($ConfigXMLPath)) { + $configPath = $ConfigXMLPath + } + + if (-not (Test-Path -PathType Leaf -LiteralPath $configPath)){ + throw "Cannot find configuration file - $configPath" + } + # Run The Load XML Config Function $Config = Import-XMLConfig -ConfigPath $configPath