Skip to content
Snippets Groups Projects
Commit 3f7433ae authored by Zanting's avatar Zanting
Browse files

Packet rate scripts for ARTS-0

parent 92e4ce5d
No related branches found
No related tags found
No related merge requests found
import subprocess
import time
########################################################################
# Execute ifconfig twice with a one second interval to find the number
# of packets received per second.
########################################################################
cmd = 'ifconfig'
args = 'em2'
cmd_output = []
rx_packets_str = []
rx_packets = []
rx_bytes_str = []
rx_bytes = []
for i in range(2):
p = subprocess.Popen([cmd, args], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
cmd_output.append(out)
time.sleep(1)
for i in range(2):
string_list = cmd_output[i].split()
rx_packets_str.append(string_list[17])
rx_bytes_str.append(string_list[19])
rx_packets.append(int(rx_packets_str[i])) #.split(':')[1]))
rx_bytes.append(int(rx_bytes_str[i])) #.split(':')[1]))
packets_per_second = rx_packets[1]-rx_packets[0]
gigabits_per_second = (float(rx_bytes[1]-rx_bytes[0])*8)/1000000000
print '\n', packets_per_second, 'packets per second'
print gigabits_per_second, 'Gbps\n'
import subprocess
import time
########################################################################
# Execute ifconfig twice with a one second interval to find the number
# of packets received per second.
########################################################################
cmd = 'ifconfig'
args = 'p4p1'
cmd_output = []
rx_packets_str = []
rx_packets = []
rx_bytes_str = []
rx_bytes = []
for i in range(2):
p = subprocess.Popen([cmd, args], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
cmd_output.append(out)
time.sleep(1)
for i in range(2):
string_list = cmd_output[i].split()
rx_packets_str.append(string_list[17])
rx_bytes_str.append(string_list[19])
rx_packets.append(int(rx_packets_str[i])) #.split(':')[1]))
rx_bytes.append(int(rx_bytes_str[i])) #.split(':')[1]))
packets_per_second = rx_packets[1]-rx_packets[0]
gigabits_per_second = (float(rx_bytes[1]-rx_bytes[0])*8)/1000000000
print '\n', packets_per_second, 'packets per second'
print gigabits_per_second, 'Gbps\n'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment