<?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>Another Geek Blog &#187; codes</title>
	<atom:link href="http://geek.linuxman.pro.br/category/codes/feed" rel="self" type="application/rss+xml" />
	<link>http://geek.linuxman.pro.br</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 16 Dec 2011 01:55:44 +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>Esse IP veio de onde?</title>
		<link>http://geek.linuxman.pro.br/codes/esse-ip-veio-de-onde</link>
		<comments>http://geek.linuxman.pro.br/codes/esse-ip-veio-de-onde#comments</comments>
		<pubDate>Fri, 28 Nov 2008 13:49:24 +0000</pubDate>
		<dc:creator>Eri</dc:creator>
				<category><![CDATA[codes]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://geek.linuxman.pro.br/?p=555</guid>
		<description><![CDATA[Você já deve ter olhado alguma vez nos seus logs, visto algum IP fazendo algo que lhe chamou a atenção, mas o reverso não resolve e você fica curioso de onde diacho vem esse nego. Para facilitar minha busca fiz um script que disponibilizo aqui para quem tiver interesse. Além do script vai precisar também [...]]]></description>
			<content:encoded><![CDATA[<p>Você já deve ter olhado alguma vez nos seus logs, visto algum IP fazendo algo que lhe chamou a atenção, mas o reverso não resolve e você fica curioso de onde diacho vem esse nego.</p>
<p>Para facilitar minha busca fiz um script que disponibilizo aqui para quem tiver interesse.</p>
<p>Além do <a href="http://geek.linuxman.pro.br/arquivos/ip-country.txt">script</a> vai precisar também do arquivo contendo a lista de IP vs País que pode ser baixado <a href="http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip">aqui</a>.</p>

	Tags: <a href="http://geek.linuxman.pro.br/tag/internet" title="internet" rel="tag">internet</a>, <a href="http://geek.linuxman.pro.br/tag/network" title="network" rel="tag">network</a>, <a href="http://geek.linuxman.pro.br/tag/python" title="python" rel="tag">python</a>, <a href="http://geek.linuxman.pro.br/tag/scripts" title="scripts" rel="tag">scripts</a><br />
]]></content:encoded>
			<wfw:commentRss>http://geek.linuxman.pro.br/codes/esse-ip-veio-de-onde/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>checkout</title>
		<link>http://geek.linuxman.pro.br/codes/checkout</link>
		<comments>http://geek.linuxman.pro.br/codes/checkout#comments</comments>
		<pubDate>Tue, 21 Oct 2008 17:35:37 +0000</pubDate>
		<dc:creator>Eri</dc:creator>
				<category><![CDATA[codes]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[servidor]]></category>
		<category><![CDATA[solaris]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://geek.linuxman.pro.br/?p=493</guid>
		<description><![CDATA[À medida que você precisa administrar mais e mais servidores, cada um rodando seus serviços e daemons específicos fica mais complicado saber o que está em casa máquina. Pior ainda quando você precisa que alguém com menos experiência ou conhecimento (aka suporte nível 1) verifique para você o estado do servidor. A idéia é então [...]]]></description>
			<content:encoded><![CDATA[<p>À medida que você precisa administrar mais e mais servidores, cada um rodando seus serviços e daemons específicos fica mais complicado saber o que está em casa máquina.</p>
<p>Pior ainda quando você precisa que alguém com menos experiência ou conhecimento (aka suporte nível 1) verifique para você o estado do servidor.</p>
<p>A idéia é então centralizar essa checagem num único script, simples e funcional, para facilitar a sua vida e a dos outros admins.</p>
<p>Tenho certeza que já existem por ai trocentos scripts/programas/whatever para fazer isso, mas eu estava entediado e precisava usar um pouco de Perl para não enferrujar completamente (É&#8230; ando usando só Python e Bash).</p>
<p>O script <a href="http://geek.linuxman.pro.br/arquivos/checkout">está disponível aqui</a> e está bem documentado e é de simples entendimento.</p>
<p>Basta criar um arquivo /etc/checks.txt contendo o que você esperaria ver rodando normalmente e está feito.</p>

	Tags: <a href="http://geek.linuxman.pro.br/tag/bash" title="bash" rel="tag">bash</a>, <a href="http://geek.linuxman.pro.br/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://geek.linuxman.pro.br/tag/perl" title="perl" rel="tag">perl</a>, <a href="http://geek.linuxman.pro.br/tag/python" title="python" rel="tag">python</a>, <a href="http://geek.linuxman.pro.br/tag/servidor" title="servidor" rel="tag">servidor</a>, <a href="http://geek.linuxman.pro.br/tag/solaris" title="solaris" rel="tag">solaris</a>, <a href="http://geek.linuxman.pro.br/tag/sysadmin" title="sysadmin" rel="tag">sysadmin</a><br />
]]></content:encoded>
			<wfw:commentRss>http://geek.linuxman.pro.br/codes/checkout/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mkfile for Linux</title>
		<link>http://geek.linuxman.pro.br/codes/mkfile-for-linux</link>
		<comments>http://geek.linuxman.pro.br/codes/mkfile-for-linux#comments</comments>
		<pubDate>Fri, 03 Oct 2008 17:20:54 +0000</pubDate>
		<dc:creator>Eri</dc:creator>
				<category><![CDATA[codes]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[solaris]]></category>

		<guid isPermaLink="false">http://geek.linuxman.pro.br/?p=458</guid>
		<description><![CDATA[Eu não conhecia o mkfile do Solaris até ontem, mas foi só usar um pouco e deu pra ver que é muito mais prático e rápido do que ficar utilizando o dd no Linux. Não sei os meus 2 leitores geeks (já que meu pai, minha mãe e minha esposa &#8211; meus outros 3 leitores [...]]]></description>
			<content:encoded><![CDATA[<p>Eu não conhecia o mkfile do Solaris até ontem, mas foi só usar um pouco e deu pra ver que é muito mais prático e rápido do que ficar utilizando o <strong>dd</strong> no Linux.</p>
<p>Não sei os meus 2 leitores geeks (já que meu pai, minha mãe e minha esposa &#8211; meus outros 3 leitores &#8211; não se encaixam nesta categoria), mas eu tenho que olhar o man ou o google toda vez que preciso criar um arquivo em branco com o dd. Tenho algum tipo de bloqueio com aquela sintaxe chata dele.</p>
<p>Então resolvi perder uns minutos e fazer um mkfile for Linux, em bash script mesmo. Divirtam-se.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#=============================================================================</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># mkfile - bash implementation of Solaris' mkfile tool for Linux</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Usage:  mkfile [-v] size [g | k | b | m] filename</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   Eri Ramos Bastos</span>
<span style="color: #666666; font-style: italic;">#   http://geek.linuxman.pro.br</span>
<span style="color: #666666; font-style: italic;">#=============================================================================</span>
&nbsp;
<span style="color: #007800;">progname</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">function</span> die <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$progname</span>: $1&quot;</span>; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #800000;">${2:-1}</span>  ; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #007800;">VERBOSE</span>=<span style="color: #ff0000;">&quot;&amp;gt;/dev/null 2&amp;gt;&amp;amp;1&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> Help <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: mkfile [-v] &amp;lt;size&amp;gt;[g|k|b|m] &amp;lt;name1&amp;gt; [&amp;lt;name2&amp;gt;] ...&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  -v    Verbose&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>    <span style="color: #666666; font-style: italic;"># ----------  end of function Help  ----------</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;">#  Check number of command line arguments and set verbose</span>
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------------------------</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-lt</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
Help; die <span style="color: #ff0000;">&quot;Insufficient number of arguments&quot;</span>
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> = <span style="color: #ff0000;">&quot;-v&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;  <span style="color: #007800;">VERBOSE</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #7a0874; font-weight: bold;">shift</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">SIZE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;$1&quot;</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>kmg<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>KMG<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #7a0874; font-weight: bold;">shift</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${@}</span>
<span style="color: #000000; font-weight: bold;">do</span>
<span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>zero <span style="color: #007800;">of</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #007800;">count</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">bs</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SIZE</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$VERBOSE</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; Help <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; die <span style="color: #ff0000;">&quot;Error creating file <span style="color: #007800;">$file</span>&quot;</span> <span style="color: #000000;">2</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>


	Tags: <a href="http://geek.linuxman.pro.br/tag/bash" title="bash" rel="tag">bash</a>, <a href="http://geek.linuxman.pro.br/tag/coding" title="coding" rel="tag">coding</a>, <a href="http://geek.linuxman.pro.br/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://geek.linuxman.pro.br/tag/scripts" title="scripts" rel="tag">scripts</a>, <a href="http://geek.linuxman.pro.br/tag/shell" title="shell" rel="tag">shell</a>, <a href="http://geek.linuxman.pro.br/tag/solaris" title="solaris" rel="tag">solaris</a><br />
]]></content:encoded>
			<wfw:commentRss>http://geek.linuxman.pro.br/codes/mkfile-for-linux/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

