Git Product home page Git Product logo

redis-stat's Introduction

redis-stat

redis-stat is a simple Redis monitoring tool written in Ruby.

It is based on INFO command of Redis, and thus generally won't affect the performance of the Redis instance unlike the other monitoring tools based on MONITOR command.

redis-stat allows you to monitor Redis instances

  • either with vmstat-like output from the terminal
  • or with the dashboard page served by its embedded web server.

Installation

gem install redis-stat

If you have trouble setting up a Ruby environment, you can download the executable JAR file and use it instead.

Usage

usage: redis-stat [HOST[:PORT][/PASS] ...] [INTERVAL [COUNT]]

    -a, --auth=PASSWORD              Password
    -v, --verbose                    Show more info
        --style=STYLE                Output style: unicode|ascii
        --no-color                   Suppress ANSI color codes
        --csv=OUTPUT_CSV_FILE_PATH   Save the result in CSV format
        --es=ELASTICSEARCH_URL       Send results to ElasticSearch: [http://]HOST[:PORT][/INDEX]

        --server[=PORT]              Launch redis-stat web server (default port: 63790)
        --daemon                     Daemonize redis-stat. Must be used with --server option.

        --version                    Show version
        --help                       Show this message

Running redis-stat for command-line monitoring

redis-stat
redis-stat 1
redis-stat 1 10
redis-stat --verbose
redis-stat localhost:6380 1 10
redis-stat localhost localhost:6380 localhost:6381 5
redis-stat localhost localhost:6380 1 10 --csv=/tmp/output.csv --verbose

Screenshot

Terminal output

redis-stat in web browser

When --server option is set, redis-stat will open up an embedded web server (default port: 63790) in the background so that you can monitor Redis in your browser.

Since redis-stat pushes updates every interval via Server-sent events, modern browsers are required to view the page.

redis-stat --server
redis-stat --verbose --server=8080 5

# redis-stat server can be daemonized
redis-stat --server --daemon

# Kill the daemon
killall -9 redis-stat-daemon

Screenshot

Dashboard

Windows support

If you're running Windows, you can only install redis-stat on JRuby. Notice that fancy terminal colors will not be printed as they are not supported in the default Windows command prompt.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Test

You need two Redis servers running on localhost with port 6379 and 6380 with no password.

bundle install
bundle exec rake test

About the name redis-stat

Since this project was supposed to be a vmstat-like monitoring script for Redis, naming it redis-stat seemed like a nice idea. That was when I was unaware of the existence of the original redis-stat included in redis-tools written by the creator of Redis himself. (My bad) Although the original C-version hasn't been updated for the past couple of years, you might want to check it out first.

redis-stat's People

Contributors

bitdeli-chef avatar flyerhzm avatar frhwang avatar junegunn avatar mmattel avatar stefanvanburen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redis-stat's Issues

Redis-stat config.

Hi,

I want to config the redis server point to another server, How can I do it?

nginx example config for proxying redis-stat

Referencing #56

Intention: act as a startingpoint to help others setting it up properly...

        location /your-access-page/ {
                # maybe you want to add authentication...
                auth_basic "Auth Text";
                auth_basic_user_file /your-path/auth-file;

                #
                proxy_set_header        Host                $host;
                proxy_set_header        X-Real-IP           $remote_addr;
                proxy_set_header        X-Forwarded-Host    $host;
                proxy_set_header        X-Forwarded-Server  $host;
                proxy_set_header        X-Forwarded-For     $proxy_add_x_forwarded_for;
                proxy_pass		http://127.0.0.1:63790/;
        }

Can't run in a background docker container

Doesn't let me run it as a background docker container without passing TERM and hackery.

root@command:~# docker run -d -p 7080:80 redis-stat --style=ascii --no-color redis-slave.ladbrokes.net.au:6379 10
21a8c8e5fc9d8c9a2cb1d61d6b605dd31cebde0651164a2d22f1fffa41fd2bad
root@command:~# docker logs 21
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
== Sinatra/1.3.6 has taken the stage on 80 for production with backup from Thin
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:80, CTRL+C to stop
:screen_width must be a positive integer

how to resolve this problem,please?

followed below scripts to install ruby & rubygems:yum install ruby;
but when starting redis-stat,error info:
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- redis-stat (LoadError) from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:inrequire'
from ./redis-stat:4:in `

'

how can I resolve this problem,please?

Improvement: get of redis instances to monitor from CLUSTER NODES command

Currently you need to list all the instances you want to watch on the command line. This allows you to only monitor what you want. It is also tedious if the number of machines is large.

It would be nice if there was an option applicable to redis cluster (currently in RC1) whereby you only need to specify one machine in the cluster. From that machine issuing a CLUSTER NODES command will list all the members of the cluster. Then use that list to specify the machines to monitor.

Redis stat authen not work!

Hi,

I use java version with follow command.

java -jar redis-stat-0.4.8.jar --server=8080 --authen=khiemnd

I use web browse to access http://xxx:8080. But it doesn't show any authen information.

Please help

Gather logs to different csv files in different time intervals...

Presently with redis-stat, it can generates log data regarding key performance indicators of redis-cluster and stash the logs into the single specified .csv file by the --csv command.
Usecase:
I wanted to stash the generated logs into different .csv files in different time intervals.
Lets say for example: we have 24 hours in a day and we divide the day into 4 different time intervals comprising of 6 hours each.

  1. For first time interval, all the generated logs are getting stashed into log1.csv file and at the end of first time interval, log1.csv stop storing the logs and passes the storage operation of logs to next .csv file which we can create automatically through a script program.
  2. For second time interval, all the generated logs are now getting stashed into log2.csv file and at the end of second time interval, log2.csv stop storing the logs and passes the storage operation of logs to next .csv file which we can create automatically through a script program. The process carry so on this way.
    Is this monitoring tool having this kind of configuration or is there also any other way to do it? Any help would be highly apprecialble.

No CPU usage after upgrade to Ruby 2.2.2

Hi guys, everything was working perfectly, I upgraded to 2.2.2 (to cheat on you guys and try a different redis monitor heh..) from 1.8.7 and now the cpu usage is gone.

which redis-stat:
/usr/local/rvm/gems/ruby-2.2.2/bin/redis-stat

gem list | grep redis-stat
redis-stat (0.4.11)

redis-cli info has the CPU usage,

however the cpu usage is not generated.

using system ruby (1.8.7) instead of rvm's 2.2.2 gets it back.

Run daemon server with custom port

Dear sir,

I want to run redis-stat as daemon web server, which connecting to another Redis server on a custom port. But I do NOT know how to config it.

Could you please show me how to do it? Thanks

"redis-stat --server" this command is suited for localhost, it do not work for remote server?Right?

when I run this command redis-stat --server, I can not monitor the remote server, just some command like redis-stat --server=106.11.188.12:6379. Am I right?

Besides, I type this command: redis-stat 182.92.155.88:6379 localhost:6379 1. And this is the result below:

img

there are two redis service in two machines.
So I want to ask the result with colorful message shows one redis info or two redis-info?The mem info seem like one machine's info. Did two redis info showed in sequence accoding to the result.

run "java -jar redis-stat {localhost:port} -a {password}" and return "Handshake Failed"

IoM_GaussDB_1228:/opt/redis # /opt/oss/manager/apps/MCDeployAgent-1.10.72/rtsp/jre/bin/java -jar redis-stat {ip}:{port} -a dbName@username@password --server
[INFO] Unable to bind key for unsupported operation: backward-delete-word
[INFO] Unable to bind key for unsupported operation: backward-delete-word
[INFO] Unable to bind key for unsupported operation: down-history
[INFO] Unable to bind key for unsupported operation: up-history
[INFO] Unable to bind key for unsupported operation: up-history
[INFO] Unable to bind key for unsupported operation: down-history
[INFO] Unable to bind key for unsupported operation: up-history
[INFO] Unable to bind key for unsupported operation: down-history
[INFO] Unable to bind key for unsupported operation: up-history
[INFO] Unable to bind key for unsupported operation: down-history
[INFO] Unable to bind key for unsupported operation: up-history
[INFO] Unable to bind key for unsupported operation: down-history
[2017/04/07 10:37:[email protected]:32095] ERR The 185.1.12.71:33385 Handshake Failed

Deploy with capistrano

Hi,
I use capistrano to deploy my project include redis-stat by add it to gem file. But I can't run redis-stat. How can I run redis-stat?

Throwing an error while using redis-stat on windows.

redis-stat_error

I get the error as shown in the images above while using redis-stat on windows but redis-stat works fine on Linux. I couldn't figure the exact problem with it as I am just a beginner to Redis. If any help would be appreciated.

cannot run redis-stat --server --daemon

/usr/lib/ruby/site_ruby/1.8/rubygems.rb:233:in activate': can't activate daemons (~> 1.1.9, runtime) for ["redis-stat-0.4.12"], already activated daemons-1.2.3 for ["thin-1.5.1", "redis-stat-0.4.12"] (Gem::LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:249:inactivate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in each' from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:inactivate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/redis-stat:18

invalid tabular data when monitoring multiple redises of different versions

redis-stat localhost:6380 localhost --verbose
┌───────────────────┬────────────────┬───────────┐
│                   │ localhost:6380 │ localhost │
├───────────────────┼────────────────┼───────────┤
│     redis_version │         2.2.15 │    2.4.14 │
│        process_id │          46584 │     45869 │
│ uptime_in_seconds │            703 │     28413 │
│    uptime_in_days │              0 │         0 │
│       gcc_version │          4.2.1 │           │
│              role │         master │    master │
│  connected_slaves │              0 │         0 │
│       aof_enabled │              0 │         0 │
│        vm_enabled │              0 │         0 │
└───────────────────┴────────────────┴───────────┘

gcc_version 4.2.1 should be shown in the second cell, not in the first.

Consider supporting custom ssl certificates configuration for elasticsearch client

It would be really great to support the transport_options hash parameter for the Elasticsearch::Client initialization, to specify a custom SSL cert for https:// urls.

See this section of the Elasticsearch README for example usage.

Not sure what your preferred method of passing this configuration data into the redis-stat server is, @junegunn.

It feels like adding another CLI flag for this option would be clunky, and you don't have any precedent for a config file. What are your thoughts here?

I'd be happy to help with a PR, or could fork if you think this change isn't generally useful.

Thanks for such a great tool!

Plans to release package?

This tool is great. Are there any plans to make a package so that it is easier to automate with ansible/chef/puppet/salt?

Currently you need to install

  • ruby
  • ruby-dev
  • gcc
  • g++

And then create your own init script.

It would be really nice if a package was made and it was hosted on packagecloud.io so that it would be easy to push out this tool to mulitiple datacenters using a configuration managment tool.

Here are a couple of tools that would make this super easy.

Elasticseach "total_commands_processed_per_second" field always zero

when i send to elasticsearch, total_commands_processed field's value is working.
but total_commands_processed_per_second field's value is always zero.

(BTW web and cli's total_commands_processed_per_second field's value is working.)

P.S elasticsearch option is very gooood!

redis auth problem

when run java -jar redis-stat-0.4.12.jar --server,then output "NOAUTH Authentication required".
if my redis config with auth,how to run redis-stat?

Not able to install with ruby 1.9.3p484

I was trying to install redis-stat, but getting "LoadError". I am new to ruby, so no idea how to resolve this problem. Do I need to install specific version of ruby to install redis-stat?
redis-stat issue

Error while running redis-stat

After successfully installed
On running
redis-stat localhost:6379/<password>
Getting following error
-bash: !dg3: event not found

OS: aws amazon linux(centos)

Multiple instances of redis-stat running as daemons

Is it possible to have multiple instances of redis-stat running as daemons on a single machine? Because it looks like the application makes a single pidfile to keep track of the latest PID.

I was running two instances of redis-stat with the daemon option for the last 24 hours or so and everything seemed to be working fine yesterday. Today morning, I noticed that both of them are giving me 500 internal server errors when I try to open either of them from a browser window.

The work around is to run redis-stat without the daemon option with nohup and send the output to /dev/null, but it would be nice if it ran with the daemon option too.

Thanks

Setup Ubuntu service command for redis-stat enabeling upstart

This is a small description for Ubuntu how to create scripts allowing usual start/stop commands including an upstart.

Kill any runnng instances

ps aux | grep redis-stat
#get pid from output
kill $PID

sudo vi /etc/init.d/redis-stat
#fill in following contetnt

#!/bin/sh
#
# https://www.yzuzun.com/2015/02/monitoring-redis-with-redis-stat/
#
### BEGIN INIT INFO
# Provides:          redis-stat
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start Redis Stat (redis-stat)
### END INIT INFO

# Defaults
RUN_MODE="daemons"

# Reads config file (will override defaults above)
#[ -r /etc/default/redis-stat ] && . /etc/default/redis-stat

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME="redis-stat"
DESC="Redis Stat"
DAEMON="/usr/local/bin/redis-stat"
DAEMONOPTS="--server"
PIDDIR="/var/run/$NAME"
PIDFILE="$PIDDIR/$NAME.pid"

# clear conflicting settings from the environment
unset TMPDIR

# See if the daemons are there
test -x $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
    start)
        log_daemon_msg "Starting $DESC"
        # Make sure we have our PIDDIR, even if they're on a tmpfs.
        install -o root -g root -m 755 -d $PIDDIR

        if [ "$RUN_MODE" != "inetd" ]; then
            log_progress_msg "$NAME"
            if ! start-stop-daemon --start --quiet --oknodo --background --make -pidfile --pidfile $PIDFILE --no-close --startas $DAEMON -- $DAEMONOPTS >> /dev/null 2>&1; then
                log_end_msg 1
                exit 1
            fi
        fi

        log_end_msg 0
        ;;
    stop)
        log_daemon_msg "Stopping $DESC"

        if [ "$RUN_MODE" != "inetd" ]; then
            log_progress_msg "$NAME"
            start-stop-daemon --stop --quiet --oknodo --retry 10 --pidfile $PIDFILE

            # Wait a little and remove stale PID file
            sleep 1
            if [ -f $PIDFILE ] && ! ps h `cat $PIDFILE` > /dev/null
            then
                # Stale PID file (process was succesfully stopped).
                rm -f $PIDFILE
            fi
        fi

        log_end_msg 0
        ;;
    reload)
        if [ "$RUN_MODE" != "inetd" ]; then
            log_daemon_msg "Reloading $DESC"

            start-stop-daemon --stop --quiet --signal HUP --pidfile $PIDFILE

            log_end_msg 0
        fi
        ;;
    restart|force-reload)
        $0 stop
        sleep 1
        $0 start
        ;;
    status)
        status="0"
        if [ "$RUN_MODE" != "inetd" ]; then
            status_of_proc -p $PIDFILE $DAEMON $NAME || status=$?
        fi
        exit $status
        ;;
    *)
        echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|status}"
        exit 1
        ;;
esac

exit 0

Set the upstart

sudo chmod +x /etc/init.d/redis-stat
sudo update-rc.d redis-stat defaults

Run the usual service command

sudo service redis-stat start|stop|reload|restart|force-reload|status

Possible memory leak in browser

We have just started using redis for a critical application in our organization, and I have deployed redis-stat for monitoring the health of the redis instances. I have noticed that the browser tab keeps using more and more memory, slowly slowing down my browser and ultimately hanging up my computer. I think the javascript code could be the culprit.
I am facing this issue in Chromium 28.0.1500.71 Ubuntu 13.04, and firefox 23.0.

In fact, I have written a small javascript script bookmarklet which keeps refreshing the redis-stat tab every 10 seconds, and my browser and OS have stopped crashing.

Proxying redis-stat (with nginx) fails

Ubuntu 16.04
Having other services proxied wih nginx successfully, it fails with redis-stat.

sudo redis-stat --server --daemon

Accessing via http(s)://domain/redis shows the following screen (proxied setup), but no content:
image

Doing the same but accessing direct (http://server:63790), without nginx and proxying, works.

Example logs entries:

access log:
"GET /js/site.js HTTP/2.0" 404 210 "https://xxxx/redis/"

error log:
open() "/var/www/xxxx/js/site.js" failed (2: No such file or directory), request: "GET /js/site.js HTTP/2.0"

It tries to access files locally instead of proxying them

Here is the corresponding config. As said, other apps proxied work like a charm

        location /redis/ {
                # proxy to redis-stat
                proxy_buffering    off;
                proxy_set_header   Host $http_host;
                proxy_set_header   X-Real-IP $remote_addr;
                proxy_http_version 1.1;
                proxy_pass         http://127.0.0.1:63790/;
        }

Tried to play with the nginx settings around, but it always ends up with the error messages described above.

redis stat track socket connection

As far as I can see in the documentation there is no way to run redis-stat to monitor a socket. redis-cli has a -s parameter, can redis-stat utilize the -s parameter also?

Improvement : Graph for replication lag offsets

It would be useful to be able to visualize the replication offsets for each slave. I have done manual calculations and the replication offset between master and slave can vary widely between 1 and 10 megabytes in my production environment. It may help pinpoint cpu spikes.

Issuing a normal kill comand to the redis-stat process does not work

% redis-stat mumble1:port mumble2:port mumble3:port mumble4:port ... --server --daemon

You see results on the web page

% ps -ef | grep redis-stats
...
12345 ... redis-stat ...

% kill -TERM 12345

The web process stops because of lost connect.
Run the ps command again. The process is still there.

% kill -KILL 12345

The process is gone.

All processes including daemon processes need to handle SIGTERM and exit gracefully. kill -KILL should not be necessary and does not allow any cleanup. kill -TERM allows the process to cleanup.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.