Shell script to copy all files recursively and upload them to remote FTP server

August 28, 2008 at 11:15 pm | In Linux | Leave a Comment
#!/bin/bash
# Shell script to copy all files recursively and upload them to
# remote FTP server (copy local all directories/tree to remote ftp server)
#
# If you want to use this script in cron then make sure you have
# file pointed by $AUTHFILE (see below) and add lines to it:
# host ftp.mycorp.com
# user myftpuser
# pass mypassword
#
# This is a free shell script under GNU GPL version 2.0 or above
# Copyright (C) 2005 nixCraft
# Feedback/comment/suggestions : http://cyberciti.biz/fb/
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------

FTP="/usr/bin/ncftpput"
CMD=""
AUTHFILE="/root/.myupload"

if [ -f $AUTHFILE ] ; then
  # use the file for auth
  CMD="$FTP -m -R -f $AUTHFILE $myf $remotedir $localdir"
else
  echo "*** To terminate at any point hit [ CTRL + C ] ***"
  read -p "Enter ftpserver name : " myf
  read -p "Enter ftp username : " myu
  read -s -p "Enter ftp password : " myp
  echo ""
  read -p "Enter ftp remote directory [/] : " remotedir
  read -p "Enter local directory to upload path [.] : " localdir
  [ "$remotedir" == "" ] && remotedir="/" || :
  [ "$localdir" == "" ] && localdir="." || :
  CMD="$FTP -m -R -u $myu -p $myp $myf $remotedir $localdir"
fi

$CMD

How to increase the root partion using LVM without unmounting

August 27, 2008 at 5:05 pm | In Linux, admins | Leave a Comment

Add new disk to existing server

a, Exicute fdisk -l

it shows the added disk at the end of the line and display no valid partions found on there. Now we need to partion  the disk and create the  primary partion type as Linux LVM (8e)

here my disk is probed as /dev/sdb

#fdisk /dev/sdb

For creating new partion press ‘p’
1, Choose create it as primary partion
2, Just ok to the last 2 questions

Now we need to create  lvm flesystem
3, Press ‘t’  for choosing file system
4, Enter “8e” for creating LVM file system
5, Press ‘w’ to write the Disk and save the changes

Now we have partioned  disk on the server #fdsik -l

[root@localhost ~]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         650     5116702+  8e  Linux LVM
/dev/sda3             651         715      522112+  82  Linux swap / Solaris

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         391     3140676   8e  Linux LVM

Now  i am showing the my linux box LVM status

[root@localhost ~]# vgdisplay
— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  2
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               1
Max PV                0
Cur PV                1
Act PV                1
VG Size               4.88 GB
PE Size               32.00 MB
Total PE              156
Alloc PE / Size       156 / 4.88 GB
Free  PE / Size       0 / 0
VG UUID               7XZTPr-VJt8-QOTu-CUlv-mmrQ-7sPg-Wz2zfH

[root@localhost ~]# lvdisplay
— Logical volume —
LV Name                /dev/VolGroup00/LogVol00
VG Name                VolGroup00
LV UUID                hI0dbV-ZcSP-XbGY-sBlj-jl7n-3daW-XJFcRG
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                4.88 GB
Current LE             156
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           253:0

Now I am going to create physical volume of the device /dev/sdb
[root@localhost ~]# pvcreate  /dev/sdb
Physical volume “/dev/sdb” successfully created

Checking the physical volume status
[root@localhost ~]# pvdisplay
— Physical volume —
PV Name               /dev/sda2
VG Name               VolGroup00
PV Size               4.88 GB / not usable 4.78 MB
Allocatable           yes (but full)
PE Size (KByte)       32768
Total PE              156
Free PE               0
Allocated PE          156
PV UUID               vrl2zH-hndd-P8Th-GYvg-vLzS-oUjH-Z0pWCX

— NEW Physical volume —
PV Name               /dev/sdb
VG Name
PV Size               3.00 GB
Allocatable           NO
PE Size (KByte)       0
Total PE              0
Free PE               0
Allocated PE          0
PV UUID               rmdH0G-l20O-6gut-tiEx-dHsU-pvhn-g3FltO

