Monday, November 25, 2013

Reset HBA Card using hbacmd in RHELinux

Here are the commands to reset the HBA Card.

Get the WWN number using list command

# /usr/sbin/hbanyware/hbacmd listhbas


Manageable HBA List

Port WWN   : 10:00:00:00:XX:XX:XX:XX
Node WWN   : 20:00:00:00:XX:XX:XX:XX
Fabric Name: 10:00:00:05:XX:XX:XX:XX
Flags      : 8000fexx
Host Name  : localhost
Mfg        : Emulex Corporation

then Reset

# /usr/sbin/hbanyware/hbacmd Reset 10:00:00:00:XX:XX:XX:XX


Reset HBA 10:00:00:00:XX:XX:XX:XX


Also, you can use the below commands to get HBA Attribute & Port attribute.


# /usr/sbin/hbanyware/hbacmd HBAAttrib 10:00:00:00:XX:XX:XX:XX

# /usr/sbin/hbanyware/hbacmd PortAttrib 10:00:00:00:XX:XX:XX:XX

Tuesday, November 19, 2013

How to delete / unmap the lun from RHEL Servers

Here is the procedure to delete / unmap the lun from RHEL Servers.

Pass echo 1 to the corresponding device which you want to delete or unmap.

# echo 1 > /sys/block/sde/device/delete
# echo 1 > /sys/block/sde/device/delete

How to scan New Lun / San Disk in RHEL Linux

Here is the different methods to scan the new Luns / SAN Disks in Qlogic and Emulex.


# /usr/bin/rescan-scsi-bus.sh (or) /sbin/rescan-scsi-bus.sh

rescan-scsi-bus.sh script can automatically update the logical unit configuration of the host as needed (after a device has been added to the system). The rescan-

scsi-bus.sh script can also perform an issue_lip on supported devices.

# lun_scan.sh

Emulex Linux LUN/target scan script enables you to dynamically (without a reboot, driver unload/reload, or HBA reset) discover new targets and LUNs (on new or existing targets) that have come online. This feature is supported via standard Linux mechanisms. The script enables you to automatically discover all new devices.


# ql-scan-lun.sh

This utility scans for the newly added LUNs. After adding the new LUNs it is not required to unload/load the QLogic FC driver or reboot the system. To see the newly added LUNs, just run the ql-scan-lun.sh utility.


By default the utility would re-scan the QLogic HBAs for new LUNs.


Manual Procedure for Qlogic


# echo "scsi-qlascan" > /proc/scsi/qla2300/0
# cat /proc/scsi/qla2300/0

Other Procedure for Emulex

for i in 0 1 2 3 4 5 6
do
echo "1" > /sys/class/fc_host/host$i/issue_lip
echo "- - -" > /sys/class/scsi_host/host$i/scan
done

Note : if scsi_host not exists, use fc_host

you can run fdisk -l or multipath -ll to see the new luns once its visible. also you can use sg_map -sd for disk mapping.

Sunday, November 17, 2013

How to find WWN/WWPN Number in RHELinux.

To find WWN/WWPN Number in RHELinux.

Here are the commands to get the wwpn from Qlogic or Emulex.
First check your HBA Card information using my previous blog.

http://shyjug.blogspot.com/2013/11/how-to-find-hba-card-qlogic-emulex-in_17.html

RHEL 3

Emulex card      # cat /proc/scsi/lpfc/host*/port_name
Qlogic card     # cat /proc/scsi/qla2*/* 2>/dev/null | grep "adapter-port"

RHEL 4

Emulex card      # cat /sys/class/scsi_host/host*/port_name
Qlogic card     # cat /proc/scsi/qla2*/* 2>/dev/null | grep "adapter-port"

RHEL 5

Emulex card      # cat /sys/class/fc_host/host*/port_name
Qlogic card     # cat /proc/scsi/qla2*/* 2>/dev/null | grep "adapter-port"

RHEL 6

Emulex card      # cat /sys/class/fc_host/host*/port_name
Qlogic card     # cat /proc/scsi/qla2*/* 2>/dev/null | grep "adapter-port"

How to find HBA Card Information ( Qlogic & Emulex ) in RHEL Linux‏

There are multiple commands you can use to get the HBA Card information weather its Qlogic or Emulex in Redhat Linux.

# lsmod | grep -i 'lpfc\|qla'

# lspci | grep -i fibre

# systool -c scsi_host –v

# /usr/sbin/hbanyware/hbacmd listhbas

Also you can see the HBA card information from dmesg and /var /log/messages after reboot.

 # inq –hba

Inq is a command line utiliy from EMC to display the storage information, Lun id, capacity and etc . also you can use inq for QLogic alswell.

# scli

Scli is a Qlogic utility to display the storage information like HBA Card, WWPN etc..
 

Friday, July 1, 2011

Remove Failed Login in Linux

To check failed Login

# faillog -u username

To remove failed Login

# faillog -r username

# pam_tally2 --user=username --reset


Saturday, February 6, 2010

Installing and configuring Nagios on RHEL5


