-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
jmx_status.go
68 lines (55 loc) · 1.77 KB
/
jmx_status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package status
import (
"sync"
)
type jmxCheckStatus struct {
InitializedChecks map[string]interface{} `json:"initialized_checks"`
FailedChecks map[string]interface{} `json:"failed_checks"`
}
// JMXStatus holds status for JMX checks
type JMXStatus struct {
Info map[string]interface{} `json:"info"`
ChecksStatus jmxCheckStatus `json:"checks"`
Timestamp int64 `json:"timestamp"`
Errors int64 `json:"errors"`
}
// JMXStartupError holds startup status and errors
type JMXStartupError struct {
LastError string
Timestamp int64
}
var (
lastJMXStatus JMXStatus
lastJMXStatusMutex sync.RWMutex
lastJMXStartupError JMXStartupError
lastJMXStartupErrorMutex sync.RWMutex
)
// SetJMXStatus sets the last JMX Status
func SetJMXStatus(s JMXStatus) {
lastJMXStatusMutex.Lock()
defer lastJMXStatusMutex.Unlock()
lastJMXStatus = s
}
// GetJMXStatus retrieves latest JMX Status
func GetJMXStatus() JMXStatus {
lastJMXStatusMutex.RLock()
defer lastJMXStatusMutex.RUnlock()
return lastJMXStatus
}
// SetJMXStartupError sets the last JMX startup error
func SetJMXStartupError(s JMXStartupError) {
lastJMXStatusMutex.Lock()
defer lastJMXStatusMutex.Unlock()
lastJMXStartupError = s
}
// GetJMXStartupError retrieves latest JMX startup error
func GetJMXStartupError() JMXStartupError {
lastJMXStartupErrorMutex.RLock()
defer lastJMXStartupErrorMutex.RUnlock()
copy := JMXStartupError{lastJMXStartupError.LastError, lastJMXStartupError.Timestamp}
return copy
}