mirror of
https://github.com/nshttpd/mikrotik-exporter.git
synced 2024-11-16 10:25:12 +01:00
f2866a3a2f
* 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
35 lines
531 B
Go
35 lines
531 B
Go
package config
|
|
|
|
import (
|
|
"io"
|
|
"io/ioutil"
|
|
|
|
yaml "gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type Config struct {
|
|
Devices []Device `yaml:"devices"`
|
|
}
|
|
|
|
type Device struct {
|
|
Name string `yaml:"name"`
|
|
Address string `yaml:"address"`
|
|
User string `yaml:"user"`
|
|
Password string `yaml:"password"`
|
|
}
|
|
|
|
func Load(r io.Reader) (*Config, error) {
|
|
b, err := ioutil.ReadAll(r)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
c := &Config{}
|
|
err = yaml.Unmarshal(b, c)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return c, nil
|
|
}
|