About Nagios:-

       Basically Nagios (http://www.nagios.org) is an open source host, service and network monitoring tool. It let's you manage different types of services and hosts running on different operating systems like linux, netware, windows, aix ,.... It's flexible in configuration and can be extended as much as you want. It's configured within text files and managed with a web browser.

Nagios Features:- 
 
      Nagios has a lot of features, making it a very powerful monitoring tool. Some of the major features are listed below:
**. Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
**. Monitoring of host resources (processor load, disk and memory usage, running processes, log files, etc.)

Prerequisites:- 

During portions of the installation you'll need to have root access to your machine.
Make sure you've installed the following packages on your Redhat installation before continuing.
* Apache
* GCC compiler
* GD development libraries
First check weather the following packeges are installed or not in your system by following commands (as root)

# rpm -qa | grep httpd*
# rpm -qa | grep gcc*
# rpm -qa | grep glibc*
# rpm -qa | grep gd*

If it is not installed (httpd, gcc, glibc, glibc-common, gd, gd-devel), You can use yum to install these packages by running the following commands.

#yum install httpd*
#
yum install gcc*
#
yum install glibc*
#
yum install gd*

1) Create Account Information

Become the root user.

#su - root
or
#sudo su -

Create a new nagios user account and give it a password.

#useradd -m nagios
#passwd nagios

Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

#groupadd nagcmd
#
usermod -a -G nagcmd nagios3
#
usermod -a -G nagcmd apache

2) Download Nagios and the Plugins

Create a directory for storing the downloads.

#mkdir ~/downloads
#
cd ~/downloads

Download the source code tarballs of both Nagios and the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions). At the time of writing, the latest versions of Nagios and the Nagios plugins were 3.2.0 and 1.4.14, respectively.

#wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.0/nagios-3.2.0.tar.gz/download
#
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.14/nagios-plugins-1.4.14.tar.gz/download


3) Compile and Install Nagios

Extract the Nagios source code tarball.

#cd ~/downloads
#
tar xzf nagios-3.2.0.tar.gz
#
cd nagios-3.2.0

Run the Nagios configure script, passing the name of the group you created earlier like so:

#./configure --with-command-group=nagcmd

Compile the Nagios source code.

#make all

Install binaries, init script, sample config files and set permissions on the external command directory.

#
make install
#
make install-init
#
make install-config
#
make install-commandmode

Don't start Nagios yet - there's still more that needs to be done...

4) Customize Configuration

Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You'll need to make just one change before you proceed...

Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts.

#vi /usr/local/nagios/etc/objects/contacts.cfg
(you can use any editor as you wish)

5) Configure the Web Interface

Install the Nagios web config file in the Apache conf.d directory.


#make install-webconf

Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.

#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache to make the new settings take effect.

#service httpd restart

Note Note: Consider implementing the ehanced CGI security measures described here to ensure that your web authentication credentials are not compromised.

6) Compile and Install the Nagios Plugins

Extract the Nagios plugins source code tarball.

#cd ~/downloads
#
tar xzf nagios-plugins-1.4.14.tar.gz
#
cd nagios-plugins-1.4.14

Compile and install the plugins.

#./configure --with-nagios-user=nagios --with-nagios-group=nagios
#
make
#
make install

7) Start Nagios

Add Nagios to the list of system services and have it automatically start when the system boots.

#chkconfig --add nagios
#
chkconfig nagios on

Verify the sample Nagios configuration files.

#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios.

#service nagios start

8) Modify SELinux Settings

Redhat /Fedora ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs.

See if SELinux is in Enforcing mode.

#getenforce

Put SELinux into Permissive mode.

#setenforce 0

To make this change permanent, you'll have to modify the settings in /etc/selinux/config and reboot.

Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode:

#chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
#
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

For information on running the Nagios CGIs under Enforcing mode with a targeted policy, visit the NagiosCommunity.org wiki at http://www.nagioscommunity.org/wiki.

9) Login to the Web Interface

You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier.

http://localhost/nagios/ or http://your ip/nagios

Click on the "Service Detail" navbar link to see details of what's being monitored on your local machine. It will take a few minutes for Nagios to check all the services associated with your machine, as the checks are spread out over time.

Screenshots:-
Login Screen 
 
 Main Page
  

  
10) Other Modifications


Make sure your machine's firewall rules are configured to allow access to the web server if you want to access the Nagios interface remotely.

Configuring email notifications is out of the scope of this documentation. While Nagios is currently configured to send you email notifications, your system may not yet have a mail program properly installed or configured. Refer to your system documentation, search the web, or look to the NagiosCommunity.org wiki for specific instructions on configuring your system to send email messages to external addresses. More information on notifications can be found here.


What You'll End Up With

If you follow these instructions, here's what you'll end up with:

* Nagios and the plugins will be installed underneath /usr/local/nagios
* Nagios will be configured to monitor a few aspects of your local system (CPU load, disk usage, etc.)
* The Nagios web interface will be accessible at http://localhost/nagios/