Here it shows 2 physical volume(/dev/sda2 & /dev/sdb(new) created on the server.

Next i am going to extended the volume of ‘VolGroup00′ to use /dev/sdb and check it was updated properly.
[root@localhost ~]# vgextend  VolGroup00 /dev/sdb
Volume group “VolGroup00″ successfully extended
[root@localhost ~]# vgdisplay
— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        2
Metadata Sequence No  3
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               1
Max PV                0
Cur PV                2
Act PV                2
VG Size               7.84 GB
PE Size               32.00 MB
Total PE              251
Alloc PE / Size       156 / 4.88 GB
Free  PE / Size       95 / 2.97 GB
VG UUID               7XZTPr-VJt8-QOTu-CUlv-mmrQ-7sPg-Wz2zfH

See it was extended  to my additional 3GB. Now I am going to extend the logical volume and checking it’s status
[root@localhost ~]# lvextend -L 6G /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 6.00 GB
Logical volume LogVol00 successfully resized
[root@localhost ~]# lvdisplay
— Logical volume —
LV Name                /dev/VolGroup00/LogVol00
VG Name                VolGroup00
LV UUID                hI0dbV-ZcSP-XbGY-sBlj-jl7n-3daW-XJFcRG
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                6.00 GB
Current LE             192
Segments               2
Allocation             inherit
Read ahead sectors     0
Block device           253:0

Wonderful!!!!!!!!!!  it is updated to 6 GB. But my fdisk -l still shows my old HDD status :-(

Now I am going to rezise the filesystem inorder to effect the space addition without unmounting the file system.

[root@localhost ~]# resize2fs  /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 1572864 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 1572864 blocks long.

Now I want to check whether my file system has increased it’s size

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5.9G  906M  4.7G  17% /
/dev/sda1              99M   12M   83M  13% /boot
tmpfs                 125M     0  125M   0% /dev/shm

Great !!!!!!!!!!!!!  it’s increased

I am facing the issue with resizing the file system. It shows the error that the cant’ resize the partion mounted. At that point

#ext2online /dev/VolGroup00/LogVol00

Did works while resize2fs shows the error.

How to redirect the page within your php application

August 26, 2008 at 10:40 pm | In Apache, Debian, Linux, RedHat EL5, Ubuntu | Leave a Comment

PHP Redirect Script

You can easily redirect using following code:

 
<?php
/* Redirect browser */
header("Location: http://theos.in/");
/* Make sure that code below does not get executed when we redirect. */
exit;
?>

Another sample hack

Sample function – sitefunctions.php (note I’m not the author of the following I found it somewhere else on the Internet):

function movePage($num,$url){
   static $http = array (
       100 => "HTTP/1.1 100 Continue",
       101 => "HTTP/1.1 101 Switching Protocols",
       200 => "HTTP/1.1 200 OK",
       201 => "HTTP/1.1 201 Created",
       202 => "HTTP/1.1 202 Accepted",
       203 => "HTTP/1.1 203 Non-Authoritative Information",
       204 => "HTTP/1.1 204 No Content",
       205 => "HTTP/1.1 205 Reset Content",
       206 => "HTTP/1.1 206 Partial Content",
       300 => "HTTP/1.1 300 Multiple Choices",
       301 => "HTTP/1.1 301 Moved Permanently",
       302 => "HTTP/1.1 302 Found",
       303 => "HTTP/1.1 303 See Other",
       304 => "HTTP/1.1 304 Not Modified",
       305 => "HTTP/1.1 305 Use Proxy",
       307 => "HTTP/1.1 307 Temporary Redirect",
       400 => "HTTP/1.1 400 Bad Request",
       401 => "HTTP/1.1 401 Unauthorized",
       402 => "HTTP/1.1 402 Payment Required",
       403 => "HTTP/1.1 403 Forbidden",
       404 => "HTTP/1.1 404 Not Found",
       405 => "HTTP/1.1 405 Method Not Allowed",
       406 => "HTTP/1.1 406 Not Acceptable",
       407 => "HTTP/1.1 407 Proxy Authentication Required",
       408 => "HTTP/1.1 408 Request Time-out",
       409 => "HTTP/1.1 409 Conflict",
       410 => "HTTP/1.1 410 Gone",
       411 => "HTTP/1.1 411 Length Required",
       412 => "HTTP/1.1 412 Precondition Failed",
       413 => "HTTP/1.1 413 Request Entity Too Large",
       414 => "HTTP/1.1 414 Request-URI Too Large",
       415 => "HTTP/1.1 415 Unsupported Media Type",
       416 => "HTTP/1.1 416 Requested range not satisfiable",
       417 => "HTTP/1.1 417 Expectation Failed",
       500 => "HTTP/1.1 500 Internal Server Error",
       501 => "HTTP/1.1 501 Not Implemented",
       502 => "HTTP/1.1 502 Bad Gateway",
       503 => "HTTP/1.1 503 Service Unavailable",
       504 => "HTTP/1.1 504 Gateway Time-out"
   );
   header($http[$num]);
   header ("Location: $url");
}

Now call it as follows:

<?php
@include("/path/to/sitefunctions.php");
movePage(403,"http://www.cyberciti.biz/");
?>

How do I erase a hard drive?

August 8, 2008 at 10:32 am | In Linux | Leave a Comment

dd is a handy tool used for making copys. It can also be used to quite securely wipe harddrives:

for (( i = 0;i<10;i++ )); do

  dd if=/dev/random of=dev/hda && dd if=dev/zero of=/dev/hda

done

This will overwrite your entire hard drive (in this case seen as hda by Linux) with random information ten time

How to install java on Ubuntu

August 8, 2008 at 10:06 am | In Ubuntu | Leave a Comment

This small guide shows how to install the original Sun Java 2 Platform Standard Edition 5.0 JRE (Java Runtime Environment) and JDK (Java Developer Kit) on Ubuntu.

The original Sun Java 2 is available in the ‘multiverse’ section of the Ubuntu repositories. To enable this section first add the multiverse repository to the apt sources file – the /etc/apt/sources.list should look like, – important parts are in bold:


deb http://dk.archive.ubuntu.com/ubuntu/ feisty universe multiverse

Now, update apt:

sudo apt-get update

Then install the Java debian packages.

sudo apt-get install sun-java5-bin

Or this for installing the JDK ( the Java SDK )

sudo apt-get install sun-java5-jdk

Secure Webserver from Php function vulernability

August 1, 2008 at 9:29 pm | In Web security | Leave a Comment

PHP has a lot of functions which can be used to crack your server if not used properly. You can set list of functions in php.ini using disable_functions directive. This directive allows you to disable certain functions for security reasons. It takes on a comma-delimited list of function names. disable_functions is not affected by Safe Mode. This directive must be set in php.ini For example, you cannot set this in httpd.conf.

Open php.ini file:
# vi /etc/php.ini
Find disable_functions and set new list as follows:
disable_functions =exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source
Save and close the file. Restart httpd:
# service httpd restart

How to run mulitple Tomcat instance on the same server

July 30, 2008 at 10:41 pm | In Apache, Debian, Linux, RedHat EL5, Ubuntu | Leave a Comment
Tags:

I am listing the steps to  archive the goal

1, Step 1: Install the Tomcat files

2, Make directories for each instance

3. Editing the server.xml

Tomcat  using  2 major port one for listening http request and another for listening shutdown port

in here i put tomcat installation on /usr/local/tomcat5.5.9 folder

now I am going to edit server.xml inside the conf folder

vi /usr/local/tomcat5.5.9 folder/conf/server.xml

Find the entry

a, <Server port=”8001″ shutdown=”SHUTDOWN”> and changed the server port to any unused port

b, <!– Define a non-SSL HTTP/1.1 Connector on port 8080 –>
<Connector port=”9000″ maxHttpHeaderSize=”8192″  Change the Connector port to any unused port which tomcat listen

Again  restart the tomcat and check the that it is listening in the connector port by

!, telnet localhost   <connector port >  if it is opend a blank window it work

2, exicute $ netstat -nlp| grep  :”<connector port> .If it shows any result it’s working

Now you can start to depoly  the website.

I recommended that always to use tomcat as a backend server for Apache. You can use proxy pass module for  this functionality in apache. It also included in my previous  blog in Apache category.

################ Tomcat start up scripts ###########

# This is the init script for starting up the
#  Jakarta Tomcat server
#
# chkconfig: 345 91 10
# description: Starts and stops the Tomcat daemon.
#

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

tomcat=/usr/local/jakarta-tomcat-5.5.9
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
export JAVA_HOME=/usr/java/jdk1.5.0_06

start(){
echo -n $”Starting Tomcat service: “
#daemon -c
$startup
RETVAL=$?
echo
}

stop(){
action $”Stopping Tomcat service: ” $shutdown
RETVAL=$?
echo
}

restart(){
stop
start
}

# See how we were called.
case “$1″ in
start)
start
;;
stop)
stop
;;
status)
# This doesn’t work ;)
status tomcat
;;
restart)
restart
;;
*)
echo $”Usage: $0 {start|stop|status|restart}”
exit 1
esac

