mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 21:02:11 +08:00
Script Refactoring
This commit is contained in:
parent
84174a1e59
commit
847dd8fe9e
@ -8,4 +8,4 @@ declare -A binaries=(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
tool_binaries=("ncpu" "infra")
|
tool_binaries=("ncpu" "infra" "check-free-memory")
|
||||||
|
|||||||
27
tools/check-free-memory/main.go
Normal file
27
tools/check-free-memory/main.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var sysInfo syscall.Sysinfo_t
|
||||||
|
|
||||||
|
err := syscall.Sysinfo(&sysInfo)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Failed to get system info: %v\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sysinfo returns memory in bytes, convert it to gigabytes
|
||||||
|
freeMemoryGB := float64(sysInfo.Freeram) / float64(1024*1024*1024)
|
||||||
|
|
||||||
|
if freeMemoryGB < 4.0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "System free memory is less than 4GB: %.2fGB\n", freeMemoryGB)
|
||||||
|
os.Exit(-1)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("System free memory is sufficient: %.2fGB\n", freeMemoryGB)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user