Merge branch 'master' into breminale

This commit is contained in:
Martin Geno 2017-07-06 13:12:44 +02:00
commit 511327ca10
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941

View File

@ -27,7 +27,7 @@ type Statistics struct {
Clients uint32 `json:"clients"` Clients uint32 `json:"clients"`
RootFsUsage float64 `json:"rootfs_usage,omitempty"` RootFsUsage float64 `json:"rootfs_usage,omitempty"`
LoadAverage float64 `json:"loadavg,omitempty"` LoadAverage float64 `json:"loadavg,omitempty"`
MemoryUsage float64 `json:"memory_usage,omitempty"` MemoryUsage *float64 `json:"memory_usage,omitempty"`
Uptime float64 `json:"uptime,omitempty"` Uptime float64 `json:"uptime,omitempty"`
Idletime float64 `json:"idletime,omitempty"` Idletime float64 `json:"idletime,omitempty"`
GatewayIPv4 string `json:"gateway,omitempty"` GatewayIPv4 string `json:"gateway,omitempty"`
@ -57,7 +57,11 @@ func NewStatistics(stats *data.Statistics) *Statistics {
* calc is coppied from node statuspage (look discussion: * calc is coppied from node statuspage (look discussion:
* https://github.com/FreifunkBremen/yanic/issues/35) * https://github.com/FreifunkBremen/yanic/issues/35)
*/ */
memoryUsage := 1 - (float64(stats.Memory.Free)+float64(stats.Memory.Buffers)+float64(stats.Memory.Cached))/float64(stats.Memory.Total) var memoryUsage *float64
if stats.Memory.Total > 0 {
usage := 1 - (float64(stats.Memory.Free)+float64(stats.Memory.Buffers)+float64(stats.Memory.Cached))/float64(stats.Memory.Total)
memoryUsage = &usage
}
return &Statistics{ return &Statistics{
NodeID: stats.NodeID, NodeID: stats.NodeID,