Fairly general building blocks used in Arista Go code and open-sourced for the benefit of all.

Overview

Arista Go library Build Status codecov.io GoDoc Go Report Card

areflect

Helper functions to work with the reflect package. Contains ForceExport(), which bypasses the check in reflect.Value that prevents accessing unexported attributes.

monotime

Provides access to a fast monotonic clock source, to fill in the gap in the Go standard library, which lacks one. Don't use time.Now() in code that needs to time things or otherwise assume that time passes at a constant rate, instead use monotime.Now().

cmd

See the cmd directory.

dscp

Provides ListenTCPWithTOS(), which is a replacement for net.ListenTCP() that allows specifying the ToS (Type of Service), to specify DSCP / ECN / class of service flags to use for incoming connections. Requires go1.9.

key

Provides common types used across various Arista projects. The type key.Key is used to work around the fact that Go can't let one use a non-hashable type as a key to a map. Because we often use a map[string]interface{} (or other non-hashable type) as a key to a map, the type key.Map is used to represent a map that can store both natively hashable and non-hashable types alike. To do this, a non-hashable type must have a custom Hash() method defined. The type key.Path is the representation of a path broken down into individual elements, where each element is a key.Key. The type key.Pointer represents a pointer to a key.Path.

path

Provides functions that can be used to manipulate key.Path objects. The type path.Map may be used for mapping paths to values. It allows for some fuzzy matching for paths containing path.Wildcard keys.

lanz

A client for LANZ streaming servers. It connects to a LANZ streaming server, listens for notifications, decodes them and sends the LANZ protobuf on the provided channel.

monitor

A library to help expose monitoring metrics on top of the expvar infrastructure.

netns

netns.Do(namespace, cb) provides a handy mechanism to execute the given callback cb in the given network namespace.

influxlib

This is a influxdb library that provides easy methods of connecting to, writing to, and reading from the service.

test

This is a Go library to help in writing unit tests.

Examples

TBD

