nezha/model/api.go

20 lines
396 B
Go
Raw Normal View History

package model
type ServiceItemResponse struct {
Monitor *Monitor
CurrentUp uint64
CurrentDown uint64
2022-05-01 22:33:21 -04:00
TotalUp uint64
TotalDown uint64
Delay *[30]float32
Up *[30]int
Down *[30]int
}
2022-05-01 22:33:21 -04:00
func (r ServiceItemResponse) TotalUptime() float32 {
if r.TotalUp+r.TotalDown == 0 {
return 0
}
2022-05-01 22:33:21 -04:00
return float32(r.TotalUp) / (float32(r.TotalUp + r.TotalDown)) * 100
}