Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get network interface througput #12

Open
obeleh opened this issue Nov 5, 2018 · 2 comments
Open

get network interface througput #12

obeleh opened this issue Nov 5, 2018 · 2 comments

Comments

@obeleh
Copy link

obeleh commented Nov 5, 2018

Where / how can I get the network interface throughput and latencies?

@mksteele
Copy link
Contributor

mksteele commented Nov 7, 2018

Depends what you mean.

Both list_network_interfaces and list_hardware have a "speed" field corresponding to the link speed.

The list_hardware speed is "live," meaning it shows the actual interface speed right now. This is the value of "Link" when you hover over an ethernet port in the GUI's health graphic. The list_network_interfaces speed is the speed configured on the port.

Here's an example of how the two can differ:

ct0.eth0
	 list_network_interfaces speed: 1.00 Gb/s
	 list_hardware speed: 1.00 Gb/s
ct0.eth1
	 list_network_interfaces speed: 1.00 Gb/s
	 list_hardware speed: 0.00 b/s     <-- nothing is plugged into this port
ct0.eth8
	 list_network_interfaces speed: 10.00 Gb/s
	 list_hardware speed: 10.00 Gb/s
ct0.eth9
	 list_network_interfaces speed: 10.00 Gb/s
	 list_hardware speed: 10.00 Gb/s
ct1.eth0
	 list_network_interfaces speed: 1.00 Gb/s
	 list_hardware speed: 1.00 Gb/s
ct1.eth1
	 list_network_interfaces speed: 1.00 Gb/s
	 list_hardware speed: 0.00 b/s
ct1.eth2
	 list_network_interfaces speed: 10.00 Gb/s
	 list_hardware speed: 10.00 Gb/s
ct1.eth3
	 list_network_interfaces speed: 10.00 Gb/s
	 list_hardware speed: 10.00 Gb/s
ct1.eth8
	 list_network_interfaces speed: 10.00 Gb/s
	 list_hardware speed: 10.00 Gb/s
ct1.eth9
	 list_network_interfaces speed: 10.00 Gb/s
	 list_hardware speed: 10.00 Gb/s

Source:

import purestorage

array = purestorage.FlashArray("dogfood-snausage", "miranda", "****")

network_ifaces = array.list_network_interfaces()
hardware_ifaces = array.list_hardware()

network_speed_val_to_suffix = {
    1: 'b/s',
    pow(10, 3) : 'Kb/s',
    pow(10, 6) : 'Mb/s',
    pow(10, 9) : 'Gb/s'
}

def display_speed(val):
    suffix = network_speed_val_to_suffix[1]
    for multiplier in reversed(sorted(network_speed_val_to_suffix.keys())):
        if val >= multiplier:
            suffix = network_speed_val_to_suffix[multiplier]
            val = float(val) / multiplier
            return '%.2f %s' % (val, suffix)
    return '%.2f %s' % (val, suffix)

for network_iface in network_ifaces:
    for hardware_iface in hardware_ifaces:
        if network_iface["name"] == hardware_iface["name"].lower():
            print("{}".format(network_iface["name"]))
            print("\t list_network_interfaces speed: {}".format(display_speed(network_iface["speed"])))
            print("\t list_hardware speed: {}".format( display_speed(hardware_iface["speed"]) ))

Hope that helps... Anything more than that (latencies, read/write stats) do not exist in the API right now.

@obeleh
Copy link
Author

obeleh commented Nov 7, 2018

Thanks for your answer. I was really looking for throughput and latency. The speeds, I've already found those.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants