6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

redis clusterで全てのサーバを一挙にmonitorする

Last updated at Posted at 2016-03-30

redisにはmonitor(Redisサーバが受け取ったすべてのコマンドをリアルタイム表示する)という便利コマンドがありますが、1サーバしか指定できません。
redis clusterを組んでいて、全サーバのmonitorをまとめて見たいケースって多いにあると思います。
調べて作ったのでここに残します。

ソース

redis-multi-monitor.sh
#!/bin/bash

trap 'eval "kill -KILL $(jobs -p|tr "\n" " ")"' EXIT
for f in "$@"; do
  IFS=':'
  set -- $f
  redis-cli -c -p $2 -h $1 monitor &
done
wait

※Ctrl+Cで抜けてもゴミプロセスを残しません。後味すっきり。

使い方

$ ./redis-multi-monitor.sh 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
1459331298.605642 [0 127.0.0.1:60922] "set" "aa" "bb"
1459331298.607053 [0 127.0.0.1:7000] "set" "aa" "bb"
↑クラスターはmaster slave構成で作ってあったので2つ出てきます

参考にさせていただいたもの

ご指摘あればよろしくお願いいたし!

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?