Skip to content

Instantly share code, notes, and snippets.

@smortex
Created September 7, 2022 19:26
Show Gist options
  • Save smortex/a16c83a1b01a714ffeef2258a5ac484f to your computer and use it in GitHub Desktop.
Save smortex/a16c83a1b01a714ffeef2258a5ac484f to your computer and use it in GitHub Desktop.
Monitoring with riemann-tools and virtual resorces
# site-modules/profile/manifests/base/linux.pp
class profile::base::linux {
# [...]
if fact('mountpoints').map |$mountpoint, $info| { $info['device'] }.any |$device| { $device =~ '^/dev/md' } {
@concat::fragment { 'riemann-wrapper-md':
target => '/etc/riemann-wrapper.yml',
order => '10',
content => @("CONFIG"),
- name: "md"
options: "--interval 60"
| CONFIG
}
}
# [...]
}
# site-modules/profile/manifests/nginx.pp
class profile::nginx (...) {
# [...]
@concat::fragment { 'riemann-wrapper-nginx':
target => '/etc/riemann-wrapper.yml',
order => '10',
content => @("CONFIG"),
- name: "nginx_status"
options: "--uri http://localhost/nginx_status --interval 30"
| CONFIG
}
# [...]
}
# site-modules/profile/manifests/riemann_tools.pp
class profile::riemann_tools {
package { 'riemann-tools':
ensure => '1.4.0',
provider => 'puppet_gem',
notify => Service['riemann-tools.service'],
}
concat { '/etc/riemann-wrapper.yml':
ensure => present,
}
@concat::fragment { 'riemann-wrapper-header':
target => '/etc/riemann-wrapper.yml',
order => '01',
content => @("CONFIG"),
---
options: "..."
tools:
| CONFIG
}
@concat::fragment { 'riemann-wrapper-health':
target => '/etc/riemann-wrapper.yml',
order => '10',
content => @(CONFIG),
- name: "health"
| CONFIG
}
$monitored_interfaces = fact('networking.interfaces').filter |$item| {
# Ignore the loopback address and interfaces with no IP address
$item[0] != 'lo' and $item[0] != 'docker0' and $item[0] !~ /^(veth|br-)/ and ($item[1]['ip'] or $item[1]['ip6'])
}.keys.map |$item| { "^${item}\$" }
@concat::fragment { 'riemann-wrapper-net':
target => '/etc/riemann-wrapper.yml',
order => '10',
content => @("CONFIG"),
- name: "net"
options: "--interfaces ${monitored_interfaces.join(' ')}"
| CONFIG
}
Concat::Fragment <| target == '/etc/riemann-wrapper.yml' |>
systemd::unit_file { 'riemann-tools.service':
content => @("UNIT"),
[Unit]
Description=Riemann Tools
After=network.target
[Service]
ExecStart=/opt/puppetlabs/puppet/bin/riemann-wrapper /etc/riemann-wrapper.yml
Restart=on-failure
[Install]
WantedBy=multi-user.target
| UNIT
enable => true,
active => true,
}
}
# site-modules/profile/manifests/zol.pp
class profile::zol {
# [...]
@concat::fragment { 'riemann-wrapper-zpool':
target => '/etc/riemann-wrapper.yml',
order => '10',
content => @("CONFIG"),
- name: "zpool"
options: "--interval 60"
| CONFIG
}
# [...]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment