diff options
author | Robert Newson <robert.newson@cloudant.com> | 2013-07-26 11:07:39 +0100 |
---|---|---|
committer | Robert Newson <robert.newson@cloudant.com> | 2013-07-26 11:07:39 +0100 |
commit | 552abfd01abf6c82893c8906c97bd68ba81e42b4 (patch) | |
tree | 457de093383e4928cf72c9f9d676370b73deec69 | |
parent | b55c8179872b625bfc90e7c330c248c342f8290f (diff) | |
download | couchdb-552abfd01abf6c82893c8906c97bd68ba81e42b4.tar.gz |
A separate alert and summary value for shards with only one remaining copy
-rw-r--r-- | src/custodian/src/custodian_server.erl | 11 | ||||
-rw-r--r-- | src/custodian/src/custodian_util.erl | 16 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/custodian/src/custodian_server.erl b/src/custodian/src/custodian_server.erl index 4429802a2..6dcf509fb 100644 --- a/src/custodian/src/custodian_server.erl +++ b/src/custodian/src/custodian_server.erl @@ -106,9 +106,10 @@ handle_db_event(_DbName, _Event, _St) -> {ok, nil}. check_shards() -> - {Unavailable, Impaired, Conflicted} = custodian:summary(), + {Unavailable, OneCopy, Impaired, Conflicted} = custodian:summary(), send_conflicted_alert(Conflicted), send_unavailable_alert(Unavailable), + send_one_copy_alert(OneCopy), send_impaired_alert(Impaired). send_conflicted_alert(0) -> @@ -134,3 +135,11 @@ send_unavailable_alert(Count) when is_integer(Count) -> twig:log(crit, "~B unavailable shards in this cluster", [Count]), os:cmd("send_snmptrap --trap CLOUDANT-DBCORE-MIB::cloudantDbcoreShardsUnavailableEvent -o cloudantDbcoreShardCount:INTEGER:" ++ integer_to_list(Count)). + +send_one_copy_alert(0) -> + twig:log(notice, "No shards with only one copy in this cluster", []), + os:cmd("send_snmptrap --trap CLOUDANT-DBCORE-MIB::cloudantDbcoreAllShardsMultipleCopiesEvent"); +send_one_copy_alert(Count) when is_integer(Count) -> + twig:log(crit, "~B shards with only one copy in this cluster", [Count]), + os:cmd("send_snmptrap --trap CLOUDANT-DBCORE-MIB::cloudantDbcoreShardsOneCopyEvent -o cloudantDbcoreShardCount:INTEGER:" + ++ integer_to_list(Count)). diff --git a/src/custodian/src/custodian_util.erl b/src/custodian/src/custodian_util.erl index 5d132d354..3a4ceb0f9 100644 --- a/src/custodian/src/custodian_util.erl +++ b/src/custodian/src/custodian_util.erl @@ -12,14 +12,16 @@ %% public functions. summary() -> - Fun = fun(_Id, _Range, unavailable, {U, I, C}) -> - {U + 1, I, C}; - (_Id, _Range, {impaired, _N}, {U, I, C}) -> - {U, I + 1, C}; - (_Id, _Range, {conflicted, _N}, {U, I, C}) -> - {U, I, C + 1} + Fun = fun(_Id, _Range, unavailable, {U, O, I, C}) -> + {U + 1, O, I, C}; + (_Id, _Range, {impaired, 1}, {U, O, I, C}) -> + {U, O + 1, I, C}; + (_Id, _Range, {impaired, _N}, {U, O, I, C}) -> + {U, O, I + 1, C}; + (_Id, _Range, {conflicted, _N}, {U, O, I, C}) -> + {U, O, I, C + 1} end, - fold_dbs({0, 0, 0}, Fun). + fold_dbs({0, 0, 0, 0}, Fun). report() -> Fun = fun(Id, Range, unavailable, Acc) -> |