UnixServerAdmin

Server Administration & Management

Apache status showing blank page in WHM

If the Apache status page is showing blank in WHM, then you can fix the same by issuing the following script:-

# /scripts/addstatus

This should fix the issue.

Advertisements

October 31, 2011 Posted by | Apache, cPanel | , | Leave a comment

java.lang.OutOfMemoryError: PermGen space

While accessing the .jsp pages or restarting tomcat on the server you face the error “java.lang.OutOfMemoryError: PermGen space”.  The error occurs due to the memry outage for  the tomcat service on the server. By default the tomcat uses 128 MB of memroy. You can increase the memory with the steps below and get rid off the errors.

HTTP Status 500 –
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.OutOfMemoryError: PermGen space
note The full stack trace of the root cause is available in the Apache Tomcat/
Apache Tomcat

1) Edit file /usr/local/jakarta/tomcat/bin/catalina.sh

# vi /usr/local/jakarta/tomcat/bin/catalina.sh

2) Add following line into the catalina.sh file.

JAVA_OPTS=”-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC”

Which will look like

=======================================================================
# JSSE_HOME (Optional) May point at your Java Secure Sockets Extension
# (JSSE) installation, whose JAR files will be added to the
# system class path used to start Tomcat.
#
# CATALINA_PID (Optional) Path of the file which should contains the pid
# of catalina startup java process, when start (fork) is used
#
# $Id: catalina.sh 609438 2008-01-06 22:14:28Z markt $
# —————————————————————————–

JAVA_OPTS=”-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC”

# OS specific support. $var _must_ be set to either true or false.
cygwin=false
os400=false
darwin=false
=======================================================================

3) Save and exit

4) Restart Tomcat

October 30, 2011 Posted by | Tomcat | | Leave a comment

Lockout Issues for CSF, when installed in VPS “OR” Can’t enter into server after CSF installation on VPS

If the required IP table modules are not properly loaded to the container node, you may lockout yourself after the installation. If you have access to the main Hardware node, you can perform the following to get it up or ask your VPS provider to perform this on the Hardware (main) node.

Before enabling iptables on VPS, it needs to make sure that the iptables modules are enabled on the Hardware Node. In order to enable iptables modules on Hardware Node, Edit it as the following:-

# /etc/vz/vz.conf
——————————–
IPTABLES_MODULES=”ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ip_conntrack_ftp ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp xt_state ipt_recent”
——————————–

# /etc/sysconfig/iptables-config
——————————–
IPTABLES_MODULES=”ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ip_conntrack_ftp ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp xt_state ipt_recent”
——————————–

Now your Hardware node is fine. You need to enable the iptable modules to the VPS nodes. (CID – container ID. You can find the value for each node by using the command vzlist -a)

# vzctl stop CID

# vzctl set CID –iptables ipt_REJECT –iptables ipt_tos –iptables ipt_TOS –iptables ipt_LOG –iptables ip_conntrack –iptables ipt_limit –iptables ipt_multiport –iptables iptable_filter –iptables iptable_mangle –iptables ipt_TCPMSS –iptables ipt_tcpmss –iptables ipt_ttl –iptables ipt_length  –iptables ipt_state –iptables iptable_nat –iptables ip_nat_ftp –save

# vzctl set CID –numiptent 2000 –save

# vzctl start CID

Now try entering into your node and restart CSF. It should start working fine.

October 29, 2011 Posted by | CSF, Firewall, Virtualization, Virtuozzo | , , , , | Leave a comment

How to make Virtuozzo Container be able to run ConfigServer Firewall(CSF)

CSF is a powerful Firewall for Linux and cPanel servers are here are the steps to get it working with Virtuozzo VPS

1. Installation

# rm -rvf csf.tgz
# wget http://www.configserver.com/free/csf.tgz
# tar -xzf csf.tgz
# cd csf
# sh install.sh

2. After the installation you will need to customize CSF to run on VPS, edit /etc/sysconfig/iptables and add

# vi /etc/sysconfig/iptables
——————————————–
-A FORWARD -j ACCEPT -p all -s 0/0 -i venet0
-A FORWARD -j ACCEPT -p all -s 0/0 -o venet0
-A INPUT -i venet0 -j ACCEPT
-A OUTPUT -o venet0 -j ACCEPT
——————————————–

