ethtool

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2016 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 0

README

ethtool go package

Build Status GoDoc

The ethtool package aims to provide a library giving a simple access to the Linux SIOCETHTOOL ioctl operations. It can be used to retrieve informations from a network device like statistics, driver related informations or even the peer of a VETH interface.

Build and Test

go get command:

go get github.com/safchain/ethtool

Testing

In order to run te

go test github.com/safchain/ethtool

Examples

Retrieve tx from eth0

import (
	"fmt"

	"github.com/safchain/ethtool"
)

func main() {
	stats, err := ethtool.Stats("eth0")
	if err != nil {
		panic
	}

	fmt.Printf("TX: %d\n", stats["tx_bytes"])
}

Retrieve peer index of a veth interface

import (
	"fmt"

	"github.com/safchain/ethtool"
)

func main() {
	stats, err := ethtool.Stats("veth0")
	if err != nil {
		panic
	}

	fmt.Printf("Peer Index: %d\n", stats["peer_ifindex"])
}

LICENSE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

View Source
const (
	ETH_GSTRING_LEN  = 32
	ETH_SS_STATS     = 1
	ETHTOOL_GDRVINFO = 0x00000003
	ETHTOOL_GSTRINGS = 0x0000001b
	ETHTOOL_GSTATS   = 0x0000001d
)

ethtool stats related constants.

View Source
const (
	IFNAMSIZ = 16
)
View Source
const (
	MAX_GSTRINGS = 100
)

MAX_GSTRINGS maximum number of stats entries that ethtool can retrieve currently.

View Source
const (
	SIOCETHTOOL = 0x8946
)

Variables

This section is empty.

Functions

func DriverName

func DriverName(intf string) (string, error)

func Stats

func Stats(intf string) (map[string]uint64, error)

Stats retrieves stats of the given interface name

Types

This section is empty.

Source Files

  • ethtool.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL