Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Don't add empty MetricPath + ability to use a different config file for Start-StatsToGraphite #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions Functions/Start-StatsToGraphite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -142,7 +155,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
}
Expand Down