snipt

Ctrl+h for KB shortcuts

Bash

free3.sh

1
2
3
grep oomguarpages /proc/user_beancounters  \
 | awk '{s=$2;t=$3;u=$4; {print "VPS Memory Usage\nCurrent Held: " s/204.8 \
   "MB\nMax Held: " t/204.8 "MB\nBarrier: "u/204.8"MB" }}'
https://snipt.net/embed/42f7d3e43ab1a6db9aa2b5fcdb915101/
/raw/42f7d3e43ab1a6db9aa2b5fcdb915101/
42f7d3e43ab1a6db9aa2b5fcdb915101
bash
Bash
3
2019-07-30T22:03:13
True
False
False
/api/public/snipt/4076/
free3sh
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>grep oomguarpages /proc/user_beancounters <span class="se">\</span> </span><span id="L-2"><a name="L-2"></a> <span class="p">|</span> awk <span class="s1">&#39;{s=$2;t=$3;u=$4; {print &quot;VPS Memory Usage\nCurrent Held: &quot; s/204.8 \</span> </span><span id="L-3"><a name="L-3"></a><span class="s1"> &quot;MB\nMax Held: &quot; t/204.8 &quot;MB\nBarrier: &quot;u/204.8&quot;MB&quot; }}&#39;</span> </span></pre></div> </td></tr></table>
free, memory

Bash

Free2.sh

1
2
3
4
5
6
7
#!/bin/bash
beans=`cat /proc/user_beancounters | grep priv`
max=`echo $beans | awk '{ print $4;}'`
use=`echo $beans | awk '{ print $2;}'`
let "per=$use*100/$max"
let "mb=$use/256"
echo "privvmpages usage: $mb MB ($per%)"
https://snipt.net/embed/2437201cb45963486be86825a28e6397/
/raw/2437201cb45963486be86825a28e6397/
2437201cb45963486be86825a28e6397
bash
Bash
7
2019-08-20T22:41:58
True
False
False
/api/public/snipt/4075/
free2sh
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="ch">#!/bin/bash</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">beans</span><span class="o">=</span><span class="sb">`</span>cat /proc/user_beancounters <span class="p">|</span> grep priv<span class="sb">`</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">max</span><span class="o">=</span><span class="sb">`</span><span class="nb">echo</span> <span class="nv">$beans</span> <span class="p">|</span> awk <span class="s1">&#39;{ print $4;}&#39;</span><span class="sb">`</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">use</span><span class="o">=</span><span class="sb">`</span><span class="nb">echo</span> <span class="nv">$beans</span> <span class="p">|</span> awk <span class="s1">&#39;{ print $2;}&#39;</span><span class="sb">`</span> </span><span id="L-5"><a name="L-5"></a><span class="nb">let</span> <span class="s2">&quot;per=</span><span class="nv">$use</span><span class="s2">*100/</span><span class="nv">$max</span><span class="s2">&quot;</span> </span><span id="L-6"><a name="L-6"></a><span class="nb">let</span> <span class="s2">&quot;mb=</span><span class="nv">$use</span><span class="s2">/256&quot;</span> </span><span id="L-7"><a name="L-7"></a><span class="nb">echo</span> <span class="s2">&quot;privvmpages usage: </span><span class="nv">$mb</span><span class="s2"> MB (</span><span class="nv">$per</span><span class="s2">%)&quot;</span> </span></pre></div> </td></tr></table>
free, memory

Bash

memory footprint of own processes

ps -x -o pid,rss,command | awk '{print $0}{sum+=$2} END {print "Total", sum}'
https://snipt.net/embed/71c793a27bb199a4b7fd2b09179324da/
/raw/71c793a27bb199a4b7fd2b09179324da/
71c793a27bb199a4b7fd2b09179324da
bash
Bash
1
2019-08-19T16:35:41
True
False
False
/api/public/snipt/2016/
memory-footprint-of-own-processes
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>ps -x -o pid,rss,command <span class="p">|</span> awk <span class="s1">&#39;{print $0}{sum+=$2} END {print &quot;Total&quot;, sum}&#39;</span> </span></pre></div> </td></tr></table>
memory, shell, stat