More features (#9)

* added config file implementation, refactoring
* add gitignore
* improved test
* preperations for more metrics
* added resource metrics
* added first bgp metrics
* added asn as label for bgp metrics
* added prefix and message counts to bgp metrics
* simplified
* Update README.md
* added yaml dependency
* fixed go routine call
* added timeout
* clean up
* added TLS support
* set default api port for TLS
* added routes metric
* added missing log information
* added type collectorContext to reduce the count of parameters for better readability
* added DHCP and DHCPv6 metrics
* filter for active dhcp leases only
* added pool metrics
* enable/disable feature in config file
* refactoring

* clean up

* comment fix
This commit is contained in:
Daniel Czerwonk
2018-04-11 15:21:38 +02:00
committed by Steve Brunton
parent f2866a3a2f
commit d170b0a4d2
16 changed files with 559 additions and 175 deletions

View File

@@ -37,7 +37,7 @@ var (
type collector struct {
devices []config.Device
collectors []metricCollector
collectors []routerOSCollector
timeout time.Duration
enableTLS bool
insecureTLS bool
@@ -53,7 +53,28 @@ func WithBGP() Option {
// WithRoutes enables routing table metrics
func WithRoutes() Option {
return func(c *collector) {
c.collectors = append(c.collectors, &routesCollector{})
c.collectors = append(c.collectors, newRoutesCollector())
}
}
// WithDHCP enables DHCP serrver metrics
func WithDHCP() Option {
return func(c *collector) {
c.collectors = append(c.collectors, newDHCPCollector())
}
}
// WithDHCPv6 enables DHCPv6 serrver metrics
func WithDHCPv6() Option {
return func(c *collector) {
c.collectors = append(c.collectors, newDHCPv6Collector())
}
}
// WithPools enables IP(v6) pool metrics
func WithPools() Option {
return func(c *collector) {
c.collectors = append(c.collectors, newPoolCollector())
}
}
@@ -84,9 +105,9 @@ func NewCollector(cfg *config.Config, opts ...Option) (prometheus.Collector, err
c := &collector{
devices: cfg.Devices,
timeout: DefaultTimeout,
collectors: []metricCollector{
&interfaceCollector{},
&resourceCollector{},
collectors: []routerOSCollector{
newInterfaceCollector(),
newResourceCollector(),
},
}
@@ -153,7 +174,8 @@ func (c *collector) connectAndCollect(d *config.Device, ch chan<- prometheus.Met
defer cl.Close()
for _, co := range c.collectors {
err = co.collect(ch, d, cl)
ctx := &collectorContext{ch, d, cl}
err = co.collect(ctx)
if err != nil {
return err
}