Pages

Tuesday, March 25, 2014

Limit Outgoing Bandwidth using 'tc' Command




You can limit the outgoing bandwidth on server with the tc tool as shown below

(1) Limit the bandwidth to 1MBps on the node(Xen node with brdge network)

#tc qdisc add dev peth0 handle 1: root htb default 11
#tc class add dev peth0 parent 1:1 classid 1:11 htb rate 1Mbit
#tc -s qdisc ls dev peth0

Note: peth0 is the bridge name. For a dedicated server it should be eth0

(2) bandwidth limiting With a Xen PV VM.

#tc qdisc add dev viftest1.0 handle 1: root htb default 11
#tc class add dev viftest1.0 parent 1:1 classid 1:11 htb rate 1Mbit

#tc -s qdisc ls dev peth0

R1Soft Agent Installation

Installing Backup Agent Using YUM
================================
You should configure the YUM repository to manage install and upgrades of the Backup Agent.
(1)Create a yum repository for r1soft
#cd /etc/yum.repos.d
# nano -w /etc/yum.repos.d/r1soft.repo
(use any text editor according to your convenience)
(2)Add the following to the .repo file
------------------------------------------------------
[r1soft]
name=R1Soft Repository Server
baseurl=http://repo.r1soft.com/yum/stable/$basearch/
enabled=1
gpgcheck=0
--------------------------------------------------------
(3) Install serverbackup-agent
#yum install serverbackup-agent
(4) Test the connectivity with r1soft server using the following command
#serverbackup-setup –test-connection
(5) Install the kernel-devel package using YUM
#yum install kernel-devel
(Note: Please make sure that you have installed proper kernel-devel and header packages.)
(6) Run the following command to build the kernel module.
#serverbackup-setup --get-module
(7) The cdp-agent is installed now and you can restart it as follows
#/etc/init.d/cdp-agent restart
(8) It is important to fetch key from the server. Use the following command to fetch key from the cdp-server
#serverbackup-setup --get-key http://<cdp-server_IP>:<port>
To view the list of keys.
#serverbackup-setup --list-keys

CMS Version Check Script

#!/bin/bash
#
# usage : sh ver.sh
#
#
read -p "ENTER LATEST WORDPRESS VERSION: " wp
read -p "ENTER LATEST JOOMLA VERSION: " jm
read -p "ENTER LATEST VBULLETIN VERSION: " vb
read -p "ENTER LATEST PHPBB VERSION: " pb
read -p "ENTER LATEST DRUPAL VERSION: " dp
cd /home
echo Printing Outdated versions:: > /tmp/versions
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~: >> /tmp/versions
echo >> /tmp/versions
echo Wordpress installations:: >> /tmp/versions
echo ------------------------: >> /tmp/versions
find /home/*/public_html/ -type f -wholename *wp-includes/version.php -exec grep -H "wp_version = " {} \; | replace "\$wp_version" "Wordpress version" | replace "," "" | replace ";" " " | grep -v $wp >> /tmp/versions
echo >> /tmp/versions
echo Joomla Installations:: >> /tmp/versions
echo ---------------------: >> /tmp/versions
find /home/*/public_html/ -name version.php -exec grep -H "var \$RELEASE " {} \; | replace "var \$RELEASE" " Joomla version" | replace "," "" | replace ";" " " | grep -v $jm >> /tmp/versions
echo >> /tmp/versions
echo vBulletin installations:: >> /tmp/versions
echo ------------------------: >> /tmp/versions
find /home/*/public_html/ -type f -wholename *includes/config.php -exec grep -H "Licence Number" {} \; | replace "," "" | replace ";" " " | grep -v $vb >> /tmp/versions
echo >> /tmp/versions
echo phpBB installations:: >> /tmp/versions
echo --------------------: >> /tmp/versions
find /home/*/public_html/ -type f -wholename *includes/constants.php -exec grep -H "PHPBB_VERSION" {} \; |replace "define(" " " | replace "," "" | replace ";" " " | grep -v $pb >> /tmp/versions
echo >> /tmp/versions
echo Drupal installations:: >> /tmp/versions
echo ---------------------: >> /tmp/versions
find /home/*/public_html/ -type f -wholename *includes/bootstrap.inc -exec grep -H "define('VERSION" {} \; | replace "define(" " " | replace "," "" | replace ";" " " | grep -v $dp >> /tmp/versions
echo >> /tmp/versions
############
cat /tmp/versions | replace "'" "" > /tmp/versions2
/bin/mv /tmp/versions2 /tmp/versions
cut -d: -f1 /tmp/versions | rev| cut -d/ -f2- | rev > /tmp/versions1
cut -d: -f2- /tmp/versions | replace ")" "" | replace "|| #" "" > /tmp/versions2
paste /tmp/versions1 /tmp/versions2
rm -f /tmp/versions1 /tmp/versions2

Forcefully remove LVM


You may come across the below error while removing an LVM especially with Xen nodes.
lvremove -f /dev/xen/vmXXX_img
Logical volume xen/vmXXX_img is used by another device.
Here are the steps to remove the LV's forcefully.
dmsetup ls
dmsetup info -c xen-vmXXX_img
dmsetup remove xen-vmXXX_img
lvremove -f /dev/xen/vmXXX_img

HDD health check script

******************************************************
for i in `lshw -class disk -class tape | grep "logical name" | cut -d: -f2`; do echo Disk $i ; echo "=========================================" ;smartctl --all $i | grep 'PASSED\|Reallocated_Sector_Ct\|Temperature_Celsius' ; echo " "; done
*****************************************************
Sample Output:
[root@localhost ~]# sh test.sh 
Disk /dev/sda 
=========================================
SMART overall-health self-assessment test result: PASSED
5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 0
194 Temperature_Celsius 0x0022 028 048 000 Old_age Always - 28 (0 19 0 0 0)

Disk /dev/sdb
=========================================
SMART overall-health self-assessment test result: PASSED
5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 0
194 Temperature_Celsius 0x0022 024 048 000 Old_age Always - 24 (0 15 0 0 0)

[root@localhost ~]#