Showing with 88 additions and 17 deletions.
  1. +8 −0 CHANGELOG.md
  2. +1 −1 README.md
  3. +12 −1 REFERENCE.md
  4. +37 −7 files/plan_files/import_archives.sh
  5. +1 −1 metadata.json
  6. +29 −7 plans/load_metrics.pp
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [v1.7.0](https://github.com/puppetlabs/puppet_operational_dashboards/tree/v1.7.0) (2022-10-18)

[Full Changelog](https://github.com/puppetlabs/puppet_operational_dashboards/compare/v1.6.0...v1.7.0)

### Added

- Accept a support script tarball for archive metrics ingest [\#96](https://github.com/puppetlabs/puppet_operational_dashboards/pull/96) ([m0dular](https://github.com/m0dular))

## [v1.6.0](https://github.com/puppetlabs/puppet_operational_dashboards/tree/v1.6.0) (2022-10-12)

[Full Changelog](https://github.com/puppetlabs/puppet_operational_dashboards/compare/v1.5.0...v1.6.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ This dashboard is to inspect Puppet server performance and troubleshoot the `pe-
This dashboard is to inspect File-sync related performance. Available Graphs:
- Number of Fetch / Commits vs Lock wait / held
- Average Lock Held Time
- Avergee Lock Wait Time
- Average Lock Wait Time
- Number of Commits
- Number of Fetches
- File-Sync timing - Client Services
Expand Down
13 changes: 12 additions & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ summary and parameters from the plan.
The following parameters are available in the `puppet_operational_dashboards::load_metrics` plan:

* [`targets`](#targets)
* [`support_script_file`](#support_script_file)
* [`metrics_dir`](#metrics_dir)
* [`dest_dir`](#dest_dir)
* [`cleanup_metrics`](#cleanup_metrics)
Expand All @@ -765,12 +766,22 @@ Data type: `TargetSpec`

The targets to run on.

##### <a name="support_script_file"></a>`support_script_file`

Data type: `Optional[String]`

Path to a support script tarball

Default value: ``undef``

##### <a name="metrics_dir"></a>`metrics_dir`

Data type: `String`
Data type: `Optional[String]`

Path to the 'metrics' directory from a PE support script

Default value: ``undef``

##### <a name="dest_dir"></a>`dest_dir`

Data type: `String`
Expand Down
44 changes: 37 additions & 7 deletions files/plan_files/import_archives.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
#!/bin/bash

conf_dir="$1"
metrics_dir="$2"
cleanup="$3"
while getopts ":t:m:s:c" opt; do
case $opt in
t)
telegraf_dir="$OPTARG"
;;
m)
metrics_dir="$OPTARG"
;;
s)
support_script="$OPTARG"
;;
c)
cleanup='true'
;;
*)
echo "WARN: invalid option $opt received"
esac
done

if [[ $support_script ]]; then
_tmp="$(mktemp -d -p "$telegraf_dir")"

tar xf "$support_script" -C "$_tmp" --strip-components=1 || {
echo "Failed to extract $support_script"
exit 1
}

cd "$_tmp" || exit 1
else
cd "$metrics_dir" || exit 1
fi

cd "$metrics_dir" || exit 1
find metrics -type f -name "*gz" -execdir tar xf "{}" \;

out="$(telegraf --once --debug --config "${conf_dir}/telegraf.conf" --config-directory "${conf_dir}/telegraf.conf.d")"
out="$(telegraf --once --debug --config "${telegraf_dir}/telegraf.conf" --config-directory "${telegraf_dir}/telegraf.conf.d")"

if [[ $cleanup == true ]] && [[ -e ${metrics_dir}/metrics ]]; then
rm "${metrics_dir}/metrics" -rf
if [[ $cleanup == true ]]; then
[[ -e ${metrics_dir}/metrics ]] && rm "${metrics_dir}/metrics" -rf
[[ -e $_tmp ]] && rm "$_tmp" -rf
[[ -e $support_script ]] && rm "$support_script"
fi


echo "$out"
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-puppet_operational_dashboards",
"version": "1.6.0",
"version": "1.7.0",
"author": "Adrian Parreiras Horta",
"summary": "A module for managing the installation and configuration of metrics dashboards for Puppet Infrastructure.",
"license": "Apache-2.0",
Expand Down
36 changes: 29 additions & 7 deletions plans/load_metrics.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# summary and parameters from the plan.
# @summary A plan created with bolt plan new.
# @param targets The targets to run on.
# @param support_script_file
# Path to a support script tarball
# @param metrics_dir
# Path to the 'metrics' directory from a PE support script
# @param dest_dir
Expand All @@ -30,7 +32,8 @@
# Directory to upload Telegraf configuration files to
plan puppet_operational_dashboards::load_metrics (
TargetSpec $targets,
String $metrics_dir,
Optional[String] $metrics_dir = undef,
Optional[String] $support_script_file = undef,
String $influxdb_org = 'puppetlabs',
String $influxdb_bucket = 'influxdb_puppet',
Integer $influxdb_port = 8086,
Expand All @@ -49,6 +52,13 @@
fail_plan('This plan only accepts a single target.')
}

unless $metrics_dir or $support_script_file {
fail_plan('Must specify one of $metrics_dir or $support_script_file')
}
if $metrics_dir and $support_script_file {
fail_plan('$metrics_dir and $support_script_file are mutually exclusive')
}

# Handle being passed a String or a Target
$target = get_targets($targets)[0].name
$target.apply_prep
Expand Down Expand Up @@ -113,10 +123,22 @@
}
}

upload_file($metrics_dir, $dest_dir, $target)
return run_script(
'puppet_operational_dashboards/plan_files/import_archives.sh',
$target,
'arguments' => [$conf_dir, $dest_dir, $cleanup_metrics]
)
if $support_script_file {
$sup_script = split($support_script_file, '/')[-1]
upload_file($support_script_file, $dest_dir, $target)

return run_script(
'puppet_operational_dashboards/plan_files/import_archives.sh',
$target,
'arguments' => ['-t', $conf_dir, '-s', "${dest_dir}/${sup_script}", '-c', $cleanup_metrics]
)
}
else {
upload_file($metrics_dir, $dest_dir, $targets)
return run_script(
'puppet_operational_dashboards/plan_files/import_archives.sh',
$targets,
'arguments' => ['-t', $conf_dir, '-m', $dest_dir, '-c', $cleanup_metrics]
)
}
}