Skip to content

Instantly share code, notes, and snippets.

@makotom
Created February 26, 2020 08:24
Show Gist options
  • Save makotom/fce9add515d36270d1c8026853c15b75 to your computer and use it in GitHub Desktop.
Save makotom/fce9add515d36270d1c8026853c15b75 to your computer and use it in GitHub Desktop.
Dump Nomad stdio
#!/bin/bash
set -eu
set -o pipefail
# Setting-up local variable
outputDir=nomad-logs-$(date +%s)
# Creating output directory
mkdir $outputDir
# Dumping `nomad status`
nomad status > $outputDir/nomad-status.log
# Walk through each job
nomad status | tail -n +2 | awk '{ print $1 }' | while read jobId
do
echo $jobId
# Dumping job status
nomad job status $jobId > $outputDir/$jobId.log
# Walk through each allocation
nomad job status $jobId | grep -P '^[0-9a-f]{8}\s' | awk '{ print $1 }' | while read allocId
do
echo $allocId
nomad logs -stderr $allocId > $outputDir/$jobId-$allocId.log
done
done
tar --remove-files -czf ${outputDir}.tar.gz $outputDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment