You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by nn...@apache.org on 2013/12/10 02:50:50 UTC

git commit: Added loadavg() convenience method to stout.

Updated Branches:
  refs/heads/master 9204faf46 -> 4f99d86fe


Added loadavg() convenience method to stout.

This patch includes a wrapper to get system load averages in uptime(1)
format. This is used by an upcoming patch which expose these averages
over master and slave stats.json endpoints.

Review: https://reviews.apache.org/r/15653


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4f99d86f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4f99d86f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4f99d86f

Branch: refs/heads/master
Commit: 4f99d86febbfc43d5c233961eb7860d766b53d72
Parents: 9204faf
Author: Niklas Q. Nielsen <ni...@mesosphere.io>
Authored: Tue Dec 10 01:50:45 2013 +0000
Committer: Niklas Q. Nielsen <ni...@mesosphere.io>
Committed: Tue Dec 10 01:50:45 2013 +0000

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/os.hpp         | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4f99d86f/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
index 544cf8c..2382d40 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -829,6 +829,35 @@ inline Try<long> cpus()
 }
 
 
+// Structure returned by loadavg(). Encodes system load average
+// for the last 1, 5 and 15 minutes.
+struct Load {
+  double one;
+  double five;
+  double fifteen;
+};
+
+
+// Returns load struct with average system loads for the last
+// 1, 5 and 15 minutes respectively.
+// Load values should be interpreted as usual average loads from
+// uptime(1).
+inline Try<Load> loadavg()
+{
+  double loadArray[3];
+  if (getloadavg(loadArray, 3) == -1) {
+    return ErrnoError("Failed to determine system load averages");
+  }
+
+  Load load;
+  load.one = loadArray[0];
+  load.five = loadArray[1];
+  load.fifteen = loadArray[2];
+
+  return load;
+}
+
+
 // Returns the total size of main memory.
 inline Try<Bytes> memory()
 {