You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 30, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+32-32
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ More details at [http://www.hodgkins.net.au/mswindows/using-powershell-to-send-m
9
9
* Sends Metrics to Graphite's Carbon daemon using TCP or UDP
10
10
* Can collect Windows Performance Counters
11
11
* Can collect values by using T-SQL queries against MS SQL databases
12
-
*Will convert time zones; If the server you want the metrics sent from is in a different time zone to your Graphite server, the script will convert the time so metrics come in with a time that matches the Graphite server
12
+
*Converts time to UTC on sending
13
13
* All configuration can be done from a simple XML file
14
14
* Reloads the XML configuration file automatically. For example, if more counters are added to the configuration file, the script will notice and start sending metrics for them to Graphite in the next send interval
15
15
* Additional functions are exposed that allow you to send data to Graphite from PowerShell easily. [Here](#functions) is the list of included functions
@@ -19,10 +19,13 @@ More details at [http://www.hodgkins.net.au/mswindows/using-powershell-to-send-m
19
19
20
20
## Installation
21
21
22
-
1. Download the *Graphite-PowerShell.ps1* file and the *StatsToGraphiteConfig.xml* configuration file into the same directory, for example *C:\GraphitePowerShell*
23
-
2. Make sure the files are un-blocked by right clicking on them and going to properties.
4. Open PowerShell and ensure you set your Execution Policy to allow scripts be run. For example `Set-ExecutionPolicy RemoteSigned`.
22
+
1. Download the repository and place into a PowerShell Modules directory called **Graphite-Powershell**. The module directories can be found by running `$env:PSModulePath` in PowerShell. For example, `C:\Program Files\WindowsPowerShell\Modules\Graphite-PowerShell`
23
+
1. Verify your folder structure looks like this, with the *.psd1* and *.psm1* files inside the **Graphite-Powershell** folder:
24
+
25
+

26
+
3. Make sure the files are un-blocked by right clicking on them and going to properties.
27
+
4. Modify the *StatsToGraphiteConfig.xml* configuration file. Instructions [here](#config).
28
+
5. Open PowerShell and ensure you set your Execution Policy to allow scripts be run. For example `Set-ExecutionPolicy RemoteSigned`.
26
29
27
30
### Modifying the Configuration File
28
31
@@ -36,8 +39,7 @@ CarbonServer | The server name where Carbon is running. The Carbon daemon is usu
36
39
CarbonServerPort | The port number for Carbon. Its default port number is 2003.
37
40
MetricPath | The path of the metric you want to be sent to the server. If you are using HostedGraphite, put your API key before the rest of the metric path, for example `YOUR-API-KEY.datacenter1.servers`.
38
41
MetricSendIntervalSeconds | The interval to send metrics to Carbon; I recommend 5 seconds or greater. The more metrics you are collecting the longer it takes to send them to the Graphite server. You can see how long it takes to send the metrics each time the loop runs by using running the `Start-StatsToGraphite` function and having *VerboseOutput* set to *True*.
39
-
TimeZoneOfGraphiteServer | Set this to the time zone of your Graphite server and the **Start-StatsToGraphite** function will convert the local time zone of the server to the time zone of the Graphite server. This is useful if you have servers in different time zones. To get a list of valid options run **Convert-TimeZone -ListTimeZones** and use the applicable ID.
40
-
SendUsingUDP | Sends metrics via UDP instead of TCP. This doesn't seem to work with HostedGraphite, but works with self-hosted.
42
+
SendUsingUDP | Sends metrics via UDP instead of TCP.
41
43
42
44
#### Performance Counters Configuration Section
43
45
@@ -101,11 +103,11 @@ VerboseOutput | Will provide each of the metrics that were sent over to Carbon a
101
103
102
104
The following shows how to use the `Start-StatsToGraphite`, which will collect Windows performance counters and send them to Graphite.
103
105
104
-
1.In PowerShell, enter the directory in which you downloaded the script.
105
-
2.Dot source the script by running `. .\Graphite-PowerShell.ps1`
106
-
3. Start the script by using the function `Start-StatsToGraphite`. If you want Verbose detailed use `Start-StatsToGraphite -Verbose`.
106
+
1.Open PowerShell
107
+
2.Import the Module by running `Import-Module -Name Graphite-PowerShell`
108
+
3. Start the script by using the function `Start-StatsToGraphite`. If you want Verbose details, use `Start-StatsToGraphite -Verbose`.
107
109
108
-
You may need to run the PowerShell instance with Administrative rights depending on the performance counters you want to access. This is due to the scripts use of the `Get-Counter` CmdLet.
110
+
You may need to run the PowerShell instance with Administrative rights depending on the performance counters you want to access. This is due to the scripts use of the `Get-Counter` CmdLet.
109
111
110
112
From the [Get-Counter help page on TechNet](http://technet.microsoft.com/library/963e9e51-4232-4ccf-881d-c2048ff35c2a(v=wps.630).aspx):
111
113
@@ -121,8 +123,8 @@ That is all there is to getting your Windows performance counters into Graphite.
121
123
122
124
The following shows how to use the `Start-SQLStatsToGraphite`, which will execute any SQL queries listed in the configuration file and send the result (which needs to be an integer) to Graphite.
123
125
124
-
1.In PowerShell, enter the directory in which you downloaded the script.
125
-
2.Dot source the script by running `. .\Graphite-PowerShell.ps1`
126
+
1.Open PowerShell
127
+
2.Import the Module by running `Import-Module -Name Graphite-PowerShell`
126
128
3. Start the script by using the function `Start-SQLStatsToGraphite`. If you want Verbose detailed use `Start-SQLStatsToGraphite -Verbose`. If you want to see what would be sent to Graphite, without actually sending the metrics, use `Start-SQLStatsToGraphite -Verbose -TestMode`
127
129
128
130
The below image is what `Start-SQLStatsToGraphite` like with **VerboseOutput** turned on in the XML configuration file looks like.
@@ -131,7 +133,7 @@ The below image is what `Start-SQLStatsToGraphite` like with **VerboseOutput** t
131
133
132
134
This function requires the Microsoft SQL PowerShell Modules/SnapIns. The easiest way to get these is to download them from the [SQL 2012 R2 SP1 Feature Pack](http://www.microsoft.com/en-us/download/details.aspx?id=35580). You will need to grab the following:
4. Check the service installed successfully `Get-Service -Name GraphitePowerShell`
182
184
5. Start the service `Start-Service -Name GraphitePowerShell`
183
185
184
186
## <aname="functions">Included Functions</a>
185
187
186
-
There are several functions that are exposed by the script which available to use in an ad-hoc manner.
188
+
There are several functions that are exposed by the module which are available to use in an ad-hoc manner.
187
189
188
-
For full help for these functions run the PowerShell command`Get-Help | <Function Name>`
190
+
For a list of functions in the module, run `Get-Command -Module Graphite-PowerShell`. For full help for these functions run `Get-Help | <Function Name>`
189
191
190
192
Function Name | Description
191
193
--- | ---
192
-
Start-StatsToGraphite | The function to collect Windows Performance Counters. This is an endless loop which will send metrics to Graphite.
193
-
Start-SQLStatsToGraphite | The function to query SQL. This is an endless loop which will send metrics to Graphite.
194
-
Send-GraphiteEvent | Sends an event to Graphite using the Graphite Event API. More information about the events API can be found [in this blog post](http://obfuscurity.com/2014/01/Graphite-Tip-A-Better-Way-to-Store-Events).
195
194
ConvertTo-GraphiteMetric | Takes the Windows Performance counter name and coverts it to something that Graphite can use.
196
-
Send-GraphiteMetric | Allows you to send metrics to Graphite in an ad-hoc manner.
197
195
Send-BulkGraphiteMetrics | Sends several Graphite Metrics to a Carbon server with one request. Bulk requests save a lot of resources for Graphite server.
198
-
Convert-TimeZone | Converts from one time zone to another.
199
-
Import-XMLConfig | Loads the XML Configuration file. Not really useful out side of the script.
196
+
Send-GraphiteEvent | Sends an event to Graphite using the Graphite Event API. More information about the events API can be found [in this blog post](http://obfuscurity.com/2014/01/Graphite-Tip-A-Better-Way-to-Store-Events).
197
+
Send-GraphiteMetric | Allows you to send metrics to Graphite in an ad-hoc manner.
198
+
Start-SQLStatsToGraphite | The function to query SQL. This is an endless loop which will send metrics to Graphite.
199
+
Start-StatsToGraphite | The function to collect Windows Performance Counters. This is an endless loop which will send metrics to Graphite.
0 commit comments