Add support for reading cpuacct usage metric

This commit is contained in:
Viacheslav V. Kovalev 2014-10-07 22:25:14 +04:00
parent dfef38f405
commit 61b1ab0019
3 changed files with 38 additions and 3 deletions

View File

@ -2,7 +2,7 @@ cg_mon
======
Simple application to extend osmon functionality when using cgroups.
Now it only supports reading memory cgroup metrics and can't automatically detect where cgroups mounted.
Now it only supports reading memory and cpuacct cgroup metrics and can't automatically detect where cgroups mounted.
Usage example.
--------------
@ -19,10 +19,12 @@ ok
1941913600
6> cg_mem_sup:usage().
4880506880
7> cg_cpu_sup:usage().
8526844361646
```
To be done:
1. Add support for another cgroups such as cpuacct, blkio and so on.
1. Add support for another cgroups such as blkio.
2. Add event notifications (for example, about excessing some limit of memory usage).
3. Add documentation.

33
src/cg_cpu_sup.erl Normal file
View File

@ -0,0 +1,33 @@
-module(cg_cpu_sup).
-author("Viacheslav V. Kovalev").
%% API
-export([
provided_resource/0,
key_value_sources/0,
single_value_sources/0
]).
-export([
usage/0
]).
-define(PROVIDED_RESOURCE, cpuacct).
-define(KEY_VALUE_SOURCES, []).
-define(SINGLE_VALUE_SOURCES, [
{usage, "cpuacct.usage"}
]).
provided_resource() ->
?PROVIDED_RESOURCE.
key_value_sources() ->
?KEY_VALUE_SOURCES.
single_value_sources() ->
?SINGLE_VALUE_SOURCES.
usage() ->
cg_mon_reader:read_meter(?PROVIDED_RESOURCE, usage).

View File

@ -130,7 +130,7 @@ cgroup_discovery_file() ->
end.
handler_modules() ->
[cg_mem_sup].
[cg_mem_sup, cg_cpu_sup].
%%%===================================================================