mirror of
https://github.com/valitydev/cg_mon.git
synced 2024-11-06 00:45:20 +00:00
Add support for reading cpuacct usage metric
This commit is contained in:
parent
dfef38f405
commit
61b1ab0019
@ -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
33
src/cg_cpu_sup.erl
Normal 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).
|
@ -130,7 +130,7 @@ cgroup_discovery_file() ->
|
||||
end.
|
||||
|
||||
handler_modules() ->
|
||||
[cg_mem_sup].
|
||||
[cg_mem_sup, cg_cpu_sup].
|
||||
|
||||
|
||||
%%%===================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user