diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-05-23 11:40:52 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-05-23 20:32:47 +0900 |
commit | 7c42e295e28c233fdb7a130681cd490308f116ca (patch) | |
tree | fa6e4117db2e9f2f31a914c0aa932772760386b8 /config | |
parent | a7521827e1d8c964f1c9f342dc39d02f45660c49 (diff) |
add collector feature
dump the update messages and the state change of peers into influxdb:
[collector.config]
url = "http://localhost:8086"
db-name = "gobgp"
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'config')
-rw-r--r-- | config/bgp_configs.go | 75 | ||||
-rw-r--r-- | config/serve.go | 1 |
2 files changed, 76 insertions, 0 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go index 2054efec..16968123 100644 --- a/config/bgp_configs.go +++ b/config/bgp_configs.go @@ -871,6 +871,76 @@ func (v RpkiValidationResultType) Validate() error { } //struct for container gobgp:state +type CollectorState struct { + // original -> gobgp:url + Url string `mapstructure:"url"` + // original -> gobgp:db-name + DbName string `mapstructure:"db-name"` + // original -> gobgp:table-dump-interval + TableDumpInterval uint64 `mapstructure:"table-dump-interval"` +} + +func (lhs *CollectorState) Equal(rhs *CollectorState) bool { + if lhs == nil || rhs == nil { + return false + } + if lhs.Url != rhs.Url { + return false + } + if lhs.DbName != rhs.DbName { + return false + } + if lhs.TableDumpInterval != rhs.TableDumpInterval { + return false + } + return true +} + +//struct for container gobgp:config +type CollectorConfig struct { + // original -> gobgp:url + Url string `mapstructure:"url"` + // original -> gobgp:db-name + DbName string `mapstructure:"db-name"` + // original -> gobgp:table-dump-interval + TableDumpInterval uint64 `mapstructure:"table-dump-interval"` +} + +func (lhs *CollectorConfig) Equal(rhs *CollectorConfig) bool { + if lhs == nil || rhs == nil { + return false + } + if lhs.Url != rhs.Url { + return false + } + if lhs.DbName != rhs.DbName { + return false + } + if lhs.TableDumpInterval != rhs.TableDumpInterval { + return false + } + return true +} + +//struct for container gobgp:collector +type Collector struct { + // original -> gobgp:collector-config + Config CollectorConfig `mapstructure:"config"` + // original -> gobgp:collector-state + State CollectorState `mapstructure:"state"` +} + +func (lhs *Collector) Equal(rhs *Collector) bool { + if lhs == nil || rhs == nil { + return false + } + if !lhs.Config.Equal(&(rhs.Config)) { + return false + } + return true +} + +//struct for container gobgp:state type ZebraState struct { // original -> gobgp:enabled //gobgp:enabled's original type is boolean @@ -3998,6 +4068,8 @@ type Bgp struct { MrtDump []Mrt `mapstructure:"mrt-dump"` // original -> gobgp:zebra Zebra Zebra `mapstructure:"zebra"` + // original -> gobgp:collector + Collector Collector `mapstructure:"collector"` } func (lhs *Bgp) Equal(rhs *Bgp) bool { @@ -4090,6 +4162,9 @@ func (lhs *Bgp) Equal(rhs *Bgp) bool { if !lhs.Zebra.Equal(&(rhs.Zebra)) { return false } + if !lhs.Collector.Equal(&(rhs.Collector)) { + return false + } return true } diff --git a/config/serve.go b/config/serve.go index a8f67725..95658a97 100644 --- a/config/serve.go +++ b/config/serve.go @@ -16,6 +16,7 @@ type BgpConfigSet struct { BmpServers []BmpServer `mapstructure:"bmp-servers"` MrtDump []Mrt `mapstructure:"mrt-dump"` Zebra Zebra `mapstructure:"zebra"` + Collector Collector `mapstructure:"collector"` DefinedSets DefinedSets `mapstructure:"defined-sets"` PolicyDefinitions []PolicyDefinition `mapstructure:"policy-definitions"` } |