Last active
November 4, 2015 07:22
-
-
Save developerworks/721aac2670caa64ea4c0 to your computer and use it in GitHub Desktop.
Compute the avg cpu load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Test do | |
require Logger | |
def get_normalized_load do | |
:application.ensure_all_started(:os_mon) | |
loads = [:cpu_sup.avg1, :cpu_sup.avg5, :cpu_sup.avg15] |> Enum.map(fn x -> | |
x / :erlang.system_info(:logical_processors) / 256 | |
end) | |
Logger.debug "Loads: #{inspect loads}" | |
loads | |
end | |
end | |
Test.get_normalized_load |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment