tplinkcmd/cmd/tpapi/config.go

71 lines
2.1 KiB
Go

package main
import (
"os"
"time"
"github.com/hashicorp/logutils"
"github.com/prometheus/client_golang/prometheus"
)
type configStructure struct {
// time configuration
TimeFormat string `json:"time_format"`
TimeZone *time.Location
TimeZoneUTC *time.Location
// logging
LogLevel int `json:"log_level"`
Log *logutils.LevelFilter `json:"log_level_fileter"`
// webserver
WebSrvPort int `json:"webserver_port"`
WebSrvIP string `json:"webserver_ip"`
WebSrvReadTimeout int `json:"webserver_read_timeout"`
WebSrvWriteTimeout int `json:"webserver_write_timeout"`
WebSrvIdleTimeout int `json:"webserver_idle_timeout"`
// prometheus
Prometheus configPrometheus
}
type configPrometheus struct {
NumGroupCreated prometheus.Gauge
NumGroupChanged prometheus.Gauge
NumGroupDeleted prometheus.Gauge
}
type alertmanagerStruct struct {
Version string `json:"version"`
GroupKey string `json:"groupKey"`
TruncatedAlerts int `json:"truncatedAlerts"`
Status string `json:"status"`
Reciver string `json:"receiver"`
GroupLabels string `json:"groupLabels"`
ComminLabels string `json:"commonLabels"`
CommonAnnotaations string `json:"commonAnnotations"`
ExternalURL string `json:"externalURL"`
Alerts []alertmanagerAlertsStruct `json:"alerts"`
}
type alertmanagerAlertsStruct struct {
Status string `json:"status"`
Labels string `json:"labels"`
Annotations string `json:"annotations"`
StartsAt string `json:"startsAt"`
EndsAt string `json:"endsAt"`
GeneratorURL string `json:"generatorURL"`
Fingerprint string `json:"fingerprint"`
}
var config = configStructure{
TimeFormat: "2006-01-02 15:04:05",
Log: &logutils.LevelFilter{
Levels: []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARNING", "ERROR"},
Writer: os.Stderr,
},
WebSrvReadTimeout: 2,
WebSrvWriteTimeout: 10,
WebSrvIdleTimeout: 2,
}