Showing with 22 additions and 7 deletions.
  1. +1 −1 .vscode/extensions.json
  2. +8 −0 CHANGELOG.md
  3. +11 −4 files/metrics_tidy
  4. +1 −1 files/system_metrics
  5. +1 −1 metadata.json
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"jpogran.puppet-vscode",
"puppet.puppet-vscode",
"rebornix.Ruby"
]
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Minor Release 6.1.0

## Improvements
- Fixes a bug where the tarballs files would contain 90 days worth of files instead of 1
- Ensure the system metrics can be tidied up
- Stop pretty-printing the system metrics.
- [PR #61](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/pull/61)

# Major Release 6.0.0

This is a major release as it drops support for Puppet 4.x and versions of PE
Expand Down
15 changes: 11 additions & 4 deletions files/metrics_tidy
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ done


# Guard against deleting or archiving files outside of a Puppet service metrics directory.
valid_paths=(puppetserver puppetdb orchestrator ace bolt activemq)
valid_paths=(puppetserver puppetdb orchestrator ace bolt activemq system_processes system_memory system_cpu)

# Arguments and defaults.
metrics_directory="${metrics_directory:-/opt/puppetlabs/puppet-metrics-collector/puppetserver}"
Expand All @@ -52,6 +52,13 @@ paths_regex="$(IFS='|'; echo "${valid_paths[*]}")"
find "$metrics_directory" -type f -ctime +"$retention_days" -delete

# Compress the remaining files in a Puppet service metrics directory.
# The return code of a pipeline is the rightmost command, which means we trigger our trap if tar fails
find "$metrics_directory" -type f -name "*json" | \
tar --create --gzip --file "${metrics_directory}/${metrics_type}-$(date +%Y.%m.%d.%H.%M.%S).tar.gz" --files-from -
# Store the list of files in a temp file so that `tar` and `rm` will operate on the same files
metrics_tmp="$(mktemp)"
find "$metrics_directory" -type f -name "*json" >"$metrics_tmp"
tar --create --gzip --file "${metrics_directory}/${metrics_type}-$(date +%Y.%m.%d.%H.%M.%S).tar.gz" \
--files-from "$metrics_tmp"

# Cleanup the backed up json files so that we do not duplicate files in the tarballs.
# We can assume that the json files have no spaces as they are created by our scripts
xargs -a "$metrics_tmp" rm
rm "$metrics_tmp"
2 changes: 1 addition & 1 deletion files/system_metrics
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ module SystemMetrics
hostkey = @hostname.gsub('.', '-')
metrics_json = {'timestamp' => @time_stamp_obj.utc.iso8601, 'servers' => {}}
metrics_json['servers'][hostkey] = {@metric_type => metrics_data}
JSON.pretty_generate(metrics_json)
JSON.generate(metrics_json)
end

# Create the metric file and put the json data in it
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": "puppetlabs-puppet_metrics_collector",
"version": "6.0.0",
"version": "6.1.0",
"author": "npwalker",
"summary": "A Puppet module for gathering metrics from PE components",
"license": "Apache-2.0",
Expand Down