3. Create file /etc/csf/csfpre.sh and enter all the extra rules directly into it prefixed with “iptables” so the contents of that file should look something like:

# vi /etc/csf/csfpre.sh
——————————————————
iptables -A INPUT -i venet0 -j ACCEPT
iptables -A OUTPUT -o venet0 -j ACCEPT
iptables -A FORWARD -j ACCEPT -p all -s 0/0 -i venet0
iptables -A FORWARD -j ACCEPT -p all -s 0/0 -o venet0
——————————————————

4. edit /etc/csf/csf.conf file and add and search for

# vi /etc/csf/csf.conf file
——————————
ETH_DEVICE = “”
change to
ETH_DEVICE = “venet+”
——————————

5. Restart

# /usr/sbin/csf -r  “OR”

# /etc/init.d/csf restart

==================================================================
Lockout Issues for CSF, when installed in VPS

“or”

Cannot enter into server after CSF installation on VPS

If the required IP table modules are not properly loaded to the container node, you may lockout yourself after the installation. If you have access to the main Hardware node, you can perform the following to get it up or ask your VPS provider to perform this on the Hardware (main) node.

Before enabling iptables on VPS, it needs to make sure that the iptables modules are enabled on the Hardware Node. In order to enable iptables modules on Hardware Node, Edit it as the following:-

# /etc/vz/vz.conf
——————————–
IPTABLES_MODULES=”ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ip_conntrack_ftp ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp xt_state ipt_recent”
——————————–

# /etc/sysconfig/iptables-config
——————————–
IPTABLES_MODULES=”ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ip_conntrack_ftp ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp xt_state ipt_recent”
——————————–

Now your Hardware node is fine. You need to enable the iptable modules to the VPS nodes. (CID – container ID. You can find the value for each node by using the command vzlist -a)

# vzctl stop CID

# vzctl set CID –iptables ipt_REJECT –iptables ipt_tos –iptables ipt_TOS –iptables ipt_LOG –iptables ip_conntrack –iptables ipt_limit –iptables ipt_multiport –iptables iptable_filter –iptables iptable_mangle –iptables ipt_TCPMSS –iptables ipt_tcpmss –iptables ipt_ttl –iptables ipt_length  –iptables ipt_state –iptables iptable_nat –iptables ip_nat_ftp –save

# vzctl set CID –numiptent 2000 –save

# vzctl start CID

Now try entering into your node and restart CSF. It should start working fine.

October 28, 2011 Posted by | CSF, Firewall, Virtualization, Virtuozzo | , , , , | Leave a comment

Error : “Virtuozzo does not recognize 82574L controller” Resolution

This error comes many times in Virtouzzo 4 installation on 32bit or 64bit Platform on CentOS , mentioning that the network controller is not recognizable by Virtouzzo. The exact error is similar to below :

The following devices are not supported by Virtuozzo:
If you will continue the installation, Virtuozzo Containers may fail to boot or some device may be not operational
8086:10d3 02:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
8086:10d3 06:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection

The reason for this is that the during default installation step the kernel installed is very old and if you boot the server after installation with that kernel despite above error message then the server will fail to boot in virotuzzo kernel, though you should be able to boot it into the default CentOS kernel. The solution for this problem is to do the installation in this sequence :

1. Install Virtouzzo normally and do NOT reboot the server at end of installation
2. Use vzup2date to install updates and new kernel, if it fails install the new kernel manually
3. Update /etc/grub.conf to set the new kernel as default.
4. Now reboot server and it will work fine.

If vzup2date fails , it will still download the latest kernel and will make it available at path like below :

# /vz/vzup2date/virtuozzo/linux/i386/4.0.0/CU-2.6.18-028stab068.9/ (For 32bit)

# /vz/vzup2date/virtuozzo/linux/x86_64/4.0.0/CU-2.6.18-028stab068.9/ (For 64bit)

You need to install three rpms vzkernel-xxx.rpm , vzkernel-devel-xxx.rpm and vzmodules-xxx.rpm, located at above path. (the CU-Kernel-Name folder will of course vary as the new kernel become available)

Hope this helps some of folks out there facing same problem.

October 27, 2011 Posted by | Virtualization, Virtuozzo | , | Leave a comment

