⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iscsi-ls

📁 ISCSI user client software.Client would be used to access the IPSAN server.
💻
字号:
#! /bin/sh# Display iscsi targetsHOST_PATH=/sys/class/iscsi_hostSCSI_HOST=/sys/class/scsi_hostCLASS_PATH=/sys/class/iscsi_transport_classprint_usage(){	echo        echo "Usage: iscsi-ls [-c] [-l] [-i host_id]"        echo "-c : iSCSI target configuration parameters"        echo "-i : Details regarding the specific host ID"        echo "-l : Lun details available on the target"}is_num(){	case "$1" in	-*[!0-9]*) rval=0;;	*) rval=1;;	esac}find_host_ids(){	i=0	if [ $opt_i ]; then		hosts=host$opt_i		if [ ! -e $SCSI_HOST/$hosts ]; then			echo "Host $opt_i does not exist"			exit 1		fi	else		hosts=`ls -1 $SCSI_HOST/`	fi	for host in $hosts; do		host=$SCSI_HOST/$host		proc_name=`cat $host/proc_name`		if [ "$proc_name" = "iscsi-sfnet" ]; then			host_no=${host:${#SCSI_HOST} + 5}			host_ids[$i]=$host_no			let "i += 1"		elif [ $opt_i ]; then			echo "Device is not an iSCSI device"		fi	done}show_session_status(){	session_alive=`cat $SCSI_HOST/host$1/session_alive`	if [ $session_alive -eq 0 ]; then		drop_time=`cat $SCSI_HOST/host$1/session_drop_time`		echo -n "SESSION STATUS          : CONNECTION DROPPED AT "		date -d ''$drop_time' seconds ago'	else		est_time=`cat $SCSI_HOST/host$1/session_established_time`		echo -n "SESSION STATUS          : CONNECTION ESTABLISHED AT "		date -d ''$est_time' seconds ago'	fi}print_common_info(){	echo "TARGET NAME             :" `cat $1/target_name`	echo "TARGET ALIAS            :" `cat $1/target_alias`	echo "HOST NO                 : $2" 	echo -n "TARGET ADDRESS          : "	echo `cat $1/ip_address`:`cat $1/port`,`cat $1/tpgt`	show_session_status $2	echo "SESSION ID              : ISID" `cat $1/isid`	echo "                          TSIH" `cat $1/tsih`}print_lun_info(){	luns=`ls -d $1/device/$2:0:0* 2> /dev/null`	echo "DEVICE DETAILS:"	echo "---------------"	for lun in $luns; do		lun_no=${lun##[/]*[:]}		echo -n "LUN NO: $lun_no               : "		unset device		if [ -h $lun/block ]; then			device=`ls -l $lun/block`		elif [ -h $lun/tape ]; then			device=`ls -l $lun/tape`		fi		if [ "$device" ]; then			device=`echo $device | awk -F ' ' '{print $NF}'`			device=${device##[.]*[/]}			echo $device		else			echo " "		fi		echo "  Vendor                :" `cat $lun/vendor`		echo "  Model                 :" `cat $lun/model`		echo "  Rev                   :" `cat $lun/rev`	done}print_config_info(){	echo "TARGET CONFIGURATION KEYS :"	echo "-------------------------"	echo "INITIAL R2T             :" `cat $1/initial_r2t`	echo "IMMEDIATE DATA          :" `cat $1/immediate_data`	echo "HEADERDIGEST            :" `cat $1/header_digest`	echo "DATA DIGEST             :" `cat $1/data_digest`	echo "FIRSTBURSTLENGTH        :" `cat $1/first_burst_len`	echo "MAXBURSTLENGTH          :" `cat $1/max_burst_len`	echo -n "MAXRECVDATASEGMENTLENGTH: initiator - "	cat $1/max_recv_data_segment_len	echo "LOGIN TIMEOUT           :" `cat $SCSI_HOST/host$2/login_timeout`	echo "AUTH TIMEOUT            :" `cat $SCSI_HOST/host$2/auth_timeout`	echo "ACTIVE TIMEOUT          :" `cat $SCSI_HOST/host$2/active_timeout`	echo "IDLE TIMEOUT            :" `cat $SCSI_HOST/host$2/idle_timeout`	echo "PING TIMEOUT            :" `cat $SCSI_HOST/host$2/ping_timeout`}while [ -n "$1" ]; docase $1 in    -c)	opt_c=1	shift 1;;    -i)	if [ $2 ];then		is_num $2		if [ $rval -eq  1 ];then			opt_i=$2			shift 2		else			print_usage			exit 1		fi	else		print_usage		exit 1	fi;;    -l)	opt_l=1	shift 1;;    *)	print_usage	exit 1;;esacdonecat /proc/devices | grep -q iscsictlif [ $? -ne 0 ]; then	echo "###############################################################################"	echo "iSCSI driver is not loaded"	echo "###############################################################################"	exitfiecho "*******************************************************************************"echo -n "SFNet iSCSI Driver Version ..."iscsid -v | awk '{ print $3 $4 $5 }'echo "*******************************************************************************"declare -a host_idsfind_host_idsno_hosts=${#host_ids[*]}i=0while [ $i -lt $no_hosts ]; do	target=$CLASS_PATH/target${host_ids[$i]}:0:0	if [ -e $target ]; then		print_common_info $target ${host_ids[$i]}		if [ $opt_l ]; then			print_lun_info $target ${host_ids[$i]}		fi		if [ $opt_c ]; then			print_config_info $target ${host_ids[$i]}		fi		echo "-------------------------------------------------------------------------------"	fi	let "i += 1"done

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -