|
11 | 11 | Array[Hash] $additional_metrics = [],
|
12 | 12 | Boolean $ssl = true,
|
13 | 13 | Optional[Puppet_metrics_collector::Metrics_server] $metrics_server_info = undef,
|
| 14 | + Optional[String] $override_metrics_command, |
14 | 15 | ) {
|
15 | 16 |
|
16 | 17 | $metrics_output_dir = "${output_dir}/${metrics_type}"
|
|
41 | 42 | $script_file_name = "${scripts_dir}/${metric_script_file}"
|
42 | 43 | $conversion_script_file_name = "${scripts_dir}/json2timeseriesdb"
|
43 | 44 |
|
44 |
| - $metrics_base_command = "${script_file_name} --metrics_type ${metrics_type} --output-dir ${metrics_output_dir}" |
45 |
| - |
46 |
| - if !empty($metrics_server_info) { |
47 |
| - $metrics_server_hostname = $metrics_server_info['hostname'] |
48 |
| - $metrics_server_port = $metrics_server_info['port'] |
49 |
| - $metrics_server_type = $metrics_server_info['metrics_server_type'] |
50 |
| - $metrics_server_db = $metrics_server_info['db_name'] |
51 |
| - |
52 |
| - if empty($metrics_server_db) and $metrics_server_type == 'influxdb' { |
53 |
| - fail( 'When using an influxdb server you must provide the db_name to store metrics in' ) |
54 |
| - } |
55 |
| - |
56 |
| - $local_metrics_command = "${metrics_base_command} | ${conversion_script_file_name} --netcat ${metrics_server_hostname} --convert-to ${metrics_server_type}" |
57 |
| - |
58 |
| - $port_metrics_command = empty($metrics_server_port) ? { |
59 |
| - false => "${local_metrics_command} --port ${metrics_server_port}", |
60 |
| - true => $local_metrics_command, |
61 |
| - } |
62 |
| - |
63 |
| - $metrics_command = $metrics_server_type ? { |
64 |
| - 'influxdb' => "${port_metrics_command} --influx-db ${metrics_server_db} > /dev/null", |
65 |
| - 'graphite' => "${port_metrics_command} > /dev/null", |
66 |
| - default => "${port_metrics_command} > /dev/null", |
| 45 | + if empty($override_metrics_command){ |
| 46 | + $metrics_base_command = "${script_file_name} --metrics_type ${metrics_type} --output-dir ${metrics_output_dir}" |
| 47 | + |
| 48 | + if !empty($metrics_server_info) { |
| 49 | + $metrics_server_hostname = $metrics_server_info['hostname'] |
| 50 | + $metrics_server_port = $metrics_server_info['port'] |
| 51 | + $metrics_server_type = $metrics_server_info['metrics_server_type'] |
| 52 | + $metrics_server_db = $metrics_server_info['db_name'] |
| 53 | + |
| 54 | + if empty($metrics_server_db) and $metrics_server_type == 'influxdb' { |
| 55 | + fail( 'When using an influxdb server you must provide the db_name to store metrics in' ) |
| 56 | + } |
| 57 | + |
| 58 | + $local_metrics_command = "${metrics_base_command} | ${conversion_script_file_name} --netcat ${metrics_server_hostname} --convert-to ${metrics_server_type}" |
| 59 | + |
| 60 | + $port_metrics_command = empty($metrics_server_port) ? { |
| 61 | + false => "${local_metrics_command} --port ${metrics_server_port}", |
| 62 | + true => $local_metrics_command, |
| 63 | + } |
| 64 | + |
| 65 | + $metrics_command = $metrics_server_type ? { |
| 66 | + 'influxdb' => "${port_metrics_command} --influx-db ${metrics_server_db} > /dev/null", |
| 67 | + 'graphite' => "${port_metrics_command} > /dev/null", |
| 68 | + default => "${port_metrics_command} > /dev/null", |
| 69 | + } |
| 70 | + } else { |
| 71 | + $metrics_command = "${metrics_base_command} --no-print" |
67 | 72 | }
|
68 | 73 | } else {
|
69 |
| - $metrics_command = "${metrics_base_command} --no-print" |
| 74 | + $metrics_command = $override_metrics_command |
70 | 75 | }
|
71 | 76 |
|
72 | 77 | cron { "${metrics_type}_metrics_collection" :
|
|
0 commit comments