Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
Ye Li committed Nov 21, 2017
0 parents commit fa0af59
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
41 changes: 41 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package config

import (
"fmt"
"io/ioutil"
"os"

"gopkg.in/yaml.v2"
)

type Promcfg struct {
Server string
Port int
Intval int
}

type Config struct {
PromPushGW Promcfg
}

var Monitor Config
var config_path = flag.String("conf", "config.yaml", "config file")

func Load(path string) {
if _, err := os.Stat(path); os.IsNotExist(err) {
fmt.Println("configure file doesn't exist")
os.Exit(-1)
}

content, err := ioutil.ReadFile(path)
if err != nil {
fmt.Printf("read configure file fail, %s\n", err.Error())
os.Exit(-1)
}

err = yaml.Unmarshal(content, &Instance)
if err != nil {
fmt.Printf("configure file format error, %s\n", err.Error())
os.Exit(-1)
}
}
17 changes: 17 additions & 0 deletions disk_exporter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"fmt"
"flag"
"github.com/liyehaha/hostmonitor/config"
)

const (
namespace = "monitor"
)

func main() {
promserver = config.PromPushGW.Server
fmt.Println(promserver)
}

0 comments on commit fa0af59

Please sign in to comment.