Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 527214f38c | |||
| fc3d6a33e3 | |||
| 2fc24d0e76 | |||
| d92a21fbca | |||
| 1d3d16eeaa | |||
| 4331f86ed4 | |||
| da890d95b6 | |||
| e5713e3a81 | |||
| 9778809cba |
@@ -99,24 +99,37 @@ OPTIONS:
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//override config with flags if set
|
||||||
if c.IsSet("host-id") {
|
if c.IsSet("host-id") {
|
||||||
config.Set("host.id", c.String("host-id")) // set/override the host-id using CLI.
|
config.Set("host.id", c.String("host-id")) // set/override the host-id using CLI.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.Bool("debug") {
|
||||||
|
config.Set("log.level", "DEBUG")
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.IsSet("log-file") {
|
||||||
|
config.Set("log.file", c.String("log-file"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.IsSet("api-endpoint") {
|
||||||
|
config.Set("api.endpoint", c.String("api-endpoint"))
|
||||||
|
}
|
||||||
|
|
||||||
collectorLogger := logrus.WithFields(logrus.Fields{
|
collectorLogger := logrus.WithFields(logrus.Fields{
|
||||||
"type": "metrics",
|
"type": "metrics",
|
||||||
})
|
})
|
||||||
|
|
||||||
if c.Bool("debug") {
|
if level, err := logrus.ParseLevel(config.GetString("log.level")); err == nil {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(level)
|
||||||
} else {
|
} else {
|
||||||
logrus.SetLevel(logrus.InfoLevel)
|
logrus.SetLevel(logrus.InfoLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.IsSet("log-file") {
|
if config.IsSet("log.file") && len(config.GetString("log.file")) > 0 {
|
||||||
logFile, err := os.OpenFile(c.String("log-file"), os.O_CREATE|os.O_WRONLY, 0644)
|
logFile, err := os.OpenFile(config.GetString("log.file"), os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Failed to open log file %s for output: %s", c.String("log-file"), err)
|
logrus.Errorf("Failed to open log file %s for output: %s", config.GetString("log.file"), err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer logFile.Close()
|
defer logFile.Close()
|
||||||
@@ -126,7 +139,7 @@ OPTIONS:
|
|||||||
metricCollector, err := collector.CreateMetricsCollector(
|
metricCollector, err := collector.CreateMetricsCollector(
|
||||||
config,
|
config,
|
||||||
collectorLogger,
|
collectorLogger,
|
||||||
c.String("api-endpoint"),
|
config.GetString("api.endpoint"),
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -144,14 +157,12 @@ OPTIONS:
|
|||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "api-endpoint",
|
Name: "api-endpoint",
|
||||||
Usage: "The api server endpoint",
|
Usage: "The api server endpoint",
|
||||||
Value: "http://localhost:8080",
|
|
||||||
EnvVars: []string{"SCRUTINY_API_ENDPOINT"},
|
EnvVars: []string{"SCRUTINY_API_ENDPOINT"},
|
||||||
},
|
},
|
||||||
|
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "log-file",
|
Name: "log-file",
|
||||||
Usage: "Path to file for logging. Leave empty to use STDOUT",
|
Usage: "Path to file for logging. Leave empty to use STDOUT",
|
||||||
Value: "",
|
|
||||||
EnvVars: []string{"COLLECTOR_LOG_FILE"},
|
EnvVars: []string{"COLLECTOR_LOG_FILE"},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ OPTIONS:
|
|||||||
logrus.SetOutput(io.MultiWriter(os.Stderr, logFile))
|
logrus.SetOutput(io.MultiWriter(os.Stderr, logFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: pass in the collector, use configuration from collector-metrics
|
||||||
stCollector, err := collector.CreateSelfTestCollector(
|
stCollector, err := collector.CreateSelfTestCollector(
|
||||||
collectorLogger,
|
collectorLogger,
|
||||||
c.String("api-endpoint"),
|
c.String("api-endpoint"),
|
||||||
|
|||||||
@@ -15,7 +15,15 @@ func ExecCmd(logger *logrus.Entry, cmdName string, cmdArgs []string, workingDir
|
|||||||
|
|
||||||
cmd := exec.Command(cmdName, cmdArgs...)
|
cmd := exec.Command(cmdName, cmdArgs...)
|
||||||
var stdBuffer bytes.Buffer
|
var stdBuffer bytes.Buffer
|
||||||
mw := io.MultiWriter(logger.Logger.Out, &stdBuffer)
|
|
||||||
|
logWriters := []io.Writer{
|
||||||
|
&stdBuffer,
|
||||||
|
}
|
||||||
|
if logger.Logger.Level == logrus.DebugLevel {
|
||||||
|
logWriters = append(logWriters, logger.Logger.Out)
|
||||||
|
}
|
||||||
|
|
||||||
|
mw := io.MultiWriter(logWriters...)
|
||||||
|
|
||||||
cmd.Stdout = mw
|
cmd.Stdout = mw
|
||||||
cmd.Stderr = mw
|
cmd.Stderr = mw
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ func (c *configuration) Init() error {
|
|||||||
|
|
||||||
c.SetDefault("devices", []string{})
|
c.SetDefault("devices", []string{})
|
||||||
|
|
||||||
|
c.SetDefault("log.level", "INFO")
|
||||||
|
c.SetDefault("log.file", "")
|
||||||
|
|
||||||
|
c.SetDefault("api.endpoint", "http://localhost:8080")
|
||||||
|
|
||||||
//c.SetDefault("collect.short.command", "-a -o on -S on")
|
//c.SetDefault("collect.short.command", "-a -o on -S on")
|
||||||
|
|
||||||
//if you want to load a non-standard location system config file (~/drawbridge.yml), use ReadConfig
|
//if you want to load a non-standard location system config file (~/drawbridge.yml), use ReadConfig
|
||||||
|
|||||||
@@ -54,7 +54,12 @@ devices:
|
|||||||
# - 3ware,4
|
# - 3ware,4
|
||||||
# - 3ware,5
|
# - 3ware,5
|
||||||
|
|
||||||
|
#log:
|
||||||
|
# file: '' #absolute or relative paths allowed, eg. web.log
|
||||||
|
# level: INFO
|
||||||
|
#
|
||||||
|
#api:
|
||||||
|
# endpoint: 'http://localhost:8080'
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
# FEATURES COMING SOON
|
# FEATURES COMING SOON
|
||||||
|
|||||||
@@ -239,15 +239,19 @@ func (n *Notify) GenShoutrrrNotificationParams(shoutrrrUrl string) (string, *sho
|
|||||||
subject := n.Payload.Subject
|
subject := n.Payload.Subject
|
||||||
switch serviceName {
|
switch serviceName {
|
||||||
// no params supported for these services
|
// no params supported for these services
|
||||||
case "discord", "hangouts", "ifttt", "mattermost", "teams", "rocketchat":
|
case "hangouts", "mattermost", "teams", "rocketchat":
|
||||||
break
|
break
|
||||||
|
case "discord":
|
||||||
|
(*params)["title"] = subject
|
||||||
case "gotify":
|
case "gotify":
|
||||||
(*params)["title"] = subject
|
(*params)["title"] = subject
|
||||||
|
case "ifttt":
|
||||||
|
(*params)["title"] = subject
|
||||||
case "join":
|
case "join":
|
||||||
(*params)["title"] = subject
|
(*params)["title"] = subject
|
||||||
(*params)["icon"] = logoUrl
|
(*params)["icon"] = logoUrl
|
||||||
case "opsgenie":
|
case "opsgenie":
|
||||||
(*params)["description"] = subject
|
(*params)["title"] = subject
|
||||||
case "pushbullet":
|
case "pushbullet":
|
||||||
(*params)["title"] = subject
|
(*params)["title"] = subject
|
||||||
case "pushover":
|
case "pushover":
|
||||||
@@ -260,7 +264,7 @@ func (n *Notify) GenShoutrrrNotificationParams(shoutrrrUrl string) (string, *sho
|
|||||||
case "standard":
|
case "standard":
|
||||||
(*params)["subject"] = subject
|
(*params)["subject"] = subject
|
||||||
case "telegram":
|
case "telegram":
|
||||||
(*params)["subject"] = subject
|
(*params)["title"] = subject
|
||||||
case "zulip":
|
case "zulip":
|
||||||
(*params)["topic"] = subject
|
(*params)["topic"] = subject
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ package version
|
|||||||
|
|
||||||
// VERSION is the app-global version string, which will be replaced with a
|
// VERSION is the app-global version string, which will be replaced with a
|
||||||
// new value during packaging
|
// new value during packaging
|
||||||
const VERSION = "0.3.7"
|
const VERSION = "0.3.8"
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
|||||||
tooltip: {
|
tooltip: {
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
x : {
|
x : {
|
||||||
format: 'MMM dd, yyyy hh:mm:ss'
|
format: 'MMM dd, yyyy HH:mm:ss'
|
||||||
},
|
},
|
||||||
y : {
|
y : {
|
||||||
formatter: (value) => {
|
formatter: (value) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user