]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Initial PCP role for performance monitoring
authorZack Cerza <zack@redhat.com>
Fri, 18 Mar 2016 00:21:50 +0000 (18:21 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 30 Mar 2016 15:54:23 +0000 (09:54 -0600)
http://pcp.io/

Signed-off-by: Zack Cerza <zack@redhat.com>
15 files changed:
cephlab.yml
pcp.yml [new file with mode: 0644]
roles/pcp/README.rst [new file with mode: 0644]
roles/pcp/defaults/main.yml [new file with mode: 0644]
roles/pcp/files/1h1m.json [new file with mode: 0644]
roles/pcp/meta/main.yml [new file with mode: 0644]
roles/pcp/tasks/collector.yml [new file with mode: 0644]
roles/pcp/tasks/main.yml [new file with mode: 0644]
roles/pcp/tasks/manager.yml [new file with mode: 0644]
roles/pcp/tasks/prep.yml [new file with mode: 0644]
roles/pcp/tasks/web.yml [new file with mode: 0644]
roles/pcp/templates/target-discovery [new file with mode: 0644]
roles/pcp/templates/target-host [new file with mode: 0644]
roles/pcp/vars/apt_systems.yml [new file with mode: 0644]
roles/pcp/vars/yum_systems.yml [new file with mode: 0644]

index 5b6f0551a55336adebfa266c196471766536c8ce..be1dd7865ee2ffab152e7e4d13ec0ac910372599 100644 (file)
@@ -18,3 +18,6 @@
 
 # if this node is in the pulpito group, configure it
 - include: pulpito.yml
+
+# if this node is in the pcp group, configure it
+- include: pcp.yml
diff --git a/pcp.yml b/pcp.yml
new file mode 100644 (file)
index 0000000..ef77510
--- /dev/null
+++ b/pcp.yml
@@ -0,0 +1,4 @@
+---
+- hosts: pcp
+  roles:
+    - pcp
diff --git a/roles/pcp/README.rst b/roles/pcp/README.rst
new file mode 100644 (file)
index 0000000..79dea44
--- /dev/null
@@ -0,0 +1,35 @@
+PCP
+===
+This role is used to configure a node to run PCP_.
+
+It has been tested on:
+
+- CentOS 7
+- Ubuntu 14.04 (Trusty)
+
+.. _PCP: https://github.com/performancecopilot/pcp
+
+Variables
++++++++++
+
+Defaults for these variables are defined in ``roles/pcp/defaults/main.yml``.
+
+To tell a given host to collect performance data::
+
+    pcp_collector: true
+
+To tell the host to aggregate data from other systems::
+
+    pcp_manager: true
+
+To tell a ``pcp_manager`` host to use Avahi to auto-discover other hosts running PCP::
+
+    pcp_use_avahi: true
+
+To tell a ``pcp_manager`` host to probe hosts on its local network for the PCP service::
+
+    pcp_probe: true
+
+To tell a ``pcp_manager`` host to run PCP's various web UIs::
+
+    pcp_web: true
diff --git a/roles/pcp/defaults/main.yml b/roles/pcp/defaults/main.yml
new file mode 100644 (file)
index 0000000..e0e05c1
--- /dev/null
@@ -0,0 +1,16 @@
+---
+## PCP Collector options
+# Set the host up to collect data
+pcp_collector: true
+
+## PCP Manager options
+# Set the host up to be able to monitor other systems
+pcp_manager: false
+# Whether or not to use avahi to auto-discover hosts
+pcp_use_avahi: false
+# Whether or not to probe the local network to auto-discover hosts
+pcp_probe: false
+
+## PCP Web UI options
+# Set up the web UI
+pcp_web: false
diff --git a/roles/pcp/files/1h1m.json b/roles/pcp/files/1h1m.json
new file mode 100644 (file)
index 0000000..f3f5385
--- /dev/null
@@ -0,0 +1,367 @@
+{
+  "id": null,
+  "title": "past 1h every 1m",
+  "originalTitle": "past 1h every 1m",
+  "tags": [],
+  "style": "light",
+  "timezone": "utc",
+  "editable": true,
+  "hideControls": false,
+  "sharedCrosshair": false,
+  "rows": [
+    {
+      "title": "load",
+      "height": "200px",
+      "editable": true,
+      "collapse": false,
+      "collapsable": true,
+      "panels": [
+        {
+          "span": 12,
+          "editable": true,
+          "type": "graph",
+          "x-axis": true,
+          "y-axis": true,
+          "scale": 1,
+          "y_formats": [
+            "short",
+            "short"
+          ],
+          "grid": {
+            "max": null,
+            "min": null,
+            "leftMax": null,
+            "rightMax": null,
+            "leftMin": null,
+            "rightMin": null,
+            "threshold1": null,
+            "threshold2": null,
+            "threshold1Color": "rgba(216, 200, 27, 0.27)",
+            "threshold2Color": "rgba(234, 112, 112, 0.22)"
+          },
+          "resolution": 100,
+          "lines": true,
+          "fill": 1,
+          "linewidth": 2,
+          "points": false,
+          "pointradius": 5,
+          "bars": false,
+          "stack": false,
+          "spyable": true,
+          "options": false,
+          "legend": {
+            "show": false,
+            "values": false,
+            "min": false,
+            "max": false,
+            "current": false,
+            "total": false,
+            "avg": false
+          },
+          "interactive": true,
+          "legend_counts": true,
+          "timezone": "utc",
+          "percentage": false,
+          "zerofill": true,
+          "nullPointMode": "connected",
+          "steppedLine": false,
+          "tooltip": {
+            "value_type": "cumulative",
+            "shared": false
+          },
+          "targets": [
+            {
+              "target": "*.kernel.all.load.1 minute"
+            }
+          ],
+          "aliasColors": {},
+          "title": "1-minute load average",
+          "id": 2,
+          "datasource": null,
+          "renderer": "flot",
+          "seriesOverrides": []
+        }
+      ],
+      "notice": false
+    },
+    {
+      "net": "demo2",
+      "height": "200px",
+      "editable": true,
+      "collapse": false,
+      "collapsable": true,
+      "panels": [
+        {
+          "span": 12,
+          "editable": true,
+          "type": "graph",
+          "x-axis": true,
+          "y-axis": true,
+          "scale": 1,
+          "y_formats": [
+            "short",
+            "short"
+          ],
+          "grid": {
+            "max": null,
+            "min": null,
+            "leftMax": null,
+            "rightMax": null,
+            "leftMin": null,
+            "rightMin": null,
+            "threshold1": null,
+            "threshold2": null,
+            "threshold1Color": "rgba(216, 200, 27, 0.27)",
+            "threshold2Color": "rgba(234, 112, 112, 0.22)"
+          },
+          "resolution": 100,
+          "lines": true,
+          "fill": 1,
+          "linewidth": 2,
+          "points": false,
+          "pointradius": 5,
+          "bars": false,
+          "stack": false,
+          "spyable": true,
+          "options": false,
+          "legend": {
+            "show": false,
+            "values": false,
+            "min": false,
+            "max": false,
+            "current": false,
+            "total": false,
+            "avg": false
+          },
+          "interactive": true,
+          "legend_counts": true,
+          "timezone": "utc",
+          "percentage": false,
+          "zerofill": true,
+          "nullPointMode": "connected",
+          "steppedLine": false,
+          "tooltip": {
+            "value_type": "cumulative",
+            "shared": false
+          },
+          "targets": [
+            {
+              "target": "*.network.interface.*.bytes.*"
+            }
+          ],
+          "aliasColors": {},
+          "title": "network i/o bytes/s",
+          "id": 3,
+          "datasource": null,
+          "renderer": "flot",
+          "seriesOverrides": [],
+          "links": []
+        }
+      ],
+      "notice": false
+    },
+    {
+      "disk": "demo3",
+      "height": "200px",
+      "editable": true,
+      "collapse": false,
+      "collapsable": true,
+      "panels": [
+        {
+          "span": 12,
+          "editable": true,
+          "type": "graph",
+          "x-axis": true,
+          "y-axis": true,
+          "scale": 1,
+          "y_formats": [
+            "short",
+            "short"
+          ],
+          "grid": {
+            "max": null,
+            "min": null,
+            "leftMax": null,
+            "rightMax": null,
+            "leftMin": null,
+            "rightMin": null,
+            "threshold1": null,
+            "threshold2": null,
+            "threshold1Color": "rgba(216, 200, 27, 0.27)",
+            "threshold2Color": "rgba(234, 112, 112, 0.22)"
+          },
+          "resolution": 100,
+          "lines": true,
+          "fill": 1,
+          "linewidth": 2,
+          "points": false,
+          "pointradius": 5,
+          "bars": false,
+          "stack": false,
+          "spyable": true,
+          "options": false,
+          "legend": {
+            "show": false,
+            "values": false,
+            "min": false,
+            "max": false,
+            "current": false,
+            "total": false,
+            "avg": false
+          },
+          "interactive": true,
+          "legend_counts": true,
+          "timezone": "utc",
+          "percentage": false,
+          "zerofill": true,
+          "nullPointMode": "connected",
+          "steppedLine": false,
+          "tooltip": {
+            "value_type": "cumulative",
+            "shared": false
+          },
+          "targets": [
+            {
+              "target": "*.disk.all.read_bytes"
+            },
+            {
+              "target": "*.disk.all.write_bytes"
+            }
+          ],
+          "aliasColors": {},
+          "title": "disk read/write kbytes/s",
+          "id": 4,
+          "datasource": null,
+          "renderer": "flot",
+          "seriesOverrides": []
+        }
+      ],
+      "notice": false
+    },
+    {
+      "mem": "demo3",
+      "height": "200px",
+      "editable": true,
+      "collapse": false,
+      "collapsable": true,
+      "panels": [
+        {
+          "span": 12,
+          "editable": true,
+          "type": "graph",
+          "x-axis": true,
+          "y-axis": true,
+          "scale": 1,
+          "y_formats": [
+            "short",
+            "short"
+          ],
+          "grid": {
+            "max": null,
+            "min": null,
+            "leftMax": null,
+            "rightMax": null,
+            "leftMin": null,
+            "rightMin": null,
+            "threshold1": null,
+            "threshold2": null,
+            "threshold1Color": "rgba(216, 200, 27, 0.27)",
+            "threshold2Color": "rgba(234, 112, 112, 0.22)"
+          },
+          "resolution": 100,
+          "lines": true,
+          "fill": 1,
+          "linewidth": 2,
+          "points": false,
+          "pointradius": 5,
+          "bars": false,
+          "stack": false,
+          "spyable": true,
+          "options": false,
+          "legend": {
+            "show": false,
+            "values": false,
+            "min": false,
+            "max": false,
+            "current": false,
+            "total": false,
+            "avg": false
+          },
+          "interactive": true,
+          "legend_counts": true,
+          "timezone": "utc",
+          "percentage": false,
+          "zerofill": true,
+          "nullPointMode": "connected",
+          "steppedLine": false,
+          "tooltip": {
+            "value_type": "cumulative",
+            "shared": false
+          },
+          "targets": [
+            {
+              "target": "*.mem.util.available"
+            },
+            {
+              "target": "*.mem.util.used"
+            }
+          ],
+          "aliasColors": {},
+          "title": "available/used memory kbytes",
+          "id": 5,
+          "datasource": null,
+          "renderer": "flot",
+          "seriesOverrides": []
+        }
+      ],
+      "notice": false
+    }
+  ],
+  "nav": [
+    {
+      "type": "timepicker",
+      "collapse": false,
+      "notice": false,
+      "enable": true,
+      "status": "Stable",
+      "time_options": [
+        "5m",
+        "15m",
+        "1h",
+        "6h",
+        "12h",
+        "24h",
+        "2d",
+        "7d",
+        "30d"
+      ],
+      "refresh_intervals": [
+        "5s",
+        "10s",
+        "30s",
+        "1m",
+        "5m",
+        "15m",
+        "30m",
+        "1h",
+        "2h",
+        "1d"
+      ],
+      "now": true
+    }
+  ],
+  "time": {
+    "from": "now-1h",
+    "to": "now"
+  },
+  "templating": {
+    "list": [],
+    "enable": false
+  },
+  "annotations": {
+    "list": []
+  },
+  "refresh": "1m",
+  "version": 6,
+  "hideAllLegends": false
+}
diff --git a/roles/pcp/meta/main.yml b/roles/pcp/meta/main.yml
new file mode 100644 (file)
index 0000000..a4b782a
--- /dev/null
@@ -0,0 +1,4 @@
+---
+dependencies:
+  - role: sudo
+  - role: users
diff --git a/roles/pcp/tasks/collector.yml b/roles/pcp/tasks/collector.yml
new file mode 100644 (file)
index 0000000..4b47aa5
--- /dev/null
@@ -0,0 +1,34 @@
+---
+- name: Install pcp
+  apt:
+    name: "{{ pcp_package }}"
+    state: latest
+  register: install_pcp_apt
+  when:
+    ansible_pkg_mgr == "apt"
+
+- name: Install pcp
+  yum:
+    name: "{{ pcp_package }}"
+    state: latest
+  register: install_pcp_yum
+  when:
+    ansible_pkg_mgr == "yum"
+
+- name: Restart pcp
+  service:
+    name: "{{ pmcd_service }}"
+    state: restarted
+    enabled: yes
+  when:
+    install_pcp_apt|changed or
+    install_pcp_yum|changed
+
+- name: Restart pmlogger
+  service:
+    name: "{{ pmlogger_service }}"
+    state: restarted
+    enabled: yes
+  when:
+    install_pcp_apt|changed or
+    install_pcp_yum|changed
diff --git a/roles/pcp/tasks/main.yml b/roles/pcp/tasks/main.yml
new file mode 100644 (file)
index 0000000..d7078a1
--- /dev/null
@@ -0,0 +1,31 @@
+---
+- name: Include package type specific vars.
+  include_vars: "{{ ansible_pkg_mgr }}_systems.yml"
+  tags:
+    - always
+
+- name: Miscellaneous preparation
+  include: prep.yml
+  tags:
+    - always
+
+- name: Set up as collector
+  include: collector.yml
+  when:
+    pcp_collector|bool == true
+  tags:
+    - collector
+
+- name: Set up as manager
+  include: manager.yml
+  when:
+    pcp_manager|bool == true
+  tags:
+    - manager
+
+- name: Set up web UI
+  include: web.yml
+  when:
+    pcp_web|bool == true
+  tags:
+    - web
diff --git a/roles/pcp/tasks/manager.yml b/roles/pcp/tasks/manager.yml
new file mode 100644 (file)
index 0000000..4fd666b
--- /dev/null
@@ -0,0 +1,83 @@
+---
+- name: Install avahi
+  apt:
+    name: "{{ avahi_package }}"
+    state: latest
+  when:
+    ansible_pkg_mgr == "apt" and
+    pcp_use_avahi|bool == true
+
+- name: Install avahi
+  yum:
+    name: "{{ avahi_package }}"
+    state: latest
+  when:
+    ansible_pkg_mgr == "yum" and
+    pcp_use_avahi|bool == true
+
+- name: Install pcp-manager
+  apt:
+    name: "{{ pcp_manager_package }}"
+    state: latest
+  when:
+    ansible_pkg_mgr == "apt"
+  register: install_pmmgr_apt
+
+- name: Install pcp-manager
+  yum:
+    name: "{{ pcp_manager_package }}"
+    state: latest
+  when:
+    ansible_pkg_mgr == "yum"
+  register: install_pmmgr_yum
+
+- name: Enable pmmgr
+  service:
+    name: "{{ pmmgr_service }}"
+    enabled: yes
+
+- set_fact:
+    pcp_target_hosts: "[{% for host in groups.pcp %}'{{ host }}',{% endfor %}]"
+
+- name: Write target-host
+  template:
+    src: target-host
+    dest: /etc/pcp/pmmgr/target-host
+    owner: root
+    group: root
+    mode: 0644
+  register: target_host
+
+- set_fact:
+    network_and_netmask: "{{ ansible_default_ipv4.network }}/{{ ansible_default_ipv4.netmask }}"
+
+- set_fact:
+    # ipaddr('net') converts a 'network/netmask' string to 'network/CIDR' format
+    network_and_cidr: "{{ network_and_netmask|ipaddr('net') }}"
+
+- name: Write target-discovery
+  template:
+    src: target-discovery
+    dest: /etc/pcp/pmmgr/target-discovery
+    owner: root
+    group: root
+    mode: 0644
+  register: target_discovery
+
+- name: Ensure /var/log/pcp is owned by pcp
+  file:
+    path: /var/log/pcp
+    owner: "{{ pcp_user }}"
+    group: "{{ pcp_user }}"
+    recurse: yes
+
+- name: Restart pmmgr
+  service:
+    name: "{{ pmmgr_service }}"
+    state: restarted
+    enabled: yes
+  when:
+    install_pmmgr_apt|changed or
+    install_pmmgr_yum|changed or
+    target_host|changed or
+    target_discovery|changed
diff --git a/roles/pcp/tasks/prep.yml b/roles/pcp/tasks/prep.yml
new file mode 100644 (file)
index 0000000..1cf903f
--- /dev/null
@@ -0,0 +1,6 @@
+---
+- name: Update apt cache
+  apt:
+    update_cache: yes
+  when:
+    ansible_pkg_mgr == "apt"
diff --git a/roles/pcp/tasks/web.yml b/roles/pcp/tasks/web.yml
new file mode 100644 (file)
index 0000000..abcfca2
--- /dev/null
@@ -0,0 +1,42 @@
+---
+- name: Fail when on Ubuntu
+  fail:
+    msg: "pcp-web isn't available on Ubuntu yet :("
+  when: ansible_distribution == "Ubuntu"
+
+- name: Install pcp-webapi
+  yum:
+    name: "{{ pcp_webapi_package }}"
+    state: latest
+  register: install_pcp_webapi
+  when: ansible_pkg_mgr == "yum"
+
+- name: Install pcp-webjs
+  yum:
+    name: "{{ pcp_webjs_package }}"
+    state: latest
+  register: install_pcp_webjs
+  when: ansible_pkg_mgr == "yum"
+
+- name: Enable pmwebd
+  service:
+    name: "{{ pmwebd_service }}"
+    enabled: yes
+  register: enable_pmwebd
+
+- name: Ship 1h1m.json dashboard
+  copy:
+    src: "../files/1h1m.json"
+    dest: "/usr/share/pcp/webapps/grafana/app/dashboards/"
+    owner: root
+    group: root
+    mode: 0644
+
+- name: Start pmwebd
+  service:
+    name: "{{ pmmgr_service }}"
+    state: restarted
+  when:
+    install_pcp_webapi|changed or
+    install_pcp_webjs|changed or
+    enable_pmwebd|changed
diff --git a/roles/pcp/templates/target-discovery b/roles/pcp/templates/target-discovery
new file mode 100644 (file)
index 0000000..caac2a5
--- /dev/null
@@ -0,0 +1,7 @@
+# {{ ansible_managed }}
+{% if pcp_use_avahi %}
+avahi,timeout=5
+{% endif %}
+{% if pcp_probe %}
+probe={{ network_and_cidr }},maxThreads=256
+{% endif %}
diff --git a/roles/pcp/templates/target-host b/roles/pcp/templates/target-host
new file mode 100644 (file)
index 0000000..2f191b3
--- /dev/null
@@ -0,0 +1,5 @@
+# {{ ansible_managed }}
+{{ lab_domain }}
+{% for host in pcp_target_hosts %}
+{{ host }}
+{% endfor %}
diff --git a/roles/pcp/vars/apt_systems.yml b/roles/pcp/vars/apt_systems.yml
new file mode 100644 (file)
index 0000000..dc30777
--- /dev/null
@@ -0,0 +1,8 @@
+---
+pcp_user: pcp
+pcp_package: pcp
+pmcd_service: pmcd
+pmlogger_service: pmlogger
+pcp_manager_package: pcp
+pmmgr_service: pmmgr
+avahi_package: avahi-daemon
diff --git a/roles/pcp/vars/yum_systems.yml b/roles/pcp/vars/yum_systems.yml
new file mode 100644 (file)
index 0000000..b47ba6f
--- /dev/null
@@ -0,0 +1,11 @@
+---
+pcp_user: pcp
+pcp_package: pcp
+pmcd_service: pmcd
+pmlogger_service: pmlogger
+pcp_manager_package: pcp-manager
+pmmgr_service: pmmgr
+avahi_package: avahi
+pcp_webapi_package: pcp-webapi
+pcp_webjs_package: pcp-webjs
+pmwebd_service: pmwebd