exit 0
####### end of scripts ########
How to   use this scripts

1, open in any editor and  change the path of java and  Tomcat install location

2, Move the scripts to the /etc/init.d

3, Give execute permission to the scripts, #chmod  755 /etc/init.d/tomcatd  and then execute the scripts for the testing. Eg: # ./etc/init.d/tomcat start

4, Setting runlevel and added it to system service list by # chkconfig –add /etc/init.d/tomcatd

5. Setting the tomcat  should be run at start up by #chkconfig tomcatd   on

That’s it

Liju

How to monitor SSH Login activities and FTP logins over the web

July 28, 2008 at 8:48 pm | In Debian, Linux, RedHat EL5, Ubuntu | Leave a Comment

Basic Idea behind scripts is,

We can able to monitor the activities of ssh logins,any hacking attempt and ftp logins. The steps are involved in this scripts is

1, first check the log log files for whether there is any entry is present

2, If any lines present in the logs regarding the login activities, write all those lines in our custom web access file.

3, Place the report file in a web accessable location

4, Create a virtual host on Apache for this

5, set a cron to automate the logs creation and removal

########################### Log monitoring scripts ##############

#!/bin/bash
#fingers: Liju mathew ~! lijumathewliju@gmail.com
#created: 27.07.2008
#purpose: to check the status of ssh/logins and notify the system personnel
#      if they are not listening!

