diff --git a/docs/administration.md b/docs/administration.md
index 322b68e12..e562f94ce 100644
--- a/docs/administration.md
+++ b/docs/administration.md
@@ -157,3 +157,5 @@ We currently track the following events
Garbage Collection: Event count when Garbage Collection occurs.
Goroutines: Number of running Goroutines.
+
+OpenFiles: Number of open file handles associated with running Pilosa process ID.
\ No newline at end of file
diff --git a/server.go b/server.go
index 7f2027f10..57f3291eb 100644
--- a/server.go
+++ b/server.go
@@ -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: