Skip to content

Commit

Permalink
Add shebang line for POSIX shell. (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
Montana committed Sep 11, 2023
1 parent 5a7f266 commit 25bb995
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions pollRawResourceMetrics.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/sh
#!/bin/sh

# Poll the metrics on an interval specified in seconds

Expand All @@ -8,20 +8,19 @@ export signalfile=$3

mkdir -p $outdir

while :
do
# Use ISO-8601 formatting for UTC timestamp
timestamp=$(date -u '+%Y%m%dT%H%M%SZ')
while :; do
# Use ISO-8601 formatting for UTC timestamp
timestamp=$(date -u '+%Y%m%dT%H%M%SZ')

# A timestamp is included in each sample, which likely won't directly align with the timestamp capture above.
# The timestamp is used to keep the sample's filenames unique.
kubectl get --raw /apis/metrics.k8s.io/v1beta1/pods -n chaordicledger | jq '. | del ( ."items"[] | select(.metadata.namespace != "chaordicledger"))' > ${outdir}/${timestamp}_sample.json

echo "[${timestamp}] Waiting ${wait} to gather next sample"
sleep ${wait}
# A timestamp is included in each sample, which likely won't directly align with the timestamp capture above.
# The timestamp is used to keep the sample's filenames unique.
kubectl get --raw /apis/metrics.k8s.io/v1beta1/pods -n chaordicledger | jq '. | del ( ."items"[] | select(.metadata.namespace != "chaordicledger"))' >${outdir}/${timestamp}_sample.json

if [[ -f "$signalfile" ]]; then
echo "Signal file $signalfile exists; stopping monitor"
break
fi
echo "[${timestamp}] Waiting ${wait} to gather next sample"
sleep ${wait}

if [[ -f "$signalfile" ]]; then
echo "Signal file $signalfile exists; stopping monitor"
break
fi
done

0 comments on commit 25bb995

Please sign in to comment.