today=`date +%d-%m-%y`
day_ftr=`date +%b” “%d`
web_location=/var/www/logs

# In the below example I guess the ssh log files are created in /var/log/secure (on debian /var/lig/auth.log) #and vsftp/proftp logs are created on /var/log/vsftp.log
## SSH Allow script for checking empty data from the file

/bin/cat /var/log/secure| grep “$day_ftr”| grep sshd | grep “Accepted password” &> /dev/null
if [ "$?" -eq "0"  ];then
/bin/cat /var/log/secure | grep sshd | grep “Accepted password” > $web_location/ssh-allow-$today.txt
fi

#SSH -Deny scripts for removing empty file creation
/bin/cat /var/log/secure |grep “$day_ftr” | grep “sshd” | grep “Failed password”$> /dev/null
if [ "$?" -eq "0"  ];then
/bin/cat /var/log/secure |grep “$day_ftr” | grep “sshd” | grep “Failed password” > $web_location/ssh-deny-$today.txt
fi
## FTP Scripts for avioding empty file creation
/bin/cat /var/log/xferlog | grep “$day_ftr” &> /dev/null
if [ "$?" -eq "0"  ];then
/bin/cat /var/log/xferlog | grep “$day_ftr” > $web_location/ftp-log-$today.txt
fi
### ############End of scripts ############

Create a virtual host entry for this

<VirtualHost *:80>

ServerName 182.163.98.2

Alias /logs  “/var/www/html/logs”

<Directory “/var/www/html/logs” >
Options +Indexes
AllowOverride All
Allow from all
Order allow,deny
</Directory>

<Location /logs>
AuthType Basic
AuthName “Admin access details “
AuthUserFile /var//pwd/prod/passwd
Require valid-user
Allow from all
</Location>

</VirtualHost>

3, Set up a cron for o this

copy this scripts to /var/opt/scripts/ssh_monitor.sh

30 12  * * * /bin/sh /var/opt/scripts/ssh-monitor.sh

That’s it

Note : pls make sure that log file is properly formatted with my  grep comand. If not. pls update it with your required strings.

howto-install-rrdtool-on-rhel-linux

