Ottomata has submitted this change and it was merged. Change subject: Adding define ganglia::view for abstracting ganglia web views. ......................................................................
Adding define ganglia::view for abstracting ganglia web views. Adding udp2log view on ganglia.wikimedia.org Change-Id: Ie3ab11316cf89e6ea1c6ec0edb2ea8a80947d9ab --- M manifests/ganglia.pp M manifests/misc/monitoring.pp M manifests/site.pp A templates/ganglia/ganglia_view.json.erb 4 files changed, 158 insertions(+), 1 deletion(-) Approvals: Ryan Lane: Looks good to me, approved Ottomata: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/manifests/ganglia.pp b/manifests/ganglia.pp index cf82867..a7110e5 100644 --- a/manifests/ganglia.pp +++ b/manifests/ganglia.pp @@ -412,6 +412,7 @@ $ganglia_servername = "ganglia.wmflabs.org" $ganglia_serveralias = "aggregator1.pmtpa.wmflabs" $ganglia_webdir = "/usr/share/ganglia-webfrontend" + $ganglia_confdir = "/var/lib/ganglia/conf" require ganglia::aggregator @@ -421,6 +422,9 @@ # TODO(ssmollett): when switching to ganglia-webfrontend # package, use /usr/share/ganglia-webfrontend $ganglia_webdir = "/srv/org/wikimedia/ganglia-web-3.5.4+security" + # Why is this set to a different directory than $ganglia_webdir??? + $ganglia_confdir = "/srv/org/ganglia_storage/3.5.1/conf" + $ganglia_ssl_cert = "/etc/ssl/certs/star.wikimedia.org.pem" $ganglia_ssl_key = "/etc/ssl/private/star.wikimedia.org.key" } @@ -538,3 +542,79 @@ } } + +# == Define ganlia::view +# Defines a Ganglia view JSON file. +# See http://sourceforge.net/apps/trac/ganglia/wiki/ganglia-web-2#JSONdefinitionforviews +# for documentation on Ganglia view JSON format. +# +# == Parameters: +# $graphs - Shortcut for of describing items that represent aggregate_graphs. +# $items - Should match exactly the JSON structure expected by Ganglia for views. +# $view_type - If you are using aggregate_graphs, this must be set to 'standard'. +# 'regex' will allow you to use non-aggregate graphs and match hostnames by regex. +# Default: 'standard'. +# $default_size - Default size for graphs. Default: 'large'. +# $conf_dir - Path to directory where ganglia view JSON files should live. +# Defaults to the appropriate directory based on WMF $::realm. Default: to /var/lib/ganglia/conf +# $template - The ERb template to use for the JSON file. Only change this if you need to do fancier things than this define allows. +# +# == Examples: +# # A 'regex' (non aggregate graph) view: +# # Note that no aggregate_graphs are used. +# # This will add 4 graphs to the 'cpu' view. +# # (i.e. cpu_user and cpu_system for each myhost and myhost1) +# $host_regex = 'myhost[01]' +# ganglia::view { 'cpu': +# view_type => 'regex', +# items => [ +# { +# 'metric' => 'cpu_user', +# 'hostname' => $host_regex, +# } +# { +# 'metric' => 'cpu_system', +# 'hostname' => $host_regex, +# } +# ], +# } +# +# +# # Use the $graphs parameter to describe aggregate graphs. +# # You can describe the same graphs to add with $items. +# # $graphs is just a shortcut. aggregate_graphs in $items +# # are a bit overly verbose. +# $host_regex = 'locke|emery|oxygen|gadolinium' +# ganglia::view { 'udp2log': +# graphs => [ +# { +# 'host_regex' => $host_regex, +# 'metric_regex' => 'packet_loss_average', +# } +# { +# 'host_regex' => $host_regex, +# 'metric_regex' => 'drops', +# } +# { +# 'host_regex' => $host_regex, +# 'metric_regex' => 'packet_loss_90th', +# } +# ], +# } +# +define ganglia::view( + $graphs = [], + $items = [], + $view_type = 'standard', + $default_size = 'large', + $conf_dir = $ganglia::web::ganglia_confdir, + $template = 'ganglia/ganglia_view.json.erb') +{ + require ganglia::web + + # require ganglia::web + $view_name = $name + file { "${conf_dir}/view_${name}.json": + content => template($template), + } +} diff --git a/manifests/misc/monitoring.pp b/manifests/misc/monitoring.pp index d1ccbc8..4f8b9f1 100644 --- a/manifests/misc/monitoring.pp +++ b/manifests/misc/monitoring.pp @@ -40,4 +40,52 @@ source => "puppet:///files/ganglia/plugins/udp_stats.pyconf", notify => Service[gmond]; } +} + +# Ganglia views that should be +# avaliable on ganglia.wikimedia.org +class misc::monitoring::views { + require ganglia::web + + misc::monitoring::view::udp2log { 'udp2log': + host_regex => 'locke|emery|oxygen|gadolinium', + } +} + +# == Define misc:monitoring::view::udp2log +# Installs a ganglia::view for a group of nodes +# running udp2log. This is just a wrapper for +# udp2log specific metrics to include in udp2log +# ganglia views. +# +# == Parameters: +# $host_regex - regex to pass to ganglia::view for matching host names in the view. +# $conf_dir +# +define misc::monitoring::view::udp2log($host_regex) { + ganglia::view { $name: + graphs => [ + { + 'host_regex' => $host_regex, + 'metric_regex' => 'packet_loss_average', + }, + { + 'host_regex' => $host_regex, + 'metric_regex' => 'packet_loss_90th', + }, + { + 'host_regex' => $host_regex, + 'metric_regex' => 'drops', + }, + { + 'host_regex' => $host_regex, + 'metric_regex' => 'pkts_in', + 'type' => 'stack', + }, + { + 'host_regex' => $host_regex, + 'metric_regex' => 'rx_queue', + }, + ], + } } \ No newline at end of file diff --git a/manifests/site.pp b/manifests/site.pp index 2295bee..ce3763b 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -1861,7 +1861,8 @@ $ganglia_aggregator = "true" include standard, - ganglia::web + ganglia::web, + misc::monitoring::views install_certificate{ "star.wikimedia.org": } } diff --git a/templates/ganglia/ganglia_view.json.erb b/templates/ganglia/ganglia_view.json.erb new file mode 100644 index 0000000..2a8b8ac --- /dev/null +++ b/templates/ganglia/ganglia_view.json.erb @@ -0,0 +1,28 @@ +<% +require 'json' + +# If graphs was specified, convert it into +# the items structure expected by ganglia-web. +graphs.each do |graph| + items.push({ + 'aggregate_graph' => 'true', + 'host_regex' => [{'regex' => graph['host_regex']}], + 'metric_regex' => [{'regex' => graph['metric_regex']}], + 'graph_type' => graph.has_key?('type') ? graph['type'] : 'line', + 'title' => graph.has_key?('title') ? graph['title'] : graph['metric_regex'], + 'size' => graph.has_key?('size') ? graph['size'] : 'large', + }) +end + +# Now render the JSON for the ganglia-web view. +-%> + +{ + "view_name":"<%= name %>", + "view_type":"<%= view_type %>", + "default_size":"<%= default_size %>", + + "items":<%= JSON.pretty_generate(items) %> +} + + -- To view, visit https://gerrit.wikimedia.org/r/56921 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie3ab11316cf89e6ea1c6ec0edb2ea8a80947d9ab Gerrit-PatchSet: 3 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Ottomata <o...@wikimedia.org> Gerrit-Reviewer: Ottomata <o...@wikimedia.org> Gerrit-Reviewer: Ryan Lane <rl...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits