Skip to content

Commit 06b2cbe

Browse files
committed
Merge pull request #4 from mothe-at/v1.5.0
V1.5.0
2 parents f7a0073 + a0c44e7 commit 06b2cbe

File tree

3 files changed

+261
-219
lines changed

3 files changed

+261
-219
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# v1.5.0 (2016-06-04)
2+
* **[ADDED]** Added feature to send metrics to more than one carbon host at a time. Fixed [#2] (https://github.com/mothe-at/VMPerf-To-Graphite-PowerShell-Script/issues/2)
3+
* **[ADDED]** Ability to add portnumber for carbon server with the hostname (`-Graphiteserver <hostname>[:<port>][,<hostname>[:<port>][,...]]`)
4+
5+
16
# v1.4.0 (2016-05-20)
27
* **[FIXED]** Parameter "-EventLogLevel None" could lead to an error message.
38
* **[ADDED]** Parameter "-FromLastPoll <xml-file>". If this parameter is set, the script will try to receive all metrics from the VCenter Server starting at the date and time of the last poll up to the most recent data (Real-Time). Best practice if you are using a scheduler to run the script with only one iteration. Check help for more information.

README.md

Lines changed: 158 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ The script is easy to setup and maintain, should be running in one minute.
99
- Check the [Version of PowerShell] (http://stackoverflow.com/questions/1825585/determine-installed-powershell-version) and update it to [PowerShell v4] (https://www.microsoft.com/en-US/download/details.aspx?id=40855) or above (POSH 2.x will cause problems, the Script will abort if the PowerShell Version is <4).
1010
- Check if the ["Statistics Level" in VCenter] (http://rettl.org/scripts/vcenter.png) for the shortest period is set to "Level 2" or higher.
1111
- Download the VMPerf-To-Graphite.ps1 script and save it on your server.
12-
- Open a new PowerShell Window, read the documentation of the script carefully and discover all the various options and parameters (call `PS C:\> Get-Help VMPerf-To-Graphite.ps1 -full`).
13-
- The script is not signed, if you receive an Execution Policy Error, just execute `PS C:\> Set-ExecutionPolicy Unrestricted` and it should work.
12+
- Open a new PowerShell Window, read the documentation of the script carefully and discover all the various options and parameters (call `PS C:\PS> Get-Help VMPerf-To-Graphite.ps1 -full`).
13+
- The script is not signed, if you receive an Execution Policy Error, just execute `PS C:\PS> Set-ExecutionPolicy Unrestricted` and it should work.
1414

1515
## How to use the script?
1616
### Modes of Operation
@@ -32,7 +32,7 @@ You also have to tell the script just to run once and then quit using the `-Iter
3232

3333
Calling the script could look something like this:
3434

35-
`PS C:\>VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass
35+
`PS C:\PS> VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass
3636
-Graphiteserver graphite1.it.acme.com -Iterations 1 -FromLastPoll Vienna_Poll.xml`
3737

3838
It does not matter if you wait 5 minutes or 30 minutes until you run the script the next time, it will gather all metrics starting at the time of the last succesfull poll. But remember that VCenter only stores real-time data for the last hour!
@@ -44,207 +44,196 @@ The script has extensive error handling but nevertheless it could happen that a
4444

4545
To call the script to run infinitely, waiting 5 minutes between each iteration, call this:
4646

47-
`PS C:\>VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass
47+
`PS C:\PS> VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass
4848
-Sleepseconds 300 -Graphiteserver graphite1.it.acme.com -Group Vienna`
4949

5050
## Some additional notes
5151
- By design principles a PowerShell Script should not generate any output, unless an error orrurs. We follow this principle and if you want to see what the script is doing, add the `-Verbose` parameter to your call.
5252
- For the user who will access VCenter, read-only permissions are enough.
5353

5454
## To-Do List
55-
- [ ] Sending metrics to more than one Carbon host at a time.
5655
- [ ] Ability to read from non-clustered ESX implementations.
5756

5857
## Syntax
59-
`VMPerf-To-Graphite.ps1 [[-Server] <String>] [[-User] <String>] [[-Password] <String>] [[-Protocol] <String>] [[-Datacenter] <String[]>] [[-Cluster] <String[]>] [[-Graphiteserver] <String>] [[-Graphiteserverport] <Int32>] [[-Group] <String>] [[-Sleepseconds] <Int32>] [[-Iterations] <Int32>] [[-FromLastPoll] <String>] [-Whatif] [[-EventLogLevel] <String>] [<CommonParameters>]`
58+
`VMPerf-To-Graphite.ps1 [[-Server] <String>] [[-User] <String>] [[-Password] <String>] [[-Protocol] <String>] [[-Datacenter] <String[]>] [[-Cluster] <String[]>] [[-Graphiteserver] <String[]>] [[-Graphiteserverport] <Int32>] [[-Group] <String>] [[-Iterations] <Int32>] [[-FromLastPoll] <String>] [[-Sleepseconds] <Int32>] [-Whatif] [[-EventLogLevel] <String>] [<CommonParameters>]`
6059

6160
### Parameters and Description
6261
```
6362
-Server <String>
64-
Specifies the IP address or the DNS name of the vCenter server to which you want to connect.
65-
66-
Required? false
67-
Position? 1
68-
Default value your_default_vcenter_server
69-
Accept pipeline input? false
70-
Accept wildcard characters? false
71-
63+
Specifies the IP address or the DNS name of the vCenter server to which you want to connect.
64+
65+
Required? false
66+
Position? 1
67+
Default value your_default_vcenter_server
68+
Accept pipeline input? false
69+
Accept wildcard characters? false
70+
7271
-User <String>
73-
Specifies the user name you want to use for authenticating with the vCenter server.
74-
75-
Required? false
76-
Position? 2
77-
Default value vcenter_user
78-
Accept pipeline input? false
79-
Accept wildcard characters? false
80-
72+
Specifies the user name you want to use for authenticating with the vCenter server.
73+
74+
Required? false
75+
Position? 2
76+
Default value vcenter_user
77+
Accept pipeline input? false
78+
Accept wildcard characters? false
79+
8180
-Password <String>
82-
Specifies the password you want to use for authenticating with the vCenter server.
83-
84-
Required? false
85-
Position? 3
86-
Default value vcenter_password
87-
Accept pipeline input? false
88-
Accept wildcard characters? false
89-
81+
Specifies the password you want to use for authenticating with the vCenter server.
82+
83+
Required? false
84+
Position? 3
85+
Default value vcenter_password
86+
Accept pipeline input? false
87+
Accept wildcard characters? false
88+
9089
-Protocol <String>
91-
Specifies the Internet protocol you want to use for the connection. It can be either http or https.
92-
93-
Required? false
94-
Position? 4
95-
Default value https
96-
Accept pipeline input? false
97-
Accept wildcard characters? false
98-
90+
Specifies the Internet protocol you want to use for the connection. It can be either http or https.
91+
92+
Required? false
93+
Position? 4
94+
Default value https
95+
Accept pipeline input? false
96+
Accept wildcard characters? false
97+
9998
-Datacenter <String[]>
100-
Specifies the VMWare Datacenters you want to receive data from. Default is to read all Clusters managed by
101-
VCenter server.
102-
103-
Required? false
104-
Position? 5
105-
Default value *
106-
Accept pipeline input? false
107-
Accept wildcard characters? false
108-
99+
Specifies the VMWare Datacenters you want to receive data from. Default is to read all Clusters
100+
managed by VCenter server.
101+
102+
Required? false
103+
Position? 5
104+
Default value *
105+
Accept pipeline input? false
106+
Accept wildcard characters? false
107+
109108
-Cluster <String[]>
110-
Specifies the VMWare Clusters you want to receive data from. Default is to read all Clusters managed by
111-
VCenter server or, if -Datacenter is specified, all Clusters in this Datacenter.
112-
113-
Required? false
114-
Position? 6
115-
Default value *
116-
Accept pipeline input? false
117-
Accept wildcard characters? false
118-
119-
-Graphiteserver <String>
120-
Specifies the IP address or the DNS name of the Graphite server to which you want to connect.
121-
122-
Required? false
123-
Position? 7
124-
Default value your_default_grafana_server
125-
Accept pipeline input? false
126-
Accept wildcard characters? false
127-
109+
Specifies the VMWare Clusters you want to receive data from. Default is to read all Clusters managed
110+
by VCenter server or, if -Datacenter is specified, all Clusters in this Datacenter.
111+
112+
Required? false
113+
Position? 6
114+
Default value *
115+
Accept pipeline input? false
116+
Accept wildcard characters? false
117+
118+
-Graphiteserver <String[]>
119+
Specifies one or more (separated by comma) IP addresses or the DNS names of the Graphite servers
120+
which you want to connect to.
121+
You can also add the Portnumber to each Server like "grafana.acme.com:2003"
122+
123+
Required? false
124+
Position? 7
125+
Default value your_default_grafana_server
126+
Accept pipeline input? false
127+
Accept wildcard characters? false
128+
128129
-Graphiteserverport <Int32>
129-
Specifies the port on the Graphite server you want to use for the connection. Defaults to 2003.
130-
131-
Required? false
132-
Position? 8
133-
Default value 2003
134-
Accept pipeline input? false
135-
Accept wildcard characters? false
136-
130+
Specifies the port on the Graphite server you want to use for the connection. Defaults to 2003.
131+
You can also add the portnumber to the servers hostname or IP address in the -Graphiteserver parameter.
132+
133+
Required? false
134+
Position? 8
135+
Default value 2003
136+
Accept pipeline input? false
137+
Accept wildcard characters? false
138+
137139
-Group <String>
138-
Specifies the Group, an additional prefix for the metrics path in Graphite. The metrics path will be
139-
"vmperf.<Group>."
140-
141-
Required? false
142-
Position? 9
143-
Default value Default
144-
Accept pipeline input? false
145-
Accept wildcard characters? false
146-
147-
-Sleepseconds <Int32>
148-
Specifies the number of seconds to wait between iterations. The counter starts after the last statistics have
149-
been sent to Graphite.
150-
Note that VCenter is collecting its performance statistics every 20 seconds and saves an average of the
151-
collected counters. It makes no sense to specify a value below 20 seconds here. The script reads the so called
152-
"Realtime" counters from VCenter which will be kept there for one hour. So do not use anything above 3600
153-
seconds.
154-
The script requests all statistics data from VCenter server since the last time they were requested,
155-
regardless of how long the Sleepseconds parameter was set. You wont miss any data.
156-
157-
Required? false
158-
Position? 10
159-
Default value 60
160-
Accept pipeline input? false
161-
Accept wildcard characters? false
162-
140+
Specifies the Group, an additional prefix for the metrics path in Graphite.
141+
The metrics path will be "vmperf.<Group>."
142+
143+
Required? false
144+
Position? 9
145+
Default value Default
146+
Accept pipeline input? false
147+
Accept wildcard characters? false
148+
163149
-Iterations <Int32>
164-
Specifies the number of iterations. 0 = indefinitely.
165-
166-
Required? false
167-
Position? 11
168-
Default value 0
169-
Accept pipeline input? false
170-
Accept wildcard characters? false
171-
150+
Specifies the number of iterations. 0 = indefinitely.
151+
152+
Required? false
153+
Position? 10
154+
Default value 0
155+
Accept pipeline input? false
156+
Accept wildcard characters? false
157+
172158
-FromLastPoll <String>
173-
Optional path and name of an .xml file where the date and time of the last poll will be saved.
174-
If the file does not exist, it will be created and overwritten after each poll.
175-
If this parameter is set, the script will try to receive all metrics from the VCenter Server starting at the
176-
date and time of the last poll up to the most recent data (Real-Time).
177-
This is useful if you want to schedule the script externally (with Task Scheduler, for instance) and you want
178-
to use the "-Iterations 1" parameter.
179-
But be careful, VCenter stores the Real-Time statistics just for a limited number of time (1 day per default).
180-
181-
Required? false
182-
Position? 12
183-
Default value
184-
Accept pipeline input? false
185-
Accept wildcard characters? false
186-
159+
Optional path and name of an .xml file where the date and time of the last poll will be saved. If the
160+
file does not exist, it will be created and overwritten after each poll.
161+
If this parameter is set, the script will try to receive all metrics from the VCenter Server starting
162+
at the date and time of the last poll up to the most recent data (Real-Time).
163+
This is useful if you want to schedule the script externally (with Task Scheduler, for instance) and you
164+
want to use the "-Iterations 1" parameter. But be careful, VCenter stores the Real-Time statistics just
165+
for a limited number of time (1 hour per default).
166+
167+
Required? false
168+
Position? 11
169+
Default value
170+
Accept pipeline input? false
171+
Accept wildcard characters? false
172+
173+
-Sleepseconds <Int32>
174+
Specifies the number of seconds to wait between iterations. The counter starts after the last statistics
175+
have been sent to Graphite.
176+
Note that VCenter is collecting its performance statistics every 20 seconds and saves an average of the
177+
collected counters. It makes no sense to specify a value below 20 seconds here. The script reads the so
178+
called "Realtime" counters from VCenter which will be kept there for one hour. So do not use anything
179+
above 3600 seconds.
180+
The script requests all statistics data from VCenter server since the last time they were requested,
181+
regardless of how long the Sleepseconds parameter was set. You wont miss any data.
182+
183+
Required? false
184+
Position? 12
185+
Default value 60
186+
Accept pipeline input? false
187+
Accept wildcard characters? false
188+
187189
-Whatif [<SwitchParameter>]
188-
Indicate that the cmdlet will process but will NOT send any metrics to Graphite, instead display a list of
189-
metrics that would be sent to Graphite.
190-
191-
Required? false
192-
Position? named
193-
Default value False
194-
Accept pipeline input? false
195-
Accept wildcard characters? false
196-
190+
Indicate that the cmdlet will process but will NOT send any metrics to Graphite, instead display a list
191+
of metrics that would be sent to Graphite.
192+
193+
Required? false
194+
Position? named
195+
Default value False
196+
Accept pipeline input? false
197+
Accept wildcard characters? false
198+
197199
-EventLogLevel <String>
198-
Set the Log-Level for writing events to the Windows Aplication log. Valid values are Error, Warning,
199-
Information, and None. The default value is Warning.
200-
Note that if you like to use logging to the Windows Event Log, you have to run this script at least once with
201-
administrative privileges on this computer!
202-
203-
Required? false
204-
Position? 13
205-
Default value Warning
206-
Accept pipeline input? false
207-
Accept wildcard characters? false
208-
200+
Set the Log-Level for writing events to the Windows Aplication log. Valid values are Error, Warning,
201+
Information, and None. The default value is Warning.
202+
Note that if you like to use logging to the Windows Event Log, you have to run this script at least once
203+
with administrative privileges on this computer!
204+
205+
Required? false
206+
Position? 13
207+
Default value Warning
208+
Accept pipeline input? false
209+
Accept wildcard characters? false
210+
209211
<CommonParameters>
210-
This cmdlet supports the common parameters: Verbose, Debug,
211-
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
212-
OutBuffer, PipelineVariable, and OutVariable. For more information, see
213-
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
214-
212+
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable,
213+
WarningAction, WarningVariable,
214+
OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters
215+
(http://go.microsoft.com/fwlink/?LinkID=113216).
215216
```
216217

217218
## Examples
218219
### Example 1
219-
`PS C:\>VMPerf-To-Graphite.ps1 -Verbose`
220-
220+
`C:\PS> VMPerf-To-Graphite.ps1 -Verbose`
221221
Use default values from within this script and display the status output on the screen.
222-
223222
### Example 2
224-
`PS C:\>VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass
225-
-Sleepseconds 300 -Graphiteserver graphite1.it.acme.com -Group Vienna`
226-
227-
Read the counters from the VCenter server myvcenter.vienna.acme.com, send the metrics to graphite1.it.acme.com
228-
with a metrics path of "vmperf.Vienna." and then wait 5 minutes before the next iteration.
229-
223+
`C:\PS> VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass -Graphiteserver graphite1.it.acme.com -Iterations 1 -FromLastPoll Vienna_Poll.xml`
224+
Run the cmdlet just once. Write the date and time of the Poll to Vienna_Poll.xml. The next time the script runs, it will read the file and gather the metrics from VCenter starting at the last poll.
230225
### Example 3
231-
`PS C:\>VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass
232-
-Sleepseconds 300 -Graphiteserver graphite1.it.acme.com -Group Vienna -Cluster TESTDEV`
233-
234-
Read the counters from Cluster TESTDEV in the VCenter server myvcenter.vienna.acme.com, send the metrics to
235-
graphite1.it.acme.com with a metrics path of "vmperf.Vienna." and then wait 5 minutes before the next iteration.
236-
226+
`C:\PS> VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass -Graphiteserver graphite1.it.acme.com,graphdev.it.acme.com:62033 -Iterations 1 -FromLastPoll Vienna_Poll.xml`
227+
Same as above but send the metrics to two servers, graphite1.it.acme.com at (default) port 2003 and graphdev.it.acme.com on port 62033.
237228
### Example 4
238-
`PS C:\>VMPerf-To-Graphite.ps1 -Verbose -Iterations 1 -WhatIf | Out-GridView`
239-
240-
Run the cmdlet just once, but do not send the metrics to Graphite, instead open a window and display the results.
241-
229+
`C:\PS> VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass -Sleepseconds 300 -Graphiteserver graphite1.it.acme.com -Group Vienna`
230+
Read the counters from the VCenter server myvcenter.vienna.acme.com, send the metrics to graphite1.it.acme.com with a metrics path of "vmperf.Vienna." and then wait 5 minutes before the next iteration.
242231
### Example 5
243-
`PS C:\>VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass
244-
-Graphiteserver graphite1.it.acme.com -Iterations 1 -FromLastPoll Vienna_Poll.xml`
245-
246-
Run the cmdlet just once. Write the date and time of the Poll to Vienna_Poll.xml. The next time the script runs,
247-
it will read the file and gather the metrics from VCenter starting at the last poll.
232+
`C:\PS> VMPerf-To-Graphite.ps1 -Verbose -Server myvcenter.vienna.acme.com -User ACME\StatsReader -Password mypass -Sleepseconds 300 -Graphiteserver graphite1.it.acme.com -Group Vienna -Cluster TESTDEV`
233+
Read the counters from Cluster TESTDEV in the VCenter server myvcenter.vienna.acme.com, send the metrics to graphite1.it.acme.com with a metrics path of "vmperf.Vienna." and then wait 5 minutes before the next iteration.
234+
### Example 6
235+
`C:\PS> VMPerf-To-Graphite.ps1 -Verbose -Iterations 1 -WhatIf | Out-GridView`
236+
Run the cmdlet just once, but do not send the metrics to Graphite, instead open a window and display the results.
248237

249238
## Licensing
250239
This work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License] (http://creativecommons.org/licenses/by-nc-sa/4.0/).

0 commit comments

Comments
 (0)