Add dstat graph roles

Change-Id: Idc359579b307f5f156dfe5fb5aab5d99bdc46884
This commit is contained in:
James E. Blair 2019-07-11 15:01:44 -07:00 committed by Andreas Jaeger
parent 9d8e765881
commit 5fee4cd753
12 changed files with 140 additions and 0 deletions

View File

@ -10,7 +10,9 @@ General Purpose Roles
.. zuul:autorole:: configure-mirrors
.. zuul:autorole:: copy-build-sshkey
.. zuul:autorole:: download-artifact
.. zuul:autorole:: dstat-graph
.. zuul:autorole:: emit-job-header
.. zuul:autorole:: ensure-dstat-graph
.. zuul:autorole:: git-prepare-nodecache
.. zuul:autorole:: log-inventory
.. zuul:autorole:: mirror-workspace-git-repos
@ -25,6 +27,7 @@ General Purpose Roles
.. zuul:autorole:: remove-gpgkey
.. zuul:autorole:: remove-sshkey
.. zuul:autorole:: revoke-sudo
.. zuul:autorole:: run-dstat
.. zuul:autorole:: sign-artifacts
.. zuul:autorole:: stage-output
.. zuul:autorole:: start-zuul-console

View File

@ -0,0 +1,32 @@
Run dstat_graph
This requires that the :zuul:role:`run-dstat` role be previously used.
Add this to a post-run playbook to run ``dstat_graph`` to graph data
from dstat.
Use the :zuul:role:`ensure-dstat-graph` in a pre-run playbook to make
sure that dstat_graph is available (since it is not currently packaged
in any operating system).
The output will appear in ``dstat.html`` in the ``zuul-output/logs``
directory.
**Role Variables**
.. zuul:rolevar:: dstat_graph_cache_path
:default: /opt/cache/dstat_graph
The role will check this location to see if a cached copy of
dstat_graph is available.
.. zuul:rolevar:: dstat_graph_download_path
:default: /tmp/dstat_graph
If a cached copy is not available, the role will check if
dstat_graph was previously downloaded to this location.
.. zuul:rolevar:: dstat_data_path
:default: "{{ ansible_user_dir }}/zuul-output/logs/dstat.csv"
The path to the dstat data file.

View File

@ -0,0 +1,3 @@
dstat_graph_cache_path: /opt/cache/dstat_graph
dstat_graph_download_path: /tmp/dstat_graph
dstat_data_path: "{{ ansible_user_dir }}/zuul-output/logs/dstat.csv"

View File

@ -0,0 +1,20 @@
- name: Check for cached dstat_graph
stat:
path: "{{ dstat_graph_cache_path }}"
register: dstat_cache
- name: Set dstat_graph path
when: dstat_cache.stat.exists
set_fact:
dstat_path: "{{ dstat_graph_cache_path }}"
- name: Set dstat_graph path
when: not dstat_cache.stat.exists
set_fact:
dstat_path: "{{ dstat_graph_download_path }}"
- name: Run dstat_graph
when: dstat_path is defined
shell: "./generate_page.sh {{ dstat_data_path }} > {{ ansible_user_dir }}/zuul-output/logs/dstat.html"
args:
chdir: "{{ dstat_path }}"

View File

@ -0,0 +1,21 @@
Install dstat_graph
This downloads ``dstat_graph`` if it is not already present on the
remote host.
Add this to a pre-run playbook to ensure it is available for roles
such as :zuul:role:`dstat-graph`.
**Role Variables**
.. zuul:rolevar:: dstat_graph_cache_path
:default: /opt/cache/dstat_graph
The role will check this location to see if a cached copy of
dstat_graph is available.
.. zuul:rolevar:: dstat_graph_download_path
:default: /tmp/dstat_graph
If a cached copy is not available, the role will download
dstat_graph to this location.

View File

@ -0,0 +1,2 @@
dstat_graph_cache_path: /opt/cache/dstat_graph
dstat_graph_download_path: /tmp/dstat_graph

View File

@ -0,0 +1,11 @@
- name: Check for cached dstat_graph
stat:
path: "{{ dstat_graph_cache_path }}"
register: dstat_cache
- name: Clone dstat_graph
when: not dstat_cache.stat.exists
git:
repo: https://github.com/Dabz/dstat_graph
dest: "{{ dstat_graph_download_path }}"
version: c99e5d201ed924a816d99056f8f7d320d625b3ef

View File

@ -0,0 +1,13 @@
Run dstat
Add this to a pre-run playbook to run ``dstat``.
The role :zuul:role:`dstat-graph` may optionally be used to graph the
resulting data.
**Role Variables**
.. zuul:rolevar:: dstat_data_path
:default: "{{ ansible_user_dir }}/zuul-output/logs/dstat.csv"
The path to the dstat data file.

View File

@ -0,0 +1 @@
dstat_data_path: "{{ ansible_user_dir }}/zuul-output/logs/dstat.csv"

View File

@ -0,0 +1,9 @@
- name: Install dstat
package:
name: dstat
state: present
become: true
- name: Run dstat
shell: "dstat -tcmndrylpg --tcp --output {{ dstat_data_path }} >& /dev/null &"
args:
executable: /bin/bash

View File

@ -0,0 +1,14 @@
- hosts: all
roles:
- ensure-dstat-graph
- run-dstat
# Simulate workload
- hosts: all
tasks:
- name: Simulate workload
shell: "sleep 10"
- hosts: all
roles:
- dstat-graph

View File

@ -117,6 +117,16 @@
- name: ubuntu-xenial
label: ubuntu-xenial
- job:
name: zuul-jobs-test-dstat-graph
description: Test the dstat-graph roles
run: test-playbooks/dstat-graph.yaml
files:
- ^roles/ensure-dstat-graph/.*
- ^roles/run-dstat/.*
- ^roles/dstat-graph/.*
- ^test-playbooks/dstat-graph.yaml
- job:
name: zuul-jobs-test-multinode-roles
description: |
@ -326,6 +336,7 @@
- zuul-jobs-test-base-roles-ubuntu-bionic
- zuul-jobs-test-base-roles-ubuntu-trusty
- zuul-jobs-test-base-roles-ubuntu-xenial
- zuul-jobs-test-dstat-graph
- zuul-jobs-test-multinode-roles-centos-7
- zuul-jobs-test-multinode-roles-debian-stretch
- zuul-jobs-test-multinode-roles-fedora-29