Skip to content

Commit bec43c3

Browse files
author
Jarret Lavallee
committed
(SUP-1969) Add metrics shipping for VMware
Prior to this commit, there was no way to ship vmware metrics to a remote metrics server. This commit adds the capability of doing metrics shipping for VMware metrics.
1 parent dfecd55 commit bec43c3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

files/vmware_metrics

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ module PuppetMetricsCollector
159159
'Defaults to 10.'],
160160
['--output_dir DIR',
161161
'Write metrics to a timestamed file under DIR instead of',
162-
'printing to STDOUT']].freeze
162+
'printing to STDOUT'],
163+
['-p', '--[no-]print', 'Always print to STDOUT']].freeze
163164

164165
def initialize(argv = [])
165166
@action = :collect_data
@@ -172,7 +173,7 @@ module PuppetMetricsCollector
172173
@action = :show_help
173174
end
174175

175-
parser.on_tail('--debug', 'Enable backtraces from errors.') do
176+
parser.on_tail('-d', '--debug', 'Enable backtraces from errors.') do
176177
@options[:debug] = true
177178
end
178179
end
@@ -208,7 +209,9 @@ module PuppetMetricsCollector
208209
FileUtils.mkdir_p(host_dir) unless File.directory?(host_dir)
209210
output_file = File.join(host_dir, Time.now.utc.strftime('%Y%m%dT%H%M%SZ') + '.json')
210211

211-
File.write(output_file, JSON.generate(data))
212+
output = JSON.generate(data)
213+
File.write(output_file, output)
214+
$stdout.puts(output) if @options[:print]
212215
else
213216
$stdout.puts(JSON.generate(data))
214217
end

manifests/system/vmware.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
String $metrics_ensure = $puppet_metrics_collector::system::system_metrics_ensure,
1313
Integer $collection_frequency = $puppet_metrics_collector::system::collection_frequency,
1414
Integer $retention_days = $puppet_metrics_collector::system::retention_days,
15+
String $metrics_shipping_command = $puppet_metrics_collector::system::metrics_shipping_command,
1516
) {
1617
$metrics_output_dir = "${puppet_metrics_collector::system::output_dir}/vmware"
1718
$metrics_output_dir_ensure = $metrics_ensure ? {
@@ -27,6 +28,7 @@
2728

2829
$metrics_command = ["${puppet_metrics_collector::system::scripts_dir}/vmware_metrics",
2930
'--output_dir', $metrics_output_dir,
31+
$metrics_shipping_command,
3032
'> /dev/null'].join(' ')
3133

3234
$tidy_command = "${puppet_metrics_collector::system::scripts_dir}/metrics_tidy -d ${metrics_output_dir} -r ${retention_days}"

0 commit comments

Comments
 (0)