From 8de7ea9e3fc2a1a344bace73010ac7996956fb8a Mon Sep 17 00:00:00 2001 From: Weston McNamee Date: Tue, 28 Oct 2014 08:40:39 -0700 Subject: [PATCH 1/2] fixing some somethings --- Graphite-PowerShell.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Graphite-PowerShell.ps1 b/Graphite-PowerShell.ps1 index 24bf2a2..b1a17b3 100644 --- a/Graphite-PowerShell.ps1 +++ b/Graphite-PowerShell.ps1 @@ -162,7 +162,7 @@ Function Start-StatsToGraphite $filterStopWatch.Stop() Write-Verbose "Job Execution Time To Get to Clean Metrics: $($filterStopWatch.Elapsed.TotalSeconds) seconds." - + }# End for each sample loop }# end if ExcludePerfCounters @@ -223,7 +223,6 @@ Function Start-StatsToGraphite "Metrics" = $metricsToSend "DateTime" = $convertedTime "UDP" = $Config.SendUsingUDP - "Verbose" = $Config.ShowOutput "TestMode" = $TestMode } @@ -983,7 +982,7 @@ function SendMetrics catch { $exceptionText = GetPrettyProblem $_ - Write-Error "Error sending metrics to the Graphite Server. Please check your configuration file. `n$exceptionText" + throw "Error sending metrics to the Graphite Server. Please check your configuration file. `n$exceptionText" } } } From bdeb4db53ea99dd93ef0caa7f95190529c930c2a Mon Sep 17 00:00:00 2001 From: Weston McNamee Date: Tue, 28 Oct 2014 08:43:44 -0700 Subject: [PATCH 2/2] fixing udp send --- Graphite-PowerShell.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Graphite-PowerShell.ps1 b/Graphite-PowerShell.ps1 index b1a17b3..8f0f63d 100644 --- a/Graphite-PowerShell.ps1 +++ b/Graphite-PowerShell.ps1 @@ -955,8 +955,12 @@ function SendMetrics { PSUsing ($udpobject = new-Object system.Net.Sockets.Udpclient($CarbonServer, $CarbonServerPort)) -ScriptBlock { $enc = new-object system.text.asciiencoding - $Message = "$($metric)`r" - $byte = $enc.GetBytes($Message) + $Message = new-object System.Text.StringBuilder + foreach($metric in $metrics) { + $Message.Append($metric) + $Message.Append("`n") + } + $byte = $enc.GetBytes($Message.ToString()) $Sent = $udpobject.Send($byte,$byte.Length) }