Skip to content

Commit 5d6e77f

Browse files
Add sentinel_total_tilt to sentinel INFO sentinel (#1904)
it will be a good idea to add total_tilt in info command to show total tilt count, in order to help admin to know sentinel tilt condition. --------- Signed-off-by: carlosfu <carlosfu@163.com> Signed-off-by: Binbin <binloveplay1314@qq.com> Co-authored-by: Binbin <binloveplay1314@qq.com>
1 parent 89d4577 commit 5d6e77f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/sentinel.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ struct sentinelState {
259259
Key is the instance name, value is the
260260
sentinelValkeyInstance structure pointer. */
261261
int tilt; /* Are we in TILT mode? */
262+
int total_tilt; /* Number of tilt. */
262263
int running_scripts; /* Number of scripts in execution right now. */
263264
mstime_t tilt_start_time; /* When TITL started. */
264265
mstime_t previous_time; /* Last time we ran the time handler. */
@@ -492,6 +493,7 @@ void initSentinel(void) {
492493
sentinel.primaries = dictCreate(&instancesDictType);
493494
sentinel.tilt = 0;
494495
sentinel.tilt_start_time = 0;
496+
sentinel.total_tilt = 0;
495497
sentinel.previous_time = mstime();
496498
sentinel.running_scripts = 0;
497499
sentinel.scripts_queue = listCreate();
@@ -4091,11 +4093,13 @@ void sentinelInfoCommand(client *c) {
40914093
"sentinel_masters:%lu\r\n"
40924094
"sentinel_tilt:%d\r\n"
40934095
"sentinel_tilt_since_seconds:%jd\r\n"
4096+
"sentinel_total_tilt:%d\r\n"
40944097
"sentinel_running_scripts:%d\r\n"
40954098
"sentinel_scripts_queue_length:%ld\r\n"
40964099
"sentinel_simulate_failure_flags:%lu\r\n",
40974100
dictSize(sentinel.primaries), sentinel.tilt,
40984101
sentinel.tilt ? (intmax_t)((mstime() - sentinel.tilt_start_time) / 1000) : -1,
4102+
sentinel.total_tilt,
40994103
sentinel.running_scripts, listLength(sentinel.scripts_queue), sentinel.simfailure_flags);
41004104

41014105
di = dictGetIterator(sentinel.primaries);
@@ -5186,6 +5190,7 @@ void sentinelCheckTiltCondition(void) {
51865190
if (delta < 0 || delta > sentinel_tilt_trigger) {
51875191
sentinel.tilt = 1;
51885192
sentinel.tilt_start_time = mstime();
5193+
sentinel.total_tilt++;
51895194
sentinelEvent(LL_WARNING, "+tilt", NULL, "#tilt mode entered");
51905195
}
51915196
sentinel.previous_time = mstime();

0 commit comments

Comments
 (0)