tools

package
v0.1.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Indexer

func Indexer(num, length int) int

Find the index of items in the list with index higher than length or less than length

func SizeToHumanReadable

func SizeToHumanReadable(size int64) string

func StatsCalculator

func StatsCalculator(stat models.Stats) (cpu_usage float64, memory_usage float64)

These are formulas to calculate stats cpu_delta = cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage system_cpu_delta = cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage number_of_cpu_cores = lenght(cpu_stats.cpu_usage.percpu_usage) or cpu_stats.online_cpus CPU usage % = (cpu_delta / system_cpu_delta) * number_of_cpu_cores * 100.0

used_memory = memory_stats.usage - memory_stats.stats.cache available_memory = memory_stats.limit Memory usage % = (used_memory / available_memory) * 100.0

CPU usage are based on the host, not VM, so in Windows devices, you may see different cpu usages in the Bot and Docker desktop and docker cli, but, that's calculable. both are correct anyway.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL