Tikejhya: Ashish Nepal

Knowledgebase

Month: November 2011 (Page 1 of 2)

Total Memory Usage Calculation

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

Print Total sum of actual Memory Usages

ps aux | awk '{sum +=$4}; END {print sum}'

Check Actual Memory Consumption
free -m

Check total usage of One particular process

ps aux | awk '{print $4,$11}' | sort |tail -n 23 |grep -w 'someprocess' |wc -l

All most consuming process

ps aux | awk '{print $4,$11}' | sort |tail -n 20

use of uninitialized value in subsitution at mytop line xx

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

use of uninitialized value in subsitution at mytop line xx

Remove this line

$host =~ s/^([^.]+).*/$1/;
$thread->{Host} = $host;

Replace with this

if ($host)
	{
		$host =~ s/^([^.]+).*/$1/;
		$thread->{Host} = $host;
	}

}

PEB INSTALLATION

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

PEB INSTALLATION

1 Download and compile peb

http://code.google.com/p/mypeb/downloads/list

$ wget http://mypweb.googlecode.com/files/peb-***.tar.gz
$ tar xzvf peb-***.tar.gz
$ cd peb-***
$ phpize
$ ./configure –enable-peb
$ make
$ make install

2 Enable peb module in your php.ini:

extension=peb.so

3 run test script in peb-****/tests

If error on finding ei.h and other files
find / -name those files and provide extra library parameter

EXTRA_LDFLAGS = -L/usr/lib64/erlang/lib/erl_interface-3.5.9/lib
EXTRA_LIBS = -L/usr/lib64/erlang/lib/erl_interface-3.5.9/lib

Prevent logging something lighttpd

IN some case you may well want to prevent logging in lighttpd

$HTTP["url"] =~ "(?i).*.(something to not log)(?.*)?$" {
  accesslog.filename = "/dev/null"
}

Password Policy

vi /etc/login.defs

PASS_MAX_DAYS 90
PASS_MIN_DAYS 0
PASS_MIN_LEN 10
PASS_WARN_AGE 7

vi /etc/default/useradd
INACTIVE=-1
EXPIRE=

/usr/bin/chage -M 90 -W 14 ashish.nepal

vi /etc/pam.d/system-auth
password required pam_cracklib.so retry=3 minlen=10 dcredit=1 ocredit=2

Mytop Centos 5.6 Mysql Version : 5.5.16

Mytop

Server Tested : Centos 5.6 64bit
Mysql Version : 5.5.16 (Compile)
Download Package: http://jeremy.zawodny.com/mysql/mytop/
tar -zxvf mytop-.tar.gz
cd mytop-
perl Makefile.PL
make
make install

Possible Errors:
Warning: prerequisite DBD::mysql 1 not found.
Warning: prerequisite DBI 1.13 not found.
Warning: prerequisite Term::ReadKey 2.1 not found.

Solution
perl-Class-Data-Inheritable-0.08-1.el5.rf.noarch.rpm
perl-DBD-MySQL-4.014-1.el5.rfx.x86_64.rpm
perl-DBI-1.616-1.el5.rfx.x86_64.rpm
perl-DBIx-ContextualFetch-1.03-1.el5.rf.noarch.rpm
perl-Ima-DBI-0.35-1.el5.noarch.rpm
perl-Ima-DBI-0.35-1.el5.src.rpm
perl-TermReadKey-2.30-4.el5.x86_64.rpm

Available to download @ http://rpm.pbone.net/

Mytop
mytop is a console-based (non-gui) tool for monitoring the threads
and overall performance of a MySQL server.
It runs on most Unix systems which have Perl,
DBI, and Term::ReadKey installed. And with Term::ANSIColor installed
you even get color.

If you install Time::HiRes, you’ll get good real-time queries/second stats.
As of version 0.7, it even runs on Windows (somewhat).

Sendmail SMART_HOST Relay -Howto

# Creating Relay with external mail server
# (lets take relay external mail server as ashish.com)

Open your configuration file:

# vi /etc/mail/sendmail.mc

Append or modify macro that read as follows :

define(`SMART_HOST',`myrelay.ashishnepal.com')
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Restart sendmail service:

# /etc/init.d/sendmail restart

Problem: /etc/mail/sendmail.mc:10: m4: Cannot open /usr/share/sendmail-cf/m4/cf.m4:

yum install sendmail-cf

Problem: ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30053, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]

This is potentially due to your mail service is not running or amavisd is looping into localhost
Lets assume you are using sendmail

# killall -9 sendmail
# /etc/init.d/sendmail start

Grep Pattern matching

tail -100 /var/log/httpd/access_log | grep -E ’20:[0-9]|22:[0-9]’

this will show only logs from 20:00 hour and 22:00 hours.. 😀

TEST YOUR SERVER PERFORMANCE

How to test your SERVER PERFORMANCE in various ways

Network /PING / MTR / TRACEROUTE
DISK / SAN / Connection

How to Test You Network.

PING

ping -l 1024 www.google.com

Check the result of packet loss (%) if any

MTR

mtr -c 100 -o SRDLBA google.com
mtr -c 100 -o SRDLBA local.domain.com

-c 100 = count 100 Number of ping sent.
-o = output order
SRDLBA – sent, recived, drop, loss, best, average

May be you would like to test,

how your disk performance is,

Make a desired directory,

cd /root/removeme/; rm -rf /root/removeme/*; sync; echo 3 > /proc/sys/vm/drop_caches; sleep 10; time tar -czf usrtest.tar.gz /usr; echo 0 > /proc/sys/vm/drop_caches;

# with cache

cd /root/removeme/; rm -rf /root/removeme/*;  time tar -czf usrtest.tar.gz /usr; rm -rf /root/removeme/*;

# without cache

cd /tmp; rm -rf /tmp/ashish.img*; time dd if=/dev/zero of=/tmp/ashish.img bs=1M count=1024;

#writing 1GB /dev/zero made img file

cd /tmp; time tar -cjf ashish.img.tar.bz2 /tmp/ashish.img; rm -rf /tmp/ashish.img*;

#taring file

Lighttpd Redirect all http to https

::::::::::::::::::::::::::::::::::::
Lighttpd, Redirect all http to https
::::::::::::::::::::::::::::::::::::

$SERVER["socket"] == ":80" {
  $HTTP["host"] =~ "(.*)" {
    url.redirect = ( "^/(.*)" => "https://%1/$1" )
  }
}

Page 1 of 2

Powered by WordPress & Theme by Anders Norén