agrover/targetcli-fb — pull request #9 by JonnyJD (2012-03-01 14:58:03+00:00)
Title: show current sessions: targetstatus script

There seems to be no way to list the current active sessions, other than ```cat /sys/kernel/config/target/iscsi/iqn.../tpg.../acls/iqn.../info```.

I would like to see who is actually connected to the target so I wrote a script that basically parses the mentioned configfs location for session information. It makes use of rtslib up to that point.

It lists the devices in use (short), the portals (short) and detailed information (both wwwns, tpg, lun, session+connection) for the currently open sessions.

Example:

Devices:
md_block0	/dev/disk/by-id/md-name-nas:iscsi
Sessions:
iscsi
iqn.2003-01.org.linux-iscsi.nas.i686:sn.xxx
tpgt_1
iqn.2005-03.org.open-iscsi:xxx (NOT AUTHENTICATED)
0 /dev/disk/by-id/md-name-nas:iscsi (r)
alias: haljo	sid: 2 type: Normal state: LOGGED_IN
address: 192.168.1.11	cid: 0 state: LOGGED_IN
iqn.2005-03.org.open-iscsi:xxx (NOT AUTHENTICATED)
0 /dev/disk/by-id/md-name-nas:iscsi (r)
alias: nas	sid: 1 type: Normal state: LOGGED_IN
address: 127.0.0.1	cid: 0 state: LOGGED_IN
Portals:
0.0.0.0:3260	iscsi

This is in use in the Arch Linux Pakage *targetcli-fb* for ```/etc/rc.d/target status```, because ```targetcli ls``` did not give the right information (and a lot of less important information).

This is somewhat of a replacement of what *lio-utils* does in ```/etc/init.d/target status```, but *lio-utils* gives no session information and has lots of information that I think are to detailed for a status overview.