Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

configurable modules #5

Merged
merged 4 commits into from

3 participants

Corey Shields Chris Van Jeremy Orem
Corey Shields

last request for now.. I added ENABLED_MODULES = ['ganglia', 'graphite', 'nagios', 'pingdom'] which just stops the options from showing up in the menu bar if they do not exist in that config. Should find a way to make their views conditional as well but I can't see an easy way to do that in flask (yet)

Chris Van

it's a nitpick and totally not a big deal but we usually use spaces within variables to help with readability: {{ config.DASHBOARD_NAME }}

will gladly fix.. My coding time is kept to a minimum, so thanks for the tip. :)

Jeremy Orem oremj merged commit 63f7fbf into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2012
  1. Corey Shields

    making a couple of zamboni-specific wording and links into config var…

    cshields authored
    …iables so they can be changed through settings_local
  2. Corey Shields
Commits on Jul 19, 2012
  1. Corey Shields
  2. Corey Shields

    adding ENABLED_MODULES so I can pull unwanted features off of the top…

    cshields authored
    … menu bar, should still make them conditional in views.py somehow
This page is out of date. Refresh to see the latest.
21 zamboni_dashboard/data/ganglia.py
View
@@ -0,0 +1,21 @@
+from .. import app
+from urllib import urlencode
+
+def ganglia_graphs(size='small', r='hour'):
+ graphs = {}
+ for group, cluster, monitors in app.config['GANGLIA_GROUPS']:
+ monitors = monitors + app.config['GANGLIA_DEFAULT_REPORTS']
+ graphs[group] = [ganglia_graph(m, cluster, size, r) for m in monitors]
+ return graphs
+
+def ganglia_graph(name, cluster, size='medium',
+ r='hour', t='g', host=None):
+ query = {'c': cluster,
+ 'z': size,
+ 'r': r,
+ t: name}
+ if host:
+ query['host'] = host
+
+ return "%s/graph.php?%s" % (app.config['GANGLIA_BASE'],
+ urlencode(query))
15 zamboni_dashboard/default_settings.py
View
@@ -1,5 +1,20 @@
class DefaultSettings(object):
+ DASHBOARD_NAME = 'Zamboni Dashboard'
+ OPS_BUG_URL = 'https://bit.ly/amo_ops_bug'
+ OPS_DOCS_URL = 'https://mana.mozilla.org/wiki/display/websites/addons.mozilla.org'
+ ENABLED_MODULES = ['ganglia', 'graphite', 'nagios', 'pingdom']
+
GANGLIA_BASE = 'https://ganglia.mozilla.org/phx1'
+ GANGLIA_DEFAULT_REPORTS = ['load_report', 'cpu_report',
+ 'mem_report', 'network_report']
+ GANGLIA_GROUPS = [('Web', 'addons', ['apache_report',
+ 'apache_server_report',
+ 'nginx_active_connections',
+ 'nginx_response_report',
+ 'nginx_server_report']),
+ ('Memcache', 'Memcache AMO Cluster', ['memcached_report']),
+ ('Redis', 'amo-redis', ['amo_redis_prod_report'])
+ ]
GRAPHITE_BASE = 'https://graphite-phx.mozilla.org'
NAGIOS_STATUS_FILE = ''
NAGIOS_STATUS_URL = ''
16 zamboni_dashboard/templates/base.html
View
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>{% block title %}Zamboni Dashboard{% endblock %}</title>
+ <title>{% block title %}{{ config.DASHBOARD_NAME }}{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/css/bootstrap.min.css') }}" />
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" />
<script src="{{ url_for('static', filename='js/jquery-1.7.2.min.js') }}"></script>
@@ -18,18 +18,26 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
- <a class="brand" href="#">Zamboni Dashboard</a>
+ <a class="brand" href="#">{{ config.DASHBOARD_NAME }}</a>
<ul class="nav">
<li><a href="{{ url_for('index') }}">Home</a></li>
+ {% if 'ganglia' in config.ENABLED_MODULES %}
<li><a href="{{ url_for('ganglia') }}">Ganglia</a></li>
+ {% endif %}
+ {% if 'graphite' in config.ENABLED_MODULES %}
<li><a href="{{ url_for('graphite') }}">Graphite</a></li>
+ {% endif %}
+ {% if 'nagios' in config.ENABLED_MODULES %}
<li><a href="{{ url_for('nagios') }}">Nagios</a></li>
+ {% endif %}
+ {% if 'pingdom' in config.ENABLED_MODULES %}
<li><a href="{{ url_for('pingdom') }}">Pingdom</a></li>
+ {% endif %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">External<b class="caret"></b></a>
<ul class="dropdown-menu">
- <li><a href="https://bit.ly/amo_ops_bug">File an operations bug</a></li>
- <li><a href="https://mana.mozilla.org/wiki/display/websites/addons.mozilla.org">Operations documentation</a></li>
+ <li><a href="{{config.OPS_BUG_URL}}">File an operations bug</a></li>
+ <li><a href="{{config.OPS_DOCS_URL}}">Operations documentation</a></li>
</ul>
</li>
</ul>
33 zamboni_dashboard/views.py
View
@@ -8,6 +8,7 @@
from .data.graphite import graphs as graphite_graphs
from .data.nagios import get_nagios_service_status
from .data.pingdom import pingdom as pingdom_data
+from .data.ganglia import ganglia_graphs
@@ -28,42 +29,12 @@ def index():
@app.route('/ganglia')
def ganglia():
- def ganglia_graphs(names, *args, **kwargs):
- return [ganglia_graph(n, *args, **kwargs) for n in names]
-
- def ganglia_graph(name, cluster, size='medium',
- r='hour', t='g', host=None):
- query = {'c': cluster,
- 'z': size,
- 'r': r,
- t: name}
- if host:
- query['host'] = host
-
- return "%s/graph.php?%s" % (app.config['GANGLIA_BASE'],
- urlencode(query))
-
ranges = ['hour', 'day', 'week', 'month', 'year']
sizes = ['small', 'medium', 'large', 'xlarge']
cur_range = request.args.get('range', 'hour')
cur_size = request.args.get('size', 'small')
- ganglia_graphs = partial(ganglia_graphs, r=cur_range, size=cur_size)
- default_reports = ['load_report', 'cpu_report',
- 'mem_report', 'network_report']
- graphs = {}
- graphs['Web'] = ganglia_graphs(default_reports +
- ['apache_report',
- 'apache_server_report',
- 'nginx_active_connections',
- 'nginx_response_report',
- 'nginx_server_report'],
- cluster='addons')
- graphs['Memcache'] = ganglia_graphs(default_reports + ['memcached_report'],
- cluster='Memcache AMO Cluster')
- graphs['Redis'] = ganglia_graphs(default_reports +
- ['amo_redis_prod_report'],
- cluster='amo-redis')
+ graphs = ganglia_graphs(cur_size, cur_range)
return render_template('ganglia.html', graphs=graphs,
sizes=sizes, ranges=ranges, cur_size=cur_size,
Something went wrong with that request. Please try again.