Skip to content

Commit

Permalink
added downtime stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Griesbacher committed Apr 5, 2017
1 parent bfd8e03 commit 7f12df3
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 11 deletions.
9 changes: 6 additions & 3 deletions cyclic/statisticsHost.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ func (s HostStatistics) run() {
hostStates.StateTypeToString(hostStates.Down): 0,
hostStates.StateTypeToString(hostStates.Unreachable): 0,
}, hostStates.StateTypeToString)
flapping, enabled := countMinorStats(meta)
prom.StatsHostsFlapping.Set(flapping)
prom.StatsHostsChecksEnabled.Set(enabled)
countMinorStats(meta,
prom.StatsHostsFlapping,
prom.StatsHostsChecksEnabled,
prom.StatsHostsFlexDowntime,
prom.StatsHostsDowntime,
)
}
}
}
20 changes: 15 additions & 5 deletions cyclic/statisticsMetaHostAndServiceList.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,24 @@ func countTypes(meta structs.MetaHostAndServiceList, target *prometheus.GaugeVec
}
}

func countMinorStats(meta structs.MetaHostAndServiceList) (flapping, enabled float64) {
for _, h := range meta {
if h.IsFlapping > 0 {
func countMinorStats(meta structs.MetaHostAndServiceList, gFlapping, gEnabled, gFlexDowntime, gDowntime prometheus.Gauge) {
flapping, enabled, flexDowntime, downtime := 0.0, 0.0, 0.0, 0.0
for _, m := range meta {
if m.IsFlapping > 0 {
flapping++
}
if h.ChecksEnabled > 0 {
if m.ChecksEnabled > 0 {
enabled++
}
if m.PendingFlexDowntimeDepth > 0 {
flexDowntime++
}
if m.ScheduledDowntimeDepth > 0 {
downtime++
}
}
return
gFlapping.Set(flapping)
gEnabled.Set(enabled)
gFlexDowntime.Set(flexDowntime)
gDowntime.Set(downtime)
}
10 changes: 7 additions & 3 deletions cyclic/statisticsService.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ func (s ServiceStatistics) run() {
serviceStates.ServiceStatesToString(serviceStates.Critical): 0,
serviceStates.ServiceStatesToString(serviceStates.Unknown): 0,
}, serviceStates.ServiceStatesToString)
flapping, enabled := countMinorStats(meta)
prom.StatsServicesFlapping.Set(flapping)
prom.StatsServicesChecksEnabled.Set(enabled)
countMinorStats(meta,
prom.StatsServicesFlapping,
prom.StatsServicesChecksEnabled,
prom.StatsServicesFlexDowntime,
prom.StatsServicesDowntime,
)

}
}
}
22 changes: 22 additions & 0 deletions prom/statisticsHost.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ var StatsHostsFlapping = prometheus.NewGauge(
},
)

//StatsHostsFlexDowntime is a Prometheus gauge
var StatsHostsFlexDowntime = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: namespaceCore,
Subsystem: subsystemStatisticsHosts,
Name: "downtime_flex_total",
Help: "Amount of Hosts currently with a flex downtime",
},
)

//StatsHostsDowntime is a Prometheus gauge
var StatsHostsDowntime = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: namespaceCore,
Subsystem: subsystemStatisticsHosts,
Name: "downtime_total",
Help: "Amount of Hosts currently with a downtime",
},
)

//StatsHostsChecksEnabled is a Prometheus gauge
var StatsHostsChecksEnabled = prometheus.NewGauge(
prometheus.GaugeOpts{
Expand All @@ -65,5 +85,7 @@ func initStatisticsHost() {
prometheus.MustRegister(StatsHostsCheckType)
prometheus.MustRegister(StatsHostsStateType)
prometheus.MustRegister(StatsHostsFlapping)
prometheus.MustRegister(StatsHostsFlexDowntime)
prometheus.MustRegister(StatsHostsDowntime)
prometheus.MustRegister(StatsHostsChecksEnabled)
}
22 changes: 22 additions & 0 deletions prom/statisticsService.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ var StatsServicesFlapping = prometheus.NewGauge(
},
)

//StatsServicesFlexDowntime is a Prometheus gauge
var StatsServicesFlexDowntime = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: namespaceCore,
Subsystem: subsystemStatisticsServices,
Name: "downtime_flex_total",
Help: "Amount of Services currently with a flex downtime",
},
)

//StatsServicesDowntime is a Prometheus gauge
var StatsServicesDowntime = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: namespaceCore,
Subsystem: subsystemStatisticsServices,
Name: "downtime_total",
Help: "Amount of Services currently with a downtime",
},
)

//StatsServicesChecksEnabled is a Prometheus gauge
var StatsServicesChecksEnabled = prometheus.NewGauge(
prometheus.GaugeOpts{
Expand All @@ -63,5 +83,7 @@ func initStatisticsService() {
prometheus.MustRegister(StatsServicesCheckType)
prometheus.MustRegister(StatsServicesStateType)
prometheus.MustRegister(StatsServicesFlapping)
prometheus.MustRegister(StatsServicesFlexDowntime)
prometheus.MustRegister(StatsServicesDowntime)
prometheus.MustRegister(StatsServicesChecksEnabled)
}

0 comments on commit 7f12df3

Please sign in to comment.