File: type.pp

package info (click to toggle)
puppet-module-voxpupuli-collectd 11.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,308 kB
  • sloc: ruby: 8,119; python: 30; sh: 10; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
define collectd::type (
  String                                                      $target,
  String                                                      $ds = $name,
  # BC compatible ....
  Optional[Enum['ABSOLUTE', 'COUNTER', 'DERIVE', 'GAUGE']]    $ds_type = undef,
  Variant[Numeric, Enum['U']]                                 $min = 'U',
  Variant[Numeric, Enum['U']]                                 $max = 'U',
  String                                                      $ds_name = 'value',
  # BC compatible .... ending

  Array[Struct[{
    min     => Variant[Numeric, Enum['U']],
    max     => Variant[Numeric, Enum['U']],
    ds_type => Enum['ABSOLUTE', 'COUNTER', 'DERIVE', 'GAUGE'],
    ds_name => String,
  }]]                                                         $types = [],
) {
  if empty($types) {
    $_types = [{
      min     => $min,
      max     => $max,
      ds_type => $ds_type,
      ds_name => $ds_name,
    }]
  } else {
    $_types = $types
  }

  $content = $_types.map |$type| { "${type['ds_name']}:${type['ds_type']}:${type['min']}:${type['max']}" }.join(', ')

  concat::fragment { "${target}/${ds}":
    content => "${ds}\t${content}",
    target  => $target,
    order   => $ds,
  }
}