# 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
--- /dev/null
+---
+- hosts: pcp
+ roles:
+ - pcp
--- /dev/null
+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
--- /dev/null
+---
+## 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
--- /dev/null
+{
+ "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
+}
--- /dev/null
+---
+dependencies:
+ - role: sudo
+ - role: users
--- /dev/null
+---
+- 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
--- /dev/null
+---
+- 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
--- /dev/null
+---
+- 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
--- /dev/null
+---
+- name: Update apt cache
+ apt:
+ update_cache: yes
+ when:
+ ansible_pkg_mgr == "apt"
--- /dev/null
+---
+- 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
--- /dev/null
+# {{ ansible_managed }}
+{% if pcp_use_avahi %}
+avahi,timeout=5
+{% endif %}
+{% if pcp_probe %}
+probe={{ network_and_cidr }},maxThreads=256
+{% endif %}
--- /dev/null
+# {{ ansible_managed }}
+{{ lab_domain }}
+{% for host in pcp_target_hosts %}
+{{ host }}
+{% endfor %}
--- /dev/null
+---
+pcp_user: pcp
+pcp_package: pcp
+pmcd_service: pmcd
+pmlogger_service: pmlogger
+pcp_manager_package: pcp
+pmmgr_service: pmmgr
+avahi_package: avahi-daemon
--- /dev/null
+---
+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