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
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.
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.
15
21
.EXAMPLE
@@ -18,15 +24,13 @@ Read the counters from Cluster TESTDEV in the VCenter server myvcenter.vienna.ac
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.
24
27
.NOTES
25
28
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
26
29
It is free-of-charge and it comes without any warranty, to the extent permitted by applicable law.
# Specifies the VMWare Clusters you want to receive data from. Default is to read all Clusters managed by VCenter server or, if -Datacenter is specified, all Clusters in this Datacenter.
46
50
[string[]]$Cluster="*",
47
-
# Specifies the IP address or the DNS name of the Graphite server to which you want to connect.
# Specifies the Group, an additional prefix for the metrics path in Graphite. The metrics path will be "vmperf.<Group>."
52
58
[string]$Group="Default",
53
-
# Specifies the number of seconds to wait between iterations. The counter starts after the last statistics have been sent to Graphite.
54
-
# Note that VCenter is collecting its performance statistics every 20 seconds and saves an average of the collected counters. It makes no sense to specify a value below 20 seconds here. The script reads the so called "Realtime" counters from VCenter which will be kept there for one hour. So do not use anything above 3600 seconds.
55
-
# The script requests all statistics data from VCenter server since the last time they were requested, regardless of how long the Sleepseconds parameter was set. You wont miss any data.
56
-
[ValidateRange(0,3600)][int]$Sleepseconds=60,
57
59
# Specifies the number of iterations. 0 = indefinitely.
58
60
[ValidateRange(0,65536)][int]$Iterations=0,
59
61
# Optional path and name of an .xml file where the date and time of the last poll will be saved.
@@ -62,6 +64,10 @@ param(
62
64
# This is useful if you want to schedule the script externally (with Task Scheduler, for instance) and you want to use the "-Iterations 1" parameter.
63
65
# But be careful, VCenter stores the Real-Time statistics just for a limited number of time (1 day per default).
64
66
[string]$FromLastPoll="",
67
+
# Specifies the number of seconds to wait between iterations. The counter starts after the last statistics have been sent to Graphite.
68
+
# Note that VCenter is collecting its performance statistics every 20 seconds and saves an average of the collected counters. It makes no sense to specify a value below 20 seconds here. The script reads the so called "Realtime" counters from VCenter which will be kept there for one hour. So do not use anything above 3600 seconds.
69
+
# The script requests all statistics data from VCenter server since the last time they were requested, regardless of how long the Sleepseconds parameter was set. You wont miss any data.
70
+
[ValidateRange(0,3600)][int]$Sleepseconds=60,
65
71
# Indicate that the cmdlet will process but will NOT send any metrics to Graphite, instead display a list of metrics that would be sent to Graphite.
66
72
[Switch]$Whatif,
67
73
# Set the Log-Level for writing events to the Windows Aplication log. Valid values are Error, Warning, Information, and None. The default value is Warning.
$msg="Connection to $graphiteserver on port $graphiteserverport failed with $ErrorMessage! Will retry in 10 seconds"
151
-
Write-Warning"$(Get-Date-format G)$msg"
152
-
Write-To-Windows-EventLog "Warning"2007$msg
153
-
Start-Sleep-s 10
154
-
}
131
+
$maxretries=10# Maximum number of retries to connect to a Graphite server. Only applicable if multiple servers are specified. With only 1 server it will try forever.
132
+
$aservers=$graphiteserver-split''
155
133
156
-
} while ($IsErr)
134
+
foreach($sin0..($aservers.count-1)){
135
+
136
+
$cserver=$aservers[$s]
137
+
if ($cserver.contains(":"))
138
+
{
139
+
$atmp=$cserver-split':'
140
+
$cserver=$atmp[0]
141
+
$cport=$atmp[1]
142
+
}
143
+
else
144
+
{
145
+
$cport=$graphiteserverport
146
+
}
147
+
148
+
$msg="Sending $scount metrics for $vcount VMs of iteration # $iteration to Graphite server $cserver`:$cport"
0 commit comments