Issues
  • goprometheus to veos ?

    goprometheus to veos ?

    Is it possible to test basic telemetry features such as bandwidth with vEOS?

    I'm getting a timeout error trying to connect to the management1 interface, wireshark shows syn but no syn ack coming back from the switch. All default vrf. Also can see the openconfig service running.

    ~/go/bin# ./ocprometheus -config /etc/arista/config.yml -addr 10.224.122.80:6030 F0219 14:44:23.665902 11331 main.go:90] rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp 10.224.122.80:6030: connect: connection timed out"

    opened by bodleytunes 19
  • ocprometheus not able to parse complex path

    ocprometheus not able to parse complex path

    Hello,

    I`m trying to collect LLDP data using the telemetry paths ( that I found in CVP ) :

    /Sysdb/l2discovery/lldp/status/local/1/portStatus/Ethernet1/1/remoteSystem/2 : sysName : { "value": "NeighborHostname" }

    Exporter config :

    Metrics:
       - name: lldpNeighborInfo
         path: /Sysdb/l2discovery/lldp/status/local/(?P<localIndex>.+)/portStatus/(?P<intf>.+)/remoteSystem/(?P<remoteSystemIndex>.+)/sysName/value
         help: LLDP metric info
         valuelabel: neighborName
         defaultvalue: 1
    
    

    The metric is not mapped and no error logs are found.

    I`m trying other paths to debug and when I try the config below :

           - name: lldpPortStatus
              path: /Sysdb/l2discovery/lldp/status/local/1/portStatus/(?P<intf>.+)/(?P<type>.+)
              help: Test with PortStatus
              valuelabel: textValue
    

    Seems the path changes for the remotesystem, adding "_counts" after the interface :

    lldpPortStatus{intf="Ethernet10\/3/_counts",job="poc-arista",textValue="textValue",type="remoteSystem"} EOS : 4.22.4M

    Could you please verify?

    Thank you, Anderson Topine

    opened by topine 7
  • -v flag redefined when using with github.com/golang/glog

    -v flag redefined when using with github.com/golang/glog

    /tmp/go-build149476797/b001/tests.test flag redefined: v panic: /tmp/go-build149476797/b001/tests.test flag redefined: v goroutine 1 [running]: flag.(*FlagSet).Var(0xc00007e180, 0x12ab2f8, 0x1b49c88, 0x1151007, 0x1, 0x116e1e8, 0x14) /usr/local/go/src/flag/flag.go:871 +0x485 flag.Var(...) /usr/local/go/src/flag/flag.go:886 github.com/golang/glog.init.0() /home/go/pkg/mod/github.com/golang/[email protected]/glog.go:401 +0x127 Further investigating we discovered that go test module has its own glog module and again goarista package is redefining the same glog module with same flags, which is conflicting and Its expected to fail [go language behavior]

    opened by biplamal 6
  • gNMI fails with timeout error

    gNMI fails with timeout error

    Hello, I am currently getting an issue.

    When I try to dial into Arista switch and subcribe a path to grab data from swith. I got an error: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: timed out waiting for server handshake.

    Does it mean too many connection requests to the switch? I am not sure why it returns timeout. Is it the issue about my code or something wrong on the switch side. Thanks

    some codes:
    ip :=ipaddress
    cfg := &aristagnmi.Config{}
    cfg.Username =username
    cfg.Password = password
    cfg.Addr = ip + ":5909"
    ctx := aristagnmi.NewContext(context.Background(), cfg)
    client, err := aristagnmi.Dial(cfg)
    if err != nil {
    	fmt.Println(err)
    }
    respChan := make(chan *pb.SubscribeResponse)
    errChan := make(chan error)
    defer close(respChan)
    defer close(errChan)
    	
    paths := append(make([]string, 0), "/lldp/interfaces/interface/neighbors")
    subscribeOptions := &aristagnmi.SubscribeOptions{
    	Mode:       "stream",
    	StreamMode: "target_defined",
    	Paths:      aristagnmi.SplitPaths(paths),
    }
    
    go aristagnmi.Subscribe(ctx, client, subscribeOptions, respChan, errChan)
    
    for {
         select {
              case resp := <-respChan:
                             .........
              case err := <-errChan:
                         **got error here: timeout**
         }
    }
    
    
    opened by jakechen0816 6
  • gnmireverse client fails to run

    gnmireverse client fails to run

    Hi,

    I am trying to run gnmireverse client on my linux machine(ubuntu 18.04). I am running go version go1.10.4 linux/amd64. When I am running the client I am getting the bellow error:

    :~/work/src$ go install gnmireverse/client
    # github.com/aristanetworks/goarista/dscp
    github.com/aristanetworks/goarista/dscp/dial.go:20:10: unknown field 'Control' in struct literal of type net.Dialer
    github.com/aristanetworks/goarista/dscp/dial.go:38:10: unknown field 'Control' in struct literal of type net.Dialer
    github.com/aristanetworks/goarista/dscp/dial.go:56:10: unknown field 'Control' in struct literal of type net.Dialer
    github.com/aristanetworks/goarista/dscp/dscp_unix.go:25:9: undefined: net.ListenConfig
    # golang.org/x/net/http2
    golang.org/x/net/http2/client_conn_pool.go:305:6: undefined: errors.Is
    golang.org/x/net/http2/server.go:234:72: undefined: tls.VersionTLS13
    

    am I doing something wrong here?

    opened by Gaurav-Pande 5
  • monotime: add Since function

    monotime: add Since function

    This is a convenience function for computing the elapsed time since a given timestamp, as it's a little cumbersome to type

    time.Duration(monotime.Now() - start)

    over and over. Adds an example to show how it should be used.

    This adds a dependency on the time package, which might not be desirable.

    opened by kevinburke 4
  • enhance importsort with directory support & exclude flag

    enhance importsort with directory support & exclude flag

    In multiple projects I am working on (e.g gardener - see example file), we are using the same import grouping this tool supports

    • stdlib,
    • VCS repo-local
    • non-local

    Added support for directories and the possibility to define a regex pattern for excluded filenames. This is useful in our case to exclude auto-generated files.

    This tool is somewhat one of the only simple enough tools I found to achieve this import grouping, so kudos for that.

    opened by danielfoehrKn 3
  • ocprometheus build fails

    ocprometheus build fails

    go get github.com/aristanetworks/goarista/cmd/ocprometheus

    # github.com/prometheus/client_model/go
    prometheus/client_model/go/metrics.pb.go:96:31: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:141:27: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:179:29: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:218:30: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:265:29: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:317:29: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:357:31: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:410:28: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:461:28: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:544:34: undefined: proto.InternalMessageInfo
    prometheus/client_model/go/metrics.pb.go:544:34: too many errors
    # github.com/aristanetworks/goarista/gnmi
    aristanetworks/goarista/gnmi/operation.go:212:12: undefined: gnmi.TypedValue_ProtoBytes
    opened by aned 3
  • gNMI build fails

    gNMI build fails

    New Go installation: go version go1.11.1 windows/amd64

    C:%GOPATH%>go get github.com/aristanetworks/goarista/cmd/gnmi

    github.com/aristanetworks/goarista/netns

    src\github.com\aristanetworks\goarista\netns\netns.go:35:17: undefined: getNs src\github.com\aristanetworks\goarista\netns\netns.go:39:8: undefined: setNs src\github.com\aristanetworks\goarista\netns\netns_110.go:34:19: undefined: getNs src\github.com\aristanetworks\goarista\netns\netns_110.go:54:11: undefined: setNs

    opened by fowie 3
  • fsnotify@v1.4.5 fails to compile under windows

    [email protected] fails to compile under windows

    Hi

    I was trying to build a go project with goarista under windows which fails to compiles.

    The project pulls in github.com/aristanetworks/goarista/gnmi which further pulls in github.com/aristanetworks/goarista/netns and then from this github.com/aristanetworks/fsnotify

    C:\project\go build .
    github.com/aristanetworks/fsnotify C:\Programming\go\pkg\mod\github.com\aristanetworks\[email protected]\windows.go:68:24: not enough arguments in call to w.AddWithFlags have (number) want (string, uint32)

    Could the AddWithFlags function be modified so that it compiles under windows ?

    many thanks

    opened by macphersonjamie 2
  • valuelabel doesn't work for non strings

    valuelabel doesn't work for non strings

    There are a few metrics in openconfig for example bgp asn along the path of

    /network-instances/network-instance[name=(?P.+)]/protocols/protocol[identifier=BGP][name=BGP]/bgp/neighbors/neighbor[neighbor-address=(?P.+)]/state/peer-as

    where valuelabel would be handy as it is difficult to join prometheus metrics based on values.

    opened by kalebris 2
  • ocprometheus fails with duplicated metrics with EOS 4.27

    ocprometheus fails with duplicated metrics with EOS 4.27

    Using latest goarista from master branch, EOS 4.27.4M, and a configuration like this:

    metrics:
    
            - name: ocprometheus_bgp_peer_as_number  #No unit
              path: /Sysdb/routing/bgp/export/vrfBgpPeerInfoStatusEntryTable/(?P<vrf>.+)/bgpPeerInfoStatusEntry/(?P<name>.+)/bgpPeerAs
              help: BGP Peer  AS Number
    

    ocprometheus fails with errors like this:

    * collected metric "ocprometheus_bgp_peer_as_number" { label:<name:"name" value:"192.168.247.17" > label:<name:"vrf" value:"default" > gauge:<value:0 > } was collected before with the same name and label values
    

    This used to work so far with EOS <= 4.26.6M :

    ocprometheus_bgp_peer_as_number{name="10.64.226.33/bgpPeerSessionStatus",vrf="default"} 1234
    ocprometheus_bgp_peer_as_number{name="10.64.226.35/bgpPeerSessionStatus",vrf="default"} 1234
    ocprometheus_bgp_peer_as_number{name="192.168.247.19/bgpPeerSessionStatus",vrf="default"} 64850
    ocprometheus_bgp_peer_as_number{name="192.168.248.19/bgpPeerSessionStatus",vrf="default"} 64850
    

    It looks like the name "(?P.+)" used to match "10.64.226.33/bgpPeerSessionStatus", but now it only constructs a label with the first part before the first "/"

    opened by freedge 1
  • cmd/ocprometheus: Allow decoding enumerated values

    cmd/ocprometheus: Allow decoding enumerated values

    Some string values represent an enumerated value that can be easily converted to a numeric value (such as interface speeds into the number of bits per second). Introduce a configuration option decodeenum that allows specifying such a mapping. Additionally, update the ocprometheus README to reflect this change.

    opened by RavuAlHemio 0
  • Add cloudEOS DPS examples

    Add cloudEOS DPS examples

    e.g.:

    metrics:
            - name: dpslatency
              path: /Smash/its/sessStatus/itsSessCharacData/(?P<dpskey>.*)/latency
              help: DPS latency
            - name: dpsthroughput
              path: /Smash/its/sessStatus/itsSessCharacData/(?P<dpskey>.*)/throughput
              help: DPS throughput
            - name: dpsloss
              path: /Smash/its/sessStatus/itsSessCharacData/(?P<dpskey>.*)/loss
              help: DPS loss
            - name: dpsjitter
              path: /Smash/its/sessStatus/itsSessCharacData/(?P<dpskey>.*)/jitter
              help: DPS jitter
    
    opened by noredistribution 0
  • Feature Request: Dynamic targeting for ocprometheus

    Feature Request: Dynamic targeting for ocprometheus

    At present, when running ocprometheus outside of the switch, the address is provided by running with -address. This makes it a bit less flexible to gather metrics for multiple devices. That is, to have the metrics for, say, switch1, you need to start the app, e.g., ./ocprometheus -addr switch1 -config config.yml; to have the metrics for switch2, you need a separate instance running, e.g., ./ocprometheus -addr switch2 -config config.yml and so on. In other words, when running ocprometheus outside of the switch, it requires as many instances running as switches you have.

    Typically, Prometheus exporters accept the target as an argument, e.g., http://prom.example.com/metrics?target=swtich1 for switch1, http://prom.example.com/metrics?target=swtich2 for switch2 etc.

    It'd be awesome if we could make the necessary adjustments to accommodate this simplified usage? Thank you!

    opened by mirceaulinic 0
