Wednesday, March 20, 2013

Install Monitoring Tool CACTI On RHEL CENTOS 6.3

ABOUT CACTI :-

Cacti is an open-source, web-based network monitoring and graphing tool designed as a front-end application for the open-source, industry-standard data logging tool RRDtool. Cacti allows a user to poll services at predetermined intervals and graph the resulting data. It is generally used to graph time-series data of metrics such as CPU load and network bandwidth utilization. A common usage is to monitor network traffic by polling a network switch or router interface via simple network management protocol (SNMP).



Required Packages for Cacti In RPM-based Operating Systems

ü  httpd
ü  php
ü  php-mysql
ü  php-snmp
ü  mysql
ü  mysql-server
ü  net-snmp

    ü  Apache : A Web server to display network graphs created by PHP and RRDTool.
ü  MySQL : A Database server to store cacti information.
ü  PHP : A script module to create graphs using RRDTool.
ü  PHP-SNMP : A PHP extension for SNMP to access data.
ü  NET-SNMP : A SNMP (Simple Network Management Protocol) is used to manage network.
ü  RRDTool : A database tool to manage and retrieve time series data like CPU loadNetwork Bandwidth etc.

INSTALL THE PRE-REQUIRED PACKAGES (FOR CACTI)

1 :- INSTALL APACHE
# yum install httpd* -y

2 :- INSTALL MYSQL
# yum install mysql* -y

3 :- INSTALL PHP
# yum install php* -y

4 :- INSTALL PHP-SNMP
# yum install php-snmp* -y

5 :- INSTALL NET-SNMP
# yum install net-snmp* -y

6 :- INSTALL RRDTOOL
# yum install rrdtool* -y

STARTING AND CHKCONFIG APACHE , MYSQL AND SNMP SERVICES

# /etc/init.d/httpd restart ; chkconfig httpd on
# /etc/init.d/mysqld restart; chkconfig mysqld on
# /etc/init.d/snmpd restart; chkconfig snmpd on


 NOW INSTALL THE CACTI ON CENTOS , RHEL


DOWNLOAD CACTI FROM :- 

wget  http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz 

Then Install Using RPM 

#rpm -ivh cacti-0.8.8a.  (using tab button)
                           OR
you need to install and enable  EPEL Repository. Once you’ve enabled repository, type the following command to install Cacti application. 

#yum install cacti* -y

CONFIGURE MYSQL SERVER FOR CACTI INSTALLATION

We need to configure MySQL for Cacti, to do this we need to set password for our newly installed MySQL server and then we will create Cacti database with user Cacti. If you’reMySQL is already password protected, then don’t need to set it again.

# mysqladmin -u root password YOUR-MYSQL-PASSWORD

CREATE MYSQL CACTI DATABASE

Login into MySQL server with newly created password and create Cacti database with userCacti and set the password for it

# mysql -u root -p
mysql>  create database cacti;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'YOUR-MYSQL-PASSWORD'
mysql> FLUSH privileges;
mysql> quit;


INSTALL CACTI TABLES TO MYSQL

Find out the database file path using RPM command, to install cacti tables into newly createdCacti 

database, use the following command.

# rpm -ql cacti | grep cacti.sql

OUTPUT :-

/usr/share/doc/cacti-0.8.7d/cacti.sql

Now we’ve of the location of Cacti.sql file, type the following command to install tables, here you need to type the Cacti user password

# mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.7d/cacti.sql

CONFIGURE MYSQL SETTING FOR CACTI

Make the following changes and save the file. Make sure you set password correctly.
# vim /etc/cacti/db.php


CONFIGURE APACHE SERVER FOR CACTI INSTALLATION.

Open the file called /etc/httpd/conf.d/cacti.conf 
#vim /etc/httpd/conf.d/cacti.conf

You need to enabled access to Cacti application for your local network or per IP level. For example we’ve enabled access to our local LAN network 192.168.1.0/24. In your case, it would be different.
Finally, restart the Apache service.

# /etc/init.d/httpd restart;

SETTING CRON FOR CACTI

OPEN file /etc/cron.d/cacti
# vim /etc/cron.d/cacti




Uncomment the following line. The poller.php script runs every 5mins and collects data of known host which is used by Cacti application to display graphs.


Cacti Installer Setup

Finally, Cacti is ready, just go to http://YOUR-SYSTEM-IPADDRESS-HERE/cacti/ & follow the installer instruction through the following screens. Click Next button.





