EZ Linux Admin random header image

Reset an accounts bandwidth in CPanel

June 23rd, 2010 by EZ linux · No Comments

  1. ssh to your server
  2. cd /var/cpanel/bandwidth.cache/
  3. vi domainname.com
  4. delete the numbers in that file and retype 0 instead of the number
  5. save and quit and show bandwidth usage in WHM you will find its 0

→ No Comments Tags: Cpanel and WHM


Clear bash history through ssh command line

May 30th, 2010 by EZ linux · 1 Comment

history -c

→ 1 Comment Tags: Linux Commands


Path to date

May 24th, 2010 by EZ linux · No Comments

The server path to date can very for different servers, you will need to run this command to find it:

which date

For most servers it is:

/bin/date

This is the same for perl and php

→ No Comments Tags: Cheat Sheets · Linux Commands · Linux Operating Systems


setroubleshoot bug

May 24th, 2010 by EZ linux · No Comments

There is a bug with the new option in Centos 5 called setroubleshoot.

The bug spins the program over and over causing high memory and sometimes CPU use. Unfortunately there is no permanent fix yet, but if you see something like this high in your daily process log:

/usr/bin/python -E /usr/sbin/setroubleshootd

To fix for now you simply have to restart the process:

/etc/init.d/setroubleshoot restart

For a long term fix f this problem click here: setroubleshootd bug

→ No Comments Tags: Cpanel and WHM · Linux Commands · Linux Software / Scripts


CPanel transfer error

May 8th, 2010 by EZ linux · No Comments

First try to upgrade perl this is the main reason for a cpanel error.

http://www.ezlinuxadmin.com/2009/08/upgrading-perl-on-cpanel/

After that if you still have a issue run this:

/scripts/perlinstaller –force YAML::Syck

or Install the YAML::Syck perl module in whm under module installers.

→ No Comments Tags: Cpanel and WHM


fsck

April 9th, 2010 by EZ linux · No Comments

fsck -a

Will automatically fix errors.

→ No Comments Tags: Cheat Sheets


Upgrading a realtech lan / nic driver

April 5th, 2010 by EZ linux · 1 Comment

The driver for the realtech lan / nic card seems to be faulty when rsync is running several files through it. There is a newer driver that resolves this issue available from the realtech website.

Website Driver Download
Here is direct link to the driver from our website:

http://www.downloadspot.com/downloads/r8168-8.018.00.tar.bz2

Upload the driver to your root directory, then run these commands.

tar vjxf r8168-8.018.00.tar.bz2

cd r8168-8.018.00

./autorun.sh

Run this to check the driver details

dmesg | grep ‘Ethernet driver’

Read me files for driver:

<Linux device driver for Realtek Ethernet controllers>

This is the Linux device driver released for RealTek RTL8168B/8111B, RTL8168C/8111C, RTL8168CP/8111CP, RTL8168D/8111D, RTL8168DP/8111DP, and RTL8168E/8111E Gigabit Ethernet controllers with PCI-Express interface.

<Requirements>

- Kernel source tree (supported Linux kernel 2.6.x and 2.4.x)
- For linux kernel 2.4.x, this driver supports 2.4.20 and latter.
- Compiler/binutils for kernel compilation

<Quick install with proper kernel settings>
Unpack the tarball :
# tar vjxf r8168-8.aaa.bb.tar.bz2

Change to the directory:
# cd r8168-8.aaa.bb

If you are running the target kernel, then you should be able to do :

# ./autorun.sh    (as root or with sudo)

You can check whether the driver is loaded by using following commands.

# lsmod | grep r8168
# ifconfig -a

If there is a device name, ethX, shown on the monitor, the linux
driver is loaded. Then, you can use the following command to activate
the ethX.

# ifconfig ethX up

,where X=0,1,2,…

<Set the network related information>
1. Set manually
a. Set the IP address of your machine.

# ifconfig ethX “the IP address of your machine”

b. Set the IP address of DNS.

Insert the following configuration in /etc/resolv.conf.

nameserver “the IP address of DNS”

c. Set the IP address of gateway.

# route add default gw “the IP address of gateway”

2. Set by doing configurations in /etc/sysconfig/network-scripts
/ifcfg-ethX for Redhat and Fedora, or /etc/sysconfig/network
/ifcfg-ethX for SuSE. There are two examples to set network
configurations.

a. Fixed IP address:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=ethernet
NETMASK=255.255.255.0
IPADDR=192.168.1.1
GATEWAY=192.168.1.254
BROADCAST=192.168.1.255

b. DHCP:
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

<Modify the MAC address>
There are two ways to modify the MAC address of the NIC.
1. Use ifconfig:

# ifconfig ethX hw ether YY:YY:YY:YY:YY:YY

