Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Bash

top twenty processes by memory

ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | head -21
https://snipt.net/embed/5a3749c4745db29b0bf5170ba77f7b9c/
https://snipt.net/raw/5a3749c4745db29b0bf5170ba77f7b9c/
5a3749c4745db29b0bf5170ba77f7b9c
bash
Bash
1
2016-12-02T16:36:09
True
False
False
/api/public/snipt/8988/
top-twenty-processes-by-memory
<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 -eo pmem,pcpu,rss,vsize,args <span class="p">|</span> sort -k <span class="m">1</span> -r <span class="p">|</span> head -21 </span></pre></div> </td></tr></table>
bash, memory, monitoring, process, server

Bash

parse mysql slow query log with maatkit script and save to database table.

mk-query-digest --review D=<database name>,t=<table name>,u=<username>,p='secret' /var/log/mysql/mysql-slow.log
https://snipt.net/embed/ec106fd3e54173b8cf23f32cc94123fa/
https://snipt.net/raw/ec106fd3e54173b8cf23f32cc94123fa/
ec106fd3e54173b8cf23f32cc94123fa
bash
Bash
1
2016-12-06T13:42:40
True
False
False
/api/public/snipt/7391/
parse-mysql-slow-query-log-with-maatkit-script-and-save-to-query_review-table
<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>mk-query-digest --review <span class="nv">D</span><span class="o">=</span>&lt;database name&gt;,t<span class="o">=</span>&lt;table name&gt;,u<span class="o">=</span>&lt;username&gt;,p<span class="o">=</span><span class="s1">&#39;secret&#39;</span> /var/log/mysql/mysql-slow.log </span></pre></div> </td></tr></table>
database, monitoring, optimization

Bash

diskspace one-liner

1
2
3
4
5
#!/bin/bash
df -h | grep disk0s2 | awk '{print "System:", $3, "of", $2, "-", $4, "available"}' | sed 's/Gi/Gb/g';
df -h | grep disk0s3 | awk '{print "UserHD:", $3, "of", $2, "-", $4, "available"}' | sed 's/Gi/Gb/g';

# change disk0s2 and the corresponding name ("System:") as necessary
https://snipt.net/embed/0f14bdd9ccd41db7694b6c4a4413d892/
https://snipt.net/raw/0f14bdd9ccd41db7694b6c4a4413d892/
0f14bdd9ccd41db7694b6c4a4413d892
bash
Bash
5
2016-12-05T17:04:50
True
False
False
/api/public/snipt/3004/
diskspace-one-liner
<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></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>df -h <span class="p">|</span> grep disk0s2 <span class="p">|</span> awk <span class="s1">&#39;{print &quot;System:&quot;, $3, &quot;of&quot;, $2, &quot;-&quot;, $4, &quot;available&quot;}&#39;</span> <span class="p">|</span> sed <span class="s1">&#39;s/Gi/Gb/g&#39;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a>df -h <span class="p">|</span> grep disk0s3 <span class="p">|</span> awk <span class="s1">&#39;{print &quot;UserHD:&quot;, $3, &quot;of&quot;, $2, &quot;-&quot;, $4, &quot;available&quot;}&#39;</span> <span class="p">|</span> sed <span class="s1">&#39;s/Gi/Gb/g&#39;</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c1"># change disk0s2 and the corresponding name (&quot;System:&quot;) as necessary</span> </span></pre></div> </td></tr></table>
bash, geektool, monitoring, scripts

Bash

External IP address

echo "External :" `curl --silent http://checkip.dyndns.org | awk '{print $6}' | cut -f 1 -d "<"`
https://snipt.net/embed/e5902772d0a7b90d980f77dfad56c486/
https://snipt.net/raw/e5902772d0a7b90d980f77dfad56c486/
e5902772d0a7b90d980f77dfad56c486
bash
Bash
1
2016-12-02T12:27:37
True
False
False
/api/public/snipt/3002/
external-ip-address
<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><span class="nb">echo</span> <span class="s2">&quot;External :&quot;</span> <span class="sb">`</span>curl --silent http://checkip.dyndns.org <span class="p">|</span> awk <span class="s1">&#39;{print $6}&#39;</span> <span class="p">|</span> cut -f <span class="m">1</span> -d <span class="s2">&quot;&lt;&quot;</span><span class="sb">`</span> </span></pre></div> </td></tr></table>
"ip address", bash, monitoring, network, scripts

Bash

geektool abbreviated "top" implementation

ps -arcwwwxo "pid %cpu command" | egrep "PID|$1" | grep -v grep | head -12 | tail -11
https://snipt.net/embed/8dc2f7159bd292ce4044558d9c631e8a/
https://snipt.net/raw/8dc2f7159bd292ce4044558d9c631e8a/
8dc2f7159bd292ce4044558d9c631e8a
bash
Bash
2
2016-12-02T17:32:24
True
False
False
/api/public/snipt/2244/
geektool-abbreviated-top-implementation
<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 -arcwwwxo <span class="s2">&quot;pid %cpu command&quot;</span> <span class="p">|</span> egrep <span class="s2">&quot;PID|</span><span class="nv">$1</span><span class="s2">&quot;</span> <span class="p">|</span> grep -v grep <span class="p">|</span> head -12 <span class="p">|</span> tail -11 </span></pre></div> </td></tr></table>
bash, geektool, monitoring, top
Copyrighted, illegal, or inappropriate content? Email [email protected].