-
Notifications
You must be signed in to change notification settings - Fork 75
/
pvc.go
45 lines (37 loc) · 894 Bytes
/
pvc.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
package pvcmonitor
import (
"time"
"github.com/abahmed/kwatch/alertmanager"
"github.com/abahmed/kwatch/config"
"k8s.io/client-go/kubernetes"
)
type PvcMonitor struct {
client kubernetes.Interface
config *config.PvcMonitor
alertManager *alertmanager.AlertManager
notifiedPvc map[string]bool
}
// NewPvcMonitor returns new instance of pvc monitor
func NewPvcMonitor(
client kubernetes.Interface,
config *config.PvcMonitor,
alertManager *alertmanager.AlertManager) *PvcMonitor {
return &PvcMonitor{
client: client,
config: config,
alertManager: alertManager,
notifiedPvc: make(map[string]bool),
}
}
func (p *PvcMonitor) Start() {
if !p.config.Enabled {
return
}
// check at startup
p.checkUsage()
ticker := time.NewTicker(time.Duration(p.config.Interval) * time.Minute)
defer ticker.Stop()
for range ticker.C {
p.checkUsage()
}
}