,where X is the device number assigned by Linux kernel, and
YY:YY:YY:YY:YY:YY is the MAC address assigned by the user.

2. Use ip:

# ip link set ethX address YY:YY:YY:YY:YY:YY

,where X is the device number assigned by Linux kernel, and
YY:YY:YY:YY:YY:YY is the MAC address assigned by the user.

<Force Link Status>

1. Force the link status when insert the driver.

If the user is in the path ~/r8168, the link status can be forced
to one of the 5 modes as following command.

# insmod ./src/r8168.ko speed=SPEED_MODE duplex=DUPLEX_MODE autoneg=NWAY_OPTION

,where
SPEED_MODE    = 1000    for 1000Mbps
= 100    for 100Mbps
= 10    for 10Mbps
DUPLEX_MODE    = 0    for half-duplex
= 1    for full-duplex
NWAY_OPTION    = 0    for auto-negotiation off (true force)
= 1    for auto-negotiation on (nway force)
For example:

# insmod ./src/r8168.ko speed=100 duplex=0 autoneg=1

will force PHY to operate in 100Mpbs Half-duplex(nway force).

2. Force the link status by using ethtool.
a. Insert the driver first.
b. Make sure that ethtool exists in /sbin.
c. Force the link status as the following command.

# ethtool -s ethX speed SPEED_MODE duplex DUPLEX_MODE autoneg NWAY_OPTION

,where
SPEED_MODE    = 1000    for 1000Mbps
= 100    for 100Mbps
= 10    for 10Mbps
DUPLEX_MODE    = half    for half-duplex
= full    for full-duplex
NWAY_OPTION    = off    for auto-negotiation off (true force)
= on    for auto-negotiation on (nway force)

For example:

# ethtool -s eth0 speed 100 duplex full autoneg on

will force PHY to operate in 100Mpbs Full-duplex(nway force).

<Jumbo Frame>
Transmitting Jumbo Frames, whose packet size is bigger than 1500 bytes, please change mtu by the following command.

# ifconfig ethX mtu MTU

, where X=0,1,2,…, and MTU is configured by user.

RTL8168B/8111B supports Jumbo Frame size up to 4 kBytes.
RTL8168C/8111C and RTL8168CP/8111CP support Jumbo Frame size up to 6 kBytes.
RTL8168D/8111D supports Jumbo Frame size up to 9 kBytes.

→ 1 Comment Tags: Hardware


When asking about a networking issue, get these details from the server

April 5th, 2010 by EZ linux · No Comments

Kernal version

uname -a

Nic / Lan driver version

dmesg | grep r8169

Internet controller

lspci -nn | grep Ethernet

Details on etho nic card

sudo ethtool eth0

Module size

lsmod | grep r8169

Module versions

cat /proc/modules | grep r8169

Don’t worry all these commands are safe and just for reporting.


→ No Comments Tags: Cheat Sheets · Hardware · Linux Commands · Linux Tricks


Mod_cband the new Mod_Bandwidth

March 29th, 2010 by EZ linux · 3 Comments

I spent hours trying to get mod_bandwidth to work simply because I have used it for years. But now with Apache 2.0 times have changed and there is a better option for Linux and it’s free. The new mod to regulate bandwidth and more is called Mod_cband I’m not sure what cband means but I can guess channel bandwidth.

Here is how to get it set up with Cantos 5.3 easily.

I wanted to host for my brother the latest WoW patch, but at a hefty 450 MB, I didn’t want to blow all my bandwidth on it either. I am setting a limit for the download at 2.5 TB of bandwidth, and limiting it to 5mbs at 10 connections a second. My hardware is RHEL 4 running on a P4 with Plesk 8. In the guide to follow, you’ll see a few steps that wouldn’t be needed on a non-plesk system. To setup bandwidth limiting for the host, we need to be able to compile a new apache module against our system, and then install and configure it.

Step 1: The prereqs

First I needed to setup a yum repository for FC4. This can be accomplished by issuing an RPM command:

rpm -ivh http://rpm.livna.org/livna-release-4.rpm

Now that you can access the RPM packages, we need to install http-devel using yum:

yum install httpd-devel

If all went well, we can now extract, compile, and install mod_cband for apache:

cd /tmp
wget http://cband.linux.pl/download/mod-cband-0.9.7.4.tgz
tar xzvf mod-cband-0.9.7.4.tgz
cd mod-cband-0.9.7.4
./configure
make
make install

If all went well, restart apache with the new module (you can check httpd.conf to make sure the module is going to be loaded):

/etc/init.d/httpd restart

Step 2: Configuration

Here’s where the Plesk part gets annoying. We can’t just edit our vhosts file, because plesk writes over it all the time. Instead, we edit a /home/httpd/vhosts/*/subdomains/*/conf/vhost.conf file. Mine looks like this:

