Detects hostname/interface ip
- Hostname is monitor's id. Incidents will be created with the monitor id.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/castawaylabs/cachet-monitor/system"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -15,14 +16,17 @@ var Config CachetConfig
|
||||
|
||||
// CachetConfig is the monitoring tool configuration
|
||||
type CachetConfig struct {
|
||||
APIUrl string `json:"api_url"`
|
||||
APIToken string `json:"api_token"`
|
||||
Monitors []*Monitor `json:"monitors"`
|
||||
APIUrl string `json:"api_url"`
|
||||
APIToken string `json:"api_token"`
|
||||
Monitors []*Monitor `json:"monitors"`
|
||||
SystemName string `json:"system_name"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
var configPath string
|
||||
var systemName string
|
||||
flag.StringVar(&configPath, "c", "/etc/cachet-monitor.config.json", "Config path")
|
||||
flag.StringVar(&systemName, "name", "", "System Name")
|
||||
flag.Parse()
|
||||
|
||||
var data []byte
|
||||
@@ -57,6 +61,14 @@ func init() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(systemName) > 0 {
|
||||
Config.SystemName = systemName
|
||||
}
|
||||
if len(Config.SystemName) == 0 {
|
||||
// get hostname
|
||||
Config.SystemName = system.GetHostname()
|
||||
}
|
||||
|
||||
if len(os.Getenv("CACHET_API")) > 0 {
|
||||
Config.APIUrl = os.Getenv("CACHET_API")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user