From 2839e351af1827d6db65fb2891016d69152718e3 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Tue, 12 Jan 2016 12:08:25 -0500 Subject: [PATCH] Add load averages to OS stats on FreeBSD This commit adds load averages to the OS stats on FreeBSD. For these stats to be available, linprocfs must be available and mounted at /compat/linux/proc. --- core/src/main/java/org/elasticsearch/monitor/os/OsProbe.java | 5 +++-- .../resources/org/elasticsearch/bootstrap/security.policy | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/monitor/os/OsProbe.java b/core/src/main/java/org/elasticsearch/monitor/os/OsProbe.java index 49c6b9ddc5a..077b4218fa9 100644 --- a/core/src/main/java/org/elasticsearch/monitor/os/OsProbe.java +++ b/core/src/main/java/org/elasticsearch/monitor/os/OsProbe.java @@ -111,8 +111,9 @@ public class OsProbe { * Returns the system load averages */ public double[] getSystemLoadAverage() { - if (Constants.LINUX) { - double[] loadAverage = readProcLoadavg("/proc/loadavg"); + if (Constants.LINUX || Constants.FREE_BSD) { + final String procLoadAvg = Constants.LINUX ? "/proc/loadavg" : "/compat/linux/proc/loadavg"; + double[] loadAverage = readProcLoadavg(procLoadAvg); if (loadAverage != null) { return loadAverage; } diff --git a/core/src/main/resources/org/elasticsearch/bootstrap/security.policy b/core/src/main/resources/org/elasticsearch/bootstrap/security.policy index ea525e55601..8db3aca8dc8 100644 --- a/core/src/main/resources/org/elasticsearch/bootstrap/security.policy +++ b/core/src/main/resources/org/elasticsearch/bootstrap/security.policy @@ -118,4 +118,7 @@ grant { // load averages on Linux permission java.io.FilePermission "/proc/loadavg", "read"; + + // load averages on FreeBSD + permission java.io.FilePermission "/compat/linux/proc/loadavg", "read"; };