<?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>Technical Diary &#187; Uncategorized</title>
	<atom:link href="http://andriigrytsenko.net/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Tue, 17 Aug 2010 08:25:33 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>UA-IX checker</title>
		<link>http://andriigrytsenko.net/2010/04/ua-ix-checker/</link>
		<comments>http://andriigrytsenko.net/2010/04/ua-ix-checker/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 08:31:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=737</guid>
		<description><![CDATA[Based on this post I have decided make some program which able to detect weather IP is a part of some network (in this case UA-IX network) or not.

Speaking about UA-IX, from wikipedia we know: 
The Ukrainian traffic exchange network (UA-IX) (Ukrainian: Українська мережа обміну інтернет-трафіком) is an Internet exchange point that was established in [...]]]></description>
			<content:encoded><![CDATA[<p>Based on <a href="http://andriigrytsenko.net/2010/03/ipcalc-on-perl/">this post</a> I have decided make some program which able to detect weather IP is a part of some network (in this case UA-IX network) or not.<br />
<span id="more-737"></span></p>
<p>Speaking about UA-IX, from <a href="http://en.wikipedia.org/wiki/Ukrainian_Internet_Exchange_Network">wikipedia</a> we know: </p>
<blockquote><p>The Ukrainian traffic exchange network (UA-IX) (Ukrainian: Українська мережа обміну інтернет-трафіком) is an Internet exchange point that was established in Kiev, the capital of Ukraine, on July 2000 and is the daughter company of Ukrainian Internet Association. Companies that established Ukrainian traffic exchange network are major Ukrainian businesses that work expanding Ukrainian Internet market.</p></blockquote>
<p>Here the <a href="http://noc.ix.net.ua/ua-list.txt">list</a> of all networks which belongs to UA-IX net. Download it to your machine and save as <em>ua-list.txt</em>.</p>
<p>Content of file. We have some networks list here:</p>
<pre>$ head -3 ua-list.txt
8.8.4.0/24
8.8.8.0/24
62.16.0.0/19
</pre>
<p>Here is the script:</p>
<pre>$cat uaix.pl
#!/usr/local/bin/perl
# Written by Andrii Grytsenko 2010
# PP: http://andriigrytsenko.net     

use POSIX;
use strict;

sub dec2bin {
   my $hex = shift;
   my $pack = unpack("B32",pack("N",$hex));
   my $pack = substr($pack,-8);
   return $pack;
}

my $bin_ip;
$bin_ip .= dec2bin($_) foreach (split(/\./,$ARGV[0]));

open(IP, "<$ARGV[1]");
while(<IP>){
    chomp();
    my ($ip,$net_mask) = split(/\//,$_);
    $net_mask = 24 if (!defined($net_mask));
    my $bin_network;
    $bin_network .= dec2bin($_) foreach (split(/\./,$ip));
    my $net_net_part = substr($bin_network,0,$net_mask);
    my $net_ip_part  = substr($bin_ip,0,$net_mask);
    if ( $net_net_part == $net_ip_part) {
        print "IP $ARGV[0] belong to network $_\n";
        exit;
    }
}

print "IP $ARGV[0] is not part of UA-IX\n";
close(IP);</pre>
<p>To run the script: </p>
<pre>$ perl uaix.pl [ip_addr] [path/to/ua-list.txt]</pre>
<p>For example: </p>
<pre>$ perl uaix.pl 72.14.228.156 ua-list.txt
IP 72.14.228.156 belong to network 72.14.192.0/18</pre>
<p>There is also some ways to use script on your own&#8230; You can use your list of networks to detect ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/04/ua-ix-checker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dbmail mailbox quota notification script</title>
		<link>http://andriigrytsenko.net/2010/02/dbmail-mailbox-quota-notification-script/</link>
		<comments>http://andriigrytsenko.net/2010/02/dbmail-mailbox-quota-notification-script/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 16:41:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=652</guid>
		<description><![CDATA[Here is the script which check quota limits in the dbmail and in case of exceeding, script send mail to user and postmaster.

Get script mail_quota.pl and mail_quota.conf configuration file at first.
To make script work fine two cpan modules should be installed:
cpan -i Mail::Send
and 
cpan -i DBD::Pg
This is dbmail table dbmail_users description:
dbmail=# \d dbmail_users
Table "public.dbmail_users"
Column  [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the script which check quota limits in the dbmail and in case of exceeding, script send mail to user and postmaster.<br />
<span id="more-652"></span></p>
<p>Get script <a href="http://andriigrytsenko.net/files/mail_quota.txt">mail_quota.pl</a> and <a href="http://andriigrytsenko.net/files/mail_quota.conf">mail_quota.conf</a> configuration file at first.</p>
<p>To make script work fine two <a href="http://www.cpan.org/">cpan</a> modules should be installed:</p>
<pre>cpan -i Mail::Send</pre>
<p>and </p>
<pre>cpan -i DBD::Pg</pre>
<p>This is dbmail table <em>dbmail_users</em> description:</p>
<pre>dbmail=# \d dbmail_users
Table "public.dbmail_users"
Column      |            Type             |                              Modifiers
-----------------+-----------------------------+---------------------------------------------------------------------
user_idnr       | bigint                      | not null default nextval('dbmail_user_idnr_seq'::regclass)
userid          | character varying(100)      | not null
passwd          | character varying(34)       | not null
client_idnr     | bigint                      | not null default 0::bigint
maxmail_size    | bigint                      | not null default 0::bigint
curmail_size    | bigint                      | not null default 0::bigint
maxsieve_size   | bigint                      | not null default 0::bigint
cursieve_size   | bigint                      | not null default 0::bigint
encryption_type | character varying(20)       | not null default ''::character varying
last_login      | timestamp without time zone | not null default '1979-11-03 22:05:58'::timestamp without time zone
</pre>
<p>There is configuration:</p>
<pre>cat mail_quota.conf:
user=user
host=localhost
port=5432
dbname=db
password=pass
min_thre=80
max_thre=90
admin_mail=admin@domain.com</pre>
<p>No comment in the configuration file is permitted. First 4 lines describe database connection.<br />
<em>min_thre</em>/<em>max_thre</em> &#8211; minimum and maximum threshold for notification measure is percent. If minimum threshold will be reached user receive mail about quota exceeding. In case of maximum reaching, mail also will be sent to administrator. </p>
<p>To make checking on regular basis add it into the crontab file. </p>
<pre>crontab -l
# m h  dom mon dow   command
59 23 * * *     /path/to/mail_quota.pl /path/to/mail_quota.conf</pre>
<p>Below we check mail quota every day at 23.59. </p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/02/dbmail-mailbox-quota-notification-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
