-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
executable file
·58 lines (45 loc) · 928 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package golagraphite
import (
"io/ioutil"
"log"
"gopkg.in/yaml.v2"
)
type Config struct {
Graphite_settings Graphite_settings
Performance_counters Performance_counters
Sql_metrics Sql_metrics
}
type Graphite_settings struct {
Udp bool
Hosts []string
}
type Performance_counters struct {
Metric_prefix string
Interval int
Counters []string
}
type Sql_metrics struct {
Sql_servers []Sql_server
}
type Sql_server struct {
Connection_string string
Queries []Query
}
type Query struct {
Interval int
Tsql_table string
Tsql_row string
Timestamp string
Metric_prefix string
}
func NewConfig(config_path string) (config Config) {
source, readfile_err := ioutil.ReadFile(config_path)
if readfile_err != nil {
log.Fatal(readfile_err)
}
readyaml_err := yaml.Unmarshal(source, &config)
if readyaml_err != nil {
log.Fatal(readyaml_err)
}
return
}