diff --git a/files/puppet-profile-parser.rb b/files/puppet-profile-parser.rb new file mode 120000 index 0000000..7d1a009 --- /dev/null +++ b/files/puppet-profile-parser.rb @@ -0,0 +1 @@ +../puppet-profile-parser.rb \ No newline at end of file diff --git a/tasks/show_summary.json b/tasks/show_summary.json new file mode 100644 index 0000000..5c5f696 --- /dev/null +++ b/tasks/show_summary.json @@ -0,0 +1,12 @@ +{ + "description": "Analyze puppetserver log with profiling information and produce a summary", + "parameters": { + "logs": { + "type": "Optional[String]", + "description": "One or more log files to analyze, space separated, can contain shell glob patterns and point to .gz files. Defaults to '/var/log/puppetlabs/puppetserver/puppetserver.log'" + } + }, + "files": [ + "puppet_profile_parser/files/puppet-profile-parser.rb" + ] +} \ No newline at end of file diff --git a/tasks/show_summary.sh b/tasks/show_summary.sh new file mode 100644 index 0000000..08a69ac --- /dev/null +++ b/tasks/show_summary.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +LOGS=${PT_logs:-/var/log/puppetlabs/puppetserver/puppetserver.log} +RUBY=$(which ruby||echo "/opt/puppetlabs/puppet/bin/ruby") +# allow expansion to empty string +shopt -s nullglob +log_list=($LOGS) +# prevent globbing to grab the parameter itself +set -o noglob +echo Supplied logs parameter: ${LOGS} +if [ ${#log_list[@]} == 0 ] ; then + echo "Could not find matching log files" + exit 1 +fi +echo "Analyzing logs: " +echo "${log_list[@]}" +# we allow $LOGS to contain globbing characters +# FIXME: potential security issue with allowing any logfile to be specified +# Probably need to restrict to files inside /var/log/puppetlabs/puppetserver +$RUBY ${PT__installdir}/puppet_profile_parser/files/puppet-profile-parser.rb ${log_list[@]}