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

[portstat, intfstat] added rates and utilization #1750

Merged
merged 1 commit into from
Sep 8, 2021

Conversation

vadymhlushko-mlnx
Copy link
Contributor

@vadymhlushko-mlnx vadymhlushko-mlnx commented Aug 10, 2021

What I did

Depends on sonic-swss-common/pull/330

According to HLD added calculation of rates and utilization columns to the portstat and intfstat scripts output

How I did it

Modified the portstat and intfstat scripts

How to verify it

Added UT

Previous command output (if the output of a command-line utility has changed)

admin@sonic:~$ show int count
      IFACE    STATE    RX_OK    RX_BPS    RX_UTIL    RX_ERR    RX_DRP    RX_OVR    TX_OK    TX_BPS    TX_UTIL    TX_ERR    TX_DRP    TX_OVR
-----------  -------  -------  --------  ---------  --------  --------  --------  -------  --------  ---------  --------  --------  --------
  Ethernet0        X        0       N/A        N/A         0         0       N/A        0       N/A        N/A         0         0       N/A
  Ethernet2        U      287       N/A        N/A         0         0       N/A      818       N/A        N/A         0         0       N/A
  Ethernet4        U      380       N/A        N/A         0         0       N/A      858       N/A        N/A         0         0       N/A
  Ethernet6        U      286       N/A        N/A         0         0       N/A      850       N/A        N/A         0         0       N/A

New command output (if the output of a command-line utility has changed)

admin@sonic:~$ show int count
      IFACE    STATE    RX_OK      RX_BPS    RX_UTIL    RX_ERR    RX_DRP    RX_OVR    TX_OK      TX_BPS    TX_UTIL    TX_ERR    TX_DRP    TX_OVR
-----------  -------  -------  ----------  ---------  --------  --------  --------  -------  ----------  ---------  --------  --------  --------
  Ethernet0        X        0    0.00 B/s      0.00%         0         0       N/A        0    0.00 B/s      0.00%         0         0       N/A
  Ethernet2        U        0    0.00 B/s      0.00%         0         0       N/A        0    0.00 B/s      0.00%         0         0       N/A
  Ethernet4        U        0    0.00 B/s      0.00%         0         0       N/A        0    0.00 B/s      0.00%         0         0       N/A
  Ethernet6        U        0    0.00 B/s      0.00%         0         0       N/A        0    0.00 B/s      0.00%         0         0       N/A

@vadymhlushko-mlnx
Copy link
Contributor Author

This PR was introduced instead of pull/817

pull/817 should be closed

@vadymhlushko-mlnx
Copy link
Contributor Author

@dgsudharsan could you please review?

@lgtm-com
Copy link

lgtm-com bot commented Aug 10, 2021

This pull request introduces 1 alert when merging b784d50 into 30907c4 - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

return "{:.2f}".format(float(rate))+'/s'

def format_util(brate, port_rate=PORT_RATE):
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid assuming PORTE_RATE=40 here? I believe there are multitude of speeds and If speed in unavailable in config_db.json I am ok with displaying rate as N/A rather than using 40.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already fixed

if brate == STATUS_NA:
return STATUS_NA
else:
util = brate/(float(port_rate)*1024*1024*1024/8.0)*100
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assume that speed is always in Gbps? I believe here we convert it from Mbps to Gpbs and pass it on here. But in future if we have a system which has deployment less than 1Gpbs this logic will fail. Instead I propose to use the default measurement unit used in the port table (Mbps) and modify the calculation accordingly here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already fixed

dgsudharsan
dgsudharsan previously approved these changes Aug 16, 2021
dgsudharsan
dgsudharsan previously approved these changes Aug 16, 2021
@vadymhlushko-mlnx
Copy link
Contributor Author

@lguohan could you please merge?

utilities_common/netstat.py Outdated Show resolved Hide resolved
@vadymhlushko-mlnx
Copy link
Contributor Author

@ganglyu, @dgsudharsan could you please approve?

dgsudharsan
dgsudharsan previously approved these changes Sep 1, 2021
ganglyu
ganglyu previously approved these changes Sep 2, 2021
@vadymhlushko-mlnx
Copy link
Contributor Author

@ganglyu, @dgsudharsan could you please review and approve again, because there were some merge conflicts?

@vadymhlushko-mlnx
Copy link
Contributor Author

@liat-grozovik could you please help to merge?

@qiluo-msft qiluo-msft merged commit 2b12aad into sonic-net:master Sep 8, 2021
@qiluo-msft
Copy link
Contributor

This commit could not be cleanly cherry-pick to 202012. Please submit another PR.

qiluo-msft pushed a commit that referenced this pull request Sep 13, 2021
#### What I did

Backport the [pull/1750](#1750) to `202012` branch

Depends on [sonic-swss-common/pull/330](sonic-net/sonic-swss-common#330)

According to [HLD](https://github.com/Azure/SONiC/blob/master/doc/rates-and-utilization/Rates_and_utilization_HLD.md) added calculation of rates and utilization columns to the `portstat` and `intfstat` scripts output

#### How I did it

Modified the `portstat` and `intfstat` scripts

#### How to verify it

Added UT
judyjoseph pushed a commit that referenced this pull request Sep 14, 2021
#### What I did

Depends on [sonic-swss-common/pull/330](sonic-net/sonic-swss-common#330)

According to [HLD](https://github.com/Azure/SONiC/blob/master/doc/rates-and-utilization/Rates_and_utilization_HLD.md) added calculation of rates and utilization columns to the `portstat` and `intfstat` scripts output

#### How I did it

Modified the `portstat` and `intfstat` scripts

#### How to verify it

Added UT

#### Previous command output (if the output of a command-line utility has changed)

```
admin@sonic:~$ show int count
      IFACE    STATE    RX_OK    RX_BPS    RX_UTIL    RX_ERR    RX_DRP    RX_OVR    TX_OK    TX_BPS    TX_UTIL    TX_ERR    TX_DRP    TX_OVR
-----------  -------  -------  --------  ---------  --------  --------  --------  -------  --------  ---------  --------  --------  --------
  Ethernet0        X        0       N/A        N/A         0         0       N/A        0       N/A        N/A         0         0       N/A
  Ethernet2        U      287       N/A        N/A         0         0       N/A      818       N/A        N/A         0         0       N/A
  Ethernet4        U      380       N/A        N/A         0         0       N/A      858       N/A        N/A         0         0       N/A
  Ethernet6        U      286       N/A        N/A         0         0       N/A      850       N/A        N/A         0         0       N/A
```

#### New command output (if the output of a command-line utility has changed)

```
admin@sonic:~$ show int count
      IFACE    STATE    RX_OK      RX_BPS    RX_UTIL    RX_ERR    RX_DRP    RX_OVR    TX_OK      TX_BPS    TX_UTIL    TX_ERR    TX_DRP    TX_OVR
-----------  -------  -------  ----------  ---------  --------  --------  --------  -------  ----------  ---------  --------  --------  --------
  Ethernet0        X        0    0.00 B/s      0.00%         0         0       N/A        0    0.00 B/s      0.00%         0         0       N/A
  Ethernet2        U        0    0.00 B/s      0.00%         0         0       N/A        0    0.00 B/s      0.00%         0         0       N/A
  Ethernet4        U        0    0.00 B/s      0.00%         0         0       N/A        0    0.00 B/s      0.00%         0         0       N/A
  Ethernet6        U        0    0.00 B/s      0.00%         0         0       N/A        0    0.00 B/s      0.00%         0         0       N/A
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants