I have written this code which will get certain output from a server using paramiko module. Now i am struggling to figure out how to search for an output that has greater then zero value and print it.
cmd1 = 'statvv -d 10 -iter 1 ' + (row[2])
stdin, stdout, stderr = ssh_client.exec_command(cmd1)
io_check = (stdout.read().decode(encoding='ascii'))
print(io_check)
This is the output i get from above:-
16:35:04 03/10/2020 r/w I/O per second KBytes per sec Svt ms IOSz KB
VVname Cur Avg Max Cur Avg Max Cur Avg Cur Avg Qlen
DW345T77-shared-NC.160 t 9 8 12 37 38 38 0.03 0.03 4.2 4.2 0
--------------------------------------------------------------------------------
1 t 9 9 38 38 0.03 0.03 4.2 4.2 0
16:35:10 03/10/2020 r/w I/O per second KBytes per sec Svt ms IOSz KB
VVname Cur Avg Max Cur Avg Max Cur Avg Cur Avg Qlen
DCAWERB07-shared-NC.120 t 0 0 0 0 0 0 0 0 0 0 0
--------------------------------------------------------------------------------
1 t 0 0 0 0 0.00 0.00 0.0 0.0 0
There will be hundreds of output like this. I am only interested on printing the output whose 'Cur' value is greater then zero. The above example is two output from the command in which first one's value is greater then zero ( which i need to print ) ... Second one has 'Cur' as zero so I don't need it.
I have no tricky/easy way to do this.
Loop through the input lines doing the obvious:
It's ugly, but anything based on regular expressions or whatever will likely be more fragile than the direct approach.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.