

<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Slaptijack</title>
	<atom:link href="https://slaptijack.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://slaptijack.com</link>
	<description>After 15+ years of hoarding network and system administration knowledge, I’m making that knowledge available to all admins - beginners and experts alike.</description>
	<lastBuildDate>Sun, 30 Oct 2016 13:48:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.2.3</generator>
	<item>
		<title>Pro Tip: Keep Asterisk Configuration Files in Version Control</title>
		<link>https://slaptijack.com/voice/keep-asterisk-configuration-files-in-version-control.html</link>
				<pubDate>Sun, 30 Oct 2016 05:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[Voice / Voice over IP]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[fabric]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[version_control]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://slaptijack.com/?guid=24a04c7c0c1a38d851d0d3d6b1ef680c</guid>
				<description><![CDATA[An Asterisk server has a very involved configuration system.  One instance I manage has over 100 configuration files.  As these configurations grow, it can be helpful to have a separate server running for testing and debugging problems.  If you are pla...]]></description>
									</item>
		<item>
		<title>TACACS Detected &#039;Invalid Argument&#039;</title>
		<link>https://slaptijack.com/networking/tacacs-detected-invalid-argument.html</link>
				<pubDate>Fri, 29 Jul 2016 13:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[tacacs+]]></category>

		<guid isPermaLink="false">http://slaptijack.com/?guid=f820aa8acc843ea04be4333e35712d62</guid>
				<description><![CDATA[<p><em>As always, I've changed pertinent details for reasons.</em></p>
<p>I was working on an ASR the other day and received the follow error:</p>
<div><pre>RP/0/RSP0/CPU0:ASR9K(config-tacacs-host)# commit
Fri Jul 29 12:55:46.243 PDT

% Failed to commit one or more configuration items during a pseudo-atomic
operation. All changes made have been reverted. Please issue 'show configuration
failed [inheritance]' from this session to view the errors
RP/0/RSP0/CPU0:ASR9K(config-tacacs-host)# show configuration failed
Fri Jul 29 12:55:55.421 PDT
!! SEMANTIC ERRORS: This configuration was rejected by
!! the system due to semantic errors. The individual
!! errors with each failed configuration command can be
!! found below.

tacacs-server host 10.0.0.2 port 49
!!% 'TACACS' detected the 'fatal' condition 'Invalid Argument'
!
end
</pre></div>


<p>The problem here is that the tacacs daemon thinks the configuration contains an
invalid argument. It doesn't. So, restart tacacs:</p>
<div><pre>RP/0/RSP0/CPU0:ASR9K# show proc &#124; inc tacacs
Fri Jul 29 12:56:32.376 PDT
1142   1    2  108K  16 Sigwaitinfo 7399:06:34:0893    0:00:00:0109 tacacsd
1142   2    0  108K  10 Receive     7399:06:35:0099    0:00:00:0000 tacacsd
1142   3    2  108K  10 Nanosleep      0:00:05:0940    0:00:00:0057 tacacsd
1142   4    1  108K  10 Receive     7399:06:34:0957    0:00:00:0000 tacacsd
1142   5    1  108K  10 Receive        0:00:00:0664    0:00:41:0447 tacacsd
1142   6    1  108K  10 Receive     2057:20:44:0638    0:00:44:0805 tacacsd
1142   7    2  108K  10 Receive     1167:26:53:0781    0:01:02:0991 tacacsd
1142   8    3  108K  10 Receive     1167:26:51:0567    0:01:29:0541 tacacsd
1142   9    2  108K  10 Receive      403:35:55:0206    0:01:09:0700 tacacsd
RP/0/RSP0/CPU0:ASR9K# process restart tacacsd
Fri Jul 29 12:56:54.768 PDT
RP/0/RSP0/CPU0:ASR9K# show proc &#124; inc tacacs
Fri Jul 29 12:56:58.455 PDT
1142   1    3   64K  16 Sigwaitinfo    0:00:03:0806    0:00:00:0069 tacacsd
1142   2    1   64K  10 Receive        0:00:03:0998    0:00:00:0000 tacacsd
1142   3    3   64K  10 Nanosleep      0:00:03:0977    0:00:00:0000 tacacsd
1142   4    1   64K  10 Receive        0:00:03:0867    0:00:00:0002 tacacsd
1142   5    3   64K  10 Receive        0:00:03:0818    0:00:00:0000 tacacsd
1142   6    2   64K  16 Receive        0:00:03:0818    0:00:00:0000 tacacsd
1142   7    1   64K  16 Receive        0:00:03:0818    0:00:00:0000 tacacsd
1142   8    3   64K  16 Receive        0:00:03:0818    0:00:00:0000 tacacsd
1142   9    3   64K  10 Receive        0:00:00:0673    0:00:00:0003 tacacsd
</pre></div>


<p>And try again:</p>
<div><pre>RP/0/RSP0/CPU0:ASR9K# config t
Fri Jul 29 12:57:04.787 PDT
RP/0/RSP0/CPU0:ASR9K(config)# tacacs-server host 10.0.0.2 port 49
RP/0/RSP0/CPU0:ASR9K(config-tacacs-host)# commit
Fri Jul 29 12:57:20.627 PDT
RP/0/RSP0/CPU0:ASR9K(config-tacacs-host)#
</pre></div>]]></description>
									</item>
		<item>
		<title>Two Column for Loop in bash</title>
		<link>https://slaptijack.com/programming/two-column-for-loop-in-bash.html</link>
				<pubDate>Mon, 18 Apr 2016 13:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">https://slaptijack.com/?guid=e85841e43c9a2efe77c5f09ad39394a0</guid>
				<description><![CDATA[<p>I had this interesting question the other day. Someone had a file with two columns of data in it. They wanted to assign each column to a different variable and then take action using those two variables. Here's the example I wrote for them:</p>
<div><pre><span>IFS</span><span>=</span><span>$'n'</span><span>;</span>
<span>for</span> LINE in <span>$(</span>cat data_file<span>)</span><span>;</span> <span>do</span>
    <span>VARA</span><span>=</span><span>$(</span><span>echo</span> <span>${</span><span>LINE</span><span>}</span> <span>&#124;</span> awk <span>'{ print $1}'</span><span>)</span>
    <span>VARB</span><span>=</span><span>$(</span><span>echo</span> <span>${</span><span>LINE</span><span>}</span> <span>&#124;</span> awk <span>'{ print $2 }'</span><span>)</span>
    <span>echo</span> <span>"VARA is </span><span>${</span><span>VARA</span><span>}</span><span>"</span>
    <span>echo</span> <span>"VARB is </span><span>${</span><span>VARB</span><span>}</span><span>"</span>
<span>done</span>
</pre></div>


<p>The key here is to set the internal field separator ($IFS) to <code>$'n'</code> so that the <code>for</code> loop interates on lines rather than words. The it's simply a matter of splitting the column into individual variables. In this case, I chose to use <code>awk</code> since it's a simple procedure and speed is not really an issue. Long-term, I would probably re-write this using arrays.</p>]]></description>
									</item>
		<item>
		<title>OpenSSH: Using a Bastion Host</title>
		<link>https://slaptijack.com/system-administration/openssh-using-a-bastion-host.html</link>
				<pubDate>Sat, 26 Mar 2016 13:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[openssh]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">https://slaptijack.com/?guid=375daed1991489e78ff1f5eeaaef020f</guid>
				<description><![CDATA[Quick and dirty OpenSSH configlet here. If you have a set of hosts or devices that require you to first jump through a bastion host, the following will allow you to run a single ssh command:
Host *
    ProxyCommand ssh -A &#60;bastion_host&#62; nc %h %p
...]]></description>
									</item>
		<item>
		<title>Interleave Two Lists of Variable Length (Python)</title>
		<link>https://slaptijack.com/programming/interleave-two-lists-of-variable-length-python.html</link>
				<pubDate>Fri, 18 Mar 2016 13:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[itertools]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">https://slaptijack.com/?guid=c618cb722ff58d04c2eb55e099402566</guid>
				<description><![CDATA[I was recently asked to take two lists and interleave them. Although I can not think of a scenario off the top of my head where this might be useful, it doesn't strike me as a completely silly thing to do. StackOverflow's top answer for this problem us...]]></description>
									</item>
		<item>
		<title>Socket Timeouts in urllib2</title>
		<link>https://slaptijack.com/programming/socket-timeouts-in-urllib2.html</link>
				<pubDate>Sat, 05 Mar 2016 00:30:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sockets]]></category>
		<category><![CDATA[urllib2]]></category>

		<guid isPermaLink="false">https://slaptijack.com/?guid=3ebe7f93a3480af8f25a33b5693b3691</guid>
				<description><![CDATA[<p><a href="http://slaptijack.com/tag/python.html"><img alt="Python logo -right" src="http://lh5.ggpht.com/_LF9bAucktRs/SxQ6Pc17nNI/AAAAAAAACCI/YL67NBS2EoM/s288/python-logo-master-v3-TM.png"></a>One of my scripts that makes an API call has been failing silently lately. It appears that the connection is timing out, but I am not catching that particular error. So, I fixed that.</p>
<div><pre><span>@@</span> <span>-</span><span>8</span><span>,</span><span>6</span> <span>+</span><span>8</span><span>,</span><span>7</span> <span>@@</span>
 <span>import</span> <span>os</span>
 <span>import</span> <span>random</span>
 <span>import</span> <span>shelve</span>
<span>+</span><span>import</span> <span>socket</span>
 <span>import</span> <span>sys</span>
 <span>import</span> <span>time</span>
 <span>import</span> <span>urllib2</span>
<span>@@</span> <span>-</span><span>225</span><span>,</span><span>11</span> <span>+</span><span>226</span><span>,</span><span>15</span> <span>@@</span>

     <span>queries</span><span>[</span><span>'eve-kill'</span><span>]</span> <span>+=</span> <span>1</span>
     <span>try</span><span>:</span>
<span>-</span>        <span>data</span> <span>=</span> <span>urllib2</span><span>.</span><span>urlopen</span><span>(</span><span>request</span><span>)</span>
<span>+</span>        <span>data</span> <span>=</span> <span>urllib2</span><span>.</span><span>urlopen</span><span>(</span><span>request</span><span>,</span> <span>timeout</span><span>=</span><span>60</span><span>)</span>
     <span>except</span> <span>urllib2</span><span>.</span><span>HTTPError</span><span>,</span> <span>e</span><span>:</span>
         <span>print</span><span>(</span><span>'url: {}'</span><span>.</span><span>format</span><span>(</span><span>url</span><span>))</span>
         <span>print</span><span>(</span><span>'error: {}'</span><span>.</span><span>format</span><span>(</span><span>e</span><span>))</span>
         <span>sys</span><span>.</span><span>exit</span><span>(</span><span>1</span><span>)</span>
<span>+</span>    <span>except</span> <span>socket</span><span>.</span><span>timeout</span><span>,</span> <span>e</span><span>:</span>
<span>+</span>        <span>print</span><span>(</span><span>'url: {}'</span><span>.</span><span>format</span><span>(</span><span>url</span><span>))</span>
<span>+</span>        <span>print</span><span>(</span><span>'error: {}'</span><span>.</span><span>format</span><span>(</span><span>e</span><span>))</span>
<span>+</span>        <span>sys</span><span>.</span><span>exit</span><span>(</span><span>1</span><span>)</span>

     <span>j</span> <span>=</span> <span>json</span><span>.</span><span>load</span><span>(</span><span>data</span><span>)</span>
</pre></div>


<p>I set the timeout particular long at 60 seconds. Since I made the change, I do not think it has ever actually taken that long.</p>
<p>Also, I need to refactor this and add my own exception class since it seems I am doing the same thing on most of my exceptions.</p>]]></description>
									</item>
		<item>
		<title>Cache has broken packages, exiting</title>
		<link>https://slaptijack.com/system-administration/cache-has-broken-packages-exiting.html</link>
				<pubDate>Tue, 23 Feb 2016 15:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[aptitude]]></category>
		<category><![CDATA[dpkg]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">https://slaptijack.com/?guid=edaa1b07541dda59940d223c904e0ce8</guid>
				<description><![CDATA[I've been getting the following error from cron.daily in my inbox lately:
/etc/cron.daily/apt:
Cache has broken packages, exiting



That's an annoying email to get everyday. I decided I would apt-get clean and that would probably fix the problem:


Th...]]></description>
									</item>
		<item>
		<title>MySQL OOM&#039;ed, But Pelican Lives</title>
		<link>https://slaptijack.com/system-administration/mysql-oomed-but-pelican-lives.html</link>
				<pubDate>Mon, 15 Feb 2016 15:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[pelican]]></category>

		<guid isPermaLink="false">https://slaptijack.com/?guid=d886b556325ef7f4a2557da15dd45965</guid>
				<description><![CDATA[<p><a href="http://slaptijack.com/tag/pelican.html"><img alt="Pelican logo -left" src="https://lh3.googleusercontent.com/fUaxzjT1yJFhj1y59oir6dlPIIVeBIt4uC4VPldIxPesyJBSu5E=s150-no"></a> I use Pingdom's free service to monitor <a href="http://slaptijack.com/">slaptijack.com</a>. Apparently, late Friday night, <code>oom-killer</code> decided that the server needed more memory and took out the MySQL server. To make matters worse, I missed the alarm from Pingdom, and slaptijack.com was down for pretty much all of Saturday. The fact that <code>oom-killer</code> was invoked is annoying, but more on that later.</p>
<p>The beauty of using Pelican rather than Wordpress (or any other database-driven content engine) is one less point of failure for the site. Obviously, I don't have all of slaptijack.com converted to Pelican yet (and perhaps never will), but at least parts of the site were up and working despite MySQL being down. If nothing else, this incident is enough to convince me that moving to Pelican was a good idea.</p>
<h2>OOM'ed</h2>
<p>Honestly, this is just plain annoying. The slaptijack.com server is has 1.75 GB of RAM and runs about half a dozen web sites -- all of which are much, much smaller than slaptijack.com. The server really doesn't do anything other than run Apache and MySQL. In fairness, I haven't spent a lot of time tuning either application, but there really shouldn't be a need to.</p>
<p>I thought perhaps one of the sites was under attack. MySQL was OOM'ed at 23:44. I had a look to see if there was a big spike in hits. As the data below shows, there really wasn't anything interesting going on during the 23:00 hour.</p>
<div><pre><span>$ </span>grep 12/Feb */logs/*.1 <span>&#124;</span> awk <span>'{ print $4 }'</span> <span></span>
&#62;   <span>&#124;</span> cut -d: -f2 <span>&#124;</span> sort <span>&#124;</span> uniq -c
    <span>953</span> 00
    <span>556</span> 01
    <span>626</span> 02
    <span>981</span> 03
   <span>1364</span> 04
   <span>1928</span> 05
   <span>2799</span> 06
   <span>1391</span> 07
   <span>1586</span> 08
   <span>1300</span> 09
   <span>2074</span> 10
   <span>1173</span> 11
   <span>2220</span> 12
    <span>909</span> 13
    <span>982</span> 14
    <span>769</span> 15
   <span>1546</span> 16
    <span>757</span> 17
    <span>480</span> 18
    <span>592</span> 19
    <span>579</span> 20
    <span>625</span> 21
    <span>581</span> 22
    <span>747</span> 23
</pre></div>


<p>Anyway, in the hopes of avoiding this in the future, I tweaked the Apache and MySQL server settings to reduce their memory footprint. I cut way back on the number of Apache processes running and reduced the number of MySQL connections allowed. According to <a href="http://mysqltuner.com/">mysqltuner</a>, MySQL's max memory usage is now 165.1 MB. Of course, that doesn't take into consideration the footprint of just running MySQL server appears to be a bit over 300 MB:</p>
<div><pre><span>$ </span>ps auwx <span>&#124;</span> grep <span>[</span>m<span>]</span>ysql
mysql     <span>6780</span>  0.1 27.6 <span>1209700</span> <span>480656</span> ?      Ssl  11:04   0:08 /usr/sbin/mysqld
</pre></div>


<p>And each Apache process is 70 MB to 100+ MB at the moment:</p>
<div><pre><span>$ </span>ps auwx <span>&#124;</span> grep <span>[</span>a<span>]</span>pache
root      <span>7717</span>  0.0  1.5 <span>386420</span> <span>26744</span> ?        Ss   11:20   0:00 /usr/sbin/apache2 -k start
www-data  <span>7721</span>  0.0  4.3 <span>391612</span> <span>75532</span> ?        S    11:20   0:04 /usr/sbin/apache2 -k start
www-data  <span>7723</span>  0.0  4.1 <span>390028</span> <span>71968</span> ?        S    11:20   0:04 /usr/sbin/apache2 -k start
www-data  <span>7724</span>  0.0  5.2 <span>406620</span> <span>91332</span> ?        S    11:20   0:05 /usr/sbin/apache2 -k start
www-data  <span>7731</span>  0.0  4.7 <span>389644</span> <span>82796</span> ?        S    11:21   0:04 /usr/sbin/apache2 -k start
www-data  <span>7732</span>  0.1  5.8 <span>406784</span> <span>101736</span> ?       S    11:21   0:06 /usr/sbin/apache2 -k start
www-data  <span>7733</span>  0.0  4.1 <span>390624</span> <span>72436</span> ?        S    11:21   0:04 /usr/sbin/apache2 -k start
www-data  <span>7806</span>  0.0  6.2 <span>414232</span> <span>108988</span> ?       S    11:26   0:04 /usr/sbin/apache2 -k start
www-data  <span>7854</span>  0.0  4.1 <span>390804</span> <span>72556</span> ?        S    11:29   0:05 /usr/sbin/apache2 -k start
www-data  <span>8679</span>  0.0  5.1 <span>408492</span> <span>89404</span> ?        S    12:06   0:01 /usr/sbin/apache2 -k start
www-data  <span>9277</span>  0.1  4.1 <span>391384</span> <span>71948</span> ?        S    12:43   0:01 /usr/sbin/apache2 -k start
</pre></div>]]></description>
									</item>
		<item>
		<title>Removing a Single Line from known_hosts With sed</title>
		<link>http://slaptijack.com/system-administration/remove-single-line-in-known-hosts.html</link>
				<pubDate>Mon, 08 Feb 2016 15:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[openssh]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://slaptijack.com/?guid=81cd920c49756f2adb8deb4fcba96b43</guid>
				<description><![CDATA[<p><a href="http://slaptijack.com/tag/openssh/"><img alt="OpenSSH logo -left" src="http://lh3.googleusercontent.com/4nJt5pkgBR9X-g4IXlQ5wO2AdrwmSJPaCIQ5W7Ky2bZ7hAq9tJ3Jzxmn9dYhaFj1JVZSFa4-cH9RjWEo_lPG7CdHgDLjzy3ZZrqeLQ-513o8xK8bUGouDdn8iVuPjf8k1FqmFnTj0n3vbes0GNpkCmLs8IYcwa5LKz36eC581gqFVfrKLUopWmXBuEJmTC1VzQc2gY1-0ckMngRPOMmIA3Wl6k0TbKZu-fgDhRoAbvIxa41veGtJG2uU8F9wuwHf0Ie7LToVOMWWlKJyIiLF4Mt0xXyMzH7hufCyedRkuKPgoOAjVZ4-z0CGwSn_3mBETD7-5HP07PzeSkFP69pKmgy1ANh-aD1-bGOKUBb9MdLz_qbm3Ds_Bu03u8zsFhCMvGI9SOHkvIywC974Mi1AfS5ZD1qlb6RQSGN99Y7zqFEeYRGFuTqtxIEm22cme5QO_MWuCDQlhj77Vti028_vJiArrKyWz87fnggiQOGMczRR7VBkAcM3H8lciEvjQ_2ggh9VBpW5hIXVplefNVHBK0U37IkHI-WpoD3XVevlGZJoLXJPPeuLuxSu72WsHp3XVhhh=s150-no"></a> Ever so often, something changes on the network, and you find that your <code>.ssh/known_hosts</code> file has gotten out of date. Usually this happens after an upgrade or device change. You'll get the rather ominous warning that <strong>REMOTE HOST IDENTIFICATION HAS CHANGED!</strong></p>
<p>If you are confident that someone isn't doing something nasty and the RSA key fingerprint on the other side has legitimately changed, you can safely remove the offending key and the new key will be added the next time you connect. Fortunately, this is easily done with a sed one-liner:</p>
<div><pre><span>$ </span>sed -i -e <span>'185d'</span> .ssh/known_hosts
</pre></div>


<p>In this case, '185' is the line number that was reported as containing the offending key.</p>]]></description>
									</item>
		<item>
		<title>Changes to OS X TCP Performance Tuning</title>
		<link>https://slaptijack.com/system-administration/changes-to-osx-tcp-performance-tuning.html</link>
				<pubDate>Mon, 01 Feb 2016 15:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Scott Hebert]]></dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[darwin]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">https://slaptijack.com/?guid=04405941ea55bca5c17f961f4a261260</guid>
				<description><![CDATA[While updating the TCP tuning parameters on one of my OS X 10.11 servers, I noticed that my existing OS X TCP Performance Tuning page had gotten out of date. The page was nearly eight years old, so it is no surprise that happened. I updated the page in...]]></description>
									</item>
	</channel>
</rss>