How to check & install a Parallels Virtuozzo Containers license

Virtouzzo is the popular Virtualization platform from Parallels ( formerly known as SWsoft ). Parallels provides Virtouzzo licensing depending on your requirements, i.e you can get a license to support 3 vpss on a node or 20 ve license for running 20 vpss or 30 ve license and so on. In this article I will discuss the common commands that can be used to check the license status and installing a new license in case it gets expired. The main command used for viewing the license information is :

# vzlicview

It provides detail information with fields like owner_name , status , version , owner_id , hwid , expiration, start_date , issue_date etc. We can use the grep command to find our specific information, e.g. we can find the status of license using below command :

# vzlicview | grep status
status=”ACTIVE”

Similarly you can check other fields in the license. In case your license has expired or it is going to expire in next few days, you will need to get a new license and install it. You can get the hwid from the server to get the new license issued. The new license number has normally the format like VZ.012211XX.00YY and the file name containing the license is also same and usually comes as a zipped text file. Once you have the license key file you can install the new license in following two ways using the main command vzlicload provided for loading the new licenses :

1. Using the below format you can load the license after uploading the license file to the server :

# vzlicload -f “/full/path/to/license/file”

2. Using the below format you can load the license using the unique license key :

# vzlicload -p product_key

The product key is the unique key like VZ.011221XX.00YY . Though please note that this later format of using product key only works with Virtouzzo version 4 and higher and will not work for Virtouzzo version below 4. If you face any issues, you can ask in comment section and I will try to help !

October 26, 2011 Posted by | Virtualization, Virtuozzo | , , | Leave a comment

How to Fixquotas for cPanel in Virtuozzo

