Thursday, 7 November 2013

Command to check load in all the VPS in a nodes

vzlist -o hostname,laverage,veid

HOSTNAME         LAVERAGE       VEID

Redirect Rule not working

We faced an issue recently where a redirect rule was not working irrespective of correctly specifying in .htaccess file. We checked in several ways but the issue was not resolved. Finally, my fellow admin suggested we add it directly in the virtual host in apache config file of the domain. And it worked!!!!.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^webmail.yourdomainname.com
RewriteRule ^/(.*)$https://www.google.com/a/yourdomainname.com/$1  [L,R=301]

How to find max apache connections to a domain from IPs

You can use the following script to determine the IP/IPs from which maximum apache connections were made to the domain.

less /usr/local/apache/domlogs/domain.com | awk ‘{print $1}’ | sort | uniq -c | sort -n

use tcpdump command to check connections to port 80

You can use the following command to get the connections to port 80:
tcpdump -nn ‘tcp[13] == 2′ and port 80 -c 100 -i any

vzquota : (error) quota file is corrupted

If you get error “vzquota : (error) quota file is corrupted”

Use below commands,

# vzquota off 5000

vzquota : (error) quota file is corrupted

# vzquota drop  5000

# vzctl start 5000
Starting container …
Initializing quota …

Now wait for quota to get recreated

How to install iftop in Linux servers

iftop is a command line tool that shows a list of active network connections between local host and any remote host, sorted by their bandwidth usage. The list of top-ranking network connections (in terms of bandwith usage) is periodically refreshed in a text-based user interface. Using iftop, you can visually check the bidirectional bandwidth usage of different network connections in real time. In order to install iftop on Linux, follow the instructions below.

If you would like to build and install the latest version of iftop manually, do the following.
$ yum -y install ncurses-devel libpcap-devel
$ wget http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.17.tar.gz
$ tar xvfvz iftop-0.17.tar.gz
$ cd iftop-0.17
$ ./configure
$ make
$ make install

How to clear eximstats db

If the size of your eximstats database is getting large, you can do the following steps to clear it.

Login to mysql

mysql

mysql> use eximstats
mysql> delete from sends;
mysql> delete from smtp;
mysql> delete from failures;
mysql> delete from defers;

You can also use the following steps.

mysqladmin drop eximstats

mysqladmin create eximstats

mysql eximstats < /usr/local/cpanel/etc/eximstats_db.sql