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

[jsk_network_tools] add skip_interfaces param in network_status.py #1664

Merged
merged 2 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ ROS Packages:
jsk_data/index
jsk_tools/index
jsk_topic_tools/index
jsk_network_tools/index
12 changes: 12 additions & 0 deletions doc/jsk_network_tools/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=================
jsk_network_tools
=================

This ROS package includes JSK network tools.

.. toctree::
:glob:
:maxdepth: 1
:caption: scripts

./scripts/*
103 changes: 103 additions & 0 deletions doc/jsk_network_tools/scripts/network_status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# network_status.py

Publish network status

```bash
$ rostopic list
/ecublens/docker0/receive
/ecublens/docker0/receive_kbps
/ecublens/docker0/receive_mbps
/ecublens/docker0/transmit
/ecublens/docker0/transmit_kbps
/ecublens/docker0/transmit_mbps
/ecublens/eno1/receive
/ecublens/eno1/receive_kbps
/ecublens/eno1/receive_mbps
/ecublens/eno1/transmit
/ecublens/eno1/transmit_kbps
/ecublens/eno1/transmit_mbps
/ecublens/eno2/receive
/ecublens/eno2/receive_kbps
/ecublens/eno2/receive_mbps
/ecublens/eno2/transmit
/ecublens/eno2/transmit_kbps
/ecublens/eno2/transmit_mbps
/ecublens/lo/receive
/ecublens/lo/receive_kbps
/ecublens/lo/receive_mbps
/ecublens/lo/transmit
/ecublens/lo/transmit_kbps
/ecublens/lo/transmit_mbps
/ecublens/nonlocal/receive
/ecublens/nonlocal/receive_kbps
/ecublens/nonlocal/receive_mbps
/ecublens/nonlocal/transmit
/ecublens/nonlocal/transmit_kbps
/ecublens/nonlocal/transmit_mbps
```

## Publishing Topics

* `/<host name>/<interface name>/receive`

Amount of receiving data by the interface in bps

* `/<host name>/<interface name>/receive_kbps`

Amount of receiving data by the interface in Kbps

* `/<host name>/<interface name>/receive_mbps`

Amount of receiving data by the interface in Mbps

* `/<host name>/<interface name>/transmit`

Amount of transmitting data by the interface in bps

* `/<host name>/<interface name>/transmit_kbps`

Amount of transmitting data by the interface in Kbps

* `/<host name>/<interface name>/transmit_mbps`

Amount of transmitting data by the interface in Mbps

* `/<host name>/nonlocal/receive`

Amount of receiving data by the non-local interfaces in bps

* `/<host name>/nonlocal/receive_kbps`

Amount of receiving data by the non-local interfaces in Kbps

* `/<host name>/nonlocal/receive_mbps`

Amount of receiving data by the non-local interfaces in Mbps

* `/<host name>/nonlocal/transmit`

Amount of transmitting data by the non-local interfaces in bps

* `/<host name>/nonlocal/transmit_kbps`

Amount of transmitting data by the non-local interfaces in Kbps

* `/<host name>/nonlocal/transmit_mbps`

Amount of transmitting data by the non-local interfaces in Mbps

## Parameters

* `~hz` (`float`, default: `10`)

Publish frequency

* `~skip_interfaces` (`List of string`, default: `None`)

List of skipping interface names

## Usage

```bash
rosrun jsk_network_tools network_status.py
```
7 changes: 5 additions & 2 deletions jsk_network_tools/scripts/network_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self):
rospy.init_node('network')
self.match_face = re.compile('(.+):(.*)')
self.hz = rospy.get_param('~hz', 10)
self.skip_interfaces = rospy.get_param('~skip_interfaces', None)
rospy.logdebug('publish network status (bps) at ' + str(self.hz) + 'Hz')
rospy.logdebug('usage:\n$rosrun jsk_network_tools network_status.py _hz:=[Hz]')
self.init_publisher()
Expand Down Expand Up @@ -48,7 +49,6 @@ def init_publisher(self):
self.faces_map[face[0]]["receive"] = {"publisher": pub_receive, "value": queue_reveice,
"publisher_kbps": pub_receive_kbps,
"publisher_mbps": pub_receive_mbps}

def publish(self, event):
faces = self.read_net_file()
non_local_transmit = 0
Expand Down Expand Up @@ -83,7 +83,10 @@ def read_net_file(self):
match = self.match_face.match(s)
if match:
nums = match.group(2).split()
ret.append([match.group(1).strip(), nums[8], nums[0]])
name = match.group(1).strip()
if (self.skip_interfaces is None
or name not in self.skip_interfaces):
ret.append([name, nums[8], nums[0]])
return ret

if __name__ == '__main__':
Expand Down