Skip to content

Commit

Permalink
Drop BIRD annotator. Fix logging from glog to logrus.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Herms committed Apr 23, 2019
2 parents fc0970b + c11ae93 commit bab0f63
Show file tree
Hide file tree
Showing 26 changed files with 314 additions and 527 deletions.
10 changes: 10 additions & 0 deletions .circleci/check-gofmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

result="$(gofmt -e -s -l . 2>&1 | grep -v '^vendor/' )"
if [ -n "$result" ]; then
echo "Go code is not formatted, run 'gofmt -e -s -w .'" >&2
echo "$result"
exit 1
else
echo "Go code is formatted well"
fi
35 changes: 26 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,33 @@ version: 2
jobs:
build:
docker:
# specify the version
- image: circleci/golang:1.10
- image: circleci/golang:1.11
steps:
- checkout

# run tests and report coverage
- run: go test -v -cover -race -coverprofile=coverage.txt ./...
- run: bash <(curl -s https://codecov.io/bash)

# build binary
- run: go install github.com/bio-routing/tflow2

working_directory: /go/src/github.com/taktv6/tflow2
checks:
docker:
- image: circleci/golang:1.11
steps:
- checkout
- run: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- run: dep ensure -v

- run: go get github.com/mattn/goveralls
- run: go test -v -cover -race -coverprofile=coverage.out ./...
- run: goveralls -coverprofile=coverage.out -service=circle-ci -repotoken=$COVERALLS_TOKEN
- run: go install github.com/taktv6/tflow2
# check goftm
- run: .circleci/check-gofmt

# check misspell
- run: go get github.com/client9/misspell/cmd/misspell
- run: misspell -error .

workflows:
version: 2
workflow:
jobs:
- checks
- build
88 changes: 68 additions & 20 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# tflow2


<<<<<<< HEAD
[![Build Status](https://circleci.com/gh/bio-routing/tflow2.svg?branch=master)](https://circleci.com/gh/bio-routing/tflow2)
[![Coverage Status](https://coveralls.io/repos/taktv6/tflow2/badge.svg?branch=master&service=github)](https://coveralls.io/github/taktv6/tflow2?branch=master)
[![Go ReportCard](http://goreportcard.com/badge/taktv6/tflow2)](http://goreportcard.com/report/taktv6/tflow2)
=======
[![CircleCI](https://circleci.com/gh/bio-routing/tflow2/tree/master.svg?style=shield)](https://circleci.com/gh/bio-routing/tflow2/tree/master)
[![Codecov](https://codecov.io/gh/bio-routing/tflow2/branch/master/graph/badge.svg)](https://codecov.io/gh/bio-routing/tflow2)
[![Go ReportCard](http://goreportcard.com/badge/bio-routing/tflow2)](http://goreportcard.com/report/bio-routing/tflow2)
>>>>>>> c11ae9376faf63300dfb8bc8d49dce1a5c04c59d
tflow2 is an in memory netflow version 9, IPFIX and Sflow analyzer.
It is designed for fast arbitrary queries and exports data to [Prometheus](https://prometheus.io/).

## Usage

Quick install with `go get -u github.com/taktv6/tflow2`
and `go build github.com/taktv6/tflow2`
Quick install with `go get -u github.com/bio-routing/tflow2`
and `go build github.com/bio-routing/tflow2`
or download a pre-built binary from the
[releases page](https://github.com/taktv6/tflow2/releases).
[releases page](https://github.com/bio-routing/tflow2/releases).

The release binaries have an additional command, `tflow2 -version`,
which reports the release version.
Expand Down Expand Up @@ -82,7 +88,7 @@ want to work with interface IDs) your SNMP RO community.

## Limitations

Please be aware this software is not platform indipendent. It will only work
Please be aware this software is not platform independent. It will only work
on little endian machines (such as x86)

## License
Expand Down
31 changes: 11 additions & 20 deletions annotation/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,22 @@ import (
"context"
"sync/atomic"

"github.com/bio-routing/tflow2/annotation/bird"
"github.com/bio-routing/tflow2/config"
"github.com/bio-routing/tflow2/netflow"
"github.com/bio-routing/tflow2/stats"
"github.com/golang/glog"
"google.golang.org/grpc"

log "github.com/sirupsen/logrus"
)

// Annotator represents an flow annotator
type Annotator struct {
inputs []chan *netflow.Flow
output chan *netflow.Flow
numWorkers int
bgpAugment bool
birdAnnotator *bird.Annotator
debug int
cfg *config.Config
inputs []chan *netflow.Flow
output chan *netflow.Flow
numWorkers int
bgpAugment bool
debug int
cfg *config.Config
}

// New creates a new `Annotator` instance
Expand All @@ -43,9 +42,6 @@ func New(inputs []chan *netflow.Flow, output chan *netflow.Flow, numWorkers int,
numWorkers: numWorkers,
cfg: cfg,
}
if cfg.BGPAugmentation.Enabled {
a.birdAnnotator = bird.NewAnnotator(cfg.BGPAugmentation.BIRDSocket, cfg.BGPAugmentation.BIRD6Socket, cfg.Debug)
}
a.Init()
return a
}
Expand All @@ -60,10 +56,10 @@ func (a *Annotator) Init() {
for _, an := range a.cfg.Annotators {
var opts []grpc.DialOption
opts = append(opts, grpc.WithInsecure())
glog.Infof("Connecting to annotator %s at %s", an.Name, an.Target)
log.Infof("Connecting to annotator %s at %s", an.Name, an.Target)
conn, err := grpc.Dial(an.Target, opts...)
if err != nil {
glog.Errorf("Failed to dial: %v", err)
log.Errorf("Failed to dial: %v", err)
}

clients = append(clients, netflow.NewAnnotatorClient(conn))
Expand All @@ -84,17 +80,12 @@ func (a *Annotator) Init() {
for _, c := range clients {
tmpFlow, err := c.Annotate(context.Background(), fl)
if err != nil {
glog.Errorf("Unable to annotate")
log.Errorf("Unable to annotate")
continue
}
fl = tmpFlow
}

// Annotate flows with ASN and Prefix information from local BIRD (bird.nic.cz) instance
if a.bgpAugment {
a.birdAnnotator.Augment(fl)
}

// Send flow over to database module
a.output <- fl
}
Expand Down
Loading

0 comments on commit bab0f63

Please sign in to comment.