July 28, 2008 at 8:20 pm | In Linux, RedHat EL5 | Leave a Comment

RRD is the Acronym for Round Robin Database. RRD is a system to store and display time-series data (i.e. network bandwidth, machine-room temperature, server load average). It stores the data in a very compact way that will not expand over time, and it presents useful graphs by processing the data to enforce a certain data density. It can be used either via simple wrapper scripts (from shell or Perl) or via frontends that poll network devices and put a friendly user interface on it.

Installing RRDTool on RHEL

In order to install RRDTool on Red Hat Enterprise Linux / CentOS Linux 64 bit version you need to install few development tools and libraries.

Step # 1: Install required dependencies

Login as root and type the following command:
# yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel
Sample output:

Loading "rhnplugin" plugin
Loading "security" plugin
rhel-x86_64-server-vt-5   100% |=========================| 1.4 kB    00:00
rhn-tools-rhel-x86_64-ser 100% |=========================| 1.2 kB    00:00
rhel-x86_64-server-5      100% |=========================| 1.4 kB    00:00
Setting up Install Process
Parsing package install arguments
Package libxml2-devel - 2.6.26-2.1.2.1.x86_64 is already installed.
Package libxml2-devel - 2.6.26-2.1.2.1.i386 is already installed.
Package pango - 1.14.9-3.el5.i386 is already installed.
Package pango - 1.14.9-3.el5.x86_64 is already installed.
Package freetype - 2.2.1-20.el5_2.i386 is already installed.
Package freetype - 2.2.1-20.el5_2.x86_64 is already installed.
Resolving Dependencies
--> Running transaction check
---> Package libart_lgpl-devel.x86_64 0:2.3.17-4 set to be updated
---> Package pango-devel.i386 0:1.14.9-3.el5 set to be updated
--> Processing Dependency: libXft-devel for package: pango-devel
--> Processing Dependency: libXrender-devel for package: pango-devel
--> Processing Dependency: libXext-devel for package: pango-devel
--> Processing Dependency: libX11-devel for package: pango-devel
--> Processing Dependency: fontconfig-devel >= 2.0 for package: pango-devel
---> Package pango-devel.x86_64 0:1.14.9-3.el5 set to be updated
---> Package freetype-devel.x86_64 0:2.2.1-20.el5_2 set to be updated
---> Package libpng-devel.i386 2:1.2.10-7.1.el5_0.1 set to be updated
---> Package cairo-devel.x86_64 0:1.2.4-5.el5 set to be updated
---> Package libpng-devel.x86_64 2:1.2.10-7.1.el5_0.1 set to be updated
---> Package cairo-devel.i386 0:1.2.4-5.el5 set to be updated
---> Package libart_lgpl-devel.i386 0:2.3.17-4 set to be updated
--> Processing Dependency: libart_lgpl_2.so.2 for package: libart_lgpl-devel
---> Package freetype-devel.i386 0:2.2.1-20.el5_2 set to be updated
--> Running transaction check
---> Package libXrender-devel.i386 0:0.9.1-3.1 set to be updated
--> Processing Dependency: xorg-x11-proto-devel for package: libXrender-devel
---> Package libXft-devel.i386 0:2.1.10-1.1 set to be updated
---> Package libX11-devel.i386 0:1.0.3-9.el5 set to be updated
--> Processing Dependency: libXdmcp-devel for package: libX11-devel
--> Processing Dependency: libXau-devel for package: libX11-devel
---> Package fontconfig-devel.i386 0:2.4.1-7.el5 set to be updated
---> Package libart_lgpl.i386 0:2.3.17-4 set to be updated
---> Package libXext-devel.i386 0:1.0.1-2.1 set to be updated
--> Running transaction check
---> Package xorg-x11-proto-devel.i386 0:7.1-9.fc6 set to be updated
--> Processing Dependency: mesa-libGL-devel for package: xorg-x11-proto-devel
---> Package libXdmcp-devel.i386 0:1.0.1-2.1 set to be updated
---> Package libXau-devel.i386 0:1.0.1-3.1 set to be updated
--> Running transaction check
---> Package mesa-libGL-devel.i386 0:6.5.1-7.5.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 libart_lgpl-devel       x86_64     2.3.17-4         rhel-x86_64-server-5   21 k
 libart_lgpl-devel       i386       2.3.17-4         rhel-x86_64-server-5   21 k
 pango-devel             i386       1.14.9-3.el5     rhel-x86_64-server-5  280 k
 pango-devel             x86_64     1.14.9-3.el5     rhel-x86_64-server-5  281 k
