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

Fixing some things... #25

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
13 changes: 8 additions & 5 deletions Graphite-PowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -223,7 +223,6 @@ Function Start-StatsToGraphite
"Metrics" = $metricsToSend
"DateTime" = $convertedTime
"UDP" = $Config.SendUsingUDP
"Verbose" = $Config.ShowOutput
"TestMode" = $TestMode
}

Expand Down Expand Up @@ -956,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)
}

Expand All @@ -983,7 +986,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"
}
}
}
Expand Down