Category Archives: LINUX

How to install Cacti on Linux

Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices. For More information http://www.cacti.net/what_is_cacti.php

  • first login as root to the server. please note this should have "yum" install already. my recommendation is to use standalone server or virtual server for monitoring . its depend on your network size.

# yum install mysql-server mysql php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-snmp php-pear-Net-SMTP php-mysql httpd

  • Configure MySQL server

# mysqladmin -u root password NEWPASSWORD

  • Create cacti MySQL database

# mysql -u root -p -e 'create database cacti'

  • Create a user called cacti with a password called 123456, enter:

# mysql -u root –p mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY '123456'; mysql> FLUSH privileges; mysql> \q

  • Install snmpd

yum install net-snmp-utils php-snmp net-snmp-libs

  • Configure snmpd

# mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.org vi /etc/snmp/snmpd.conf add line rocommunity  public and save the file. ( wq!)

  • Turn on snmpd service:

# /etc/init.d/snmpd start # chkconfig snmpd on

  • Install cacti

# rpm –Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm # yum install cacti

  • Install cacti tables

# rpm -ql cacti | grep cacti.sql # mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.7d/cacti.sql

  • Configure cacti

# vi /etc/cacti/db.php

  • Make changes as follows:

$database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cacti"; $database_password = "123456"; $database_port = "3306";

  • Configure httpd

# vi /etc/httpd/conf.d/cacti.conf # # Cacti: An rrd based graphing tool # Alias /cacti    /usr/share/cacti <Directory /usr/share/cacti/> Order Deny,Allow Allow from all </Directory>

  • restart apache

# service httpd restart

  • Setup cacti cronjob

# vi /etc/cron.d/cacti

  • Uncomment

*/5 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

  • Run cacti installer

http://your.example.com/cacti/ please follow the instruction to complete the installation. after that you can go in add the devices you like to monitor. this is very usefully when you need to monitor bandwidth on switch etc. Hope this help you guys. if there is any question feel free to contact me on rebeladm@live.com

How to Restore off a mounted slave disk on Redhat + Cpanel (crash/hack/bad kernel)

How to Restore off a mounted slave disk on Redhat + Cpanel (crash/hack/bad kernel)

Warning: This is not to be done by the unexperienced admins bad things could happen. Hire someone.

Sometimes if you get hacked or boot with a bad kernel you need to have the datacenter mount your old drive, and install a new one with a fresh installation of redhat. First things first lets make sure you have an updated kernel, we will do it with up2date for ease of use:

up2date -f kerne
l

check the grub.conf /or lilo config to ensure the settings are right. (if using lilo run this command aswell /sbin/lilo -v -v and check for errors)

Now reboot the server

shutdown -r now
I. Mount the backup Drive

First check to see if there are any drives mounted.

df -h

You should get something simular to this if it isent mounted yet:

[root@localhost root]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 37G 1.4G 33G 4% /
/dev/hda1 101M 7.7M 88M 9% /boot
none 125M 0 125M 0% /dev/shm
[root@localhost root]#

if it is mounted you will see something like this:

-bash-2.05b# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda3 53G 31G 20G 62% /
/dev/hda1 99M 14M 80M 15% /boot
none 248M 0 248M 0% /dev/shm
/dev/hdc3 53G 31G 20G 61% /mnt/old
-bash-2.05b#

as you can see hdc3 is the old drive, and it is mounted as /mnt/old. Yours will be diffent possibly. But keep in mind you need to know the mount point for the backup drive for the following steps.

Lets mount if not already mounted.

fdisk -l

check for additional drives, in this tutorial we will use /dev/hdc3.

mount /dev/hdb3 /mnt/old

now that the drive is mounted you can browse files like:

ls /mnt/old/home

II. Rsync the files

Do these commands one by one,

rsync -vrplogDtH /mnt/old/usr/local/apache/conf /usr/local/apache
rsync -vrplogDtH /mnt/old/var/named /var
rsync -vrplogDtH /mnt/old/home/* /home
rsync -vrplogDtH /mnt/old/usr/local/cpanel /usr/local
rsync -vrplogDtH /mnt/old/var/lib/mysql /var/lib
rsync -vrplogDtH /mnt/old/var/cpanel /var
rsync -vrplogDtH /mnt/old/usr/share/ssl /usr/share
rsync -vrplogDtH /mnt/old/var/ssl /var
rsync -vrplogDtH /mnt/old/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty
rsync -vrplogDtH /mnt/old/var/log/bandwidth /var/log
rsync -vrplogDtH /mnt/old/usr/local/frontpage /usr/local
rsync -vrplogDtH /mnt/old/var/spool/cron /var/spool

Next Step – Get some important files from etc:

cd /mnt/old/etc
rsync -vrplogDtH secondarymx domainalias valiases vfilters exim* proftpd* pure-ftpd* passwd* group* *domain* *named* wwwacct.conf cpupdate.conf quota.conf shadow* *rndc* ips* ipaddrpool* ssl /etc

Now would be a good time to change your password for root:

passwd

III. Updating software and restarting services

/scripts/upcp
/scripts/updatenow
/scripts/sysup
/scripts/fixeverything
/scripts/exim4
/scripts/easyapache
/scripts/securetmp

This is needed to update cpanel information. Please note, sshd might fail and not start after running fixeverything. You have to login to whm, and go to the rpm installer and “FORCE” install opensshd-server, opensshd, opensshd-client and then restart sshd from whm.

IV. Restarting services

/scripts/restartsrv httpd
/scripts/restartsrv cpanel
/scripts/restartsrv mysql
/scripts/restartsrv named
/scripts/restartsrv exim

After you are pleased that everything is working fine, restart the entire server.

This tutorial works 100% on redhat, 7.3, 8.0, 9.0 and fedora. it has been tested on those boxes. But remember, if you dont know what your doing them hire someone to check your server out.

Move Large Site from one Server to another

1. Login to your server and su – to root (do not forget the – after su).

2. Change to the /home directory:

# cd /home

3. Run the following command: (this may take a while depending on the size of your site)

# /scripts/pkgacct USERNAME

(NOTE: USERNAME is the name of the user account not domain in cPanel).

4. Move the resulting file to the home directory of your primary user:

# mv /home/cpmove-USERNAME.tar.gz /home/primaryuser/cpmove-USERNAME.tar.gz

5. Change permissions of the file:

# chmod 755 /home/primaryuser/cpmove-USERNAME.tar.gz

6. Login to the destination server and su – to root (do not forget the – after su).

7. Change to the /home directory (see step #2).

8. Run the following command:

# /scripts/restorepkg USERNAME

**You may want to delete the “cpmove-USERNAME.tar.gz” from both servers as it may consume a lot of disk space.*