From aa33129a41c2c640ce221ddedc5ba0cb759c58fc Mon Sep 17 00:00:00 2001 From: Alex Krzos Date: Fri, 26 Feb 2016 21:31:49 -0500 Subject: [PATCH] Fix Node Ordering when Node count > 10. Use rows to page 20 nodes at a time. + Attempted to make this as robust as possibly + Made the batching of hosts configurable. Change-Id: I228859b4626e02514574b22f9e2b1512aa7ae3ed --- .../filter_plugins/dashboard_filters.py | 20 +++++ ansible/install/group_vars/all | 3 + .../templates/all_cpu_graphs.json.j2 | 41 ++++++---- .../templates/all_disk_graphs.json.j2 | 76 ++++++++++++------- .../templates/all_memory_graphs.json.j2 | 41 ++++++---- .../templates/all_network_graphs.json.j2 | 76 ++++++++++++------- 6 files changed, 171 insertions(+), 86 deletions(-) create mode 100644 ansible/install/filter_plugins/dashboard_filters.py diff --git a/ansible/install/filter_plugins/dashboard_filters.py b/ansible/install/filter_plugins/dashboard_filters.py new file mode 100644 index 000000000..286a09430 --- /dev/null +++ b/ansible/install/filter_plugins/dashboard_filters.py @@ -0,0 +1,20 @@ +def hosts_to_dictionary(arg): + """Changes list format of hosts to dictionary format. The key of the dictionary is the index + of the host. The index is defined by the host's suffix, example: overcloud-controller-10 is 10. + If there is no suffix, I use an increamented value above 1000000.""" + + dictionary = {} + nonindex = 1000000 + for item in arg: + if '-' in item: + idx = item.rindex('-') + dictionary[int(item[idx + 1:])] = item + else: + nonindex += 1 + dictionary[nonindex] = item + return dictionary + + +class FilterModule(object): + def filters(self): + return {'hosts_to_dictionary': hosts_to_dictionary} diff --git a/ansible/install/group_vars/all b/ansible/install/group_vars/all index 00fc45a96..b8ff68035 100644 --- a/ansible/install/group_vars/all +++ b/ansible/install/group_vars/all @@ -30,6 +30,9 @@ grafana_api_key: (Your Grafana API Key) # Grafana Server IP Address (Can be hosted on the Graphite server) grafana_host: 1.1.1.1 +# Dashboards - Batch number of hosts per row for all-{cpu, memory, disk, network} dashboards +dashboards_batch: 20 + # Port for Shaker (5555 should suffice) shaker_port: 5555 diff --git a/ansible/install/roles/dashboard/templates/all_cpu_graphs.json.j2 b/ansible/install/roles/dashboard/templates/all_cpu_graphs.json.j2 index 2283bcbc6..c0edd93d9 100644 --- a/ansible/install/roles/dashboard/templates/all_cpu_graphs.json.j2 +++ b/ansible/install/roles/dashboard/templates/all_cpu_graphs.json.j2 @@ -1,5 +1,5 @@ -{% set panel_idx = {'value': 0} %} -{% set osp_groups = ['undercloud', 'controller', 'ceph', 'compute'] %} +{% set vars = {'panel_idx': 0, 'inital': 0} %} +{% set dashboard_groups = ['undercloud', 'controller', 'ceph', 'compute'] %} { "dashboard": { "id": null, @@ -13,14 +13,20 @@ "hideControls": false, "sharedCrosshair": false, "rows": [ -{% for group in osp_groups %} +{% for group in dashboard_groups %} + {% if group in groups %} + {% for batched_hosts in groups[group]|hosts_to_dictionary|dictsort|batch(dashboards_batch) %} + {% if vars.inital == 0 %} + {% if vars.update({'inital': (vars.inital + 1)}) %} {% endif %} + {% else %} + }, + {% endif %} { "collapse": true, "editable": true, "height": "250px", "panels": [ - {% if group in groups %} - {% for host in groups[group] %} + {% for index, host in batched_hosts %} { "aliasColors": {}, "bars": false, @@ -40,8 +46,8 @@ "threshold2": null, "threshold2Color": "rgba(234, 112, 112, 0.22)" }, - {% if panel_idx.update({'value': (panel_idx.value + 1)}) %} {% endif %} - "id": {{panel_idx.value}}, + {% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %} + "id": {{vars.panel_idx}}, "isNew": true, "legend": { "alignAsTable": true, @@ -114,19 +120,22 @@ "percent", "short" ] - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } + {% else %} + }, {% endif %} + {% endfor %} + ], + {% if 'undercloud' in group %} + "title": "{{group}} CPU Usage", + {% else %} + "title": "{{group}} ({{batched_hosts[0][0]}} - {{batched_hosts[-1][0]}}) CPU Usage", + {% endif %} + "showTitle": true {% endfor %} {% endif %} - ], - "title": "{{group}} CPU Usage", - "showTitle": true - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } {% endif %} {% endfor %} diff --git a/ansible/install/roles/dashboard/templates/all_disk_graphs.json.j2 b/ansible/install/roles/dashboard/templates/all_disk_graphs.json.j2 index c6d23c61f..e848e0cba 100644 --- a/ansible/install/roles/dashboard/templates/all_disk_graphs.json.j2 +++ b/ansible/install/roles/dashboard/templates/all_disk_graphs.json.j2 @@ -1,5 +1,5 @@ -{% set panel_idx = {'value': 0} %} -{% set osp_groups = ['undercloud', 'controller', 'ceph', 'compute'] %} +{% set vars = {'panel_idx': 0, 'inital': 0, 'initial2': 0} %} +{% set dashboard_groups = ['undercloud', 'controller', 'ceph', 'compute'] %} { "dashboard": { "id": null, @@ -13,14 +13,20 @@ "hideControls": false, "sharedCrosshair": false, "rows": [ -{% for group in osp_groups %} +{% for group in dashboard_groups %} + {% if group in groups %} + {% for batched_hosts in groups[group]|hosts_to_dictionary|dictsort|batch(dashboards_batch) %} + {% if vars.inital == 0 %} + {% if vars.update({'inital': (vars.inital + 1)}) %} {% endif %} + {% else %} + }, + {% endif %} { "collapse": true, "editable": true, "height": "250px", "panels": [ - {% if group in groups %} - {% for host in groups[group] %} + {% for index, host in batched_hosts %} { "aliasColors": {}, "bars": false, @@ -40,8 +46,8 @@ "threshold2": null, "threshold2Color": "rgba(234, 112, 112, 0.22)" }, - {% if panel_idx.update({'value': (panel_idx.value + 1)}) %} {% endif %} - "id": {{panel_idx.value}}, + {% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %} + "id": {{vars.panel_idx}}, "isNew": true, "legend": { "alignAsTable": true, @@ -95,26 +101,39 @@ "iops", "short" ] - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } + {% else %} + }, {% endif %} + {% endfor %} + ], + {% if 'undercloud' in group %} + "title": "{{group}} Disk iops", + {% else %} + "title": "{{group}} ({{batched_hosts[0][0]}} - {{batched_hosts[-1][0]}}) Disk iops", + {% endif %} + "showTitle": true {% endfor %} {% endif %} - ], - "title": "{{group}} Disk iops", - "showTitle": true + {% if loop.last %} }, + {% endif %} {% endfor %} -{% for group in osp_groups %} +{% for group in dashboard_groups %} + {% if group in groups %} + {% for batched_hosts in groups[group]|hosts_to_dictionary|dictsort|batch(dashboards_batch) %} + {% if vars.initial2 == 0 %} + {% if vars.update({'initial2': (vars.initial2 + 1)}) %} {% endif %} + {% else %} + }, + {% endif %} { "collapse": true, "editable": true, "height": "250px", "panels": [ - {% if group in groups %} - {% for host in groups[group] %} + {% for index, host in batched_hosts %} { "aliasColors": {}, "bars": false, @@ -134,8 +153,8 @@ "threshold2": null, "threshold2Color": "rgba(234, 112, 112, 0.22)" }, - {% if panel_idx.update({'value': (panel_idx.value + 1)}) %} {% endif %} - "id": {{panel_idx.value}}, + {% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %} + "id": {{vars.panel_idx}}, "isNew": true, "legend": { "alignAsTable": true, @@ -189,19 +208,22 @@ "Bps", "short" ] - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } + {% else %} + }, {% endif %} + {% endfor %} + ], + {% if 'undercloud' in group %} + "title": "{{group}} Disk Throughput", + {% else %} + "title": "{{group}} ({{batched_hosts[0][0]}} - {{batched_hosts[-1][0]}}) Disk Throughput", + {% endif %} + "showTitle": true {% endfor %} {% endif %} - ], - "title": "{{group}} Disk Throughput", - "showTitle": true - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } {% endif %} {% endfor %} diff --git a/ansible/install/roles/dashboard/templates/all_memory_graphs.json.j2 b/ansible/install/roles/dashboard/templates/all_memory_graphs.json.j2 index cb6a8da3f..7d92c9e0e 100644 --- a/ansible/install/roles/dashboard/templates/all_memory_graphs.json.j2 +++ b/ansible/install/roles/dashboard/templates/all_memory_graphs.json.j2 @@ -1,5 +1,5 @@ -{% set panel_idx = {'value': 0} %} -{% set osp_groups = ['undercloud', 'controller', 'ceph', 'compute'] %} +{% set vars = {'panel_idx': 0, 'inital': 0} %} +{% set dashboard_groups = ['undercloud', 'controller', 'ceph', 'compute'] %} { "dashboard": { "id": null, @@ -13,14 +13,20 @@ "hideControls": false, "sharedCrosshair": false, "rows": [ -{% for group in osp_groups %} +{% for group in dashboard_groups %} + {% if group in groups %} + {% for batched_hosts in groups[group]|hosts_to_dictionary|dictsort|batch(dashboards_batch) %} + {% if vars.inital == 0 %} + {% if vars.update({'inital': (vars.inital + 1)}) %} {% endif %} + {% else %} + }, + {% endif %} { "collapse": true, "editable": true, "height": "250px", "panels": [ - {% if group in groups %} - {% for host in groups[group] %} + {% for index, host in batched_hosts %} { "aliasColors": {}, "bars": false, @@ -40,8 +46,8 @@ "threshold2": null, "threshold2Color": "rgba(234, 112, 112, 0.22)" }, - {% if panel_idx.update({'value': (panel_idx.value + 1)}) %} {% endif %} - "id": {{panel_idx.value}}, + {% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %} + "id": {{vars.panel_idx}}, "isNew": true, "legend": { "alignAsTable": true, @@ -106,19 +112,22 @@ "bits", "short" ] - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } + {% else %} + }, {% endif %} + {% endfor %} + ], + {% if 'undercloud' in group %} + "title": "{{group}} Memory Usage", + {% else %} + "title": "{{group}} ({{batched_hosts[0][0]}} - {{batched_hosts[-1][0]}}) Memory Usage", + {% endif %} + "showTitle": true {% endfor %} {% endif %} - ], - "title": "{{group}} Memory Usage", - "showTitle": true - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } {% endif %} {% endfor %} diff --git a/ansible/install/roles/dashboard/templates/all_network_graphs.json.j2 b/ansible/install/roles/dashboard/templates/all_network_graphs.json.j2 index 1f45da2a9..21e131e88 100644 --- a/ansible/install/roles/dashboard/templates/all_network_graphs.json.j2 +++ b/ansible/install/roles/dashboard/templates/all_network_graphs.json.j2 @@ -1,5 +1,5 @@ -{% set panel_idx = {'value': 0} %} -{% set osp_groups = ['undercloud', 'controller', 'ceph', 'compute'] %} +{% set vars = {'panel_idx': 0, 'inital': 0, 'initial2': 0} %} +{% set dashboard_groups = ['undercloud', 'controller', 'ceph', 'compute'] %} { "dashboard": { "id": null, @@ -13,14 +13,20 @@ "hideControls": false, "sharedCrosshair": false, "rows": [ -{% for group in osp_groups %} +{% for group in dashboard_groups %} + {% if group in groups %} + {% for batched_hosts in groups[group]|hosts_to_dictionary|dictsort|batch(dashboards_batch) %} + {% if vars.inital == 0 %} + {% if vars.update({'inital': (vars.inital + 1)}) %} {% endif %} + {% else %} + }, + {% endif %} { "collapse": true, "editable": true, "height": "250px", "panels": [ - {% if group in groups %} - {% for host in groups[group] %} + {% for index, host in batched_hosts %} { "aliasColors": {}, "bars": false, @@ -40,8 +46,8 @@ "threshold2": null, "threshold2Color": "rgba(234, 112, 112, 0.22)" }, - {% if panel_idx.update({'value': (panel_idx.value + 1)}) %} {% endif %} - "id": {{panel_idx.value}}, + {% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %} + "id": {{vars.panel_idx}}, "isNew": true, "legend": { "alignAsTable": true, @@ -95,26 +101,39 @@ "pps", "short" ] - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } + {% else %} + }, {% endif %} + {% endfor %} + ], + {% if 'undercloud' in group %} + "title": "{{group}} Network pps", + {% else %} + "title": "{{group}} ({{batched_hosts[0][0]}} - {{batched_hosts[-1][0]}}) Network pps", + {% endif %} + "showTitle": true {% endfor %} {% endif %} - ], - "title": "{{group}} Network pps", - "showTitle": true + {% if loop.last %} }, + {% endif %} {% endfor %} -{% for group in osp_groups %} +{% for group in dashboard_groups %} + {% if group in groups %} + {% for batched_hosts in groups[group]|hosts_to_dictionary|dictsort|batch(dashboards_batch) %} + {% if vars.initial2 == 0 %} + {% if vars.update({'initial2': (vars.initial2 + 1)}) %} {% endif %} + {% else %} + }, + {% endif %} { "collapse": true, "editable": true, "height": "250px", "panels": [ - {% if group in groups %} - {% for host in groups[group] %} + {% for index, host in batched_hosts %} { "aliasColors": {}, "bars": false, @@ -134,8 +153,8 @@ "threshold2": null, "threshold2Color": "rgba(234, 112, 112, 0.22)" }, - {% if panel_idx.update({'value': (panel_idx.value + 1)}) %} {% endif %} - "id": {{panel_idx.value}}, + {% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %} + "id": {{vars.panel_idx}}, "isNew": true, "legend": { "alignAsTable": true, @@ -189,19 +208,22 @@ "Bps", "short" ] - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } + {% else %} + }, {% endif %} + {% endfor %} + ], + {% if 'undercloud' in group %} + "title": "{{group}} Disk Throughput", + {% else %} + "title": "{{group}} ({{batched_hosts[0][0]}} - {{batched_hosts[-1][0]}}) Network Throughput", + {% endif %} + "showTitle": true {% endfor %} {% endif %} - ], - "title": "{{group}} Network Throughput", - "showTitle": true - {% if not loop.last %} - }, - {% else %} + {% if loop.last %} } {% endif %} {% endfor %}