Create a gist now

Instantly share code, notes, and snippets.

class role::leonardo::client (
$dashboard_root = '/opt/leonardo/leonardo/graphs/servers',
)
{
$collectd_name = regsubst($::fqdn, '\.', '_', 'G'),
$dashboard_dir = "${dashboard_root}/${::hostname}",
# Each host needs a directory to hold the graph files
@@file { $dashboard_dir:
ensure => directory,
mode => '0755',
tag => "env_leonardo_${environment}",
}
# Export a dash.yaml file
@@leonardo::dashboard { $::hostname:
target => "${dashboard_dir}/dash.yaml",
name => $::hostname,
description => 'System Metrics',
include_properties => ['common.yaml'],
tag => "env_${environment}",
require => File[$dashboard_dir],
}
# Export a cpu graph
@@leonardo::graph { "${::hostname}-cpu":
target => "${dashboard_dir}/10-cpu.graph",
parameters => { 'title' => 'Combined CPU Usage',
'vtitle' => 'percent',
'area' => 'stacked' },
fields => {
'iowait' => { 'data' => "sumSeries(collectd.${collectd_name}.cpu*.cpu-wait)",},
'system' => { 'data' => "sumSeries(collectd.${collectd_name}.cpu*.cpu-system)",},
'user' => { 'data' => "sumSeries(collectd.${collectd_name}.cpu*.cpu-user)",},
},
tag => "env_leonardo_${environment}",
require => File[$dashboard_dir],
}
# Export a load graph
@@leonardo::graph { "${::hostname}-load":
target => "${dashboard_dir}/20-load.graph",
parameters => { 'title' => 'Load Average',
'vtitle' => 'Load',
'area' => 'first' },
fields => {
'shortterm' => { 'data' => "sumSeries(collectd.${collectd_name}.load.load.shortterm)",},
'midterm' => { 'data' => "sumSeries(collectd.${collectd_name}.load.load.midterm)",},
'longterm' => { 'data' => "sumSeries(collectd.${collectd_name}.load.load.longterm)",},
},
tag => "env_leonardo_${environment}",
require => File[$dashboard_dir],
}
# Export a memory graph
@@leonardo::graph { "${::hostname}-memory":
target => "${dashboard_dir}/30-memory.graph",
parameters => { 'title' => 'Memory Usage',
'vtitle' => 'Bytes',
'area' => 'stacked' },
fields => {
'used' => { 'data' => "sumSeries(collectd.${collectd_name}.memory.memory-used)",},
'bufferd'=> { 'data' => "sumSeries(collectd.${collectd_name}.memory.memory-buffered)",},
'cached' => { 'data' => "sumSeries(collectd.${collectd_name}.memory.memory-cached)",},
'free' => { 'data' => "sumSeries(collectd.${collectd_name}.memory.memory-free)",},
},
tag => "env_leonardo_${environment}",
require => File[$dashboard_dir],
}
# Export a network usage graph for each interface on the machine
$goodif = grep(split($::interfaces, ','), '^[^_]+$')
each($goodif) |$ethname| {
@@leonardo::graph { "${::hostname}-${ethname}-network":
target => "${dashboard_dir}/40-net-${ethname}.graph",
parameters => { 'title' => "Network Usage by ${ethname}",
'vtitle' => 'Bits',
'area' => 'first' },
fields => {
'outgoing' => { 'data' => "sumSeries(collectd.${collectd_name}.interface-${ethname}.if_octets.rx)",},
'incoming' => { 'data' => "sumSeries(collectd.${collectd_name}.interface-${ethname}.if_octets.tx)",},
},
tag => "env_leonardo_${environment}",
require => File[$dashboard_dir],
}
}
# Export graphs of block device usage for each block device
# Solaris has no blockdevices fact and is skipped
if $::blockdevices {
$gooddev = grep(split($::blockdevices, ','), '^.[^r].')
each($gooddev) |$devname| {
@@leonardo::graph { "${::hostname}-${devname}-disk_octets":
target => "${dashboard_dir}/50-disk-octets-${devname}.graph",
parameters => { 'title' => "Octets on ${devname}",
require => File[$dashboard_dir],
}
}
# Export graphs of block device usage for each block device
# Solaris has no blockdevices fact and is skipped
if $::blockdevices {
$gooddev = grep(split($::blockdevices, ','), '^.[^r].')
each($gooddev) |$devname| {
@@leonardo::graph { "${::hostname}-${devname}-disk_octets":
target => "${dashboard_dir}/50-disk-octets-${devname}.graph",
parameters => { 'title' => "Octets on ${devname}",
'vtitle' => 'Bytes/s' },
fields => {
'read' => { 'data' => "sumSeries(collectd.${collectd_name}.disk-${devname}.disk_octets.read)",},
'write' => { 'data' => "sumSeries(collectd.${collectd_name}.disk-${devname}.disk_octets.write)",},
},
tag => "env_leonardo_${environment}",
require => File[$dashboard_dir],
}
@@leonardo::graph { "${::hostname}-${devname}-disk_ops":
target => "${dashboard_dir}/60-disk-ops-${devname}.graph",
parameters => { 'title' => "Operations on ${devname}",
'vtitle' => 'Ops/s' },
fields => {
'read' => { 'data' => "sumSeries(collectd.${collectd_name}.disk-${devname}.disk_ops.read)",},
'write' => { 'data' => "sumSeries(collectd.${collectd_name}.disk-${devname}.disk_ops.write)",},
},
tag => "env_leonardo_${environment}",
require => File[$dashboard_dir],
}
@@leonardo::graph { "${::hostname}-${devname}-disk_time":
target => "${dashboard_dir}/70-disk-time-${devname}.graph",
parameters => { 'title' => "Average time for operation to complete on ${devname}",
'vtitle' => 'Seconds' },
fields => {
'read' => { 'data' => "sumSeries(collectd.${collectd_name}.disk-${devname}.disk_time.read)",},
'write' => { 'data' => "sumSeries(collectd.${collectd_name}.disk-${devname}.disk_time.write)",},
},
tag => "env_leonardo_${environment}",
require => File[$dashboard_dir],
}
@@leonardo::graph { "${::hostname}-${devname}-disk_merged":
target => "${dashboard_dir}/80-disk-merged-${devname}.graph",
parameters => { 'title' => "Operations merged into other operations on ${devname}",
'vtitle' => 'Merged Ops/s' },
fields => {
'read' => { 'data' => "sumSeries(collectd.${collectd_name}.disk-${devname}.disk_merged.read)",},
'write' => { 'data' => "sumSeries(collectd.${collectd_name}.disk-${devname}.disk_merged.write)",},
},
tag => "env_leonardo_${environment}",
require => File[$dashboard_dir],
}
}
# Export a swap graph
@@leonardo::graph { "${::hostname}-swap":
target => "${dashboard_dir}/90-swap.graph",
parameters => { 'title' => 'Swap Usage',
'vtitle' => 'Bytes',
'area' => 'stacked' },
fields => {
'used' => { 'data' => "sumSeries(collectd.${collectd_name}.swap.swap-used)",},
'cached' => { 'data' => "sumSeries(collectd.${collectd_name}.swap.swap-cached)",},
'free' => { 'data' => "sumSeries(collectd.${collectd_name}.swap.swap-free)",},
},
tag => "env_leonardo_${::environment}",
require => File[$dashboard_dir],
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment