Defined Type: zabbix::userparameters

Defined in:
manifests/userparameters.pp

Summary

This will install an userparameters file with keys for items that can be checked with zabbix.

Overview

Examples:

zabbix::userparameters { 'mysql':
  source => 'puppet:///modules/zabbix/mysqld.conf',
}
zabbix::userparameters { 'mysql':
  content => 'UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive',
}

Or when using exported resources (manage_resources is set to true)

zabbix::userparameters { 'mysql':
  source   => 'puppet:///modules/zabbix/mysqld.conf',
  template => 'Template App MySQL',
}

Parameters:

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    If the userparameter should be ‘present` or `absent`

  • source (Optional[Stdlib::Filesource]) (defaults to: undef)

    File which holds several userparameter entries.

  • content (Optional[String[1]]) (defaults to: undef)

    When you have 1 userparameter entry which you want to install.

  • script (Optional[Stdlib::Filesource]) (defaults to: undef)

    Low level discovery (LLD) script.

  • script_ext (Optional[String[1]]) (defaults to: undef)

    The script extention. Should be started with the dot. Like: .sh .bat .py

  • template (Optional[String[1]]) (defaults to: undef)

    When you use exported resources (when manage_resources is set to true on other components) you’ll can add the name of the template which correspondents with the ‘content’ or ‘source’ which you add. The template will be added to the host.

  • script_dir (Stdlib::Absolutepath) (defaults to: '/usr/bin')

    When ‘script’ is used, this parameter can provide the directly where this script needs to be placed. Default: ‘/usr/bin’

  • config_mode (Stdlib::Filemode) (defaults to: '0644')

    When ‘config_mode’ is used, this parameter can provide the mode of the config file who will be created to keep some credidentials private. Default: ‘0644’

Author:

  • Werner Dijkerman <ikben@werner-dijkerman.nl>



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'manifests/userparameters.pp', line 30

define zabbix::userparameters (
  Enum['present', 'absent']    $ensure      = 'present',
  Optional[Stdlib::Filesource] $source      = undef,
  Optional[String[1]]          $content     = undef,
  Optional[Stdlib::Filesource] $script      = undef,
  Optional[String[1]]          $script_ext  = undef,
  Optional[String[1]]          $template    = undef,
  Stdlib::Absolutepath         $script_dir  = '/usr/bin',
  Stdlib::Filemode             $config_mode = '0644',
) {
  include zabbix::agent
  $include_dir          = $zabbix::agent::include_dir
  $zabbix_package_agent = $zabbix::agent::zabbix_package_agent
  $agent_config_owner   = $zabbix::agent::agent_config_owner
  $agent_config_group   = $zabbix::agent::agent_config_group
  $agent_servicename    = $zabbix::agent::servicename

  if $source {
    file { "${include_dir}/${name}.conf":
      ensure  => $ensure,
      owner   => $agent_config_owner,
      group   => $agent_config_group,
      mode    => $config_mode,
      source  => $source,
      notify  => Service[$agent_servicename],
      require => Package[$zabbix_package_agent],
    }
  }

  if $content {
    file { "${include_dir}/${name}.conf":
      ensure  => $ensure,
      owner   => $agent_config_owner,
      group   => $agent_config_group,
      mode    => $config_mode,
      content => $content,
      notify  => Service[$agent_servicename],
      require => Package[$zabbix_package_agent],
    }
  }

  if $script {
    file { "${script_dir}/${name}${script_ext}":
      ensure  => $ensure,
      owner   => $agent_config_owner,
      group   => $agent_config_group,
      mode    => '0755',
      source  => $script,
      notify  => Service[$agent_servicename],
      require => Package[$zabbix_package_agent],
    }
  }

  # If template is defined, it means we have an template in zabbix
  # which needs to be loaded for this host. When exported resources is
  # used/enabled, we do this automatically.
  if $template {
    zabbix::resources::userparameters { "${facts['networking']['hostname']}_${name}":
      ensure   => $ensure,
      hostname => $facts['networking']['fqdn'],
      template => $template,
    }
  }
}