Created
February 26, 2020 08:24
-
-
Save makotom/fce9add515d36270d1c8026853c15b75 to your computer and use it in GitHub Desktop.
Dump Nomad stdio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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