Installing for dependencies:
 cairo-devel             x86_64     1.2.4-5.el5      rhel-x86_64-server-5  131 k
 cairo-devel             i386       1.2.4-5.el5      rhel-x86_64-server-5  130 k
 fontconfig-devel        i386       2.4.1-7.el5      rhel-x86_64-server-5  168 k
 freetype-devel          x86_64     2.2.1-20.el5_2   rhel-x86_64-server-5  151 k
 freetype-devel          i386       2.2.1-20.el5_2   rhel-x86_64-server-5  151 k
 libX11-devel            i386       1.0.3-9.el5      rhel-x86_64-server-5  665 k
 libXau-devel            i386       1.0.1-3.1        rhel-x86_64-server-5   11 k
 libXdmcp-devel          i386       1.0.1-2.1        rhel-x86_64-server-5  7.6 k
 libXext-devel           i386       1.0.1-2.1        rhel-x86_64-server-5   57 k
 libXft-devel            i386       2.1.10-1.1       rhel-x86_64-server-5   16 k
 libXrender-devel        i386       0.9.1-3.1        rhel-x86_64-server-5  8.9 k
 libart_lgpl             i386       2.3.17-4         rhel-x86_64-server-5   76 k
 libpng-devel            i386       2:1.2.10-7.1.el5_0.1  rhel-x86_64-server-5  182 k
 libpng-devel            x86_64     2:1.2.10-7.1.el5_0.1  rhel-x86_64-server-5  186 k
 mesa-libGL-devel        i386       6.5.1-7.5.el5    rhel-x86_64-server-5  465 k
 xorg-x11-proto-devel    i386       7.1-9.fc6        rhel-x86_64-server-5  247 k

Transaction Summary
=============================================================================
Install     20 Package(s)
Update       0 Package(s)
Remove       0 Package(s)         

Total download size: 3.2 M
Is this ok [y/N]: 

Downloading Packages:
(1/20): libXext-devel-1.0 100% |=========================|  57 kB    00:00
(2/20): freetype-devel-2. 100% |=========================| 151 kB    00:00
(3/20): libXau-devel-1.0. 100% |=========================|  11 kB    00:00
(4/20): libart_lgpl-devel 100% |=========================|  21 kB    00:00
(5/20): libart_lgpl-2.3.1 100% |=========================|  76 kB    00:00
(6/20): cairo-devel-1.2.4 100% |=========================| 130 kB    00:00
(7/20): libpng-devel-1.2. 100% |=========================| 186 kB    00:00
(8/20): cairo-devel-1.2.4 100% |=========================| 131 kB    00:00
(9/20): fontconfig-devel- 100% |=========================| 168 kB    00:00
(10/20): mesa-libGL-devel 100% |=========================| 465 kB    00:01
(11/20): libXdmcp-devel-1 100% |=========================| 7.6 kB    00:00
(12/20): libpng-devel-1.2 100% |=========================| 182 kB    00:00
(13/20): libX11-devel-1.0 100% |=========================| 665 kB    00:02
(14/20): freetype-devel-2 100% |=========================| 151 kB    00:00
(15/20): libXft-devel-2.1 100% |=========================|  16 kB    00:00
(16/20): pango-devel-1.14 100% |=========================| 281 kB    00:01
(17/20): pango-devel-1.14 100% |=========================| 280 kB    00:01
(18/20): libXrender-devel 100% |=========================| 8.9 kB    00:00
(19/20): libart_lgpl-deve 100% |=========================|  21 kB    00:00
(20/20): xorg-x11-proto-d 100% |=========================| 247 kB    00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: libart_lgpl                  ####################### [ 1/20]
  Installing: freetype-devel               ####################### [ 2/20]
  Installing: fontconfig-devel             ####################### [ 3/20]
  Installing: libpng-devel                 ####################### [ 4/20]
  Installing: libXau-devel                 ####################### [ 5/20]
  Installing: libart_lgpl-devel            ####################### [ 6/20]
  Installing: libart_lgpl-devel            ####################### [ 7/20]
  Installing: libpng-devel                 ####################### [ 8/20]
  Installing: freetype-devel               ####################### [ 9/20]
  Installing: xorg-x11-proto-devel         ####################### [10/20]
  Installing: libX11-devel                 ####################### [11/20]
  Installing: libXrender-devel             ####################### [12/20]
  Installing: libXft-devel                 ####################### [13/20]
  Installing: cairo-devel                  ####################### [14/20]
  Installing: libXext-devel                ####################### [15/20]
  Installing: pango-devel                  ####################### [16/20]
  Installing: pango-devel                  ####################### [17/20]
  Installing: libXdmcp-devel               ####################### [18/20]
  Installing: mesa-libGL-devel             ####################### [19/20]
  Installing: cairo-devel                  ####################### [20/20] 

