Showing with 70 additions and 5 deletions.
  1. +6 −0 CHANGELOG.md
  2. +16 −2 README.md
  3. +24 −2 manifests/init.pp
  4. +1 −1 metadata.json
  5. +23 −0 templates/puppet-metrics-collector.epp
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Minor Release 4.5.0

## Improvements:
- Add a script to zip up metrics for sharing
- [PR #41](https://github.com/npwalker/pe_metric_curl_cron_jobs/pull/41)

# Z Release 4.4.2

## Bug Fixes:
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Table of Contents
* [Grepping for Metrics](#grepping-for-metrics)
* [Puppetserver](#puppetserver)
* [PuppetDB](#puppetdb)
* [Sharing Metrics data](#sharing-metrics-data)
* [How to use](#how-to-use)
* [Monolithic Install](#monolithic-install)
* [Hiera data Example](#hiera-data-example)
Expand Down Expand Up @@ -104,7 +105,7 @@ puppetdb/127.0.0.1/20170404T171502Z.json: "queue_depth": 0,

PE 2016.5 and below:

~~~
```
grep Cursor puppetdb/127.0.0.1/*.json
puppetdb/127.0.0.1/20170404T171001Z.json: "CursorMemoryUsage": 0,
puppetdb/127.0.0.1/20170404T171001Z.json: "CursorFull": false,
Expand All @@ -115,7 +116,20 @@ puppetdb/127.0.0.1/20170404T171502Z.json: "CursorPercentUsage": 0,
puppetdb/127.0.0.1/20170404T172002Z.json: "CursorMemoryUsage": 0,
puppetdb/127.0.0.1/20170404T172002Z.json: "CursorFull": false,
puppetdb/127.0.0.1/20170404T172002Z.json: "CursorPercentUsage": 0,
~~~
```

## Sharing Metrics data

When working on performance tuning you may be asked to create a metrics data tarball to transport and share your metrics data.

The module provides a utility script, `puppet-metrics-collector` to aid in preparing metrics data for transport.

```
[root@master ~]# /opt/puppetlabs/bin/puppet-metrics-collector create-tarball
Metrics data tarball created at: /root/puppet-metrics-20170801T180338Z.tar.gz
```

The script creates a tarball containing your metrics in the current working directory.dd

# How to use

Expand Down
26 changes: 24 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,41 @@
String $activemq_metrics_ensure = 'absent',
Array[String] $activemq_hosts = [ '127.0.0.1' ],
Integer $activemq_port = 8161,
Boolean $symlink_puppet_metrics_collector = true,
) {
$scripts_dir = "${output_dir}/scripts"
$bin_dir = "${output_dir}/bin"

file { [ $output_dir, $scripts_dir ] :
file { [ $output_dir, $scripts_dir, $bin_dir] :
ensure => directory,
}

file { "${scripts_dir}/tk_metrics" :
ensure => present,
mode => '0744',
mode => '0755',
source => 'puppet:///modules/pe_metric_curl_cron_jobs/tk_metrics'
}

file { "${bin_dir}/puppet-metrics-collector":
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
content => epp('pe_metric_curl_cron_jobs/puppet-metrics-collector.epp', {
'output_dir' => $output_dir,
}),
}

$symlink_ensure = $symlink_puppet_metrics_collector ? {
false => 'absent',
true => 'symlink',
}

file { "/opt/puppetlabs/bin/puppet-metrics-collector":
ensure => $symlink_ensure,
target => "${bin_dir}/puppet-metrics-collector",
}

include pe_metric_curl_cron_jobs::puppetserver

include pe_metric_curl_cron_jobs::puppetdb
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npwalker/pe_metric_curl_cron_jobs",
"version": "4.4.2",
"version": "4.5.0",
"author": "npwalker",
"summary": "A Puppet module for gathering metrics from PE components",
"license": "Apache-2.0",
Expand Down
23 changes: 23 additions & 0 deletions templates/puppet-metrics-collector.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<%- | String $output_dir,
| -%>
#!/bin/bash


[ "$1" = "create-tarball" ] || { echo >&2 "ERROR: Usage: $0 create-tarball"; exit 1; }

timestamp=$(date -u +"%Y%m%dT%H%M%SZ")
tarball="puppet-metrics-${timestamp}.tar.gz"

output_dir="<%= $output_dir %>"
cwd=$(dirname "${output_dir}")
target=$(basename "${output_dir}")

tar \
--exclude scripts \
--exclude bin \
--transform "s/${target}/puppet-metrics-${timestamp}/" \
-czf "${tarball}" \
-C "${cwd}" \
"${target}"

echo "Metrics data tarball created at: $(pwd)/${tarball}"