Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

splitting ganglia out #4

Merged
merged 2 commits into from

3 participants

@cshields

ganglia is split out in /data/ and acts a bit more like nagios.py, also worked it up so ganglia is configurable and not amo-specific.

added the following config options:

GANGLIA_DEFAULT_REPORTS replaced default_reports before
GANGLIA_GROUPS defines the groups to be displayed, a bit like nagios behaves. For example, see default_settings.py (I'll add details to the readme in the next commit)

(also added spaces for my last pull request per tip from cvan)

@cvan

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. :)

@oremj oremj merged commit 9604f29 into mozilla:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2012
  1. @cshields

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

    cshields authored
    …iables so they can be changed through settings_local
  2. @cshields
This page is out of date. Refresh to see the latest.
View
17 zamboni_dashboard/data/ganglia.py
@@ -0,0 +1,17 @@
+from .. import app
+from urllib import urlencode
+
+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))
View
5 zamboni_dashboard/default_settings.py
@@ -1,5 +1,10 @@
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'
GANGLIA_BASE = 'https://ganglia.mozilla.org/phx1'
+ GANGLIA_DEFAULT_REPORTS = ['load_report', 'cpu_report',
+ 'mem_report', 'network_report']
GRAPHITE_BASE = 'https://graphite-phx.mozilla.org'
NAGIOS_STATUS_FILE = ''
NAGIOS_STATUS_URL = ''
View
8 zamboni_dashboard/templates/base.html
@@ -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,7 +18,7 @@
<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>
<li><a href="{{ url_for('ganglia') }}">Ganglia</a></li>
@@ -28,8 +28,8 @@
<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>
View
28 zamboni_dashboard/views.py
@@ -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,40 +29,25 @@ 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)
+ # putting ganglia_graphs in a lib causes a problem here when trying to reuse the name,
+ # so we call it ganglia_graphs_sized locally
+ ganglia_graphs_sized = 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 +
+ graphs['Web'] = ganglia_graphs_sized(app.config['GANGLIA_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'],
+ graphs['Memcache'] = ganglia_graphs_sized(app.config['GANGLIA_DEFAULT_REPORTS'] + ['memcached_report'],
cluster='Memcache AMO Cluster')
- graphs['Redis'] = ganglia_graphs(default_reports +
+ graphs['Redis'] = ganglia_graphs_sized(app.config['GANGLIA_DEFAULT_REPORTS'] +
['amo_redis_prod_report'],
cluster='amo-redis')
Something went wrong with that request. Please try again.