quotacheck: Scanning /dev/vzfs [/] quotacheck: lstat Cannot stat `//usr/share/sgml/docbook/xmlcatalog’: No such file or directory
Guess you’d better run fsck first !
exiting…

This is because cPanel has changed files provided by the OS template on which the system is built. The solution is:
On the main node server:

# vzfsutil –cM -t /vz/template /vz/private/

This will give you a set of files that has been modified.
do:

# chmod -S -t /vz/private//root/

then try:

# vzfsutil –cM -t /vz/template /vz/private/

once done, re-enter the C-panel server and run:

# /scripts/fixquotas

that will do.

October 25, 2011 Posted by | cPanel, Virtualization, Virtuozzo | , , , , | Leave a comment

How to enable Quota for cPanel in Virtuozzo

On Virtuozzo VPS with Cpanel control panel, disk quota is showing unlimited. I tried to enable quota through WHM –> Server Configuration –> Initial Quota Setup, but got following error.

Installing Default Quota Databases……Done
Quotas are now on
Updating Quota Files……
quotacheck: Can’t find filesystem to check or
filesystem not mounted with quota option.

quotacheck: Can’t find filesystem to check or
filesystem not mounted with quota option.
….Done

The problem is fixed by changing the VPS quotaugidlimit value to 800.

1. Click on Infrastructure Manager
2. Click on Virtual Private Servers
3. Click on VPS you need to enable quota
4. Click Preferences
5. Click on Resources tab
6. Click Extend button
7. Disk Quota – Click to set up Disk Quota parameters
8. Click Modify Button on top and change value of quotaugidlimit to 800 and save, this will restart the VPS.

Now you need to delete old quota to enable new quota.

# rm -rf /aquota.user 2>/dev/null

# rm -rf /aquota.group 2>/dev/null

# unlink /aquota.user 2>/dev/null

# unlink /aquota.group 2>/dev/null

And run following command, it should be in one line, No line breaks

for x in `find /proc/vz/vzaquota/ | tail -1 | xargs find | tail -2 `; do ln -s $x /; done

Now your Virtuozzo VPS will work with cPanel disk quotas.

October 24, 2011 Posted by | cPanel, Virtualization, Virtuozzo | , , , , | Leave a comment

How to install yum on Virtuozzo VPS

1. SSH Login into Hardware Node

2. Run following command on the Hardware node assuming 101 is the VEID [VPS ID]

# vzpkg install 101 -p yum

Now yum utility will work on VPS

October 23, 2011 Posted by | Virtualization, Virtuozzo | , , , | Leave a comment

How to clone or copy a VPS in Virtuozzo

Virtouzzo provides a shell utility named ‘vzmlocal‘ , it can be used to clone a vps and comes handy in many situations. There are multiple reasons for which you may want to clone a vps, like :

* clone a vps before doing any major installation or changes within vps, so it can be reverted back in case something goes wrong
* clone a vps or vps template to create a new vps with same OS and applications, e.g. a clone for cPanel vps template to create a new cPanel vps
* to create a exact replica of a vps to be used as redundant copy of the vps

Lets see how we can use this command to create a vps clone :

# vzmlocal -C SOURCEVIED:TARGETVEID

above is general syntax , a real time example would be :

#vzmlocal -C 145:245
Moving/copying Container#145 -> Container#245, [], [] …
Syncing private area ‘/vz/private/145′->’/vz/private/245’

Successfully completed

The above command will create the exact replica of VPS with id 145 into a new VPS who’s id will be 245

Additional parameters can be used as per requirement , some of the command parameters are below :

 -s, –fast-sid : allows to speed up cloning process

-d, –destroy-source : destroys the source container after making a clone

-l, –skiplock : allows to clone the locked containers

October 22, 2011 Posted by | Virtualization, Virtuozzo | , , | Leave a comment

How to Install/ Setup a Virtuozzo VPS from CLI

Parallels provides two graphical options to create and manage VPSs.

VZCC, the  Virtuozzo control center is one of those gui options, the second is the desktop based application.

VZMC,  the Virtuozzo management console, which is a powerful tool and is capable of creating and managing vpss with all details.

However techs or admins that spend most of their time on shell, mostly prefer to do these things on shell, in this article I will list the commands that can be used to setup new vps on shell and can set its basic parameters. The main commands used for this process are ‘vzctl create‘ to create the vps and then ‘vzctl set‘ to set the configs.

Below is complete set of commands to achieve this :

# vzctl create VEID –ostemplate centos-5-x86 –config basic

# vzctl set VEID –onboot yes –save

# vzctl set VEID –offline_management yes –save

# vzctl set VEID –hostname vps.unixserveradmin.com –save

# vzctl set VEID –userpasswd root:redhat@123 –save

# vzctl set VEID –ipadd 11.22.33.44 –ipadd 11.22.33.45 –save

# vzctl set VEID –nameserver “8.8.8.8 8.8.4.4” –save

–ostemplate using which you select the tmplate on which you will create the vps, it can be centos, fedora etc.

–config which applies default values for different QOS parameters from a config files.

–onboot option is set to yes so that the vps boots up automatically on node reboot.

–offline_management is set to yes as well so that the vps user has access to the vzpp ( Virtuozzo Power Panel ) so they can reboot their vps themselves and access other vzpp options.

–hostname option is simply used to set the hostname of the vps.

–userpasswd option as you can see is used to set the root password for the vps

–ipadd parameter is used for assigning IPs, the more IPs can be added by adding more

–ipadd sections in the command and lastly the

–nameserver option is used to set the Nameservers for the vps.

You can see the command help on shell for complete details of vzctl set and vzctl create commands.

October 21, 2011 Posted by | Virtualization, Virtuozzo | , , | Leave a comment

OpenVZ Commands

Inroduction

VZ -> Virtuozzo –> recommends ext3 file system
PIM -> Parallels Infrastructure Manager –> IP:4643
PMC -> Parallels Management Console –> managing hardware node
PPP -> Parallels Power Panel –> for managing a single container
All the above things need a license from parallel

Templates

OS template -> vzpkg (cache needs to created before creating the container)
EZ template -> points to the repository that contains packages that constitute the template
Application template -> mysql template

Virtuozzo – User’s guide

OS virtualization – (1-2% of is spent on the virtualization s/w) VZFS – allows sharing of common files among containers Hardware node & Containers

/etc/vz/vz.conf
/etc/vz/conf/
/etc/vzbackup.conf

Delete the container

# vzctl destroy

Disabling the container

# vzctl set

Suspending the container

# vzctl suspend

To check the status of the quota info

# vzquota

Managing CPU – cpu share and the number of processors the node can make use of

# vzcpucheck

Monitoring tools

# vzstat
# vzps
# vzpid
# vztop
# vzsetxinetd

Virtuozzo networks

# vznetcfg if list
# vznetcfg vlan add eth0 5
# vznetcfg vlan del eth0.5
# vznetcfg net addif vznetwork1 eth0
# vznetcfg net delif eth0
# vznetcfg net new vznetwork1
# vznetcfg net del vznetwork1
# vznetcfg net list

Keeping system up2date : The h/w node can be updated using the normal update procedures without affecting virtuozzo

# vzup2date – /etc/sysconfig/vzup2date/vzup2date.conf
# vzup2date -m batch install –core
# vzup2date -t -m batch install –all-os

Updating the containers

# vzpkg update 101 redhat-el5-x86
# vzpkg update 101
# vzpkg update cache fedora-core-8-x86

October 20, 2011 Posted by | Virtualization, Virtuozzo | , , | Leave a comment

Virtuozzo Guide: Parameters Explained

Primary Parameters

1. numproc = max ‘number of processes’ and kernel level threads allowed for a VE
It is the total number of processes that can be run on a server, i.e httpd, ftp, mail spawn a process to handle each client and limiting number of processes define how many clients the application will be able to handle in parallel. However number of processes does not limit how heavy the application may be. But increasing this value to more than about 16000 processes start to cause poor responsiveness of the system, worsening when the number grows. Total number of processes exceeding 32000 is very likely to cause hang of the system. With typical processes, it is normal to be able to run only up to 8000 processes in a system. The number of sockets needs to be controlled because each socket needs certain amount of memory for receive and transmit buffers. Barrier of this parameter should be set equal to the limit.

2. numtcpsock = max ‘number of TCP sockets’
This parameter limits the number of TCP connections and, thus, the number of clients the server application can handle in parallel. If each VE has its own set of IP addresses, there are no direct limits on the total number of TCP sockets in the system.Barrier of this parameter should be set equal to the limit.

3. numothersock = max ‘number of sockets other than TCP’
Local sockets (sockets used for communication inside the system), UDP sockets (DNS queries). The number of sockets needs to be controlled because each socket needs certain amount of memory for receive and transmit buffers. Barrier of this parameter should be set equal to the limit.

4. vmguarpages = ‘virtual memory guaranteed pages’
This parameter controls how much memory is available to the VE. The more clients are served or the more “heavy” the application is, the more memory it needs The meaning of the limit for the vmguarpages parameter is unspecified and should be set to the maximal allowed value.If the current amount of allocated memory space does not exceed the guaranteed amount (the barrier of vmguarpages), memory allocations of VE applications always succeed. If the current amount of allocated memory space exceeds the guarantee but below the barrier of privvmpages, allocations may or may not succeed, depending on the total amount of available memory in the system.

=====================================================================

Secondary Parameters

1. kmemsize = ‘kernel memory size’
Size of unswappable kernel memory allocated for the internal kernel structures. This parameter is related to the number of processes, numproc.Kmemsize limits can’t be set arbitrarily high. It is important to have a certain safety gap between the barrier and the limit of the kmemsize parameter. Equal barrier and limit of the kmemsize parameter may lead to the situation where the kernel will need to kill Virtual Environment’ applications to keep the kmemsize usage under the limit.

2. tcpsndbuf = total size of ‘send buffers for TCP sockets’
The amount of kernel memory allocated for the data sent from an application to a TCP socket. tcpsndbuf parameter depends on number of TCP sockets, numtcpsock and should allow for some minimal amount of socket buffer memory for each socket.

3. tcprcvbuf = total size of ‘receive buffers for TCP’
The amount of kernel memory allocated for the data received from the remote side, but not read by the local application yet. Tcprcvbuf parameter depends on number of TCP sockets, numtcpsock and should allow for some minimal amount of socket buffer memory for each socket.

4. othersockbuf = total size of ‘buffers used by other sockets’
Othersockbuf parameter depends on number of non-TCP sockets,numothersock. Othersockbuf configuration should satisfy,othersockbuf_{lim} – othersockbuf_{bar} ge 2.5KB cdot numothersock.Increased limit for othersockbuf is necessary for high performance of communications through local sockets. However, similarly to tcpsndbuf, hitting othersockbuf affects the communication performance only and does not affect the functionality. The total amount of other sock buf consumable by all VE in the system plus the kmemsize and other socketbuffers is limited by the hardware resources of the system

5. dgramrcvbuf = total size of ‘receive buffers of UDP and other datagram protocol’
The total size of buffers used to temporary store the incoming packets of UDP and other datagram protocols. Dgramrcvbuf parameters depend on number of non-TCP sockets (numothersock). dgramrcvbuf limits usually don’t need to be high. Only if the VE needs to send and receive very large datagrams, the barriers for both othersockbuf and dgramrcvbuf parameters should be raised.

6. oomguarpages = ‘out of memory guarantee in pages’
Any VE process will not be killed even in case of heavy memory shortage if the current memory consumption (including both physical memory and swap) does not reach the oomguarpages barrier.oomguarpages parameter is related to vmguarpages. If applications start to consume more memory than the computer has, the system faces an out-of-memory condition. In this case the operating system will start to kill VE processes to free some memory and prevent the total death of the system. oomguarpages parameter accounts the total amount of memory and swap space used by the processes of a particular Virtual Environment.The barrier of the oomguarpages parameter is the out-of-memory guarantee.

=====================================================================

Auxiliary Parameters

1. privvmpages = ‘private virtual memory pages’
privvmpages parameter allows controlling the amount of memory allocated by applications. The memory that is always shared among different applications is not included in this resource parameter. The barrier and the limit of privvmpages parameter control the upper boundary of the total size of allocated memory. Note that this upper boundary doesn’t guarantee that the Virtual Environment will be able to allocate that much memory, neither does it guarantee that other Virtual Environments will be able to allocate their fair share of memory. The primary mechanism to control memory allocation is the vmguarpages guarantee. Privvmpages parameter accounts allocated (but, possibly, not used yet) memory. The accounted value is an estimation how much memory will be really consumed when the Virtual Environment’s applications start to use the allocated memory. Consumed memory is accounted into oomguarpages parameter.

2. lockedpages
The memory not allowed to be swapped out in pages. The size of these pages is also accounted into kmemsize. The barrier may be set equal to the limit or may allow some gap between the barrier and the limit, depending on the nature of applications using memory locking features.

3. shmpages = total size of ‘shared memory pages’
These pages are also accounted into privvmpages. The barrier should be set equal to the limit. The configuration of this parameter doesn’t affect security and stability of the whole system or isolation between Virtual Environments. Its configuration affects functionality and resource shortage reaction of applications in the given Virtual Environment only.

October 19, 2011 Posted by | Virtualization, Virtuozzo | , | Leave a comment

Protected: bandwidth.sh

This content is password protected. To view it please enter your password below:

October 18, 2011 Posted by | Security, Shell Script, Tips & Tricks, Unix/Linux | , , , , , , | Enter your password to view comments.

vnStat Commands

# vnstat         -q,      –query          query database

# vnstat         -h,      –hours          show hours

# vnstat         -d,      –days           show days

# vnstat         -m,      –months         show months

# vnstat         -w,      –weeks          show weeks

# vnstat         -t,      –top10          show top10

# vnstat        -s,     –short          use short output

# vnstat        -i,      –iface          select interface (default: eth0)

# vnstat        -?,      –help           short help

# vnstat        -v,      –version        show version

# vnstat        -tr,     –traffic        calculate traffic

# vnstat        -ru,     –rateunit       swap configured rate unit

# vnstat        -l,      –live           show transfer rate in real time

October 17, 2011 Posted by | Tips & Tricks, Unix/Linux | , , , , | Leave a comment

How to monitor bandwidth usage with vnStat PHP based web frontend

You may find it inconvenient to have to login to your server every time you want to see your server’s bandwidth statistics. To make it easier to see bandwidth stats one kind soul made a PHP frontend that uses vnStat to obtain the necessary data and display it with pretty graphs.

vnStat php frontend requires that you have apache, php and the php-gd image processing library installed. Installing the latter is as easy as running the following command as root:

1. Install Apache Web server, php and php-gd

# yum install httpd

# yum install php

# yum install php-gd

2. Download vnStat PHP for Installation

# wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.4.1.tar.gz

# tar -xzf vnstat_php_frontend-1.4.1.tar.gz

3. place it in a web accessible place like /var/www/html

# mkdir /var/www/html/vnstat

# mv vnstat_php_frontend/* /var/www/html/vnstat

4. Edit the config.php file: Just set the correct binary name:

# vi /var/www/html/vnstat/config.php

———————————
$vnstat_bin = ‘vnstat’;
———————————

October 16, 2011 Posted by | PHP, Tips & Tricks, Unix/Linux | , , , , | Leave a comment

How to configure vnStat for monitoring bandwidth usage

VMSTAT is a tool for those people, having dedicated server hosted somewhere remote at IDC/ISP.

vnStat is a console-based network traffic monitor for Linux that keeps a log of network traffic for the selected interface(s). It uses the network interface statistics provided by the kernel as information source. This means that vnStat won’t actually be sniffing any traffic and also ensures light use of system resources. However, in Linux at least a 2.2 series kernel is required.

* It keeps a log of daily and monthly network traffic for the selected network interface(s).
* It collects all data from /proc file system it means normal user can monitor traffic (no need to run vnstat as a root user)
* Easy to setup & configure
* Ease of use

1. Install vnstat using yum

# yum install vnstat

2. Setup database: Before vnStat can begin logging bandwidth usage you need to tell it to setup the database for your network interface.
Replace eth0 with the correct interface

# vnstat -u -i eth0

Where,

-u :forces a database update for interface or creates the database if it doesn’t exist
-i eth0 : use to specify interface

3. Setup correct interface in config file: By default the vnStat cron job will attempt to collect statistics for the eth0 interface.
If your network interface is different from that one you will have to modifiy the /etc/sysconfig/vnstat file:

# vi /etc/sysconfig/vnstat

—————————————–
VNSTAT_OPTIONS=”-i eth3″
—————————————–

4. Setup bash alias: Logout of root now and back to your regular user account. If you intend to use vnstat over the command line and
your network interface is not eth0 you should setup a bash alias for ease of use in your .bashrc file:

—————————————–
alias vnstat=”vnstat -i eth3″
—————————————–

5. Statistics by day

# vnstat -d

6. Statistics by Hour

# vmstat -h

7. Statistics By month

# vnstat -m

8. Live monitoring of the network interface

# vnstat -l

9. Display all time top10 traffic days

# vnstat -t

October 15, 2011 Posted by | Tips & Tricks, Unix/Linux | , , , , | Leave a comment

Maximum file limit reach while starting Apache

Maximum file limit reach error is occur while we are starting the Apache server at that time you can fix the issue by using root login details.

1. edit /etc/sysctl.conf file

# vi /etc/sysctl.conf

Add following line as
—————————
fs.file-max = 22992
—————————

Save and exit from the file.

2. You need to run following command from shell to active changes.

# sysctl -p

It will increase the maximum number of open files for your Server.

October 14, 2011 Posted by | Apache, Tips & Tricks | , | Leave a comment

How to Pointing a sub-domain to folder outside public_html

Issue : When you create a sub-domain, cPanel points it to the corresponding folder under public_html by default. How to point it to a folder outside the public_html?

Solution : This cannot be done via cPanel/WHM but can be achieved if you have ‘root’ SSH access to the server.

1. Open the apache configuration file

# vi /usr/local/apache/conf/httpd.conf

2. Search for the virtual host entry for your sub-domain.

3. Edit the document root of your sub-domain to match the desired location.

4. Save and Exit; Restart apache.

# /etc/init.d/httpd restart

Note : cPanel rebuilds httpd.conf from userdata files and its overwritten on every cPanel update, on every account creation, subdomain addition, or any such activity related to apache and any manual changes you make will be overwritten. To make permanent changes to a subdomain’s root folder :

1. Edit the file /var/cpanel/userdata/<username>/subdomain.domain.com file, change the path and save it.

# vi /var/cpanel/userdata/username/subdomain.domain.com

2. Run /scripts/rebuildhttpdconf

# /scripts/rebuildhttpdconf

3. Restart apache.

# /etc/init.d/httpd restart

October 13, 2011 Posted by | Apache, DNS | , , | Leave a comment

How to modify Apache default success page in cPanel

To modify the apache default success page, follow the steps below.

1. You just have to login to your server via ssh.

2. Navigate to /usr/local/apache/htdocs

# cd /usr/local/apache/htdocs/

3. And finally edit the file index.html

# vi index.html

October 12, 2011 Posted by | Apache, cPanel | , , | Leave a comment