choose installation Type as New Install




















Make sure all the following values are correct before continuing. Click  Finish button.



Cacti Login Screen, enter username as admin and password as admin.





















Once you’ve entered username and password, it will ask you to enter a new password for cacti.






















Cacti Console Screen























_____________________________
_________________________________



Some Important Links

1 For php-snmp package for centos 6.3

http://rpm.pbone.net/index.php3/stat/4/idpl/18075757/dir/scientific_linux_6/com/php-snmp-5.3.3-3.el6_2.8.x86_64.rpm.html

2 To Download The Cacti

http://rpm.pbone.net/index.php3/stat/4/idpl/19569839/dir/redhat_el_6/com/cacti-0.8.8a-2.el6.noarch.rpm.html

3 Cacti Official WebSite

 http://www.cacti.net/



Monday, March 18, 2013

SSH LOGIN WITHOUT PASSWORD USING SSH-KEYGEN


I have 2 machine :-

a) 192.168.1.6 {server.example.com}
b) 192.168.1.110 {station110.example.com}

1 :- Create the key using ssh-keygen on 1st  machine i.e.       {server.example.com(192.168.1.6)}

[root@server ~]# ssh-keygen

Generating public/private rsa key pair. (Press Enter)
Enter file in which to save the key (/root/.ssh/id_rsa) (Press Enter)
Enter passphrase (empty for no passphrase): (Press Enter)
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
7f:b9:07:00:57:a0:55:c3:97:3f:f8:2d:36:53:ad:c4 root@server.example.com
The key's randomart image is:
+--[ RSA 2048]----+
|          o=+  . |
|        .o. ..o  |
|        .o   o...|
|          .  .E.+|
|        S  . ..oo|
|         .  ..*..|
|          . oo + |
|           . ..  |
|            ..   |
+-----------------+

2 :- Copy The Key to Second Machine using ssh-copy-id

[root@server ~]# ssh-copy-id -i  /root/.ssh/id_rsa.pub root@192.168.1.110
                                                            or
[root@server ~]# ssh-copy-id -i  /root/.ssh/id_rsa.pub station110.example.com

[root@server ~]#Enter Password  {only one time password entered of 2nd machine i.e. station110.example.com(192.168.1.110)}

Now try logging into the machine, with "ssh 'station110.example.com'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

3 :- Login to Second Machine {i.e. station110.example.com (192.168.1.110)}

[root@server ~]# ssh -Y 192.168.1.110

Last login: Mon Mar 18 02:36:34 2013 from 192.168.1.6 {Now This Time It Will Not Ask Any Password }

[root@station110 ~]# hostname
station110.example.com

[root@station110 ~]#


__________________________________________
If You See Error Like Agent admitted failure to sign using the key then-

This problem will fix using the command #ssh-add

[root@server ~]# ssh-add


Tuesday, March 12, 2013

Linux Locate Command With Example


ABOUT LOCATE COMMAND :-
:->> The locate command is usually the simplest and fastest way to find or search the locations of files and directories on Linux and other Unix-like operating systems.
NOTE:-   First of all Update the DataBase (Using the command updatedb )
#updatedb

The basic syntax for locate command is:-
#locate [options] name  (searching)

1  [root@station110 ~]# locate vinod
Output is :-
/home/vinod
/home/vinod/.bash_logout
/home/vinod/.bash_profile
/home/vinod/.bashrc
/home/vinod/.gnome2
/home/vinod/.mozilla
/home/vinod/.mozilla/extensions
/home/vinod/.mozilla/plugins
/root/vinod.gpg
/root/vinod.txt
/var/run/vinod.ping
/var/spool/mail/vinod

2  [root@station110 ~]# locate vinod.txt (it will locate vinod.txt file get into the system)
output :-   /root/vinod.txt

3  [root@station110 ~]# locate httpd.conf    (locate the configuration file path of httpd.conf)
/etc/httpd/conf/httpd.conf

4 [root@station110 ~]# locate tpvmlp.conf  (locate the all path of tpvmlp.conf )
/etc/tpvmlp.conf
/etc/vmware-tools/tpvmlp.conf

5 -Find(Locate) ignore-case (not a case sensitive)
[root@station110 ~]# locate htTpd.conf
[root@station110 ~]# locate -i htTpd.conf
/etc/httpd/conf/httpd.conf