CBandScoreboard /var/www/scoreboard
CBandPeriod 4W
CBandDefaultExceededCode 509
CBandLimit 2500G
CBandSpeed 5000 5 10
CBandRemoteSpeed 1600 3 1
<Location /cband-status>
SetHandler cband-status
</Location>
<Location /cband-status-me>
SetHandler cband-status-me
</Location>

What does this mean? (1) Use /var/www/scoreboard to log usage and limits (2) Reset the limit count every 4 weeks (3) Throw a 509 error when the limits are exceeded (4) Allow 2.5TB per period (5) Allow 5mbs with 5 requests a second and 10 connections at a time oeverall (6) Allow 1.6mbs with 3 requests a second and 1 connections at a time per client (7) Allow us to access a page at /cband-status to view the status.

You’ll also need to issue commands to make the scoreboard directory, and to allow apache to own it:

mkdir /var/www/scoreboard
chown apache:apache /var/www/scoreboard

Finally, Plesk requires you to inform it of your work:

/usr/local/psa/admin/sbin/websrvmng -u –vhost-name=yourdomain.com

If you restart Apache now, everything should work!

/etc/init.d/httpd restart

Step 3: An Example

You can take a peek at my status page right now if you’d like. It looks a bit like this:

A quick note, I simply just added:

CBandPeriod 4W
CBandLimit 10000G
CBandSpeed 12000 40 80
CBandRemoteSpeed 6400 12 4

Now this set the limit to about 12 megs (MPS) a second which is a lot, but this customer is paying $250 a month to cover it. Most websites should max at about 5 MPS. I left out the other options because I didn’t need them and it’s less load on the server without them.

→ 3 Comments Tags: Cheat Sheets · Cpanel and WHM · Linux Security · Linux Software / Scripts · Linux Tricks


Raise apache 2.0 max clients hard limit in cpanel

March 23rd, 2010 by EZ linux · No Comments

Apache 2.0 makes raising the max client from the default 256 hard limit a little harder now. If you have cpanel then it’s even a little harder or I should you just need to know what to do, figuring it out is a shot in the dark.

One main difference is you have raise the server limit if you want to raise the max client limit.

The easiest way to do this is to go to:

  1. Web Hosting Manager
  2. Then click Apache Configuration
  3. Then click Include Editor
  4. Then click the apache version under the pre-main include
  5. Then add this to the input section:

ServerLimit 512

StartServers 32
MinSpareServers 5
MaxSpareServers 20
MaxClients 512
MaxRequestsPerChild 1000

Then save and it will ask to restart apache you click yes there.

Now your apache limit is set to 512 and cpanel will not mess with it.

Here is the explanation for each derivative in the above code:

MaxClients:

The MaxClients sets the limit on maximum simultaneous requests that can be supported by the server; no more than this number of child processes are spawned. It shouldn’t be set too low; otherwise, an ever-increasing number of connections are deferred to the queue and eventually time-out while the server resources are left unused. Setting this too high, on the other hand, will cause the server to start swapping which will cause the response time to degrade drastically. The appropriate value for MaxClients can be calculated as:

If there are more concurrent users than MaxClients, the requests will be queued up to a number based on ListenBacklog directive. Increase ServerLimit to set MaxClients above 256.

MinSpareServers, MaxSpareServers, and StartServers:

MaxSpareServers and MinSpareServers determine how many child processes to keep active while waiting for requests. If the MinSpareServers is too low and a bunch of requests come in, Apache will have to spawn additional child processes to serve the requests. Creating child processes is relatively expensive. If the server is busy creating child processes, it won’t be able to serve the client requests immediately. MaxSpareServers shouldn’t be set too high: too many child processes will consume resources unnecessarily.

Tune MinSpareServers and MaxSpareServers so that Apache need not spawn more than 4 child processes per second (Apache can spawn a maximum of 32 child processes per second). When more than 4 children are spawned per second, a message will be logged in the ErrorLog.

The StartServers directive sets the number of child server processes created on startup. Apache will continue creating child processes until the MinSpareServers setting is reached. This doesn’t have much effect on performance if the server isn’t restarted frequently. If there are lot of requests and Apache is restarted frequently, set this to a relatively high value.

MaxRequestsPerChild:

The MaxRequestsPerChild directive sets the limit on the number of requests that an individual child server process will handle. After MaxRequestsPerChild requests, the child process will die. It’s set to 0 by default, the child process will never expire. It is appropriate to set this to a value of few thousands. This can help prevent memory leakage, since the process dies after serving a certain number of requests. Don’t set this too low, since creating new processes does have overhead.

→ No Comments Tags: Cpanel and WHM · Linux Software / Scripts · Linux Tricks