Ottomata has uploaded a new change for review.
https://gerrit.wikimedia.org/r/56921
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, 165 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/21/56921/1
diff --git a/manifests/ganglia.pp b/manifests/ganglia.pp
index cf82867..cb1a713 100644
--- a/manifests/ganglia.pp
+++ b/manifests/ganglia.pp
@@ -538,3 +538,89 @@
}
}
+
+# == 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 = undef,
+ $template = 'ganglia/ganglia_view.json.erb')
+
+{
+ if ($conf_dir != undef) {
+ $confdir = $conf_dir
+ }
+ else {
+ $confdir = $::realm ? {
+ 'production' => '/srv/org/ganglia_storage/3.5.1/conf',
+ 'labs' => '/var/lib/ganglia/conf',
+ default => '/var/lib/ganglia/conf',
+ }
+ }
+
+ # require ganglia::web
+ $view_name = $name
+ file { "${confdir}/view_${name}.json":
+ content => template($template),
+ }
+}
diff --git a/manifests/misc/monitoring.pp b/manifests/misc/monitoring.pp
index d1ccbc8..722d758 100644
--- a/manifests/misc/monitoring.pp
+++ b/manifests/misc/monitoring.pp
@@ -40,4 +40,53 @@
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, $conf_dir = undef) {
+ 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',
+ },
+ ],
+ conf_dir => $conf_dir,
+ }
}
\ 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: newchange
Gerrit-Change-Id: Ie3ab11316cf89e6ea1c6ec0edb2ea8a80947d9ab
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ottomata <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits