mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
Add -b option to lsof to avoid kernel blocks.
This commit is contained in:
parent
1e793a1c52
commit
cd532e08cb
2 changed files with 8 additions and 3 deletions
|
|
@ -157,3 +157,5 @@ We currently track the following events
|
|||
<strong id="garbage_collection">Garbage Collection:</strong> Event count when Garbage Collection occurs.
|
||||
|
||||
<strong id="goroutines">Goroutines:</strong> Number of running Goroutines.
|
||||
|
||||
<strong id="openfiles">OpenFiles:</strong> Number of open file handles associated with running Pilosa process ID.
|
||||
|
|
@ -513,12 +513,15 @@ func CountOpenFiles() int {
|
|||
case "unix":
|
||||
fallthrough
|
||||
case "freebsd":
|
||||
out, err := exec.Command("/bin/sh", "-c", fmt.Sprintf("lsof -p %v", os.Getpid())).Output()
|
||||
// -b option avoid kernel blocks
|
||||
pid := os.Getpid()
|
||||
out, err := exec.Command("/bin/sh", "-c", fmt.Sprintf("lsof -b -p %v", pid)).Output()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
lines := strings.Split(string(out), "\n")
|
||||
count = len(lines) - 1
|
||||
// only count lines with our pid, avoiding warning messages from -b
|
||||
lines := strings.Split(string(out), strconv.Itoa(pid))
|
||||
count = len(lines)
|
||||
case "windows":
|
||||
// TODO: count open file handles on windows
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue