Revision e25047aa2e0c03e33a88aca81f4ef8371671e76d authored by Marco Iorio on 13 June 2024, 12:56:24 UTC, committed by André Martins on 17 June 2024, 08:28:59 UTC
Fixes: 811cb7f0273e ("make: Add include to Makefile.override within binary-specific makefiles")
Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
1 parent 0b29687
Raw File
health_linux.go
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

package server

import (
	"strconv"

	"golang.org/x/sys/unix"

	healthModels "github.com/cilium/cilium/api/v1/health/models"
)

func dumpLoad() (*healthModels.LoadResponse, error) {
	var info unix.Sysinfo_t
	err := unix.Sysinfo(&info)
	if err != nil {
		return nil, err
	}

	scale := float64(1 << unix.SI_LOAD_SHIFT)
	return &healthModels.LoadResponse{
		Last1min:  strconv.FormatFloat(float64(info.Loads[0])/scale, 'f', 2, 64),
		Last5min:  strconv.FormatFloat(float64(info.Loads[1])/scale, 'f', 2, 64),
		Last15min: strconv.FormatFloat(float64(info.Loads[2])/scale, 'f', 2, 64),
	}, nil
}
back to top