]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/iscsi_tgt/idle_migration/connection_status.py
7 from subprocess
import check_output
9 rpc_py
= os
.path
.dirname(os
.path
.realpath(__file__
)) + '/../../../scripts/rpc.py'
11 class spdk_rpc(object):
13 def __init__(self
, rpc_py
):
16 def __getattr__(self
, name
):
18 cmd
= "python {} {}".format(self
.rpc_py
, name
)
20 cmd
+= " {}".format(arg
)
21 return check_output(cmd
, shell
=True)
24 if __name__
== '__main__':
26 if (len(sys
.argv
) < 2) or (sys
.argv
[1] != "idle" and sys
.argv
[1] != "active"):
27 print "must specify \"idle\" or \"active\""
30 rpc
= spdk_rpc(rpc_py
)
35 # capture connection state 10 times, 10 ms apart and keep a
36 # a running count of how many connections were found idle
40 conns
= json
.loads(rpc
.get_iscsi_connections())
41 num_conns
= len(conns
)
44 if conn
['is_idle'] == 1:
52 active_pct
= float(active
) / (idle
+ active
)
54 # even when there is no active I/O on a connection, there could be
55 # a nopin/nopout being processed which causes a connection to
56 # temporarily go active; also even when fio is actively running
57 # there could be a brief period of time where the initiator has
58 # no active I/O to some connection
60 # so do not enforce that *all* connections must be idle or active;
61 # allow for some percentage of anomalies
62 anomaly_pct_allowed
= 0.10
64 print "active = {}".format(active
)
65 print "idle = {}".format(idle
)
66 print "active_pct = {}".format(active_pct
)
68 if sys
.argv
[1] == "idle" and active_pct
> anomaly_pct_allowed
:
71 if sys
.argv
[1] == "active" and active_pct
< (1.00 - anomaly_pct_allowed
):