Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60cfac948b | ||
|
|
958446050f | ||
|
|
88e94642d9 | ||
|
|
bc83a51907 |
+14
-25
@@ -1,32 +1,23 @@
|
|||||||
---
|
---
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- asciicheck
|
- errname
|
||||||
- bodyclose
|
- errorlint
|
||||||
- dogsled
|
|
||||||
- dupl
|
|
||||||
- exhaustive
|
- exhaustive
|
||||||
- gochecknoinits
|
|
||||||
- gocognit
|
|
||||||
- gocritic
|
|
||||||
- gocyclo
|
|
||||||
- goerr113
|
|
||||||
- gofumpt
|
- gofumpt
|
||||||
- goimports
|
- goimports
|
||||||
- gomnd
|
- gomnd
|
||||||
- goprintffuncname
|
- goprintffuncname
|
||||||
# - gosec
|
|
||||||
# - ifshort
|
|
||||||
- interfacer
|
|
||||||
- maligned
|
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
- promlinter
|
||||||
- nestif
|
- tagliatelle
|
||||||
- nlreturn
|
- tenv
|
||||||
- noctx
|
- testpackage
|
||||||
- unparam
|
- thelper
|
||||||
|
- tparallel
|
||||||
|
- unconvert
|
||||||
|
- wrapcheck
|
||||||
- wsl
|
- wsl
|
||||||
# - errorlint
|
|
||||||
disable:
|
disable:
|
||||||
- gochecknoglobals
|
- gochecknoglobals
|
||||||
|
|
||||||
@@ -34,15 +25,13 @@ linters-settings:
|
|||||||
gosec:
|
gosec:
|
||||||
excludes:
|
excludes:
|
||||||
- G204
|
- G204
|
||||||
# gomnd:
|
tagliatelle:
|
||||||
# settings:
|
case:
|
||||||
# mnd:
|
rules:
|
||||||
# ignored-functions: math.*
|
yaml: snake
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
- path: _test\.go
|
- path: _test\.go
|
||||||
linters:
|
linters:
|
||||||
- errcheck
|
|
||||||
- gosec
|
- gosec
|
||||||
- maligned
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.4.0
|
rev: v4.4.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
@@ -11,15 +11,10 @@ repos:
|
|||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
- repo: https://github.com/golangci/golangci-lint
|
- repo: https://github.com/golangci/golangci-lint
|
||||||
rev: v1.42.1
|
rev: v1.50.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: golangci-lint
|
- id: golangci-lint
|
||||||
- repo: git://github.com/dnephin/pre-commit-golang
|
|
||||||
rev: v0.4.0
|
|
||||||
hooks:
|
|
||||||
- id: go-fmt
|
|
||||||
- id: go-imports
|
|
||||||
- repo: https://github.com/hadolint/hadolint
|
- repo: https://github.com/hadolint/hadolint
|
||||||
rev: v2.4.0
|
rev: v2.12.1-beta
|
||||||
hooks:
|
hooks:
|
||||||
- id: hadolint
|
- id: hadolint
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func checkMonitors(config *Config) error {
|
|||||||
|
|
||||||
// Track status metrics
|
// Track status metrics
|
||||||
Metrics.SetMonitorStatus(monitor.Name, monitor.IsUp())
|
Metrics.SetMonitorStatus(monitor.Name, monitor.IsUp())
|
||||||
Metrics.CountCheck(monitor.Name, success, monitor.LastCheckMilliseconds(), hasAlert)
|
Metrics.CountCheck(monitor.Name, success, monitor.LastCheckSeconds(), hasAlert)
|
||||||
|
|
||||||
if alertNotice != nil {
|
if alertNotice != nil {
|
||||||
err := sendAlerts(config, monitor, alertNotice)
|
err := sendAlerts(config, monitor, alertNotice)
|
||||||
|
|||||||
+4
-4
@@ -43,14 +43,14 @@ func NewMetrics() *MinitorMetrics {
|
|||||||
),
|
),
|
||||||
checkTime: prometheus.NewGaugeVec(
|
checkTime: prometheus.NewGaugeVec(
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Name: "minitor_check_milliseconds",
|
Name: "minitor_check_seconds",
|
||||||
Help: "Time in miliseconds that a check ran for",
|
Help: "Time in miliseconds that a check ran for",
|
||||||
},
|
},
|
||||||
[]string{"monitor", "status"},
|
[]string{"monitor", "status"},
|
||||||
),
|
),
|
||||||
monitorStatus: prometheus.NewGaugeVec(
|
monitorStatus: prometheus.NewGaugeVec(
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Name: "minitor_monitor_up_count",
|
Name: "minitor_monitor_up",
|
||||||
Help: "Status of currently responsive monitors",
|
Help: "Status of currently responsive monitors",
|
||||||
},
|
},
|
||||||
[]string{"monitor"},
|
[]string{"monitor"},
|
||||||
@@ -77,7 +77,7 @@ func (metrics *MinitorMetrics) SetMonitorStatus(monitor string, isUp bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CountCheck counts the result of a particular Monitor check
|
// CountCheck counts the result of a particular Monitor check
|
||||||
func (metrics *MinitorMetrics) CountCheck(monitor string, isSuccess bool, ms int64, isAlert bool) {
|
func (metrics *MinitorMetrics) CountCheck(monitor string, isSuccess bool, secs float64, isAlert bool) {
|
||||||
status := "failure"
|
status := "failure"
|
||||||
if isSuccess {
|
if isSuccess {
|
||||||
status = "success"
|
status = "success"
|
||||||
@@ -94,7 +94,7 @@ func (metrics *MinitorMetrics) CountCheck(monitor string, isSuccess bool, ms int
|
|||||||
|
|
||||||
metrics.checkTime.With(
|
metrics.checkTime.With(
|
||||||
prometheus.Labels{"monitor": monitor, "status": status},
|
prometheus.Labels{"monitor": monitor, "status": status},
|
||||||
).Set(float64(ms))
|
).Set(secs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountAlert counts an alert
|
// CountAlert counts an alert
|
||||||
|
|||||||
+3
-3
@@ -91,9 +91,9 @@ func (monitor Monitor) IsUp() bool {
|
|||||||
return monitor.alertCount == 0
|
return monitor.alertCount == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// LastCheckMilliseconds gives number of miliseconds the last check ran for
|
// LastCheckSeconds gives number of seconds the last check ran for
|
||||||
func (monitor Monitor) LastCheckMilliseconds() int64 {
|
func (monitor Monitor) LastCheckSeconds() float64 {
|
||||||
return monitor.lastCheckDuration.Milliseconds()
|
return monitor.lastCheckDuration.Seconds()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (monitor *Monitor) success() (notice *AlertNotice) {
|
func (monitor *Monitor) success() (notice *AlertNotice) {
|
||||||
|
|||||||
Reference in New Issue
Block a user