Installed: libart_lgpl-devel.x86_64 0:2.3.17-4 libart_lgpl-devel.i386 0:2.3.17-4 pango-devel.i386 0:1.14.9-3.el5 pango-devel.x86_64 0:1.14.9-3.el5
Dependency Installed: cairo-devel.x86_64 0:1.2.4-5.el5 cairo-devel.i386 0:1.2.4-5.el5 fontconfig-devel.i386 0:2.4.1-7.el5 freetype-devel.x86_64 0:2.2.1-20.el5_2 freetype-devel.i386 0:2.2.1-20.el5_2 libX11-devel.i386 0:1.0.3-9.el5 libXau-devel.i386 0:1.0.1-3.1 libXdmcp-devel.i386 0:1.0.1-2.1 libXext-devel.i386 0:1.0.1-2.1 libXft-devel.i386 0:2.1.10-1.1 libXrender-devel.i386 0:0.9.1-3.1 libart_lgpl.i386 0:2.3.17-4 libpng-devel.i386 2:1.2.10-7.1.el5_0.1 libpng-devel.x86_64 2:1.2.10-7.1.el5_0.1 mesa-libGL-devel.i386 0:6.5.1-7.5.el5 xorg-x11-proto-devel.i386 0:7.1-9.fc6
Complete!

Step # 2: Download latest rrdtool tar ball

Type the following commands:
# cd /opt/
# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.1.tar.gz

Untar tar ball, enter:
# tar -zxvf rrdtool-1.3.1.tar.gz

Step #3: Compile and install rrdtool

You need to set PKG_CONFIG_PATH, enter:
# export PKG_CONFIG_PATH=/usr/lib/pkgconfig/
Type the following commands:
# ./configure
Sample output:

config.status: executing default-1 commands
config.status: executing intltool commands
config.status: executing default commands
config.status: executing po/stamp-it commands
checking in... and out again
ordering CD from http://tobi.oetiker.ch/wish .... just kidding ;-) 

----------------------------------------------------------------
Config is DONE!

          With MMAP IO: yes
       Static programs: no
          Perl Modules: perl_piped perl_shared
           Perl Binary: /usr/bin/perl
          Perl Version: 5.8.8
          Perl Options: PREFIX=/usr/local/rrdtool-1.3.1 LIB=/usr/local/rrdtool-1.3.1/lib/perl/5.8.8
          Ruby Modules:
           Ruby Binary: no
          Ruby Options: sitedir=$(DESTDIR)NONE/lib/ruby
    Build Tcl Bindings: no
 Build Python Bindings: yes
          Build rrdcgi: yes
       Build librrd MT: yes
     Link with libintl: yes

             Libraries: -lxml2 -lcairo -lcairo -lcairo -lm  -lcairo -lpng12   -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0  

Type 'make' to compile the software and use 'make install' to
install everything to: /usr/local/rrdtool-1.3.1.

       ... that wishlist is NO JOKE. If you find RRDtool useful
make me happy. Go to http://tobi.oetiker.ch/wish and
place an order.

Optional compile time settings

By default RRDTool will get installed at /usr/local/rrdtool-1.3.1/ directory. To change default installation directory use following command:
# ./configure --prefix=/usr/local/rrdtool
# make install

To see all compile configuration option enter:
# ./configure --help


                               -- Tobi Oetiker
