<?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>Linux * Screw &#187; perl</title>
	<atom:link href="http://www.linuxscrew.com/category/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.linuxscrew.com</link>
	<description></description>
	<lastBuildDate>Fri, 04 Nov 2011 14:19:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=8892</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to monitor traffic at Cisco router using Linux (Netflow)</title>
		<link>http://www.linuxscrew.com/2010/11/25/how-to-monitor-traffic-at-cisco-router-using-linux-netflow/</link>
		<comments>http://www.linuxscrew.com/2010/11/25/how-to-monitor-traffic-at-cisco-router-using-linux-netflow/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 21:16:38 +0000</pubDate>
		<dc:creator>artiomix</dc:creator>
				<category><![CDATA[applications]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[distros]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[howtos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.linuxscrew.com/?p=1109</guid>
		<description><![CDATA[By default Cisco IOS doesn&#8217;t provide any traffic monitoring tools like iftop or iptraff available in Linux. While there are lots of proprietary solutions for this purpose including Cisco Netflow Collection, you are free to choose nfdump and nfsen open source software to monitor traffic of one or many Cisco routers and get detailed monitoring [...]]]></description>
			<content:encoded><![CDATA[<p>By default <strong>Cisco IOS</strong> doesn&#8217;t provide any <strong>traffic monitoring</strong> tools like <a href="http://www.ex-parrot.com/pdw/iftop/">iftop</a> or <a href="http://iptraf.seul.org/shots/iptraf-iptm1.gif">iptraff</a> available in <strong>Linux</strong>. While there are lots of proprietary solutions for this purpose including <a href="http://www.cisco.com/en/US/products/sw/netmgtsw/ps1964/index.html">Cisco Netflow Collection</a>, you are free to choose <a href="http://nfdump.sourceforge.net/"><strong>nfdump</strong></a> and <strong><a href="http://nfdump.sourceforge.net/">nfsen</a></strong> open source software to monitor traffic of one or many Cisco routers and get detailed monitoring data through your Linux command line or as graphs at absolutely no cost.</p>
<p>Below is beginner&#8217;s guide that helps to quickly deploy netflow collector and visualizer under Linux and impress everybody by cute and descriptive graphs like these:</p>
<p><center><img src="http://www.linuxscrew.com/wp-content/uploads/2010/11/nfsen1.png" alt="nfsen screen" title="nfsen screen" width="500" height="307" class="aligncenter size-full wp-image-1115" /></center></p>
<p>It is highly recommended to look through Netflow basics to get brief understanding of how it works before configuring anything. For example, <a href="http://www.cisco.com/en/US/prod/collateral/iosswrel/ps6537/ps6555/ps6601/prod_white_paper0900aecd80406232.html">here is Cisco&#8217;s document</a> that gives complete information about <a href="http://en.wikipedia.org/wiki/Netflow">Netflow</a>. In a few words to get started you should enable netflow exporting on Cisco router and point it to netflow collector running under Linux. Exported data will contain complete information about all packets the router has received/sent so nfdump and nfsen working under Linux will collect it and visualize to present you the graph like above example.</p>
<p><strong>Cisco Router Setup</strong></p>
<p>1. Enable flow export on ALL Cisco router&#8217;s interfaces that send and receive some traffic, here is an example:</p>
<pre>Router1# configure terminal
Router1(config)#interface FastEthernet 0/0
Router1(config-if)#ip route-cache flow input
Router1(config-if)#interface FastEthernet 0/1
Router1(config-if)#ip route-cache flow input
...</pre>
<p>2. Setup netflow export:</p>
<pre>Router1# configure terminal
Router1(config)#ip flow-export source FastEthernet0/0
Router1(config)#ip flow-export source FastEthernet0/1
Router1(config)#ip flow-export version 5
Router1(config)#ip flow-export destination 1.1.1.1 23456</pre>
<p>Where <em>1.1.1.1</em> is IP address of Linux host where you plan to collect and analyze netflow data. <em>23456</em> is port number of netflow collector running on Linux.</p>
<p><b>Linux Setup</b></p>
<p>1. Download and install nfdump.</p>
<pre>cd /usr/src/
wget http://sourceforge.net/projects/nfdump/files/stable/nfdump-1.6.2/nfdump-1.6.2.tar.gz/download
tar -xvzf nfdump-1.6.2.tar.gz
cd nfdump-1.6.2
./configure --prefix=/ --enable-nfprofile
make
make install
</pre>
<p>2. Download and install nfsen.</p>
<p>It requires web server with php module and <a href="http://www.mrtg.org/rrdtool/">RRD</a> so make sure you have the corresponding packages installed. I hope you&#8217;re running httpd with php already so below are rrd/perl related packages installation hints only.</p>
<p>Fedora/Centos/Redhat users should type this:</p>
<pre>yum install rrdtool rrdtool-devel rrdutils perl-rrdtool</pre>
<p>Ubuntu/Debian:</p>
<pre>aptitude install rrdtool librrd2-dev librrd-dev librrd4 librrds-perl librrdp-perl</pre>
<p>If you run some exotic Linux distribution just install everything that is related to rrd + perl.</p>
<p>At last, nfsen installation:</p>
<pre>cd /usr/src/
wget http://sourceforge.net/projects/nfsen/files/stable/nfsen-1.3.5/nfsen-1.3.5.tar.gz/download
tar -xvzf nfsen-1.3.5.tar.gz
cd nfsen-1.3.5
cp etc/nfsen-dist.conf etc/nfsen.conf
</pre>
<p>In order to continue you should edit file <em>etc/nfsen.conf</em> to specify where to install nfsen, web server&#8217;s username, its document root directory etc. That file is commented so there shouldn&#8217;t be serious problems with it.</p>
<p>One of the major sections of <em>nfsen.conf</em> is &#8216;Netflow sources&#8217;, it should contain exactly the same port number(s) you&#8217;ve configured Cisco with &#8212; recall &#8216;ip flow-export &#8230;&#8217; line where we&#8217;ve specified port 23456. E.g.</p>
<pre>%sources = (
    'Router1'    => { 'port' => '23456', 'col' => '#0000ff', 'type' => 'netflow' },
);</pre>
<p>Now it&#8217;s time to finish the installation:</p>
<pre>./install.pl etc/nfsen.conf</pre>
<p>In case of success you&#8217;ll see corresponding notification after which you will have to start nfsen daemon to get the ball rolling:</p>
<pre>/path/to/nfsen/bin/nfsen start</pre>
<p>From this point nfdump started collecting netflow data exported by Cisco router and nfsen is hardly working to visualize it &#8212; just open web browser and go to <em>http://linux_web_server/nfsen/nfsen.php</em> to make sure. If you see empty graphs just wait for a while to let nfsen to collect enough data to visualize it.</p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxscrew.com/2010/11/25/how-to-monitor-traffic-at-cisco-router-using-linux-netflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tiny perl script for UDP flooding</title>
		<link>http://www.linuxscrew.com/2008/04/10/tiny-perl-script-for-udp-flooding/</link>
		<comments>http://www.linuxscrew.com/2008/04/10/tiny-perl-script-for-udp-flooding/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 20:05:19 +0000</pubDate>
		<dc:creator>artiomix</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.linuxscrew.com/2008/04/10/tiny-perl-script-for-udp-flooding/</guid>
		<description><![CDATA[Sometimes it is necessary to perform UDP flood towards some network device(s) in order to test its behavior in stress&#8230; Actually I am sure that every system administrator might use this small perl script for this purpose. Certainly there are many  special programs for this but believe me that it is much more easier [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it is necessary to perform <strong>UDP flood</strong> towards some network device(s) in order to test its behavior in stress&#8230; Actually I am sure that every system administrator might use this small <strong>perl script</strong> for this purpose. Certainly there are many  special programs for this but believe me that it is much more easier to do the following:</p>
<p><strong>1</strong>. <code>#touch &gt; /tmp/flood.pl</code><br />
<strong>2</strong>. <code>#chmod +x /tmp/flood.pl</code><br />
<strong>3</strong>. Copy the this code to /tmp/flood.pl:</p>
<p><a href="/files/udp_flood.txt" target="_blank"><img src="/files/script_paranaid.png" height="500" width="543" /></a></p>
<p><strong>4</strong>. Then <code>/tmp/flood.pl 192.168.0.1 0 0 0</code>, where 192.168.0.1 is IP you would like to flood with huge amount of UDP datagrams.</p>
<p>Thanks to Ivan Pepelnjak from <a href="http://ioshints.blogspot.com/" target="_blank">http://ioshints.blogspot.com/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxscrew.com/2008/04/10/tiny-perl-script-for-udp-flooding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Linux user with password</title>
		<link>http://www.linuxscrew.com/2007/09/19/create-linux-user-with-password/</link>
		<comments>http://www.linuxscrew.com/2007/09/19/create-linux-user-with-password/#comments</comments>
		<pubDate>Wed, 19 Sep 2007 19:56:27 +0000</pubDate>
		<dc:creator>artiomix</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.linuxscrew.com/2007/09/19/create-linux-user-with-password/</guid>
		<description><![CDATA[Sometimes it&#8217;s necessary to create Linux user accounts in batch mode (fully automatic) but often newbies ask how to set password for a new user without entering it manually. Thanks to heaven command useradd can get password as an input parameter, but it should be encrypted.
In other words, to create Linux user account with password [...]]]></description>
			<content:encoded><![CDATA[<p align="left"><span class="file-link image"><img src="http://www.linuxscrew.com/wp-content/uploads/2007/09/linux-logo.jpg" title="linux-logo.jpg" alt="linux-logo.jpg" align="right" /></span>Sometimes it&#8217;s necessary to create <strong>Linux</strong> user accounts in batch mode (fully automatic) but often newbies ask how to set <strong>password</strong> for a new user without entering it manually. Thanks to heaven command <em><strong>useradd</strong> </em>can get password as an input parameter, but it should be encrypted.</p>
<p>In other words, to create Linux user account with password the following command will be useful:</p>
<p><code><em>useradd -m <strong>-p encryptedPass</strong> username</em></code></p>
<p>I know at least two ways to get password encrypted. The first one is to use <strong>perl</strong> <em>crypt();</em> function:</p>
<p><em><code>perl -e 'print crypt("password_to_be_encrypted", "salt"),"\n"'</code></em></p>
<p>which will give you an output <em>sa3tHJ3/KuYvI</em>.</p>
<p>The second way (more simple) is to use command:</p>
<p><em><code><strong>openssl</strong> passwd password_to_be_encrypted</code></em><a href="http://www.linuxscrew.com/wp-admin/upload.php?style=inline&amp;tab=browse-all&amp;post_id=-1190230328&amp;_wpnonce=a61642a847&amp;ID=147&amp;action=view&amp;paged=2" id="file-link-147" title="linux-logo.jpg" class="file-link image"> 			 </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxscrew.com/2007/09/19/create-linux-user-with-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CGI Perl scripts debugging (solve 500 Internal Server Error)</title>
		<link>http://www.linuxscrew.com/2007/08/17/cgi-perl-scripts-debugging-solve-500-internal-server-error/</link>
		<comments>http://www.linuxscrew.com/2007/08/17/cgi-perl-scripts-debugging-solve-500-internal-server-error/#comments</comments>
		<pubDate>Fri, 17 Aug 2007 08:10:00 +0000</pubDate>
		<dc:creator>artiomix</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://linuxscrew.com/?p=47</guid>
		<description><![CDATA[When you run your perl scripts in browser you would get &#8220;500 Internal Server Error&#8221; when something goes wrong. There would be several reasons of this but one thing to be done is to check if your perl script contains errors. To do it login to server you&#8217;re running perl script (I hope you use [...]]]></description>
			<content:encoded><![CDATA[<p>When you run your perl scripts in browser you would get &#8220;500 Internal Server Error&#8221; when something goes wrong. There would be several reasons of this but one thing to be done is to check if your perl script contains errors. To do it login to server you&#8217;re running perl script (I hope you use Linux ;] ) and execute command:</p>
<p><em>/usr/bin/perl -w /path/to/script.cgi</em></p>
<p>It will show debug information and it would be much easier to find and solve the problem.</p>
<p>Good luck!</p>
<p>You may also be interested in:<br />
<a href="http://www.linuxscrew.com/2007/08/14/access-to-sqlite3-database-through-perl-script-example/" rel="bookmark" title="Permanent Link to ">Access to sqlite3 database through perl (script example)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxscrew.com/2007/08/17/cgi-perl-scripts-debugging-solve-500-internal-server-error/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Access to sqlite3 database through perl (script example)</title>
		<link>http://www.linuxscrew.com/2007/08/14/access-to-sqlite3-database-through-perl-script-example/</link>
		<comments>http://www.linuxscrew.com/2007/08/14/access-to-sqlite3-database-through-perl-script-example/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 18:44:00 +0000</pubDate>
		<dc:creator>artiomix</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://linuxscrew.com/?p=41</guid>
		<description><![CDATA[By publishing this post I try to help people who want to get access to popular and simple database engine sqlite through perl script. I use sqlite to store e-mails statistics at small mail server in order to retrieve information about users&#8217; mail activity like average response time, sent and received messages and etc. There [...]]]></description>
			<content:encoded><![CDATA[<p>By publishing this post I try to help people who want to get access to popular and simple database engine <a href="http://www.sqlite.org/">sqlite</a> through perl script. I use sqlite to store e-mails statistics at small mail server in order to retrieve information about users&#8217; mail activity like average response time, sent and received messages and etc. There is perl script that is used to get this data per every user or get summary statistics. This script is to be run by web server (I use <a href="http://apache.org/">Apache</a>) and has name index.cgi in my case.</p>
<p>Here is part of it:</p>
<p align="left"><em>#!/usr/bin/perl<br />
use DBI;<br />
print &#8220;Content-type: text/html\n\n&#8221;;<br />
print &#8220;&lt;html&gt;&lt;head&gt;&lt;title&gt;perl and sqlite example script&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&#8221;;<br />
$dbh = DBI-&gt;connect( &#8220;dbi:SQLite:dbname=/tmp/mail_data.db&#8221;,&#8221;", &#8220;&#8221;, { RaiseError =&gt; 1, AutoCommit =&gt; 0 });</em></p>
<p align="left"><em>my $fst = $dbh-&gt;selectall_arrayref(&#8220;SELECT min(time_1),max(time_1) FROM mail_data&#8221;);<br />
foreach my $row (@$fst) {<br />
my ($fst_pr,$lst_pr) = @$row;<br />
print &#8220;oldest entry in database: &#8220;.gmtime($fst_pr).&#8221; gmt&lt;br&gt;newest entry in database: &#8220;.gmtime($lst_pr);<br />
}</em></p>
<p align="left"><em>print &#8220;&lt;/body&gt;&#8221;;<br />
print &#8220;&lt;/html&gt;&#8221;;<br />
$dbh-&gt;disconnect;</em></p>
<p>After you load this example through any web browser (please read your web server&#8217;s manual on how to allow cgi/perl script exec, for example <a href="http://httpd.apache.org/docs/2.2/howto/cgi.html">here</a>), script will read sqlite database that is located at /tmp/mail_data.db and display minimal and maximal values of field time_1 from mail_data table.</p>
<p>In order to run this script it&#8217;s necessary to install perl, sqlite3 and perl-DBI-SQLite <a href="http://www.cpan.org">cpan</a> module.</p>
<p>You may also be interested in:<br />
<a href="http://www.linuxscrew.com/2007/08/17/cgi-perl-scripts-debugging-solve-500-internal-server-error/" rel="bookmark" title="Permanent Link to ">CGI Perl scripts debugging (solve 500 Internal Server Error)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxscrew.com/2007/08/14/access-to-sqlite3-database-through-perl-script-example/feed/</wfw:commentRss>
		<slash:comments>91</slash:comments>
		</item>
	</channel>
</rss>

