-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POSIX shell, reformat to current spacing style guides. (#41)
- Loading branch information
Showing
1 changed file
with
16 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
#/bin/sh | ||
#!/bin/sh | ||
|
||
# Poll the metrics on an interval specified in seconds | ||
|
||
export sampleDir=$1 | ||
export datafile=$2 | ||
|
||
echo "Timestamp,Pod_Name,CPU_in_nanocores,Memory_in_Kibibytes" > $datafile | ||
echo "Timestamp,Pod_Name,CPU_in_nanocores,Memory_in_Kibibytes" >$datafile | ||
|
||
for filename in $(ls ${sampleDir}) | ||
do | ||
absolutePath=${sampleDir}/$filename | ||
#baseFileName="$(basename "$filename" | sed 's/\(.*\)\..*/\1/')" | ||
#jq -r '.items[] | (.metadata.creationTimestamp + "," + (.metadata.labels.app + "," + .containers[].usage.cpu + "," + .containers[].usage.memory)' ${filename} | sed "s|n,|,|g" | sed "s|Ki||g" > ${formattedoutdir}/${baseFileName}.txt | ||
for filename in $(ls ${sampleDir}); do | ||
absolutePath=${sampleDir}/$filename | ||
#baseFileName="$(basename "$filename" | sed 's/\(.*\)\..*/\1/')" | ||
#jq -r '.items[] | (.metadata.creationTimestamp + "," + (.metadata.labels.app + "," + .containers[].usage.cpu + "," + .containers[].usage.memory)' ${filename} | sed "s|n,|,|g" | sed "s|Ki||g" > ${formattedoutdir}/${baseFileName}.txt | ||
|
||
# Scale of units isn't guaranteed to always be nanocores and kibibytes | ||
# Need to normalize the file. | ||
# Scale micro to nano by "multiplying" by 1000. Note: the \1 is a backreference to the parenthetical capture. | ||
# Scale MiB to KiB by "multiplying" by 1024; this isn't precise, but should be representative for our purposes. | ||
# As far as I can tell, sed doesn't support in-lined arithmetic expressions, though something like awk could. | ||
jq -r '.items[] | (.metadata.creationTimestamp + "," + .metadata.labels.app + "," + .containers[].usage.cpu + "," + .containers[].usage.memory)' ${absolutePath} \ | ||
| sed "s|n,|,|g" \ | ||
| sed "s|Ki||g" \ | ||
| sed 's|\(,[0-9]*\)u,|\1000,|g' \ | ||
| sed 's|\(,[0-9]*\)Mi$|\1024|g' >> ${datafile} | ||
# Scale of units isn't guaranteed to always be nanocores and kibibytes | ||
# Need to normalize the file. | ||
# Scale micro to nano by "multiplying" by 1000. Note: the \1 is a backreference to the parenthetical capture. | ||
# Scale MiB to KiB by "multiplying" by 1024; this isn't precise, but should be representative for our purposes. | ||
# As far as I can tell, sed doesn't support in-lined arithmetic expressions, though something like awk could. | ||
jq -r '.items[] | (.metadata.creationTimestamp + "," + .metadata.labels.app + "," + .containers[].usage.cpu + "," + .containers[].usage.memory)' ${absolutePath} | | ||
sed "s|n,|,|g" | | ||
sed "s|Ki||g" | | ||
sed 's|\(,[0-9]*\)u,|\1000,|g' | | ||
sed 's|\(,[0-9]*\)Mi$|\1024|g' >>${datafile} | ||
done |