Skip to content

Instantly share code, notes, and snippets.

@jkordish
Last active December 15, 2015 22:20
Show Gist options
  • Save jkordish/05cd07d22e42ebeec5d3 to your computer and use it in GitHub Desktop.
Save jkordish/05cd07d22e42ebeec5d3 to your computer and use it in GitHub Desktop.
random awk so i don't forget
pre-start script
set -e
MEM=$(awk '/^MemFree/ {free=$2 * 1024 - 1610612736}; END \
{ if ( free > 4294967296 ) print 4294967296; \
else if ( free < 134217728 ) print 134217728; \
else print free }' /proc/meminfo)
CPU=$(awk '/^processor/ { n++ }; END { if ( n > 2) print n-2; else print n+0}' /proc/cpuinfo)
sed -i "s/^chunkMemQueueBytes.*/chunkMemQueueBytes\ =\ $MEM/" /opt/tap-cbs/config.txt
sed -i "s/^nDigesters.*/nDigesters\ =\ $CPU/" /opt/tap-cbs/config.txt
end script
awk '/^MemTotal/ {free=$2 / 1024 / 2 } END {split(free, a, "."); print substr(a[1], 1)}' /proc/meminfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment