Permalink
Browse files

Merge pull request #1 from mprymek/master

rrd_create: start_time support
  • Loading branch information...
archaelus committed Jan 15, 2014
2 parents e88239c + 3c24361 commit 9c3f98403354a4f0bec3582f69b513364306ff9a
Showing with 9 additions and 3 deletions.
  1. +1 −1 include/errd.hrl
  2. +8 −2 src/errd_command.erl
View
@@ -13,7 +13,7 @@
args :: string()}).
-record(rrd_create, {file :: string(),
- start_time :: any(), %% TODO
+ start_time = now :: 'now' | string(),
step = 300 :: pos_integer(),
ds_defs = [] :: [#rrd_ds{}],
rra_defs = [] :: [#rrd_rra{}]}).
View
@@ -24,11 +24,17 @@
%% @doc Converts the data structure describing the rrd command to
%% a string that can be executed by rrdtool.
%% @end
-format(#rrd_create{file=File,start_time=undefined,
+format(#rrd_create{file=File,start_time=Time,
step=Step,ds_defs=DSs,rra_defs=RRAs}) when is_integer(Step) ->
+ TimeStr = case Time of
+ now ->
+ "now-10s"; % default according to man rrdcreate
+ _ ->
+ Time
+ end,
Dstr = lists:flatten(string:join(lists:map(fun (D) -> format(D) end, DSs), " ")),
RRAstr = lists:flatten(string:join(lists:map(fun (D) -> format(D) end, RRAs), " ")),
- lists:flatten(io_lib:format("create ~s --step ~p ~s ~s~n", [File, Step, Dstr, RRAstr]));
+ lists:flatten(io_lib:format("create ~s -b ~s --step ~p ~s ~s~n", [File, TimeStr, Step, Dstr, RRAstr]));
format(#rrd_ds{name=Name,type=Type,args=Args}) when is_atom(Type) ->
io_lib:format("DS:~s:~s:~s", [Name, to_list(Type), Args]);

0 comments on commit 9c3f984

Please sign in to comment.