----------------------------------------------------------------

Now compile and install RRDTool on RHEL:
# make
# make install
# cd /usr/local/
# ln -s rrdtool-1.3.1/ rrdtool/
# cd rrdtool
# ls -l

How do I verify my installation?

Now RRDtool is installed and ready to use. You can go to /usr/local/rrdtool/share/rrdtool/examples/ directory and run them to see if your installation has been successful or not:
# cd /usr/local/rrdtool/share/rrdtool/examples/
# ./stripes.pl
# ls -l
# cp stripes.png /var/www/html/

Fire a web browser and see a graph for yourself by typing the following url:
http://your-domain.com/stripes.png

Install ntop on Red Hat / CentOS Linux

July 28, 2008 at 8:18 pm | In Linux, RedHat EL5 | 1 Comment

ntop is a network and traffic analyzer that provides a wealth of information on various networking hosts and protocols. ntop is primarily accessed via a built-in web interface.

# cd /opt
# wget http://freshmeat.net/redir/ntop/7279/url_tgz/ntop-3.3.6.tar.gz

Configure and Compile ntop under RHEL

You must have RRDTool installed. You also need to install libpcap, enter:
# yum install libpcap-devel libpcap

Type the following commands to compile and install ntop:
# cd ntop
# ./autogen.sh

Just type make to compile ntop:
# make
Just type make install to install ntop:
# make install
# make install-data-as

Create ntop user

Type the following command to run ntop as ntop user, enter:
# useradd -M -s /sbin/nologin -r ntop

Setup directory permissions

Next, you need to setup directory permissions, enter:
# chown ntop:root /usr/local/var/ntop/
# chown ntop:ntop /usr/local/share/ntop/

Setup ntop user admin password

Type the following command to set ntop admin password, enter:
# ntop -A
Sample output:

Mon Jul 28 03:38:34 2008  NOTE: Interface merge enabled by default
Mon Jul 28 03:38:34 2008  Initializing gdbm databases

ntop startup - waiting for user response!

Please enter the password for the admin user:
Please enter the password again:
Mon Jul 28 03:38:42 2008  Admin user password has been set

Start ntop

Type the following command to start ntop:
# /usr/local/bin/ntop -d -L -u ntop -P /usr/local/var/ntop --skip-version-check --use-syslog=daemon
Sample output:

Mon Jul 28 03:42:19 2008  NOTE: Interface merge enabled by default

Mon Jul 28 03:42:19 2008  Initializing gdbm databases

If you have multiple interface (eth0, eth1 and so on), start ntop as follows:
# /usr/local/bin/ntop -i "eth0,eth1" -d -L -u ntop -P /usr/local/var/ntop --skip-version-check --use-syslog=daemon
Where,

  • -i “eth0,eth1″ : Specifies the network interface or interfaces to be used by ntop for network monitoring. Here you are monitoring eth0 and eth1.
  • -d : Run ntop as a daemon.
  • -L : Send all log messages to the system log (/var/log/messages) instead of screen.
  • -u ntop : Start ntop as ntop user
  • -P /usr/local/var/ntop : Specify where ntop stores database files. You may need to backup database as part of your disaster recovery program.
  • –skip-version-check : By default, ntop accesses a remote file to periodically check if the most current version is running. This option disables that check.
  • –use-syslog=daemon : Use syslog daemon.

How do I view ntop stats?

By default ntop listen on 3000 port. You can view ntop stats by visiting following url:
http://localhost:3000/
OR
http://server-ip:3000/

How do I view ntop stats without opening port 3000?

Setup simple tunnel using ssh, enter the following on your local UNIX / Linux desktop system:
$ ssh -L 3000:localhost:3000 -N -f user@server.yourcorp.com
Now open browser and type the following command:
http://localhost:3000/

How do I start ntop on boot?

Open /etc/rc.local file, enter:
# vi /etc/rc.local
Append the following line:
/usr/local/bin/ntop -i "eth0,eth1" -d -L -u ntop -P /usr/local/var/ntop --skip-version-check --use-syslog=daemon
Save and close the file.

How do I stop ntop?

Use web interface to shutdown ntop, or use normal kill / killall command:
# killall ntop

Next Page »

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.