syncthing/lib/ur/memsize_netbsd.go

31 lines
607 B
Go
Raw Permalink Normal View History

2015-02-05 20:29:27 +01:00
// Copyright (C) 2014 The Syncthing Authors.
//
2015-03-07 21:36:35 +01:00
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
2015-02-05 20:29:27 +01:00
package ur
2015-02-05 20:29:27 +01:00
import (
"os/exec"
"strconv"
"strings"
)
func memorySize() int64 {
2015-02-05 20:29:27 +01:00
cmd := exec.Command("/sbin/sysctl", "hw.physmem64")
out, err := cmd.Output()
if err != nil {
return 0
2015-02-05 20:29:27 +01:00
}
fs := strings.Fields(string(out))
if len(fs) != 3 {
return 0
2015-02-05 20:29:27 +01:00
}
bytes, err := strconv.ParseInt(fs[2], 10, 64)
if err != nil {
return 0
2015-02-05 20:29:27 +01:00
}
return bytes
2015-02-05 20:29:27 +01:00
}