<?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>Vita di un sys-admin &#187; bash</title>
	<atom:link href="http://blog.angelofailla.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.angelofailla.com</link>
	<description>Storie, esperienze e pensieri da Dublino.</description>
	<lastBuildDate>Sun, 14 Aug 2011 22:11:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Monitoring SSL certificate expiration with Nagios</title>
		<link>http://blog.angelofailla.com/2008/07/17/monitoring-ssl-certificate-expiration-with-nagios/</link>
		<comments>http://blog.angelofailla.com/2008/07/17/monitoring-ssl-certificate-expiration-with-nagios/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 10:49:42 +0000</pubDate>
		<dc:creator>pallotron</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Lavoro]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[expiration]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://blog.angelofailla.com/?p=873</guid>
		<description><![CDATA[Hi Lads, This is a post for nerds so I&#8217;m writing it in English. If you don&#8217;t understand English or technical stuff please close this page I&#8217;m at work and I&#8217;ve just finished to write a Nagios script to monitor expiration date of a SSL certificate. I wanna share it with you. To have the [...]]]></description>
			<content:encoded><![CDATA[<p>Hi Lads,</p>
<p>This is a post for nerds so I&#8217;m writing it in English. If you don&#8217;t understand English or technical stuff please close this page <img src='http://blog.angelofailla.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
I&#8217;m at work and I&#8217;ve just finished to write a Nagios script to monitor expiration date of a SSL certificate.</p>
<p>I wanna share it with you.</p>
<p>To have the script working properly you just need to install OpenSSL and let the <span>openssl</span><br />
command be in your PATH environment.</p>
<p>This is the usage:</p>
<pre>
Usage:
check_ssl_cert.sh hostname port [warningdays]
</pre>
<p>Warning days default value is 30 days.</p>
<p>Some examples:</p>
<pre>[afailla@terminus ~]$  /usr/local/nagios/bin/check_ssl_cert.sh google.com 443
OK: Certificate is valid for 289 days expires on May  2 17:02:55 2009 GMT

[afailla@terminus ~]$  /usr/local/nagios/bin/check_ssl_cert.sh google.com 443 400
CRITICAL: Certificate will expire in 289 days on May  2 17:02:55 2009 GMT</pre>
<p>Download the script <a href="http://blog.angelofailla.com/wp-content/uploads/2008/07/check_ssl_cert.sh">here</a> and enjoy it.</p>
<img src="http://blog.angelofailla.com/?ak_action=api_record_view&id=873&type=feed" alt="" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.angelofailla.com%2F2008%2F07%2F17%2Fmonitoring-ssl-certificate-expiration-with-nagios%2F&amp;title=Monitoring%20SSL%20certificate%20expiration%20with%20Nagios" id="wpa2a_2"><img src="http://blog.angelofailla.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.angelofailla.com/2008/07/17/monitoring-ssl-certificate-expiration-with-nagios/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Highlight text on the fly thanks to terminfo and sed.</title>
		<link>http://blog.angelofailla.com/2011/06/27/highlight-text-on-the-fly-thanks-to-terminfo-and-sed/</link>
		<comments>http://blog.angelofailla.com/2011/06/27/highlight-text-on-the-fly-thanks-to-terminfo-and-sed/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 18:36:02 +0000</pubDate>
		<dc:creator>pallotron</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Lavoro]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[highlight]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[terminfo]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://blog.angelofailla.com/?p=2337</guid>
		<description><![CDATA[A colleague today was looking for a way to pipe something to a command that highlights particular strings of text, keeping intact the stdin, similar to what you can see on some modern distros, ie Gentoo. Grep is not the way as it only prints the lines which contain the pattern that we are looking [...]]]></description>
			<content:encoded><![CDATA[<p>A colleague today was looking for a way to pipe something to a command that highlights particular strings of text, keeping intact the stdin, similar to what you can see on some modern distros, ie Gentoo.</p>
<p>Grep is not the way as it only prints the lines which contain the pattern that we are looking for.</p>
<p>While there are a bunch of tools that can do that, like supercat, etc. I felt no need to install additional packages for something you can do with few lines of bash and knowing terminal capabilities.</p>
<p>Therefore I wrote this small script, put it in the PATH env variable. The script uses sed and makes use of the terminfo database and of the terminal capabilities to color the text, here it is in case you find it useful:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">red</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>tput bold;tput setaf <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">normal</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>tput sgr0<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$line</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/\($1\)/<span style="color: #007800;">$red</span>\1<span style="color: #007800;">$normal</span>/&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p>If you don&#8217;t like red just read `man tput` and read <a href="http://wiki.bash-hackers.org/scripting/terminalcodes">this link</a> about terminal codes.</p>
<p>Example of usage:</p>
<p><a href="http://blog.angelofailla.com/wp-content/uploads/2011/06/highlight.jpg"><img src="http://blog.angelofailla.com/wp-content/uploads/2011/06/highlight.jpg" alt="" title="highlight" width="607" height="284" class="aligncenter size-full wp-image-2343" /></a></p>
<p>It also accept regexps (in sed syntax, not perl syntax), for example:</p>
<p><code><br />
$ sudo tail -f /var/log/system.log | highlight [Ss]potify<br />
</code></p>
<img src="http://blog.angelofailla.com/?ak_action=api_record_view&id=2337&type=feed" alt="" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.angelofailla.com%2F2011%2F06%2F27%2Fhighlight-text-on-the-fly-thanks-to-terminfo-and-sed%2F&amp;title=Highlight%20text%20on%20the%20fly%20thanks%20to%20terminfo%20and%20sed." id="wpa2a_4"><img src="http://blog.angelofailla.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.angelofailla.com/2011/06/27/highlight-text-on-the-fly-thanks-to-terminfo-and-sed/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

