<?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</title>
	<atom:link href="http://andriigrytsenko.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Wed, 10 Mar 2010 15:44:59 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Clean up the shared memory in Solaris</title>
		<link>http://andriigrytsenko.net/2010/03/clean-up-the-shared-memory-in-solaris/</link>
		<comments>http://andriigrytsenko.net/2010/03/clean-up-the-shared-memory-in-solaris/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 15:44:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[solaris]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=713</guid>
		<description><![CDATA[Here is short trick how to clean the shared memory up in Solaris OS. 

Here is short info about the host(solaris 5.9, arch sparc):
uname -a
SunOS hostname1 5.9 Generic_118558-25 sun4u sparc SUNW,Sun-Fire-V890 Solaris

To see all shared memory segment, use ipcs

user1@~>ipcs -m -a
IPC status from  as of Wed Mar 10 16:26:20 CET 2010
T    [...]]]></description>
			<content:encoded><![CDATA[<p>Here is short trick how to clean the shared memory up in Solaris OS. </p>
<p><span id="more-713"></span></p>
<p>Here is short info about the host(solaris 5.9, arch sparc):</p>
<pre>uname -a
SunOS hostname1 5.9 Generic_118558-25 sun4u sparc SUNW,Sun-Fire-V890 Solaris
</pre>
<p>To see all shared memory segment, use <em>ipcs</em></p>
<pre>
user1@~>ipcs -m -a
IPC status from <running system> as of Wed Mar 10 16:26:20 CET 2010
T         ID      KEY        MODE        OWNER    GROUP  CREATOR   CGROUP NATTCH      SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
Shared Memory:
m       4608   0x5efaa728 --rw-r-----   oracle oinstall   oracle oinstall     23 3992993792  5720 18925 16:24:47 16:24:47 11:59:42
m    5246977   0x517b6233 --rw-r--r-- user1   os_int user1   os_int     32    7352048 10685 16417 16:21:26 16:21:26 16:13:35
m    1969154   0x22b80b3e --rw-r--r-- user1   os_int user1   os_int      3   72552448 10689 11443 16:14:19 16:13:51 16:13:37
m    1967619   0x1b68b6e6 --rw-r--r-- user1   os_int user1   os_int      8  438326272 10689 16417 16:21:26 16:21:26 16:13:38
m    1966084   0x5724f977 --rw-r--r-- user1   os_int user1   os_int     14  212926464 10689 11379 16:14:27 16:13:50 16:13:40
m    1966085   0x534aab2a --rw-r--r-- user1   os_int user1   os_int     10  216572928 10689 11442 16:14:38 16:13:51 16:13:42
m   11391045   0x7bfc552e --rw-r--r-- user2   os_int user2   os_int      0    7352048  8047  9445 14:43:22 14:43:40 13:41:22
m   10461766   0x63fcba9b --rw-r--r-- user2   os_int user2   os_int      0   72552448  8114  9457 14:43:22 14:43:38 13:41:25
m    9721415   0x5cad6643 --rw-r--r-- user2   os_int user2   os_int      0  583097344  8114  9459 14:43:22 14:43:38 13:41:27
m    9655368   0x1869a8d4 --rw-r--r-- user2   os_int user2   os_int      0  212926464  8114  9466 14:43:22 14:43:38 13:41:29
m    9753673   0x148f5a87 --rw-r--r-- user2   os_int user2   os_int      0  216572928  8114  9473 14:43:22 14:43:38 13:41:31
</pre>
<p>To delete/destroy/remove any segment of the shared memory, use <em>ipcrm</em>. You can specify segment by  <em>shmkey</em>(3-rd field in ipcs output) or by <em>shmid</em>(2-nd field) use <strong>-M</strong> and <strong>-m</strong> accordingly . Like : </p>
<pre>ipcrm -m 4608</pre>
<p>or </p>
<pre>ipcrm -M 0x5efaa728</pre>
<p>To remove all segment in shared memory where owner is <em>user1</em>, run </p>
<pre>ipcs -m -a | awk '{if($5 ~ /user1/ &#038;&#038; $1 ~ /m/) print "ipcrm -m "$2;}' | bash</pre>
<p>END.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/03/clean-up-the-shared-memory-in-solaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl performance optimization</title>
		<link>http://andriigrytsenko.net/2010/03/perl-performance-optimization/</link>
		<comments>http://andriigrytsenko.net/2010/03/perl-performance-optimization/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 18:05:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=671</guid>
		<description><![CDATA[I&#8217;d like to describe my own experience with perl optimization. There several common way to make you code works more faster.

I used perl module Benchmark to make measurements. Rules:
1. If you can use single quotes instead of double quote, do it. In most cases it will be executed more faster because of string in single [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to describe my own experience with perl optimization. There several common way to make you code works more faster.<br />
<span id="more-671"></span></p>
<p>I used perl module Benchmark to make measurements. Rules:</p>
<p>1. If you can use single quotes instead of double quote, do it. In most cases it will be executed more faster because of string in single quotes is not going to concatenate. </p>
<p>2. Use compiled regexps in case you have loops. It can brings huge performance: </p>
<pre>
use Benchmark;

sub qwe {
    my $re = shift;
    my $line = "wer";
    foreach my $reg (@$re){
        if ( $line =~ /$reg/) {
            my $l=0;
        }
    }
}

my $line = "sdfsdfsdfsdf";
my $ref = ".*";
my @arr = qw(qwe sdf wer); #plaine regexps
my @c_re;
foreach my $p_re (@arr) { # compile it and put in to the @c_re
    my $re = qr/\b$p_re\b/i ;
    push(@c_re,$re);
}

Benchmark::cmpthese(100000, {
    'Compiled' => sub { qwe(\@c_re) },
    'Not_compiled' => sub { qwe(\@arr) },
});</pre>
<p>As result:</p>
<pre>
                 Rate Not_compiled     Compiled
Not_compiled  36232/s           --         -79%
Compiled     169492/s         368%           --</pre>
<p>3. Extract values from string with <em>substr</em> if you can. There are three well knows ways to do such kind of operation: regular expressions, split and substr. Let&#8217;s compare it:</p>
<pre>sub mksplit {
    my ($line) = @_;
    my ($fst,$snd) = split(/-/,$line);
    return($fst,$snd);
}

sub mkregexp {
    my ($line,$re) = @_;
    $line =~ m/$re/;
    return($1,$2);
}

sub mkstr {
    my ($line) = @_;
    my $pos = index($line,'-');
    my $fst = substr($line,0,$pos);
    my $snd = substr($line,$pos+1);
    return($fst,$snd);
}

my $line = "12-34";
my $n_comp_re = '(\d+)-(\d+)';
my $comp_re = qr/\b$n_comp_re\b/i ;

Benchmark::cmpthese(1000000, {
    'Compiled' => sub { mkregexp($line,$comp_re) },
    'Not_compiled' => sub { mkregexp($line,$n_comp_re) },
    'STR' => sub { mkstr($line) },
    'Split' => sub { mksplit($line) },
});

Benchmark::timethese(1000000, {
    'Compiled' => sub { mkregexp($line,$comp_re) },
    'Not_compiled' => sub { mkregexp($line,$n_comp_re) },
    'STR' => sub { mkstr($line) },
    'Split' => sub { mksplit($line) },
});
</pre>
<p>Where <em>compiled</em> and <em>not_compiles</em>  we use when talk about regular expression.</p>
<pre>
                 Rate        Split     Compiled Not_compiled          STR
Split        297619/s           --          -9%         -12%         -25%
Compiled     327869/s          10%           --          -4%         -17%
Not_compiled 340136/s          14%           4%           --         -14%
STR          396825/s          33%          21%          17%           --
Benchmark: timing 1000000 iterations of Compiled, Not_compiled, STR, Split...
  Compiled:  4 wallclock secs ( 3.14 usr +  0.00 sys =  3.14 CPU) @ 318471.34/s (n=1000000)
Not_compiled:  3 wallclock secs ( 2.91 usr +  0.00 sys =  2.91 CPU) @ 343642.61/s (n=1000000)
       STR:  2 wallclock secs ( 2.53 usr +  0.00 sys =  2.53 CPU) @ 395256.92/s (n=1000000)
     Split:  3 wallclock secs ( 3.19 usr +  0.00 sys =  3.19 CPU) @ 313479.62/s (n=1000000)
</pre>
<p>As you can see from output the more faster way to exract values from string is <em>substr</em>, next is split and regular expressions is the most slower. I don&#8217;t know why compiled regexps is more slow than regular one in this case. I guess its because of 1 iteration. </p>
<p>4. Don&#8217;t use sort in hash loops if there is no necessity. The most faster way to through over the hash is <em>keys</em> statement: </p>
<pre>
sub mkeach {
    my $hash = shift;
    my %hash2;
    while ( my($key,$value) = each(%$hash)){
        $hash2{$key} = $value;
    }
    return(\%hash2);
}

sub mkkeys {
    my $hash = shift;
    my %hash2;
    for my $key (keys(%$hash)){
        $hash2{$key} = $hash->{$key};
    }
    return(\%hash2);
}

sub mksort {
    my $hash = shift;
    my %hash2;
    foreach my $key (sort keys %$hash) {
        $hash2{$key} = $hash->{$key};
    }
    return(\%hash2);
}

my %hash = (name => 'name1', surname => 'surname1', address => 'address', var => 'var1', var2 => 'var2');

Benchmark::cmpthese(1000000, {
    'Keys' => sub { mkkeys(\%hash) },
    'Each' => sub { mkeach(\%hash) },
    'Sort' => sub { mksort(\%hash) },
});

Benchmark::timethese(1000000, {
    'Keys' => sub { mkkeys(\%hash) },
    'Each' => sub { mkeach(\%hash) },
    'Sort' => sub { mksort(\%hash) },
});
</pre>
<pre>
        Rate Each Sort Keys
Each 66800/s   --  -3% -14%
Sort 68681/s   3%   -- -11%
Keys 77459/s  16%  13%   --
Benchmark: timing 1000000 iterations of Each, Keys, Sort...
      Each: 16 wallclock secs (14.92 usr +  0.00 sys = 14.92 CPU) @ 67024.13/s (n=1000000)
      Keys: 12 wallclock secs (12.91 usr +  0.00 sys = 12.91 CPU) @ 77459.33/s (n=1000000)
      Sort: 15 wallclock secs (14.62 usr +  0.00 sys = 14.62 CPU) @ 68399.45/s (n=1000000)
</pre>
<p>That&#8217;s all for now, but I&#8217;ll continue to optimize my code so I think there will be an updates soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/03/perl-performance-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check if the perl module is installed</title>
		<link>http://andriigrytsenko.net/2010/02/check-if-the-perl-module-is-installed/</link>
		<comments>http://andriigrytsenko.net/2010/02/check-if-the-perl-module-is-installed/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 15:40:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=665</guid>
		<description><![CDATA[Under cover you can find some trick and script to check perl module installation.

To figure out whether perl module is installed at the system. Run:
perl -M&#60;module_name&#62; -e 1
if command return an error or NOT 0(zero) then module is not installed at the moment.
Here is also perl script which help you check a lot of modules:
#!/usr/local/bin/perl

my [...]]]></description>
			<content:encoded><![CDATA[<p>Under cover you can find some trick and script to check perl module installation.<br />
<span id="more-665"></span></p>
<p>To figure out whether perl module is installed at the system. Run:</p>
<pre>perl -M&lt;module_name&gt; -e 1</pre>
<p>if command return an error or NOT 0(zero) then module is not installed at the moment.</p>
<p>Here is also perl script which help you check a lot of modules:</p>
<pre>#!/usr/local/bin/perl

my @modules = qw (put your modules here separated by space without any quotes);

foreach my $module (@modules){
print $module,"\t";
my $result=system("perl -M$module -e 1");
print "Installed" if (!$result);
print "\n";
}</pre>
<p>EOF</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/02/check-if-the-perl-module-is-installed/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>
		<item>
		<title>Network bandwidth script</title>
		<link>http://andriigrytsenko.net/2010/02/network-bandwidth-script/</link>
		<comments>http://andriigrytsenko.net/2010/02/network-bandwidth-script/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 17:35:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=634</guid>
		<description><![CDATA[I spent several hours to find suitable script which help me figure out my network speed between two servers. But it was fruitlessly. So, I decided to make my own script with blackjack and hoockers. (c)

My Perl script require several things :

Perl interpreter of course
IO::Socket perl module
Getopt::Long perl module

I will tell you nothing about first [...]]]></description>
			<content:encoded><![CDATA[<p>I spent several hours to find suitable script which help me figure out my network speed between two servers. But it was fruitlessly. So, I decided to make my own script with blackjack and hoockers. (c)</p>
<p><span id="more-634"></span></p>
<p>My Perl script require several things :</p>
<ol>
<li>Perl interpreter of course</li>
<li>IO::Socket perl module</li>
<li>Getopt::Long perl module</li>
</ol>
<p>I will tell you nothing about first one. To install perl modules run <em>cpan</em> as root:</p>
<pre>cpan -i Getopt::Long</pre>
<p>and</p>
<pre>cpan -i IO::Socket</pre>
<p>When installation will be finished. Download <a href="http://andriigrytsenko.net/files/bandtest_pl.txt">bandtest.pl</a> and save it at 1-st server.</p>
<p>Now go to the second one and run <em>netcat</em>(please make sure you have this package installed):</p>
<pre>server02# nc -4tl 7777 &gt; /dev/null</pre>
<p>You can use any free port instead port 7777.</p>
<p>Back to first server and run <em>bandtest.pl</em>, but before make sure there is no any firewalls rules which hamper in connection between to hosts on port 7777.</p>
<p>Use <em>telnet</em> to check connection:</p>
<pre>server01# telnet server02 7777
Connected to kivras01.
Escape character is '^]'.</pre>
<p>This output means connection is successfully opened, so you can continue.</p>
<p>Make file with size for example 100Mb(I advice you to don&#8217;t use very big files, 100Mb is fit size which doesn&#8217;t fill your memory out and enough for proper results.  I intentionally put file into memory before sending the data&#8217;s. This allow me delete any I/O operation during the network connection and as result prevent any result distortion.):</p>
<pre>server01# dd if=/dev/zero of=/tmp/test bs=1024 count=1000000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB) copied, 1.20234 s, 85.2 MB/s</pre>
<p>Run <em>bandtest.pl</em> to get a results:</p>
<pre>server01$ ./bandtest.pl -h server02 -p 7777 -f /tmp/test
Bytes were transfered 102.40 MB
Seconds taken: 8
Average speed 12.80 MB
</pre>
<p>EOF.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/02/network-bandwidth-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get system temperature in Linux</title>
		<link>http://andriigrytsenko.net/2010/01/get-system-temperature-in-linux/</link>
		<comments>http://andriigrytsenko.net/2010/01/get-system-temperature-in-linux/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 13:17:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=624</guid>
		<description><![CDATA[How to get online temperature status on your linux box.

There is one good package which allow you to control and check your computer temperature in online mode. To install  For debian:
apt-get install lm-sensors
for CentOS or RH:
yum install lm-sensors
Next software should discover all sensors in your PC, run sensors-detect:
agrytsenko:~# sensors-detect
# sensors-detect revision 5729 (2009-06-02 15:51:29 [...]]]></description>
			<content:encoded><![CDATA[<p>How to get online temperature status on your linux box.<br />
<span id="more-624"></span></p>
<p>There is one good package which allow you to control and check your computer temperature in online mode. To install  For debian:</p>
<pre>apt-get install lm-sensors</pre>
<p>for CentOS or RH:</p>
<pre>yum install lm-sensors</pre>
<p>Next software should discover all sensors in your PC, run <em>sensors-detect</em>:</p>
<pre>agrytsenko:~# sensors-detect
# sensors-detect revision 5729 (2009-06-02 15:51:29 +0200)
# System: Hewlett-Packard HP Compaq 6510b (GB866EA#ACB) (laptop)
# Board: Hewlett-Packard 30C0                                   

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.                                

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no):
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD K10 thermal sensors...                                  No
Intel Core family thermal sensor...                         Success!
    (driver `coretemp')
Intel AMB FB-DIMM thermal sensor...                         No
VIA C7 thermal and voltage sensors...                       No          

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no):
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor'...                   No
Trying family `SMSC'...                                     Yes
Found unknown chip with ID 0x3600
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor'...                   No
Trying family `SMSC'...                                     Yes
Found unknown non-standard chip with ID 0x7a                      

Some hardware monitoring chips are accessible through the ISA I/O ports.
We have to write to arbitrary I/O ports to probe them. This is usually
safe though. Yes, you do have ISA I/O ports even if you do not have any
ISA slots! Do you want to scan the ISA I/O ports? (YES/no):
Probing for `National Semiconductor LM78' at 0x290...       No
Probing for `National Semiconductor LM79' at 0x290...       No
Probing for `Winbond W83781D' at 0x290...                   No
Probing for `Winbond W83782D' at 0x290...                   No          

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no):
Sorry, no supported PCI bus adapters found.
Module i2c-dev loaded successfully.

Now follows a summary of the probes I have just done.
Just press ENTER to continue:

Driver `coretemp':
  * Chip `Intel Core family thermal sensor' (confidence: 9)

To load everything that is needed, add this to /etc/modules:
#----cut here----
# Chip drivers
coretemp
#----cut here----
If you have some drivers built into your kernel, the list above will
contain too many modules. Skip the appropriate ones!

Do you want to add these lines automatically to /etc/modules? (yes/NO)yes
Successful!

Monitoring programs won't work until the needed modules are
loaded. You may want to run '/etc/init.d/module-init-tools start'
to load them.

Unloading i2c-dev... OK</pre>
<p>If you have choosen &#8220;yes&#8221; on last question then all needed kernel modules were added to your module config file. In my case only one module is found, here is it:</p>
<pre>agrytsenko:~# grep temp /etc/modules
coretemp</pre>
<p>To get sensors status and data run <em>sensors</em>:</p>
<pre>agrytsenko:~# sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:       +60.0°C  (crit = +256.0°C)
temp2:       +58.0°C  (crit = +108.0°C)
temp3:       +45.0°C  (crit = +105.0°C)
temp4:       +32.5°C  (crit = +108.0°C)
temp5:       +65.0°C  (crit = +110.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +59.0°C  (high = +100.0°C, crit = +100.0°C)

coretemp-isa-0001
Adapter: ISA adapter
Core 1:      +61.0°C  (high = +100.0°C, crit = +100.0°C)
</pre>
<p>The output depends on your hardware sensors. This output from my another PC:</p>
<pre>w83627hf-isa-0290
Adapter: ISA adapter
VCore 1:   +1.47 V  (min =  +1.30 V, max =  +1.71 V)
VCore 2:   +1.82 V  (min =  +1.30 V, max =  +1.71 V)       ALARM
+3.3V:     +3.25 V  (min =  +2.82 V, max =  +3.79 V)
+5V:       +4.89 V  (min =  +4.06 V, max =  +5.70 V)
+12V:     +12.28 V  (min =  +7.24 V, max =  +9.97 V)       ALARM
-12V:     -11.95 V  (min =  +4.58 V, max = -11.87 V)       ALARM
-5V:       -5.20 V  (min =  +2.09 V, max =  -4.39 V)       ALARM
V5SB:      +5.46 V  (min =  +5.99 V, max =  +5.19 V)       ALARM
VBat:      +2.85 V  (min =  +3.54 V, max =  +3.49 V)       ALARM
fan1:        0 RPM  (min = 10887 RPM, div = 2)              ALARM
fan2:        0 RPM  (min = 3947 RPM, div = 2)              ALARM
fan3:        0 RPM  (min = 4411 RPM, div = 2)              ALARM
temp1:       +28 C  (high =   +68 C, hyst =   +48 C)   sensor = thermistor
temp2:     +43.0 C  (high =   +70 C, hyst =   +65 C)   sensor = diode(beep)
temp3:      -1.5 C  (high =   +70 C, hyst =   +65 C)   sensor = diode
vid:      +1.500 V  (VRM Version 8.5)
alarms:
beep_enable:
          Sound alarm enabled
</pre>
<p>Now you can do with these info whatever you want, for instance put into the file as plain text or excel document or even storage in RDBMS. I prefer to store these data&#8217;s in Round Robin Database and draw nice graphs by <strong>rrdtool</strong> util.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/01/get-system-temperature-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google maps API to show users location</title>
		<link>http://andriigrytsenko.net/2010/01/google-maps-api/</link>
		<comments>http://andriigrytsenko.net/2010/01/google-maps-api/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 20:18:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=605</guid>
		<description><![CDATA[I will show you how to use google maps to print location of your site visitors.

First of all you need to get Google KEY, to do this you should have google account. If you have it visit google key page to generate the map key.
After you&#8217;ve done it -&#62; you will be ready for next [...]]]></description>
			<content:encoded><![CDATA[<p>I will show you how to use google maps to print location of your site visitors.<br />
<span id="more-605"></span></p>
<p>First of all you need to get Google KEY, to do this you should have google account. If you have it visit <a href="http://code.google.com/apis/maps/signup.html">google key page</a> to generate the map key.</p>
<p>After you&#8217;ve done it -&gt; you will be ready for next steps.</p>
<p>Below the script should be downloaded in your html directory as location.cgi for example:</p>
<pre>#!/usr/bin/perl                                              

use strict;
use LWP;   

sub GetCode {
 my ($map_key,$lat,$long,$zoom)=@_;

 my $head = &lt;&lt;HEAD;
 &lt;title&gt;Your current location&lt;/title&gt;
 &lt;script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;sensor=false&amp;amp;key=$map_key"
 type="text/javascript"&gt;&lt;/script&gt;
 &lt;script type="text/javascript"&gt;
 function initialize() {
 if (GBrowserIsCompatible()) {
 var map = new GMap2(document.getElementById("map_canvas"));
 map.setCenter(new GLatLng($lat, $long), $zoom);
 map.setUIToDefault();
 }
 }
 &lt;/script&gt;
HEAD
 my $body= &lt;&lt;BODY;
 &lt;body onload="initialize()" onunload="GUnload()"&gt;
 Your current location is $ENV{REMOTE_ADDR}:&lt;br&gt;
 &lt;div id="map_canvas" style="width: 500px; height: 300px"&gt;&lt;/div&gt;
 &lt;/body&gt;
BODY
return($head,$body);
}                                                                                                

sub GetHTMLCode {
 my ($head,$body)=@_;
 my $html = &lt;&lt;HTML;
 &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
 &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"&gt;
 &lt;head&gt;
 &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/&gt;
 $head
 &lt;/head&gt;
 $body
HTML
 return $html;
}

sub GetCoordinates {
 my $ip = shift;
 my ($lat,$long);
 my $ua = new LWP::UserAgent;
 $ua-&gt;agent("Opera/9.0 " . $ua-&gt;agent);
 $ua-&gt;timeout("5");

 my $req = new HTTP::Request( GET =&gt; "http://www.geobytes.com/IpLocator.htm?GetLocation&amp;template=php3.txt&amp;IpAddress=$ip");
 my $res = $ua-&gt;request($req);
 if (! $res-&gt;is_success) {
 die "can't get acccess to server \n";
 }
 my $content=$res-&gt;content;
 foreach my $str (split(/\n/,$content)){
 $lat = $1 if ($str =~ /meta name=.latitude. content=.(\d+\.\d+)./);
 $long = $1 if ($str =~ /meta name=.longitude. content=.(\d+\.\d+)./);
 }
 return($long,$lat);
}
my $map_key="";
my $zoom="10";
my $ip_addr=$ENV{REMOTE_ADDR};
my ($long,$lat)=GetCoordinates($ip_addr);
my ($head,$body)=GetCode($map_key,$lat,$long,$zoom);
my $html = GetHTMLCode($head,$body);
print "Content-type: text/html\n\n";
print $html;</pre>
<p>This script also available by this <a href="http://andriigrytsenko.net/files/location.txt">link</a>.<br />
Your google key should be defined as variable <strong>map_key</strong> in the code.</p>
<p>Function <strong>GetCode</strong> &#8211; return two values:</p>
<ol>
<li><em>$head</em> &#8211; this block should be put into the &lt;head&gt; section of your html code.</li>
<li><em>$body</em> &#8211; into the &lt;body&gt; section.</li>
</ol>
<p>Function <strong>GetCoordinates</strong> return <em>longitude</em> and <em>latitude </em>of got ip.</p>
<p>Function  <strong>GetHTMLCode </strong>was used<strong> </strong>to generate example html code.</p>
<p>You also can implement these functions into your page as module. Download <a href="http://andriigrytsenko.net/files/google_map.pm">google_map.pm</a> and save it in your perl modules directory or do it as describe in this  <a href="http://andriigrytsenko.net/2009/11/use-perl-module-without-root-access/">post</a>. After, you can easily call this functions from your code as show below:</p>
<pre>#!/usr/bin/perl

use lib "path/to/directory/where/you/save/google_map.pm";
require google_map;

my $map_key="your_map_key_was_described_below";
my $zoom="10";
my $ip_addr=$ENV{REMOTE_ADDR};
my ($long,$lat)=google_map::GetCoordinates($ip_addr);
my ($head,$body)=google_map::GetCode($map_key,$lat,$long,$zoom);
my $html = google_map::GetHTMLCode($head,$body);
print "Content-type: text/html\n\n";
print $html;</pre>
<p>To see how it work check this <a href="http://andriigrytsenko.net/google_map.cgi">link</a> out.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/01/google-maps-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>D-link dwa-110 on Debian Box</title>
		<link>http://andriigrytsenko.net/2009/12/d-link-dwa-110-on-debian-box/</link>
		<comments>http://andriigrytsenko.net/2009/12/d-link-dwa-110-on-debian-box/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 12:23:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=524</guid>
		<description><![CDATA[Here some manual how to set up wireless usb stick(D-link dwa-110) on Debian Linux box step-by-step.

First you need to get Windows drivers from your drivers CD(you can find this stuff in your modem&#8217;s box). Also you need to install ndiswrapper.
Put directory with drivers to /root/Drivers/ and install ndiswrapper:
apt-get install ndiswrapper-common ndiswrapper-utils-1.9 rt73-common
Make ndiswrapper work with [...]]]></description>
			<content:encoded><![CDATA[<p>Here some manual how to set up wireless usb stick(D-link dwa-110) on Debian Linux box step-by-step.</p>
<p><span id="more-524"></span></p>
<p>First you need to get Windows drivers from your drivers CD(you can find this stuff in your modem&#8217;s box). Also you need to install <em>ndiswrapper</em>.</p>
<p>Put directory with drivers to /root/Drivers/ and install ndiswrapper:</p>
<pre>apt-get install ndiswrapper-common ndiswrapper-utils-1.9 rt73-common</pre>
<p>Make ndiswrapper work with your windows driver:</p>
<pre>ndiswrapper -i /root/Drivers/WinXP_2K_9X/Dr71WU.inf</pre>
<p>in case of previous step was successfully done, generate new configuration for modprobe:</p>
<pre>ndiswrapper -m</pre>
<p>Try to determine what name has you wireless interface:</p>
<pre>ifconfig -a</pre>
<p>By default it&#8217;s <em>wlan0</em> , but in my case it&#8217;s <em>wlan1</em>. Let&#8217;s bring it up:</p>
<pre>ifconfig wlan1 up</pre>
<p>Add interface configuration to your <em>/etc/network/interfaces</em>. In case you have no dhcpd server inside the network set your settings statically :</p>
<pre>auto wlan1
allow-hotplug wlan1
iface wlan1 inet static
    address 192.168.0.3
    network 192.168.0.0
    gateway 192.168.0.1
    netmask 255.255.255.0
    wireless-essid Homeee
    wireless-mode Managed
    wireless-key DFFB9E2CC1</pre>
<p>Or if you have dynamic server inside:</p>
<pre>auto wlan1
iface wlan1 inet dhcp
    wireless-essid amber
    wireless-mode managed
    wireless-key 6170-706C-65
    wireless-rate 54M</pre>
<p>Restart your computer and enjoy. Or at least run :</p>
<pre>/etc/init.d/networking restart</pre>
<p>Also below some tips how to make manual configuration:</p>
<pre>ifconfig wlan1 192.168.0.1 netmask 255.255.255.0 up</pre>
<p>- bring network up with defined ip and net mask.</p>
<pre>iwconfig wlan1 essid "name of network"</pre>
<p>- to set network name</p>
<pre>iwconfig wlan1 mode "new_mode"</pre>
<p>- set mode there is 7 modes are present. See <em>man iwconfig</em> to get more details.</p>
<pre>iwconfig wlan1 key "key string"</pre>
<p>- to set key up</p>
<p>or</p>
<pre>iwconfig wlan1 key "s:key_string"</pre>
<p>- to WEP ascii key.</p>
<pre>iwconfig wlan1 rate 54M</pre>
<p>- to set up spesific transfer date speed</p>
<pre>iwlist wlan1 scan</pre>
<p>- to get all available networks and its parameters.</p>
<p>UPDATE:<br />
You can create little script which will be able restart ot start you wifi connection.</p>
<pre>cat &gt; /bin/wifi-restart </pre>
<pre>#!/bin/bash

ifconfig wlan1 down
sleep 5
iwconfig wlan1 essid amber
iwconfig wlan1 key s:apple
iwconfig wlan1 rate 54M
ifconfig wlan1 up
dhclient3 wlan1</pre>
<p>Now set executable  bit on it:</p>
<pre>chmod +x /bin/wifi-restart</pre>
<p>To start or restart wifi, run it: </p>
<pre>wifi-restart</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/12/d-link-dwa-110-on-debian-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl debug</title>
		<link>http://andriigrytsenko.net/2009/12/perl-debug/</link>
		<comments>http://andriigrytsenko.net/2009/12/perl-debug/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 12:13:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=535</guid>
		<description><![CDATA[One of the perl debug way.

Perl module  PadWalker is require. Install it over cpan util:
cpan -i PadWalker 
Let&#8217;s create simple script:
$cat ./hello.pl
#!/usr/bin/perl
sub say_hello {
my $what=shift;
print "Hello $what\n";
}

my $var1="var1";
my $var2="var2";
say_hello("you");
my $var3="var3";

And try to debug it:
$ perl -dF hello.pl
Loading DB routines from perl5db.pl version 1.31
Editor support available.Enter h or `h h' for help, or `man perldebug' [...]]]></description>
			<content:encoded><![CDATA[<p>One of the perl debug way.<br />
<span id="more-535"></span></p>
<h4>Perl module  <em>PadWalker</em> is require. Install it over <em>cpan</em> util:</h4>
<pre><code>cpan -i PadWalker </code></pre>
<h4>Let&#8217;s create simple script:</h4>
<pre><code>$cat ./hello.pl</code></pre>
<pre>#!/usr/bin/perl
sub say_hello {
my $what=shift;
print "Hello $what\n";
}

my $var1="var1";
my $var2="var2";
say_hello("you");
my $var3="var3";
</pre>
<h4>And try to debug it:</h4>
<pre><code>$ perl -dF hello.pl</code></pre>
<pre>Loading DB routines from perl5db.pl version 1.31
Editor support available.Enter h or `h h' for help, or `man perldebug' for more help.main::(hello.pl:8):     say_hello("you");
DB&lt;1&gt;
</pre>
<h4>type <strong>&#8220;h&#8221;</strong> to get help.  To list  a function use <strong>&#8220;l function_name&#8221;</strong>:<br />
</h4>
<pre> DB&lt;1&gt; l say_hello
3       sub say_hello {
4:              my $what=shift;
5:              print "Hello $what\n";
6       }</pre>
<h4>To make step without entry to function use <strong>&#8220;n&#8221;</strong>. To  go through function <strong>&#8220;s&#8221;</strong></h4>
<pre> DB&lt;2&gt; s
main::say_hello(hello.pl:4):            my $what=shift;
</pre>
<h4>To return from subroutine use <strong>&#8220;r&#8221;</strong>.</h4>
<h4> use <strong>&#8220;y&#8221;</strong> to print all variables and their values or use <strong>&#8220;y variable&#8221;</strong> to print specific.</h4>
<pre> DB&lt;1&gt; y
$var1 = 'var1'
$var2 = 'var2'</pre>
<h4>and</h4>
<pre>DB&lt;1&gt; y var1
$var1 = 'var1'
</pre>
<h4> Options <strong>&#8220;M&#8221;</strong> print all used modules and path to them:</h4>
<pre> DB&lt;2&gt; M
'AutoLoader.pm' =&gt; '5.67 from /usr/local/lib/perl5/5.8.9/AutoLoader.pm'
'Carp.pm' =&gt; '1.10 from /usr/local/lib/perl5/5.8.9/Carp.pm'
...</pre>
<h4> <strong>&#8220;R&#8221;</strong> &#8211; restart the scripts.<br />
</h4>
<h4> <strong>&#8220;V&#8221;</strong> &#8211; list variables<br />
</h4>
<h4> <strong>&#8220;S&#8221;</strong> &#8211; list subroutine<br />
</h4>
<h4> <strong>&#8220;q&#8221;</strong> &#8211; for exit </h4>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/12/perl-debug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wireless connection issue</title>
		<link>http://andriigrytsenko.net/2009/12/wireless-connection-issue/</link>
		<comments>http://andriigrytsenko.net/2009/12/wireless-connection-issue/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 11:10:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=529</guid>
		<description><![CDATA[Recently I have faced with the next problem-&#62; my wireless connection time-to-time became unavailable.

I was starting investigation and figure out that my problem was the same as this. There is also workaround solution was found. First, let me describe my hardware and symptom data.
I have usb wireless adapter  D-link  DWA-110.
#lsusb
....
Bus 002 Device 004: [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have faced with the next problem-&gt; my wireless connection time-to-time became unavailable.</p>
<p><span id="more-529"></span></p>
<p>I was starting investigation and figure out that my problem was the same as <a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/200500">this</a>. There is also workaround solution was found. First, let me describe my hardware and symptom data.</p>
<p>I have usb wireless adapter  D-link  DWA-110.</p>
<pre>#lsusb
....
Bus 002 Device 004: ID 07d1:3c07 D-Link System Wireless G DWA-110 Adapter </pre>
<p>Linux kernel:</p>
<pre># uname -r
2.6.30-1-686</pre>
<p>Sometimes I observed that my network going to hung. In my logs I observer such messages:</p>
<pre>Dec 22 21:45:36 agrytsenko kernel: [52190.300066] wlan1: no probe response from AP 00:26:5a:95:8b:cc - disassociating
Dec 22 21:46:56 agrytsenko kernel: [52269.860040] wlan1: direct probe to AP 00:26:5a:95:8b:cc try 1
Dec 22 21:46:56 agrytsenko kernel: [52270.060080] wlan1: direct probe to AP 00:26:5a:95:8b:cc try 2</pre>
<p>I have written little script which restart my network:</p>
<pre>#!/bin/bash
ifconfig wlan1 down
sleep 5
iwconfig wlan1 essid amber
iwconfig wlan1 key s:apple
iwconfig wlan1 rate 54M
ifconfig wlan1 up
dhclient3 wlan1
</pre>
<p>But this way is not good idea at all. So after googling I find next solution(it&#8217;s also not complete solution, but quite better then my previous). This solution involve kernel sources. Therefore you should download it. After downloading you need to compile and install new kernel. Here is good <a href="http://andriigrytsenko.net/2009/07/linux-kernel-from-sources-for-debian/">how to</a> for Debian users.</p>
<p>Before you begin to compile new kernel and after unpacking the sources you should change one line in your sources. First, try to find it:</p>
<pre>cd /usr/src/linux
# grep -r IEEE80211_MONITORING_INTERVAL *
debian/linux-image-2.6.30/lib/modules/2.6.30/build/net/mac80211/mlme.c:#define IEEE80211_MONITORING_INTERVAL (2 * HZ)
.......</pre>
<p>So our line is found. Go there and set value to 100. Ex.:<br />
from</p>
<pre>#define IEEE80211_MONITORING_INTERVAL (2 * HZ)</pre>
<p>to</p>
<pre>#define IEEE80211_MONITORING_INTERVAL (100 * HZ)</pre>
<p>After new kernel installed and loaded my problem disappeared.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/12/wireless-connection-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use perl module without root access</title>
		<link>http://andriigrytsenko.net/2009/11/use-perl-module-without-root-access/</link>
		<comments>http://andriigrytsenko.net/2009/11/use-perl-module-without-root-access/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 14:46:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=512</guid>
		<description><![CDATA[Take this simple instruction if you need to include module (which is not installed at your system) to your perl script.


Get module and install it to directory where you have write permission (For example: /home/user1/libs).
Go to your script and add new library path to your INC array:
use lib '/home/user1/libs';
to check that it was successfully put [...]]]></description>
			<content:encoded><![CDATA[<p>Take this simple instruction if you need to include module (which is not installed at your system) to your perl script.<br />
<span id="more-512"></span></p>
<ol>
<li>Get module and install it to directory where you have write permission (For example: <em>/home/user1/libs</em>).</li>
<li>Go to your script and add new library path to your INC array:</li>
<pre>use lib '/home/user1/libs';</pre>
<p>to check that it was successfully put in INC array, print it out</p>
<pre>print "\@INC = @INC\n";</pre>
<li>Include it to your script with &#8220;<em>require</em>&#8221; or &#8220;<em>use</em>&#8221; directives.</li>
<pre>require "test.pm";</pre>
<p>or</p>
<pre>use "test.pm";</pre>
</ol>
<p style="text-align: center;"><strong>SAMPLE</strong></p>
<p>Here is some little sample how it&#8217;s work. <strong></strong></p>
<p><strong>Our module:</strong></p>
<pre>user1@agrytsenko:~/tmp2$ cat lib/test.pm
package test;

use strict;

sub say {
my $word=shift;
my $str="Hello my $word world\n";
return($str);
}
1;
__END__</pre>
<p><strong>Our script:</strong></p>
<pre>user1@agrytsenko:~/tmp2$ cat bin/test.pl
#!/usr/bin/perl

use lib '/home/user1/tmp2/lib';
require 'test.pm';

my $string=test::say("good");
print $string, "\n";</pre>
<p><strong>Our running result:</strong></p>
<pre>sheva@agrytsenko:~/tmp2/bin$ ./test.pl
Hello my good world
</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/11/use-perl-module-without-root-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wireless internet AP based on RedHat linux</title>
		<link>http://andriigrytsenko.net/2009/11/wireless-internet-ap-based-on-linux/</link>
		<comments>http://andriigrytsenko.net/2009/11/wireless-internet-ap-based-on-linux/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 02:36:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=498</guid>
		<description><![CDATA[I will try to describe how to make own home wireless access point based on RedHat linux machine.

This post include 2 part. In first one I&#8217;ll describe step which should be taken on linux machine and in second one step for windows client.
Linux(server side)
We use this host to share internet connection between users over wireless [...]]]></description>
			<content:encoded><![CDATA[<p>I will try to describe how to make own home wireless access point based on RedHat linux machine.</p>
<p><span id="more-498"></span></p>
<p>This post include 2 part. In first one I&#8217;ll describe step which should be taken on linux machine and in second one step for windows client.</p>
<h2 style="text-align: center;">Linux(server side)</h2>
<p>We use this host to share internet connection between users over wireless network, so the machine has to have at least two connection:</p>
<ol>
<li>Internet ( regular ethernet connection)</li>
<li>Wireless connection( provided by wi-fi card)</li>
</ol>
<p>I will skip how to setup your Internet connection, therefore make sure its work properly.<br />
If you mounted your wi-fi card to pci slot use <em>lspci</em> to check it out:</p>
<pre>[root@localhost ~]# lspci  | grep -i wireless
02:01.0 Ethernet controller: Atheros Communications Inc. Atheros AR5001X+ Wireless Network Adapter (rev 01)</pre>
<p>For this card kernel module <em>ath5k</em> should be loaded into the kernel. Check it:</p>
<pre>lsmod | grep ath5k</pre>
<p>Use <em>modprobe</em> unless module is not loaded.</p>
<pre>modprobe ath5k</pre>
<p>If you done it without any problem I will able to set up the wi-fi card. Here is network configuration file for interface wlan0 with some comments:</p>
<pre>[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-wlan0# Atheros Communications Inc. Atheros AR5001X+ Wireless Network Adapter
DEVICE=wlan0
ONBOOT=yes
IPADDR=192.168.0.1
NETMASK=255.255.255.0
HWADDR=00:17:9a:b7:d6:01
TYPE=Wireless
MODE=Ad-Hoc  # set this mode if want to make this card as access point
ESSID=homeee # the name of this connection which will be displayed for users
KEY=dffb9e2cc2 # secret key for connection</pre>
<p>To generate connection key run:</p>
<pre>dd if=/dev/random bs=1 count=5| xxd -ps</pre>
<p>Now restart the network service:</p>
<pre>service network restart</pre>
<p>and verify:</p>
<pre>iwconfig wlan0</pre>
<p>and</p>
<pre>ifconfig wlan0</pre>
<p>So 50% of linux part is done. Tune your kernel to make it forward ip traffic:</p>
<pre>vi /etc/sysctl.conf</pre>
<p>and set
<pre>net.ipv4.ip_forward</pre>
<p> to 1:<br />
<em>net.ipv4.ip_forward = <strong>1</strong></em><br />
Make changes affected:</p>
<pre>sysctl -p /etc/sysctl.conf</pre>
<p>Verify:</p>
<pre>sysctl -a | grep all.forwarding | grep ipv4</pre>
<p>And last but very important step. Its firewall and nat settings:<br />
!!! Be careful because this command flush all your rules in OUTPUT chain</p>
<pre>iptables -F OUTPUT</pre>
<p>turn masquerading on:</p>
<pre> iptables -t nat -I POSTROUTING -s 192.168.0.2/32 -o eth0 -j MASQUERADE</pre>
<p>where <em>eth0</em> your interface for share.<br />
save it all:</p>
<pre>service iptables save</pre>
<p>The linux router is ready on all 100%.</p>
<h2 style="text-align: center;">Windows(client side)</h2>
<p>I use windows Vista for this, but this steps can be used to Windows XP as well. Go to:<br />
<em>Start-&gt;Control Panel-&gt;Network and Internet-&gt; Network and Sharing center -&gt;  manage network connections </em><br />
Click right button on your <em>Wireless Network Connection</em> and choose <em>Properties</em>.<br />
Make double click on <em>Internet Protocol Version 4</em>.<br />
When new window is appear fill it up:<br />
<em>Ip address: 192.168.0.2<br />
Subnet mask: 255.255.255.0<br />
Default gateway: 192.168.0.1</em><br />
Also you need to specify you DNS server. Put the ip address of DNS server provided by your ISP.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/11/wireless-internet-ap-based-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Local Cent-OS repository step-by-step</title>
		<link>http://andriigrytsenko.net/2009/10/local-cent-os-repository-step-by-step/</link>
		<comments>http://andriigrytsenko.net/2009/10/local-cent-os-repository-step-by-step/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 14:28:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=486</guid>
		<description><![CDATA[There is some instruction how to make centralized repository for CentOS software.

As repository I have used my own Debian machine. Firstly, I have installed createrepo. This program generate some metadata which is necessary for RPM repository. Run
apt-get install createrepo
to install it from yum repository.  Create two directories in the DocumentRoot environment. In my case [...]]]></description>
			<content:encoded><![CDATA[<p>There is some instruction how to make centralized repository for CentOS software.</p>
<p><span id="more-486"></span></p>
<p>As repository I have used my own Debian machine. Firstly, I have installed <em>createrepo</em>. This program generate some metadata which is necessary for RPM repository. Run</p>
<pre>apt-get install createrepo</pre>
<p>to install it from yum repository.  Create two directories in the <em>DocumentRoot</em> environment. In my case its <em>/var/www/html/</em> :</p>
<pre>mkdir -pv /var/www/html/centos/5/{os,updates}/i386</pre>
<p>Now  copy packages from your CD/DVD installation disk to <em>./centos/5/os/i386</em> directory.<br />
As I have an image file I should mount it first:</p>
<pre>mount -o loop ~/CentOS-5.3-i386-bin-DVD.iso /mnt/dvd/</pre>
<p>Only after you may start to copy:</p>
<pre>cp /mnt/dvd/CentOS/* /var/www/html/centos/5/os/i386/</pre>
<p>Its can take a while.<br />
Also you need to get updates for your repository:</p>
<pre>rsync -avrt rsync://mirror.web-ster.com/centos/5/updates/i386  --exclude=debug/</pre>
<p>Take a look about more suitable rsync mirror for you <a href="http://www.centos.org/modules/tinycontent/index.php?id=30">here</a>. It&#8217;s good idea to keep this directory updated all the time via cron. </p>
<p>Generate metadata for both directories.</p>
<pre>cd /var/www/html/centos/5/os/i386/ &#038;&#038; createrepo . </pre>
<pre>cd /var/www/html/centos/5/updates/i386/ &#038;&#038; createrepo . </pre>
<p>For server side is done. Please pay attention that your web-server should be run to keep the repository available. </p>
<h3>Client side:</h3>
<p>Backup your *.repo files in your <em>/etc/yum.repos.d</em>: </p>
<pre>for i in *.repo; do mv $i $i.bak; done</pre>
<p>And new one <em>CentOS-Base.repo</em> config with next context:</p>
<pre>[base]
name=CentOS-$releasever - Base
baseurl=http://{IP address of your server}/centos/$releasever/os/$basearch/
gpgcheck=0
[update]
name=CentOS-$releasever - Updates
baseurl=http://{IP address of your server}/centos/$releasever/updates/$basearch/
gpgcheck=0</pre>
<p>This steps should be repeated for each client machine.  </p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/10/local-cent-os-repository-step-by-step/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux hard reboot and System Request Key</title>
		<link>http://andriigrytsenko.net/2009/10/linux-hard-reboot-and-system-request-key/</link>
		<comments>http://andriigrytsenko.net/2009/10/linux-hard-reboot-and-system-request-key/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 12:14:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=482</guid>
		<description><![CDATA[Sometimes we need to reboot remote machine. But all we get an error in console.

The most popular reason of this disk problems. To perform force rebooting turn on SRK feature in the kernel via proc VFS:
# sysctl -w kernel.sysrq=1 
and send command to kernel to reboot the system without unmounting file systems:
echo b > /proc/sysrq-trigger
Here [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes we need to reboot remote machine. But all we get an error in console.<br />
<span id="more-482"></span><br />
The most popular reason of this disk problems. To perform force rebooting turn on SRK feature in the kernel via proc VFS:</p>
<pre># sysctl -w kernel.sysrq=1 </pre>
<p>and send command to kernel to reboot the system without unmounting file systems:</p>
<pre>echo b > /proc/sysrq-trigger</pre>
<p>Here is some additional SRK features:<br />
• <strong>r</strong> — Disables raw mode for the keyboard and sets it to XLATE (a limited keyboard mode which<br />
  does not recognize modifiers such as Alt, Ctrl, or Shift for all keys).<br />
• <strong>k</strong> — Kills all processes active in a virtual console. Also called Secure Access Key (SAK), it is<br />
  often used to verify that the login prompt is spawned from init and not a trojan copy designed to<br />
  capture usernames and passwords.<br />
• <strong>b</strong> — Reboots the kernel without first unmounting file systems or syncing disks attached to the<br />
  system.<br />
• <strong>c</strong> — Crashes the system without first unmounting file systems or syncing disks attached to the<br />
  system.<br />
• <strong>o</strong> — Shuts off the system.<br />
• <strong>s</strong> — Attempts to sync disks attached to the system.<br />
• <strong>u</strong> — Attempts to unmount and remount all file systems as read-only.<br />
• <strong>p</strong> — Outputs all flags and registers to the console.<br />
• <strong>t</strong> — Outputs a list of processes to the console.<br />
• <strong>m</strong> — Outputs memory statistics to the console.<br />
• <strong>0-9</strong> — Sets the log level for the console.<br />
• <strong>i</strong> — Kills all processes except init using SIGKILL.<br />
• <strong>l</strong> — Kills all processes using SIGKILL (including init). The system is unusable after issuing this SR Key pre.<br />
• <strong>h</strong> — Displays help text.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/10/linux-hard-reboot-and-system-request-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing IMAP and POP3 servers over the telnet</title>
		<link>http://andriigrytsenko.net/2009/09/testing-imap-and-pop3-servers-over-the-telnet/</link>
		<comments>http://andriigrytsenko.net/2009/09/testing-imap-and-pop3-servers-over-the-telnet/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 12:49:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[pop3]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=456</guid>
		<description><![CDATA[Command list of IMAP and POP3 protocols. They can be used to test your server remotely over telnet connection.

Assume you set up pop3 and imap and want to check it out. 
POP3 
POP3 is quite simple protocol. I think you will make out how it&#8217;s work without any problem. 
First, let&#8217;s go to check the [...]]]></description>
			<content:encoded><![CDATA[<p>Command list of IMAP and POP3 protocols. They can be used to test your server remotely over telnet connection.<br />
<span id="more-456"></span></p>
<p>Assume you set up pop3 and imap and want to check it out. </p>
<p><center><strong>POP3 </strong></center><br />
POP3 is quite simple protocol. I think you will make out how it&#8217;s work without any problem. </p>
<p>First, let&#8217;s go to check the POP3 server. Make sure that it bound at port 110: </p>
<pre># netstat -lnp | grep 110
tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      2779/dovecot</pre>
<p>As you can see I use dovecot as server application and it&#8217;s works on all interfaces.<br />
Next, make connection attempt:</p>
<pre># telnet 127.0.0.1 110
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK Dovecot ready.</pre>
<p>Now, we got server answer. Do authorization with command <em>user</em> and <em>pass</em></p>
<pre>USER user1
+OK
PASS qwe
+OK Logged in.</pre>
<p>and <em>LIST</em> to see headers of all inbox mails:</p>
<pre>LIST
+OK 1 messages:
1 306
.</pre>
<p>We have only one mail. First field of answer means
<pre>mail_id</pre>
<p>.<br />
To see whole mail use <em>RETR mail_id</em>: </p>
<pre>RETR 1
+OK 306 octets
Return-Path: <fd@test.com>
Received: from d (node1 [10.0.30.1])
        by mail.test.com (8.13.8/8.13.8) with SMTP id n8ONtVLG011279
        for user1@test.com; Fri, 25 Sep 2009 03:04:08 +0300
Date: Fri, 25 Sep 2009 03:04:08 +0300
From: fd@test.com
Message-Id: <200909250004.n8ONtVLG011279@mail.test.com>
test</pre>
<p>To delete it:</p>
<pre>DELE 1
+OK Marked to be deleted.</pre>
<p>This message marked as deleted and will be removed when you send command <em>QUIT</em> to server. To unmark messages use command <em>RSET</em> without any arguments:</p>
<pre>RSET
+OK</pre>
<p>Use command <em>QUIT</em> to leave the server.</p>
<pre>QUIT
+OK Logging out.</pre>
<p>Refer to <a href="http://www.faqs.org/rfcs/rfc1939.html">RFC 1939</a> for more details.</p>
<p><center><strong>IMAP</strong></center><br />
By default IMAP listen port 143. Therefore let&#8217;s check it first:
<pre>
# netstat -lnp | grep 143
tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      2779/dovecot</pre>
<p>Try to connect: </p>
<pre># telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
* OK Dovecot ready.</pre>
<p>Okay, we have got good answer. Now, we should authorize on server. Syntax is:<br />
<em>? LOGIN USER/ALIAS PASSWORD</em></p>
<p>For example:</p>
<pre>? login user1 qwe
? OK Logged in.</pre>
<p>To get folders list make: </p>
<pre>? LIST "" "*"
* LIST (\NoInferiors \UnMarked) "/" "INBOX"
? OK List completed.</pre>
<p>In folder INBOX contain all incoming messages. To select it: </p>
<pre>? SELECT INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 1 EXISTS
* 0 RECENT
* OK [UNSEEN 1] First unseen.
* OK [UIDVALIDITY 1253837819] UIDs valid
* OK [UIDNEXT 2] Predicted next UID
? OK [READ-WRITE] Select completed.</pre>
<p><em>1 EXISTS</em> &#8211; means 1 incoming message. You can choose between see full message or only message body instead:<br />
<em>? FETCH message_number All</em><br />
OR<br />
<em>? FETCH message_number Body</em></p>
<p>Let&#8217;s see whole message:</p>
<pre>? FETCH 1 all
* 1 FETCH (FLAGS () INTERNALDATE "25-Sep-2009 03:04:12 +0300" RFC822.SIZE 306 ENVELOPE ("Fri, 25 Sep 2009 03:04:08 +0300" NIL ((NIL NIL "fd" "test.com")) ((NIL NIL "fd" "test.com")) ((NIL NIL "fd" "test.com")) NIL NIL NIL NIL "<200909250004.n8ONtVLG011279@mail.test.com>"))
? OK Fetch completed.</pre>
<p>Exit user command  is <em>? LOGOUT</em>. </p>
<p>To learn more about IMAP refer to <a href="http://www.faqs.org/rfcs/rfc3501.html">RFC 3501</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/09/testing-imap-and-pop3-servers-over-the-telnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reset mysql password in several steps.</title>
		<link>http://andriigrytsenko.net/2009/08/reset-mysql-password-in-several-steps/</link>
		<comments>http://andriigrytsenko.net/2009/08/reset-mysql-password-in-several-steps/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 19:52:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=437</guid>
		<description><![CDATA[Make new password for mysql user in 5 simple steps.

1.Stop mysql server:
#service mysql stop
2.Start in safe mode(use Ctrl+Z to send process to background):
#/usr/bin/mysqld_safe --skip-grant-tables --user=root &#038;
3.Login as root:
#mysql -u root
4.Make mysql execute next queries:
UPDATE mysql.user SET Password=PASSWORD(’newpwd’) WHERE User=’root’;
FLUSH PRIVILEGES;
exit;
Where newpwd is a new password for mysql user &#8220;root&#8221;.
5.Restart mysql:
#service mysql restart
Now you are ready [...]]]></description>
			<content:encoded><![CDATA[<p>Make new password for mysql user in 5 simple steps.<br />
<span id="more-437"></span></p>
<p>1.Stop mysql server:</p>
<pre>#service mysql stop</pre>
<p>2.Start in safe mode(use <em>Ctrl+Z</em> to send process to background):</p>
<pre>#/usr/bin/mysqld_safe --skip-grant-tables --user=root &#038;</pre>
<p>3.Login as root:</p>
<pre>#mysql -u root</pre>
<p>4.Make mysql execute next queries:</p>
<pre>UPDATE mysql.user SET Password=PASSWORD(’newpwd’) WHERE User=’root’;
FLUSH PRIVILEGES;
exit;</pre>
<p>Where <em>newpwd</em> is a new password for mysql user &#8220;root&#8221;.<br />
5.Restart mysql:</p>
<pre>#service mysql restart</pre>
<p>Now you are ready to connect to server with new password.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/08/reset-mysql-password-in-several-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Login restriction by time over pam.d</title>
		<link>http://andriigrytsenko.net/2009/08/login-restriction-by-time-over-pam-d/</link>
		<comments>http://andriigrytsenko.net/2009/08/login-restriction-by-time-over-pam-d/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 15:53:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[pam]]></category>
		<category><![CDATA[redhat]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=423</guid>
		<description><![CDATA[If you I want to allow users log in in to system only at working hours use pam_time.so module. This example works on CentOS and I suspect that it will be work at RHEL as well.

We should edit to files for this:
/etc/pam.d/login
/etc/security/time.conf
Let&#8217;s begin from first one. Put next line into the file:
account    [...]]]></description>
			<content:encoded><![CDATA[<p>If you I want to allow users log in in to system only at working hours use pam_time.so module. This example works on CentOS and I suspect that it will be work at RHEL as well.</p>
<p><span id="more-423"></span></p>
<p>We should edit to files for this:<br />
<em>/etc/pam.d/login<br />
/etc/security/time.conf</em></p>
<p>Let&#8217;s begin from first one. Put next line into the file:</p>
<pre>account    required     pam_time.so</pre>
<p>after that go to the <em>/etc/security/time.conf</em>, and insert next:</p>
<pre>login;tty*;user1|user2|user3;Wk0009-1800 &#038; !Wd0000-2400</pre>
<p>where<br />
<em>login</em> &#8211; the type of pam service<br />
<em>tty*</em> &#8211; terminal name(in this case all terminal ttyXXX, you also specify defined terminal as well)<br />
<em>user1|user2|user3</em> &#8211; users or user name which should be restricted<br />
<em>Wk0009-1800 &#038; !Wd0000-2400</em> &#8211; time frame. Time where actions is allowed. To inverse it put &#8220;!&#8221; before.  There is 7 types of day:<br />
<em>Mo Tu We Th Fr Sa Su Wk Wd Al</em><br />
First seven is according to weeks day.<br />
<em>Wk</em>  &#8211; means all work days(Mo-Fr)<br />
<em>Wd</em> &#8211; it&#8217;s week end(Sa,SU)<br />
<em>Al</em> &#8211; all days of week.</p>
<p>Now, you new rules was applied. And users user1, user2, user3 can&#8217;t log on system at no working time. No restart is required. </p>
<p>But we still have one problem. Users which logined at work time can be continuous use system without problem. To prevent this situation I have written little <a href="http://andriigrytsenko.net/files/time.txt">script</a>.</p>
<p>Rename it to <em>time.sh</em> and put anywhere at your system. After this new crontab entry should be added:</p>
<pre>crontab -e</pre>
<pre>55 17 * * 1-5    /path/to/time.sh</pre>
<p>Now all session will be destroyed at the end of working day and script notify user via user&#8217;s terminal 5 minutes before this. After that nobody from specified users can&#8217;t log in to the system.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/08/login-restriction-by-time-over-pam-d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to export NFS home directories over the Autofs</title>
		<link>http://andriigrytsenko.net/2009/08/how-to-export-nfs-home-directories-over-the-autofs/</link>
		<comments>http://andriigrytsenko.net/2009/08/how-to-export-nfs-home-directories-over-the-autofs/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 03:16:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[autofs]]></category>
		<category><![CDATA[nfs]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=417</guid>
		<description><![CDATA[Step-by-step instruction to get benefits from NFS and Autofs.

We have two machines as always:

srv2: has NFS server and a lot of disk space.(IP 10.0.30.2)
srv1: has users and autofs daemon(IP 10.0.30.1)

Go to srv1 and make new user: 
srv1#adduser user1
Get id: 
srv1#id user1
uid=500(user1) gid=500(user1) groups=500(user1)
Open console on srv2 and make directory for home&#8217;s directoies:
srv2#mkdir /export_home
now make directory [...]]]></description>
			<content:encoded><![CDATA[<p>Step-by-step instruction to get benefits from NFS and Autofs.</p>
<p><span id="more-417"></span></p>
<p>We have two machines as always:</p>
<ul>
<li>srv2: has NFS server and a lot of disk space.(IP 10.0.30.2)</li>
<li>srv1: has users and autofs daemon(IP 10.0.30.1)</li>
</ul>
<p>Go to srv1 and make new user: </p>
<pre>srv1#adduser user1</pre>
<p>Get id: </p>
<pre>srv1#id user1
uid=500(user1) gid=500(user1) groups=500(user1)</pre>
<p>Open console on srv2 and make directory for home&#8217;s directoies:</p>
<pre>srv2#mkdir /export_home</pre>
<p>now make directory for specific user(user1):</p>
<pre>srv2#mkdir /export_home/user1</pre>
<p>and set proper owner:</p>
<pre>srv2#chown 501 /export_home/user1</pre>
<p>!!!where 501 owner ID which is got  from srv1.</p>
<p>Next step is NFS configuration at srv2. Open <em>/etc/exports</em> and add new share point:</p>
<pre>/export_home/user1     10.0.30.1(rw)</pre>
<p>After changes is done reload services and put into boot:</p>
<pre>/etc/init.d/nfs reload
chkconfig --level 45 nfs on</pre>
<p>srv2 is completely done. Back to srv1:<br />
Add new line into <em>/etc/auto.master</em>:</p>
<pre>/home   /etc/auto.home</pre>
<p>It&#8217;s pointed at new configuration file which will define mount point for /home directory. Put next line into it(<em>/etc/auto.home</em>):</p>
<pre>user1            -rw,soft,intr           10.0.30.2:/export_home/user1</pre>
<p>This line means mount NFS share <em>/export_home/user1</em> from server 10.0.30.2 into local directory <em>/home/user1</em>. Restart autofs daemon to make changes take effect:</p>
<pre>/etc/init.d/autofs restart</pre>
<p>Now when you log in into system as user1 the NFS share from remote host will mount as your home directory. And will be unmount in timeout(300 seconds by default) after you have logged out.</p>
<p>Also you can put together this system with NIS so as to use common user database. As benefits you will get very flexible system and simplified user management.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/08/how-to-export-nfs-home-directories-over-the-autofs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH connection without password</title>
		<link>http://andriigrytsenko.net/2009/08/ssh-connection-without-password/</link>
		<comments>http://andriigrytsenko.net/2009/08/ssh-connection-without-password/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 14:53:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=400</guid>
		<description><![CDATA[SSH password-less log in method.

Let&#8217;s imagine that we have 2 hosts.

 Host A with user1 is your local host from which you will connect to remote.
Host B with user2 is remote host where you want to log in as user2.

Run
ssh-keygen
 as user1 on Host A to generate keys unless old one is exist. When I [...]]]></description>
			<content:encoded><![CDATA[<p>SSH password-less log in method.<br />
<span id="more-400"></span></p>
<p>Let&#8217;s imagine that we have 2 hosts.</p>
<ul>
<li> Host A with user1 is your local host from which you will connect to remote.</li>
<li>Host B with user2 is remote host where you want to log in as user2.</li>
</ul>
<p>Run
<pre>ssh-keygen</pre>
<p> as user1 on Host A to generate keys unless old one is exist. When I will be prompted to enter  passphrase just keep it blank. This command generate RSA key with long in 2048 bit:</p>
<pre>ssh-keygen -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user1/.ssh/id_rsa):
/home/user1/.ssh/id_rsa already exists.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user1/.ssh/id_rsa.
Your public key has been saved in /home/user1/.ssh/id_rsa.pub.
The key fingerprint is:
9e:f0:44:4a:e2:81:72:02:0b:3c:b5:3d:be:a7:c2:95 user1@host_a
The key's randomart image is:
+--[ RSA 2048]----+
...
+-----------------+
</pre>
<p>After it&#8217;s done check content of your <em>id_rsa.pub</em> file:</p>
<pre>host_a:~# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzU6SlO7EZksPGmLTz3EcMpFQXME9otJ4vWqQ1Nnzd0g0FX5MS
/H1m2xJWCLfgsWTWyOP7hHQufPrzY5kqJkeF0tgOSPHnzDQt4YBE1Xi0ihR/cDK+KHOlIFG4kHlEs/ThTDpD0mwgBC755Tu5g2GOW3ogsrViZbyfa72HJQaEbISZwfiPnJUwmtGJ/+PQiEoN8cgK1zrk8oVnlguK0V52ZygFuvNKd6jmKIiDKOcQ2ZIobu6jYVd/Nit1gg+9llbuAdXDFn24AdNHatBzvlwb76yYa/ZAwZQKzytWca0NnMMwMeQ== user1@host_a</pre>
<p>Copy it and log in remote Host B as user2. And append it to <em>authorized_keys</em> file:</p>
<pre>$ cat &gt;&gt; /home/grytsenko/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzU6SlO7EZksPGmLTz3EcMpFQXME9otJ4vWqQ1Nnzd0g0FX5MS
/H1m2xJWCLfgsWTWyOP7hHQufPrzY5kqJkeF0tgOSPHnzDQt4YBE1Xi0ihR/cDK+KHOlIFG4kHlEs/ThTDpD0mwgBC755Tu5g2GOW3ogsrViZbyfa72HJQaEbISZwfiPnJUwmtGJ/+PQiEoN8cgK1zrk8oVnlguK0V52ZygFuvNKd6jmKIiDKOcQ2ZIobu6jYVd/Nit1gg+9llbuAdXDFn24AdNHatBzvlwb76yYa/ZAwZQKzytWca0NnMMwMeQ== user1@host_a</pre>
<p>Set proper permissions for file:</p>
<pre>user2@host_b:~$ chmod 600 ~/.ssh/authorized_keys</pre>
<p>Now you are ready to log in without password from Host A:</p>
<pre>host_a~# ssh -p 443 user2@host_b
Linux host_b 2.6.18-5-686 #1 SMP Fri Jun 1 00:47:00 UTC 2007 i686</pre>
<p>That&#8217;s all folks:).</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/08/ssh-connection-without-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quickstart: backup on hard disk with AMANDA</title>
		<link>http://andriigrytsenko.net/2009/07/quick-start-backup-on-hard-disk-with-amanda/</link>
		<comments>http://andriigrytsenko.net/2009/07/quick-start-backup-on-hard-disk-with-amanda/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 12:10:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[amanda]]></category>
		<category><![CDATA[backup]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=370</guid>
		<description><![CDATA[In this post I will explain how to backup data to hard disk instead of tape with amanda backup tools over the network.

!!!CATION: Use this information on your own risk. Please remember that every step should be double checked unless you want to lose your data.
Preamble
I have two host and one of them will be [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I will explain how to backup data to hard disk instead of tape with amanda backup tools over the network.<br />
<span id="more-370"></span></p>
<p><span style="color: #ff0000;">!!!CATION: Use this information on your own risk. Please remember that every step should be double checked unless you want to lose your data.</span></p>
<p><strong>Preamble</strong><br />
I have two host and one of them will be used as backup server another as backup client:</p>
<ul>
<li>node1 &#8211; uses as client it will be backuped side. It&#8217;s critical server and directory <em>/etc</em> should be backuped as well.</li>
<li>node2 &#8211; backup server which has good RAID equipment for backup mounted at <em>/opt/backups</em>.</li>
</ul>
<p>Let&#8217;s start from server side:</p>
<p><strong>SERVER SIDE</strong></p>
<p>Go to the node2 and get all needed software</p>
<pre>yum install amanda
yum install amanda-client
yum install amanda-server</pre>
<p>After that we are ready to start server in over xinetd. Go to the <em>/etc/xinetd.d</em> directory and set directive
<pre>disable</pre>
<p> to
<pre>no</pre>
<p> in files : amanda, amandaidx and amidxtape.</p>
<pre>service amanda
{
socket_type             = dgram
protocol                = udp
wait                    = yes
user                    = amanda
group                   = disk
server                  = /usr/lib/amanda/amandad
disable                 = no
}
service amandaidx
{
socket_type             = stream
protocol                = tcp
wait                    = no
user                    = amanda
group                   = disk
server                  = /usr/lib/amanda/amindexd
disable                 = no
}
service amidxtape
{
socket_type             = stream
protocol                = tcp
wait                    = no
user                    = amanda
group                   = disk
server                  = /usr/lib/amanda/amidxtaped
disable                 = no
}</pre>
<p>to make new configuration works, restart xinted daemon:</p>
<pre>/etc/init.d/xinetd restart</pre>
<p>Check that everything is running:</p>
<pre>netstat -a | grep amand</pre>
<p>You should get something like that:</p>
<pre>tcp        0      0 *:amandaidx                 *:*                         LISTEN
udp        0      0 *:amanda                    *:*</pre>
<p>Make changes at .amandahosts allow users  amanda and root from host localhost connect to server:</p>
<pre>cat /var/lib/amanda/.amandahosts
localhost amanda  amindexd amidxtaped amdump
localhost.localdomain amanda  amindexd amidxtaped amdump
localhost root amindexd amidxtaped
localhost.localdomain root amindexd amidxtaped
node1 root  amindexd amidxtaped amdump</pre>
<p>Set properly permissions to protect config from illegal access :</p>
<pre>chmod 600 /var/lib/amanda/.amandahosts</pre>
<p>I will store backups at local hard disk.Mount point is <em>/opt/backups</em>. First, make directory with read-write permissions for user amanda:</p>
<pre>mkdir /opt/backups
chown amanda /opt/backups</pre>
<p>Next step, check value in
<pre>tapecycle</pre>
<p> at your <em>amanda.conf</em>. In my case it&#8217;s 25. That means that I should have 25 virtual tapes at my <em>/opt/backups</em>. Let&#8217;s create it and label, put in console next line:</p>
<pre>i=1; while [ $i -lt 26 ]; do mkdir -v /opt/backups/slot$i; let i=i+1; done</pre>
<p>also make symlink to first tape:</p>
<pre>ln -s /opt/backups/slot1 /opt/backups/data</pre>
<p>and set owner:</p>
<pre>chown -R amanda.disk /opt/backups/</pre>
<p>Now, login as amanda and label slots:</p>
<pre>su - amanda
i=1; while [ $i -lt 26 ]; do /usr/sbin/amlabel DailySet1 DailySet1-$i slot $i; let i=i+1;  done</pre>
<p>Check is everything labeled properly:</p>
<pre>/usr/sbin/amtape DailySet1 show</pre>
<p>Let&#8217;s take a look at amanda.conf. It&#8217;s located at <em>/etc/amanda/DailySet1</em>.</p>
<p>Below describe some change in configuration file which should be done.<br />
Add new section into your amanda.conf :</p>
<pre>define tapetype HARD-DISK {
comment "On Hard Disk"
length 3000 mbytes
}</pre>
<p>Specify directory for backups:</p>
<pre>tapedev "file:/opt/backups"</pre>
<p>and change
<pre>tapetype</pre>
<p> to
<pre>HARD-DISK</pre>
<pre>tapetype HARD-DISK</pre>
<p>In section
<pre>define dumptype global</pre>
<p> comment out and set to yes next:</p>
<pre>index yes
record yes
</pre>
<p>Change
<pre>tpchanger</pre>
<p> to this:</p>
<pre>tpchanger "chg-disk"</pre>
<p>If you have CentOS and Amanda Version 2.5.0p2  set chunksize to 0:</p>
<pre>chunksize 0</pre>
<p>to prevent errors concerning with recovery.</p>
<p>There is listing of main configuration file <a href="http://andriigrytsenko.net/files/amanda.conf">amanda.conf</a>:</p>
<p>Next files and directories should be created set owner to user amanda:</p>
<pre>touch /etc/amanda/DailySet1/tapelist
chown amanda /etc/amanda/DailySet1/tapelist
mkdir -p /dumps/amanda
chown amanda /dumps/amanda
mkdir /etc/amanda/DailySet1/curinfo
mkdir /etc/amanda/DailySet1/index
chown amanda /etc/amanda/DailySet1/index
chown amanda /etc/amanda/DailySet1/curinfo
mkdir  /etc/amanda/DailySet1/curinfo/localhost
chown amanda /etc/amanda/DailySet1/curinfo/localhost
mkdir  /etc/amanda/DailySet1/index/localhost
chown amanda /etc/amanda/DailySet1/index/localhost
mkdir /etc/amanda/DailySet1/curinfo/localhost/_etc
mkdir  /etc/amanda/DailySet1/index/localhost/_etc
chown amanda  /etc/amanda/DailySet1/index/localhost/_etc
chown amanda  /etc/amanda/DailySet1/curinfo/localhost/_etc
touch /etc/amanda/DailySet1/curinfo/localhost/_etc/info
chown amanda  /etc/amanda/DailySet1/curinfo/localhost/_etc/info</pre>
<p>Also very important file disklist located at <em>/etc/amanda/DailySet1</em>. Its consist all targets which have to backuped.</p>
<pre>cat disklist
node1 /etc comp-root-tar</pre>
<p><strong>CLIENT SIDE</strong></p>
<p>First, you should install software:</p>
<pre>yum install amanda-client</pre>
<p>and edit access file:</p>
<pre>cat /var/lib/amanda/.amandahosts
localhost amanda amindexd amidxtaped amdump
localhost  root amindexd amidxtaped
node2 amanda amindexd amidxtaped amdump
node2 root amindexd amidxtaped</pre>
<p>Set properly permissions:</p>
<pre>chmod 600 /var/lib/amanda/.amandahosts</pre>
<p>And last step enable amanda in xinetd as was mentioned above. Set
<pre>disable = no</pre>
<p> at <em>/etc/xinetd.d/amanda</em> and restart xinetd:</p>
<pre>/etc/init.d/xinetd restart</pre>
<p><strong>LITTLE PRACTISE</strong></p>
<p>Make test file at client side(node1) :</p>
<pre>echo "test"  &gt; /etc/testing</pre>
<p>To make backup go to the node2 login as amanda and run
<pre>amdump</pre>
<pre>su - amanda
/usr/sbin/amdump  DailySet1 node1</pre>
<p>Now you are ready to restore any file from backup. Go back to node1 and delete test file:</p>
<pre>rm /etc/testing</pre>
<p>Try to restart it over the amrecovery.</p>
<pre>amrecovery -t node2 -s node2</pre>
<p>if you get interactive mode type:
<pre>
&gt; sethost node1
&gt; setdisk /etc
&gt; add testing
&gt; lcd /etc
&gt; extract </pre>
<p>type &#8220;y&#8221; twice when you be prompted. Go to the <em>/etc</em> and check if was file restored:</p>
<pre>cat /etc/testing
test</pre>
<p>As you can see we successfully recover file which was mistaken delete.</p>
<p>!!!Keep in mind that in case of node1 will be failed date could be recovered from node2 as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/07/quick-start-backup-on-hard-disk-with-amanda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
