diff options
author | Magnus Ahltorp <map@kth.se> | 2017-03-08 23:20:36 +0100 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2017-03-08 23:23:13 +0100 |
commit | 27b809c9525a876ecde0a5346e0264643197d934 (patch) | |
tree | 31c916cd4905d9bfc0a7f31098c6cb44e3bb70fd /statusserver/src/statusserver.erl | |
parent | 64daaf148cd59bf19942014bc754992b6bc6d86d (diff) |
Added heartbeat service. Add source. Send better messages.
Diffstat (limited to 'statusserver/src/statusserver.erl')
-rw-r--r-- | statusserver/src/statusserver.erl | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/statusserver/src/statusserver.erl b/statusserver/src/statusserver.erl index 323b28d..f38bf69 100644 --- a/statusserver/src/statusserver.erl +++ b/statusserver/src/statusserver.erl @@ -17,9 +17,10 @@ request(post, ?APPURL_PLOP_STATUS, Service, Input) -> Entries when is_list(Entries) -> lists:foreach(fun ({struct, PropList}) -> Target = proplists:get_value(<<"target">>, PropList), + Source = proplists:get_value(<<"source">>, PropList), Variable = proplists:get_value(<<"key">>, PropList), Status = proplists:get_value(<<"value">>, PropList), - set_status(Service, Target, Variable, Status) + set_status(Service, Source, Target, Variable, Status) end, Entries) end, success({[{result, <<"ok">>}]}); @@ -27,11 +28,12 @@ request(get, "", "status", Input) -> Now = erlang:monotonic_time(millisecond), Variables = [{struct, [ {service, list_to_binary(Service)}, + {source, Source}, {target, Target}, {variable, Variable}, {status, Status}, {age, (Now - Timestamp) / 1000} - ]} || {{Service, Target, Variable}, Status, Timestamp} <- get_status()], + ]} || {{Service, Source, Target, Variable}, Status, Timestamp} <- get_status()], success({[{result, Variables}]}). @@ -63,9 +65,9 @@ create_statusdb() -> get_status() -> [E || [E] <- ets:match(?STATUSDB_TABLE, '$1')]. -set_status(Service, Target, Variable, Status) -> - lager:info("status: ~p ~p ~p ~p", [Service, Target, Variable, Status]), +set_status(Service, Source, Target, Variable, Status) -> + lager:info("status: ~p ~p ~p ~p ~p", [Service, Source, Target, Variable, Status]), Timestamp = erlang:monotonic_time(millisecond), true = ets:insert(?STATUSDB_TABLE, - {{Service, Target, Variable}, Status, Timestamp}), + {{Service, Source, Target, Variable}, Status, Timestamp}), ok. |