Skip to content

Commit

Permalink
scripts: Improve formatting in cc-collect-data.sh
Browse files Browse the repository at this point in the history
Add sub-section headings and separators to improve the readability
of the output of "cc-collect-data.sh".

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Sep 25, 2017
1 parent 53bd495 commit 16b1dae
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions data/cc-collect-data.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ heading()
echo -e "\n# $name\n"
}

subheading()
{
local name="$*"
echo -e "\n## $name\n"
}

separator()
{
echo -e '\n---\n'
}

have_cmd()
{
local cmd="$1"
Expand Down Expand Up @@ -87,7 +98,8 @@ show_runtime_configs()
die "failed to check config files - runtime is probably too old ($version)"
fi

msg "Runtime default config files"
subheading "Runtime default config files"

show_quoted_text "$configs"

# add in the standard defaults for good measure "just in case"
Expand All @@ -97,7 +109,7 @@ show_runtime_configs()
# create a unique list of config files
configs=$(echo $configs|tr ' ' '\n'|sort -u)

msg "Runtime config file contents"
subheading "Runtime config file contents"

for config in $configs; do
if [ -e "$config" ]; then
Expand All @@ -106,6 +118,8 @@ show_runtime_configs()
msg "Config file \`$config\` not found"
fi
done

separator
}

show_runtime_log_details()
Expand Down Expand Up @@ -146,11 +160,12 @@ show_runtime_log_details()
else
msg "Global log not enabled."
fi

separator
}

show_package_versions()
{

heading "Packages"

local pattern="("
Expand Down Expand Up @@ -182,19 +197,25 @@ show_package_versions()
if have_cmd "rpm"; then
run_cmd_and_show_quoted_output "rpm -qa|egrep \"$pattern\""
fi

separator
}

show_container_mgr_details()
{
heading "Container manager details"

if have_cmd "docker"; then
subheading "Docker"
run_cmd_and_show_quoted_output "docker info"
fi

if have_cmd "kubectl"; then
subheading "Kubernetes"
run_cmd_and_show_quoted_output "kubectl config view"
fi

separator
}

show_meta()
Expand All @@ -203,6 +224,8 @@ show_meta()

date=$(date '+%Y-%m-%d.%H:%M:%S.%N')
msg "Running \`$script_name\` version \`$script_version\` at \`$date\`."

separator
}

show_runtime()
Expand All @@ -212,6 +235,8 @@ show_runtime()
cmd="cc-env"
heading "\`$cmd\`"
run_cmd_and_show_quoted_output "$runtime $cmd"

separator
}

main()
Expand Down

0 comments on commit 16b1dae

Please sign in to comment.