6 -Using Limit to Locate the output file
[root@station110 ~]# locate -l 3 conf (it search 3 conf file it can be 30 , 100 etc.)
/boot/config-2.6.32-279.el6.x86_64
/boot/grub/grub.conf
/etc/ant.conf

7 -Find(Locate) file with full information related to it
[root@station110 ~]# locate httpd.conf | xargs ls -lah
-rw-r--r--. 1 root root 34K Feb  7  2012 /etc/httpd/conf/httpd.conf

8 -Find(Locate) 3 (.html) file
[root@station110 ~]# locate -n 3 "*.html"
/usr/lib64/eclipse/about.html
/usr/lib64/eclipse/epl-v10.html
/usr/lib64/eclipse/notice.html
                  OR
[root@station110 ~]# locate ".*html" | less
[root@station110 ~]# locate -n 2 "*.png" -q (The -q option is used to suppress error messages)
/etc/favicon.png
/root/.thumbnails/fail/gnome-thumbnail-factory/05e29bc60b9f79b9aa80c6ab93a31d00.png

______________________________________________
DIFFERENCE BETWEEN FIND AND LOCATE COMMAND:-

Both find and locate are useful commands in system administration. Both these commands can be used to search for data:
 find searches within the real system. Is slower however forever up-to-date and has a lots    of options (size, modification time,...)

 locate uses a previously built database (command updatedb). Is much faster, but uses an 'older' database and searches only names or parts of them.








Linux Find Command With Example

ABOUT FIND COMMAND :-
:->>  Find command is used to locate files on Linux system. Find command can search any set of directories you specify for files that match provided search criteria. We can search file by name size user permission etc. find provide the accurate result
                                        
The Linux Find Command is one of the most important and much used command in Linux systems. Find command used to search and locate list of files and directories based on conditions you specify

 1 -To Find all Passwd File in the system
 #find / -name passwd

2 -Find File Under A particular Directory   (Taking an example of directory /etc)
#find /etc -name passwd


3 -Find File using name Ignoring the upper-case and lower-case
#find / -iname PassWD          (Upper Case and Lower Case)

-Find Directories by Using Name
[root@station110 ~]# mkdir aa            (Create a directory aa)
[root@station110 ~]# cd /home/
[root@station110 home]# mkdir aa      (Create a directory in /home)
[root@station110 home]# cd
[root@station110 ~]# find / -type d -name aa
the output will be:-
/usr/share/locale/aa
/root/aa
/home/aa

5-find all .txt file
[root@station110 ~]# find . -type f -name "*.txt"
./.subversion/README.txt
./abc.txt
./vinod.txt

6-Find all files with using Permission
if we know only permission of the file then
#find / -perm 642
      or
# find . -type f -perm 642 -print
[root@station110 ~]# find / -perm 642
/root/ab.txt

 7-Find all file without permission of 642
# find  / -type f! -perm 642 -print

8 -Find Read Only Files
# find / -perm /u=r
Find Executable file
#find / perm /a=x

9 -Find the Empty file
[root@station110 ~]# find /tmp/ -type f -empty

10-Find and remove the Multiple File in single step
#Find . -type f -name "*.mp3" -exec rm -f {} \;
          or
#Find . -type f -name "*.gpg" -exec rm -f {} \;

11-Find all empty directories
 # find /tmp/ -type d -empty

12 -Find all the hidden files in the system
#find /tmp -type f -name ".*"

13 -Find files based on a particular user name
#find / -user root -name vinod.txt

14 -Find all the files based on the user (username)
#find /home -user vinod  (Here Vinod is a username)

15 -Find a particular file of a user
#find /home -user  redhat -iname "*.txt" (Redhat is username)

16 -Find all file based on group
#find /home -group developer(Group Name)

17 -Find last 50 days modified Files
#find / -mtime 50(find all files which are modified 50 days back)
     or
#find / -atime 50 (accessed)
   or
#find  / -mtime +50 -mtime -100 (find all file b/w 50-100 days)

18 Find -changed file in Last 1 Hour
#find / -cmin -60


19 -find modified files in last 1 hour
#find / -mmin -60
                 or
#find / -amin -60 (access file)

20 -Find files by using a particular size
#find / -size +32M   
                  or
# find / -size +50M -size -100M  (file size b/w 50-100MB)
          
21- Find the file with size and delete (all in single step)
find / -size +100M -exec rm -rf {} \; (find and delete)