码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 如何通过 iscsi target name 获取 ip

时间:2019-07-26 17:23:37      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:bash   user   The   linux   not found   and   res   idg   bin   

by Mike Andrews

# lsscsi -t
[2:0:0:0]    disk    iqn.2009-12.com.blockbridge:t-pjxfzufjkp-illoghjk,t,0x1  /dev/sda
[3:0:0:0]    disk    iqn.2009-12.com.blockbridge:t-pjxfzuecga-eajejghg,t,0x1  /dev/sdb
[4:0:0:0]    disk    iqn.2009-12.com.blockbridge:t-pjxfzufjjo-pokqaja,t,0x1  /dev/sdd
[5:0:0:0]    disk    iqn.2009-12.com.blockbridge:t-pjxfzufnfg-cqikkgl,t,0x1  /dev/sdc

 

# iscsiadm -m node -T iqn.2009-12.com.blockbridge:t-pjxfzufjkp-illoghjk | egrep node.conn.+address

node.conn[0].address = 172.16.5.148

 

#!/usr/bin/bash

if [[ -z $1 ]]; then
    >&2 echo "Usage: devip.sh <device>"
    exit 1
fi

iqn=$(sudo lsscsi -t | grep "$1" | grep iqn | awk {print $3} | awk -F , {print $1})
if [[ -z "$iqn" ]]; then
    >&2 echo "IQN not found for \"$1\"."
    exit 1
fi

sudo iscsiadm -m node -T $iqn | egrep node.conn.+address | awk -F  *= * {print $2}
exit $?

 

Linux 如何通过 iscsi target name 获取 ip

标签:bash   user   The   linux   not found   and   res   idg   bin   

原文地址:https://www.cnblogs.com/liujx2019/p/11251605.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!