Tuesday, September 26, 2017

Send mail as HTML Format using Shell Script

Use the below script to send the mail as HTML Format using Shell Script.

# Send mail

export MAILTO="abc@xyz.com" ## Mail address
export CONTENT="/var/index.html" ## HTML Path
export SUBJECT="HTML Mail"
(
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
cat $CONTENT
) | /usr/sbin/sendmail $MAILTO

fi

Tuesday, July 8, 2014

How check the HBA Port status in Linux

Use the below commands to check the HBA Port status in Linux

[root@localhost ~]# ls /sys/class/fc_host/
host5  host6
[root@localhost ~]# cat /sys/class/fc_host/host*/port_state 
Online
Online
[root@localhost ~]# 

Reset the HBA using the below procedure. If not fixed check the hardware. 

http://shyjug.blogspot.com/2013/11/reset-hba-card-using-hbacmd-in-rhelinux.html

Friday, December 6, 2013

Clear swap cache memory in RHEL Linux

Here is the command to clear the swap cache memory in RHEL Linux.

sync; echo 3 > /proc/sys/vm/drop_caches

or

sync && /sbin/sysctl vm.drop_caches=3 && swapoff -a && swapon -a


Now check the cache using top , free -m or vmstat 2 5.

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"