Releases(ockafka-v0.0.5)
Owner
Arista Networks
Arista Networks
A Gomora template for building dApps and web3-powered API and smart contract listeners

Gomora dApp A Gomora template for building dApps and web3-powered API and smart contract listeners Local Development Setup the .env file first cp .env

Nuxify Inc. 3 Feb 15, 2022
The Cosmos-SDK is a framework for building blockchain applications in Golang.

The Cosmos-SDK is a framework for building blockchain applications in Golang. It is being used to build Gaia, the first implementation of the Cosmos Hub.

null 0 Nov 26, 2021
ChainMaker, a blockchain platform for building secure

ChainMaker, a blockchain platform for building secure, trustworthy value-exchange networks to power the new global digital economy. ChainMaker aim

Devin 4 Jul 28, 2022
This project parses all mails from google-search within key-words and ban-words

mailParser This project parses all mails from google-search within key-words and ban-words For launch program create the input file first string conta

null 0 Feb 2, 2022
All the missing AMD64 atomic instructions

atomics All the AMD64 atomic instructions, exposed as Go functions: ⚠️ PRE-ALPHA ⚠️ Features LOCK {ADD,ADC,AND,BTC,BTR,BTS,CMPXCHG,CMPXCH8B,CMPXCHG16B

Carlo Alberto Ferraris 6 Sep 20, 2021
A binary that continuously displays Ethiopian date and time (Amharic). best used in i3-status.

i3-eth-time Display ethiopian calendar date/time in i3-wm! Intended for use in i3-status. How to use Clone/Download repo and compile Open up your i3co

Tibebes. 1 Jan 4, 2022
Ots - The Bhojpur OTS is a software-as-a-service product used as an Object Tracking System based on Bhojpur.NET Platform for application delivery.

Bhojpur OTS - Object Tracking System The Bhojpur OTS is a software-as-a-service product used as an Object Tracking System based on Bhojpur.NET Platfor

Bhojpur Consulting 0 Dec 31, 2021
The Bhojpur Wallet is a platform-as-a-service product used as a Wallet Engine based on the Bhojpur.NET Platform for application delivery.

Bhojpur Wallet - Data Processing Engine The Bhojpur Wallet is a platform-as-a-service used as a Service Engine based on the Bhojpur.NET Platform. It l

Bhojpur Consulting 1 Feb 2, 2022
Security research and open source implementation of the Apple 'Wireless Accessory Configuration' (WAC) protocol

Apple 'Wireless Accessory Configuration' (WAC) research Introduction This repository contains some research on how the WAC protocol works. I was mostl

Bertold Van den Bergh 8 Jul 28, 2022
Poweth - Etchash go module intended for use by core-pool (and open-ethereum-pool)

go-etchash Etchash go module intended for use by core-pool (and open-ethereum-po

2zo 0 Jan 20, 2022
hack-browser-data is an open-source tool that could help you decrypt data from the browser.

hack-browser-data is an open-source tool that could help you decrypt data ( password|bookmark|cookie|history|credit card|download

idiotc4t 105 Aug 2, 2022
Open Source Ethereum Mining Pool With Go

Open Source Ethereum Mining Pool Features This pool is being further developed to provide an easy to use pool for Ethereum miners. This software is fu

null 2 Mar 10, 2022
Open Source Etho Mining Pool - tuned for 8000000 block hardfork on EthoProtocol blockchain.

Open Source Etho Mining Pool - tuned for 8000000 block hardfork on EthoProtocol blockchain. image to be updated soon! Features This pool is being furt

Don Kingdon 7 Jul 3, 2022
Mastering Bitcoin 2nd Edition - Programming the Open Blockchain

Code Examples: Mastering Bitcoin Mastering Bitcoin is a book for developers, although the first two chapters cover bitcoin at a level that is also app

Mastering Bitcoin 20.1k Aug 1, 2022
An open source smart contract platform

EOSIO - The Most Powerful Infrastructure for Decentralized Applications Welcome to the EOSIO source code repository! This software enables businesses

EOSIO 11.4k Jul 31, 2022
A cryptocurrency implementation in less than 1500 lines of code

Naivecoin - a cryptocurrency implementation in less than 1500 lines of code Motivation Cryptocurrencies and smart-contracts on top of a blockchain are

Conrado Quilles Gomes 1.1k Jul 29, 2022
The source-code for: "Build a Blockchain from Scratch in Go" eBook.

The Blockchain Bar The source-code for: "Build a Blockchain from Scratch in Go" eBook. ?? Get the eBook from: https://gumroad.com/l/build-a-blockchain

Lukas Lukac 378 Jul 30, 2022
Card-encrypt - The encryption code necessary to enroll debit cards in the Palla API

?? Card RSA Encryption Thank you for choosing Palla! ?? In this repository you'l

palla 0 Jul 15, 2022
sops is an editor of encrypted files that supports YAML, JSON, ENV, INI and BINARY formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP

sops is an editor of encrypted files that supports YAML, JSON, ENV, INI and BINARY formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP. (demo)

Mozilla 10.4k Aug 7, 2022