Giter VIP home page Giter VIP logo

zabbix-redis-template's Introduction

Redis Template for Zabbix

Redis General View

Dashboard

Table of Contents

Features

  • Ability to discovery multiple Redis instances running on same host
  • Generate automatically a zabbix screen for general statistics, commands and replication overview on host! level.
  • Triggers identify command anomaly (not done yet) and instance crash

Installation

  • Import zbx_template/zbx_export_templates.xml via Zabbix -> Configuration -> Templates -> Import
  • Place zbx_template/zbx_redis_discovery.sh under /usr/bin/zbx_redis_discovery.sh
  • Place template userparameters under /etc/zabbix/zabbix_agentd.d/ or other place according your installation
  • Restart your zabbix agent where all above were placed

Installation (OPTIONAL)

  • Replace following line your.first.redis.host.local under zbx_screens/zbx_export_screens.xml with your first redis host
  • Import saved file zbx_export_screens.xml via Zabbix -> Monitoring -> Screens

Important

  • Make sure your redis-server configuration file ends with .conf otherwise INSTANCE name won't be discovered
  • Discovery produce stats files from where template gathers stats per 1 min basis, so important to leave discovery rules to run with short interval only. (current template do that each 1 min)
  • You don't have to worry about discovery process to update all items per 1 min basic, actually Zabbix Server use its own cache and perform DB update only when there is a new item appears.

Debuging / Issue reporting

  • if Discovery: "Discover Redis Instances" doesn't work: execute following command zbx_template/zbx_redis_discovery.sh general debug and output attach to the issue ticket
  • if Discovery: "Discover Redis Commands" doesn't work: execute following command zbx_template/zbx_redis_discovery.sh stats debug and output attach to the issue ticket
  • if Discovery: "Discover Redis Slaves" doesn't work: execute following command zbx_template/zbx_redis_discovery.sh replications debug and output attach to the issue ticket

Plans

  • Keep pushing on Zabbix R&D to let create graphs with multiple prototype items, meanwhile use Zabbix Grafana

Discovery with Statistics Report Flow

Discovery Flow

Example Instance Discovery:

zabbix_get -s redis.host.me -k redis.discovery[general,"123456 123456"] | jq .
{
  "data": [
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6399",
      "{#INSTANCE}": "INSTANCE1",
      "{#RDB_PATH}": "/usr/share/redis/instance1.rdb"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6395",
      "{#INSTANCE}": "INSTANCE2",
      "{#RDB_PATH}": "/usr/share/redis/instance2.rdb"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6397",
      "{#INSTANCE}": "INSTANCE3",
      "{#RDB_PATH}": "/usr/share/redis/instance3.rdb"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6389",
      "{#INSTANCE}": "INSTANCE4",
      "{#RDB_PATH}": "/usr/share/redis/instance4.rdb"
    }
  ]
}

Example Commands Stats Discovery:

zabbix_get -s redis.host.me -k redis.discovery[stats,"123456 123456"] | jq .
{
  "data": [
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6399",
      "{#COMMAND}": "cmdstat_auth",
      "{#INSTANCE}": "INSTANCE1"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6399",
      "{#COMMAND}": "cmdstat_ping",
      "{#INSTANCE}": "INSTANCE1"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6399",
      "{#COMMAND}": "cmdstat_info",
      "{#INSTANCE}": "INSTANCE1"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6399",
      "{#COMMAND}": "cmdstat_config",
      "{#INSTANCE}": "INSTANCE1"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6399",
      "{#COMMAND}": "cmdstat_slowlog",
      "{#INSTANCE}": "INSTANCE1"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6395",
      "{#COMMAND}": "cmdstat_auth",
      "{#INSTANCE}": "INSTANCE2"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6395",
      "{#COMMAND}": "cmdstat_ping",
      "{#INSTANCE}": "INSTANCE2"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6395",
      "{#COMMAND}": "cmdstat_info",
      "{#INSTANCE}": "INSTANCE2"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6395",
      "{#COMMAND}": "cmdstat_config",
      "{#INSTANCE}": "INSTANCE2"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6395",
      "{#COMMAND}": "cmdstat_slowlog",
      "{#INSTANCE}": "INSTANCE2"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6397",
      "{#COMMAND}": "cmdstat_set",
      "{#INSTANCE}": "INSTANCE3"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6397",
      "{#COMMAND}": "cmdstat_select",
      "{#INSTANCE}": "INSTANCE3"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6397",
      "{#COMMAND}": "cmdstat_auth",
      "{#INSTANCE}": "INSTANCE3"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6397",
      "{#COMMAND}": "cmdstat_ping",
      "{#INSTANCE}": "INSTANCE3"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6397",
      "{#COMMAND}": "cmdstat_info",
      "{#INSTANCE}": "INSTANCE3"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6397",
      "{#COMMAND}": "cmdstat_config",
      "{#INSTANCE}": "INSTANCE3"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6397",
      "{#COMMAND}": "cmdstat_slowlog",
      "{#INSTANCE}": "INSTANCE3"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6389",
      "{#COMMAND}": "cmdstat_auth",
      "{#INSTANCE}": "INSTANCE4"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6389",
      "{#COMMAND}": "cmdstat_ping",
      "{#INSTANCE}": "INSTANCE4"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6389",
      "{#COMMAND}": "cmdstat_info",
      "{#INSTANCE}": "INSTANCE4"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6389",
      "{#COMMAND}": "cmdstat_config",
      "{#INSTANCE}": "INSTANCE4"
    },
    {
      "{#HOST}": "127.0.0.1",
      "{#PORT}": "6389",
      "{#COMMAND}": "cmdstat_slowlog",
      "{#INSTANCE}": "INSTANCE4"
    }
  ]
}

Example Commands Stats Discovery:

zabbix_get -s redis.host.me -k redis.discovery[replication] | jq .
{
 "data": [
   {
     "{#HOST}": "127.0.0.1",
     "{#PORT}": "6400",
     "{#SLAVE}": "slave0",
     "{#INSTANCE}": "INSTANCE1"
   },
   {
     "{#HOST}": "127.0.0.1",
     "{#PORT}": "6400",
     "{#SLAVE}": "slave1",
     "{#INSTANCE}": "INSTANCE1"
   },
   {
     "{#HOST}": "127.0.0.1",
     "{#PORT}": "6400",
     "{#SLAVE}": "slave2",
     "{#INSTANCE}": "INSTANCE1"
   },
   {
     "{#HOST}": "127.0.0.1",
     "{#PORT}": "6400",
     "{#SLAVE}": "slave4",
     "{#INSTANCE}": "INSTANCE1"
   },
   {
     "{#HOST}": "127.0.0.1",
     "{#PORT}": "6400",
     "{#SLAVE}": "slave5",
     "{#INSTANCE}": "INSTANCE1"
   }
 ]
}    

zabbix-redis-template's People

Contributors

e-kuznetsov avatar frimn avatar pavelnemirovsky 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

zabbix-redis-template's Issues

Cannot find graph "Redis: "{#INSTANCE}" - {#COMMAND} Calls Overview" used in screen "Redis Monitoring: Redis Command Overview".

Hello, Pavel
I have problem with this steps:

Installation (OPTIONAL)

  • Replace following line your.first.redis.host.local under zbx_screens/zbx_export_screens.xml with your first redis host
    (replace 'your.first.redis.host.local' to 'redis01.intra' (this is my local IP for redis server)
  • Import saved file zbx_export_screens.xml via Zabbix -> Monitoring -> Screens
    When i importing.... zabbix web throw me this message "Cannot find graph "Redis: "{#INSTANCE}" - {#COMMAND} Calls Overview" used in screen "Redis Monitoring: Redis Command Overview".

Other steps complited successfuly.
Please, help to resolve this issue.... thanks

Can not import the screen file

Cannot find graph "Redis: "{#INSTANCE}" - {#COMMAND} Calls Overview" used in screen "Redis Monitoring: Redis Command Overview".
1

Discover Redis Instances marked as Not supported

Hello,

I have installed your template, and I don't understand why it's not working. Discover Redis Commands and Discover Redis Slaves are working correctly, but Discover Redis Instances shows as Not supported in Zabbix. The error message is Value should be a JSON object., but the output looks like a valid JSON.

{"data":[{"{#HOST}":"127.0.0.1","{#PORT}":"6379","{#INSTANCE}":"REDIS","{#RDB_PATH}":"/var/lib/redis/dump.rdb"}]}

Here is my debug

$ ./zbx_redis_discovery.sh general debug
+ '[' -e /tmp/redis-cli ']'
++ cat /tmp/redis-cli
+ REDIS_CLI=/usr/bin/redis-cli
+ '[' -a /tmp/stdbuf ']'
++ cat /tmp/stdbuf
+ STDBUF=/usr/bin/stdbuf
+ '[' general '!=' general ']'
+ echo -n '{"data":['
{"data":[+ sed -e 's:\},$:\}:'
+ for s in '$LIST'
++ echo redis:/usr/bin/redis-server:127.0.0.1:6379:
++ sed 's/*/127.0.0.1/g'
++ cut -d: -f3
+ HOST=127.0.0.1
++ echo redis:/usr/bin/redis-server:127.0.0.1:6379:
++ sed 's/*/127.0.0.1/g'
++ cut -d: -f4
+ PORT=6379
+ [[ 1 -ne 0 ]]
+ (( i=0 ))
+ (( i<1 ))
+ PASSWORD=debug
++ discover_redis_instance 127.0.0.1 6379 debug
++ HOST=127.0.0.1
++ PORT=6379
++ PASSWORD=debug
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
++ ALIVE=PONG
++ [[ PONG != \P\O\N\G ]]
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug info
+++ grep config_file
+++ cut -d : -f2
+++ cut -d / -f1
+++ rev
+++ tr -d '[:space:]'
+++ rev
+++ tr '[:lower:]' '[:upper:]'
+++ sed s/.conf//g
++ INSTANCE=REDIS
++ '[' REDIS = '' ']'
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get dir
+++ cut -d ' ' -f2
+++ sed -n 2p
++ INSTANCE_RDB_PATH=/var/lib/redis
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get dbfilename
+++ sed -n 2p
+++ cut -d ' ' -f2
++ INSTANCE_RDB_FILE=dump.rdb
++ echo REDIS
+ INSTANCE=REDIS
++ discover_redis_rdb_database 127.0.0.1 6379 debug
++ HOST=127.0.0.1
++ PORT=6379
++ PASSWORD=debug
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
++ ALIVE=PONG
++ [[ PONG != \P\O\N\G ]]
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get dir
+++ cut -d ' ' -f2
+++ sed -n 2p
++ INSTANCE_RDB_PATH=/var/lib/redis
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get dbfilename
+++ cut -d ' ' -f2
+++ sed -n 2p
++ INSTANCE_RDB_FILE=dump.rdb
++ echo /var/lib/redis/dump.rdb
+ RDB_PATH=/var/lib/redis/dump.rdb
++ discover_redis_avalable_commands 127.0.0.1 6379 debug
++ HOST=127.0.0.1
++ PORT=6379
++ PASSWORD=debug
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
++ ALIVE=PONG
++ [[ PONG != \P\O\N\G ]]
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug info all
+++ grep cmdstat
+++ cut -d: -f1
++ REDIS_COMMANDS='cmdstat_get
cmdstat_set
cmdstat_setnx
cmdstat_del
cmdstat_incr
cmdstat_rpush
cmdstat_lpush
cmdstat_rpop
cmdstat_lpop
cmdstat_llen
cmdstat_lrange
cmdstat_sadd
cmdstat_spop
cmdstat_mset
cmdstat_select
cmdstat_expire
cmdstat_scan
cmdstat_auth
cmdstat_ping
cmdstat_type
cmdstat_info
cmdstat_config
cmdstat_eval
cmdstat_slowlog
cmdstat_command'
++ IFS='
'
++ echo 'cmdstat_get
cmdstat_set
cmdstat_setnx
cmdstat_del
cmdstat_incr
cmdstat_rpush
cmdstat_lpush
cmdstat_rpop
cmdstat_lpop
cmdstat_llen
cmdstat_lrange
cmdstat_sadd
cmdstat_spop
cmdstat_mset
cmdstat_select
cmdstat_expire
cmdstat_scan
cmdstat_auth
cmdstat_ping
cmdstat_type
cmdstat_info
cmdstat_config
cmdstat_eval
cmdstat_slowlog
cmdstat_command'
+ COMMANDS='cmdstat_get
cmdstat_set
cmdstat_setnx
cmdstat_del
cmdstat_incr
cmdstat_rpush
cmdstat_lpush
cmdstat_rpop
cmdstat_lpop
cmdstat_llen
cmdstat_lrange
cmdstat_sadd
cmdstat_spop
cmdstat_mset
cmdstat_select
cmdstat_expire
cmdstat_scan
cmdstat_auth
cmdstat_ping
cmdstat_type
cmdstat_info
cmdstat_config
cmdstat_eval
cmdstat_slowlog
cmdstat_command'
++ discover_redis_avalable_slaves 127.0.0.1 6379 debug
++ HOST=127.0.0.1
++ PORT=6379
++ PASSWORD=debug
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
++ ALIVE=PONG
++ [[ PONG != \P\O\N\G ]]
+++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug info all
+++ grep '^slave'
+++ cut -d : -f1
+++ grep '[0-1024]'
++ REDIS_SLAVES=
++ IFS='
'
++ echo ''
+ SLAVES=
+ [[ -n REDIS ]]
+ [[ general == \g\e\n\e\r\a\l ]]
+ generate_redis_stats_report 127.0.0.1 6379 debug
+ HOST=127.0.0.1
+ PORT=6379
+ PASSWORD=debug
++ stdbuf -oL /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug info all
+ REDIS_REPORT=
++ stdbuf -oL /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug slowlog len
++ cut -d ' ' -f2
++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug slowlog reset
+ REDIS_SLOWLOG_LEN=
++ stdbuf -oL /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug slowlog get
+ REDIS_SLOWLOG_RAW=
++ cut -d ' ' -f2
++ stdbuf -oL /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get '*maxclients*'
++ sed -n 2p
+ REDIS_MAX_CLIENTS=
+ generate_general_discovery_json 127.0.0.1 6379 REDIS /var/lib/redis/dump.rdb
+ HOST=127.0.0.1
+ PORT=6379
+ INSTANCE=REDIS
+ RDB_PATH=/var/lib/redis/dump.rdb
+ echo -n '{'
+ echo -n '"{#HOST}":"127.0.0.1",'
+ echo -n '"{#PORT}":"6379",'
+ echo -n '"{#INSTANCE}":"REDIS",'
+ echo -n '"{#RDB_PATH}":"/var/lib/redis/dump.rdb"'
+ echo -n '},'
+ (( i++  ))
+ (( i<1 ))
+ unset
{"{#HOST}":"127.0.0.1","{#PORT}":"6379","{#INSTANCE}":"REDIS","{#RDB_PATH}":"/var/lib/redis/dump.rdb"}+ echo -n ']}'
]}+ echo ''

+ unset IFS

I don't know if it's related, but I see REDIS_MAX_CLIENTS is blank in output message. If I execute the command I see there in the command line, it works

$ stdbuf -oL /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get '*maxclients*' | sed -n 2p
10000

What can be wrong in my setup?

Thanks

Incorrectly identifies redis-cli executable.

$ locate redis-cli
/etc/bash_completion.d/redis-cli
/home/khazhy/redis/redis-stable/src/redis-cli
/home/khazhy/redis/redis-stable/src/redis-cli.c
/home/khazhy/redis/redis-stable/src/redis-cli.o
/home/khazhy/redis/redis-stable/tests/integration/redis-cli.tcl
/usr/local/bin/redis-cli

Using locate redis-cli seems iffy. In this case, the real binary is the very last item, but the script uses the first item, which is a bash completion script. If redis-cli is on PATH, which redis-cli seems better

Template file for zabbix 5.0

Hi,

I am trying to use this template with zabbix 5.0.10 however I fail to upload the template file through zabbix frontend. I assume this is because zabbix 5.0 requires different syntax than zabbix 3.4.

Do you have the template file for zabbix 5.0?

Here is the error I get during the upload.

Invalid tag "/zabbix_export/templates/template(1)/discovery_rules/discovery_rule(1)/graph_prototypes/graph_prototype(1)/graph_items/graph_item(1)/type": a character string is expected.

thanks in advance

How to change {$REDIS_PASSWORDS} for everal different srv?

Hello!
I can change {$REDIS_PASSWORDS} for all templates, but how i can specific setup different password for others several servers ?
And if password is not correct for new server, discover app redis will not be created

All templates
image

Specific server
image

not working, why ? Help

[root@redis bin]# zbx_redis_discovery.sh general debug

  • '[' -e /tmp/redis-cli ']'
    ++ cat /tmp/redis-cli

  • REDIS_CLI=/usr/bin/redis-cli

  • '[' -a /tmp/stdbuf ']'
    ++ cat /tmp/stdbuf

  • STDBUF=/usr/bin/stdbuf

  • '[' general '!=' general ']'

  • echo -n '{"data":['
    {"data":[+ for s in '$LIST'

  • sed -e 's:},$:}:'
    ++ sed 's/*/127.0.0.1/g'
    ++ cut -d: -f3
    ++ echo redis:/usr/bin/redis-server:127.0.0.1:6379

  • HOST=127.0.0.1
    ++ echo redis:/usr/bin/redis-server:127.0.0.1:6379
    ++ sed 's/*/127.0.0.1/g'
    ++ cut -d: -f4

  • PORT=6379

  • [[ 1 -ne 0 ]]

  • (( i=0 ))

  • (( i<1 ))

  • PASSWORD=debug
    ++ discover_redis_instance 127.0.0.1 6379 debug
    ++ HOST=127.0.0.1
    ++ PORT=6379
    ++ PASSWORD=debug
    +++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
    ++ ALIVE='NOAUTH Authentication required.'
    ++ [[ NOAUTH Authentication required. != \P\O\N\G ]]
    ++ return 1

  • INSTANCE=
    ++ discover_redis_rdb_database 127.0.0.1 6379 debug
    ++ HOST=127.0.0.1
    ++ PORT=6379
    ++ PASSWORD=debug
    +++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
    ++ ALIVE='NOAUTH Authentication required.'
    ++ [[ NOAUTH Authentication required. != \P\O\N\G ]]
    ++ return 1

  • RDB_PATH=
    ++ discover_redis_avalable_commands 127.0.0.1 6379 debug
    ++ HOST=127.0.0.1
    ++ PORT=6379
    ++ PASSWORD=debug
    +++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
    ++ ALIVE='NOAUTH Authentication required.'
    ++ [[ NOAUTH Authentication required. != \P\O\N\G ]]
    ++ return 1

  • COMMANDS=
    ++ discover_redis_avalable_slaves 127.0.0.1 6379 debug
    ++ HOST=127.0.0.1
    ++ PORT=6379
    ++ PASSWORD=debug
    +++ /usr/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
    ++ ALIVE='NOAUTH Authentication required.'
    ++ [[ NOAUTH Authentication required. != \P\O\N\G ]]
    ++ return 1

  • SLAVES=

  • [[ -n '' ]]

  • (( i++ ))

  • (( i<1 ))

  • unset

  • echo -n ']}'
    ]}+ echo ''

  • unset IFS

Template import problem

Problem with importing template.
Cannot read XML: (41) Specification mandate value for attribute data-pjax-transient [Line: 43 | Column: 89].

Can't get it work. Please help!

Hello, Pavel!

If it's possible, please help!
Seems like i did something wrong, or didn't understand something.

I set all userparametrs directly in /opt/zabbix/etc/zabbix_agentd.conf. Path to script is set here
UserParameter=redis.discovery[*], /opt/zabbix/etc/scripts/zbx_redis_discovery.sh $1 $2

I edited /opt/zabbix/etc/scripts/zbx_redis_discovery.sh to specify redis location:
REDIS_CLI_DEFAULT_PATH="/opt/redis/bin/redis-cli"

When i run zbx_redis_discovery.sh general debug, few files redis-127.0.0.1-6379* in /tmp are created with root privileges.
After this i can request some information with
./opt/zabbix/sbin/zabbix_agentd -t redis.stat.get[expired_keys,127.0.0.1,6379]
redis.stat.get[expired_keys,127.0.0.1,6379] [t|29562818]
And remotely the same.

But i get, only what is in redis-127.0.0.1-6379 file (so it's not in realtime)

chown zabbix.zabbix redis-127.0.0.1* didn't help.

I imported template in gui, but it show Timeout while executing a shell script.

Here's resutl of zbx_redis_discovery.sh general debug

`+ '[' -e /tmp/redis-cli ']'
++ cat /tmp/redis-cli

  • REDIS_CLI=/opt/redis/bin/redis-cli

  • '[' general '!=' general ']'

  • echo -n '{"data":['
    {"data":[+ for s in '$LIST'

  • sed -e 's:},$:}:'
    ++ echo root:/opt/redis/bin/redis-server:127.0.0.1:6379:
    ++ sed 's/*/127.0.0.1/g'
    ++ cut -d: -f3

  • HOST=127.0.0.1
    ++ echo root:/opt/redis/bin/redis-server:127.0.0.1:6379:
    ++ sed 's/*/127.0.0.1/g'
    ++ cut -d: -f4

  • PORT=6379

  • [[ 1 -ne 0 ]]

  • (( i=0 ))

  • (( i<1 ))

  • PASSWORD=debug
    ++ discover_redis_instance 127.0.0.1 6379 debug
    ++ HOST=127.0.0.1
    ++ PORT=6379
    ++ PASSWORD=debug
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
    ++ ALIVE=PONG
    ++ [[ PONG != \P\O\N\G ]]
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug info
    +++ grep config_file
    +++ cut -d : -f2
    +++ sed s/.conf//g
    +++ rev
    +++ cut -d / -f1
    +++ rev
    +++ tr -d '[:space:]'
    +++ tr '[:lower:]' '[:upper:]'
    ++ INSTANCE=REDIS
    ++ '[' REDIS = '' ']'
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get dir
    +++ cut -d ' ' -f2
    +++ sed -n 2p
    ++ INSTANCE_RDB_PATH=/
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get dbfilename
    +++ cut -d ' ' -f2
    +++ sed -n 2p
    ++ INSTANCE_RDB_FILE=dump.rdb
    ++ echo REDIS

  • INSTANCE=REDIS
    ++ discover_redis_rdb_database 127.0.0.1 6379 debug
    ++ HOST=127.0.0.1
    ++ PORT=6379
    ++ PASSWORD=debug
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
    ++ ALIVE=PONG
    ++ [[ PONG != \P\O\N\G ]]
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get dir
    +++ cut -d ' ' -f2
    +++ sed -n 2p
    ++ INSTANCE_RDB_PATH=/
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get dbfilename
    +++ cut -d ' ' -f2
    +++ sed -n 2p
    ++ INSTANCE_RDB_FILE=dump.rdb
    ++ echo //dump.rdb

  • RDB_PATH=//dump.rdb
    ++ discover_redis_available_commands 127.0.0.1 6379 debug
    ++ HOST=127.0.0.1
    ++ PORT=6379
    ++ PASSWORD=debug
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
    ++ ALIVE=PONG
    ++ [[ PONG != \P\O\N\G ]]
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug info all
    +++ grep cmdstat
    +++ cut -d: -f1
    ++ REDIS_COMMANDS='cmdstat_get
    cmdstat_del
    cmdstat_exists
    cmdstat_srem
    cmdstat_sunion
    cmdstat_smembers
    cmdstat_hset
    cmdstat_hget
    cmdstat_hmset
    cmdstat_hmget
    cmdstat_hincrby
    cmdstat_select
    cmdstat_expire
    cmdstat_keys
    cmdstat_auth
    cmdstat_ping
    cmdstat_multi
    cmdstat_exec
    cmdstat_info
    cmdstat_config
    cmdstat_slowlog
    cmdstat_command'
    ++ IFS='
    '
    ++ echo 'cmdstat_get
    cmdstat_del
    cmdstat_exists
    cmdstat_srem
    cmdstat_sunion
    cmdstat_smembers
    cmdstat_hset
    cmdstat_hget
    cmdstat_hmset
    cmdstat_hmget
    cmdstat_hincrby
    cmdstat_select
    cmdstat_expire
    cmdstat_keys
    cmdstat_auth
    cmdstat_ping
    cmdstat_multi
    cmdstat_exec
    cmdstat_info
    cmdstat_config
    cmdstat_slowlog
    cmdstat_command'

  • COMMANDS='cmdstat_get
    cmdstat_del
    cmdstat_exists
    cmdstat_srem
    cmdstat_sunion
    cmdstat_smembers
    cmdstat_hset
    cmdstat_hget
    cmdstat_hmset
    cmdstat_hmget
    cmdstat_hincrby
    cmdstat_select
    cmdstat_expire
    cmdstat_keys
    cmdstat_auth
    cmdstat_ping
    cmdstat_multi
    cmdstat_exec
    cmdstat_info
    cmdstat_config
    cmdstat_slowlog
    cmdstat_command'
    ++ discover_redis_available_slaves 127.0.0.1 6379 debug
    ++ HOST=127.0.0.1
    ++ PORT=6379
    ++ PASSWORD=debug
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug ping
    ++ ALIVE=PONG
    ++ [[ PONG != \P\O\N\G ]]
    +++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug info all
    +++ grep '^slave'
    +++ cut -d : -f1
    +++ grep '[0-1024]'
    ++ REDIS_SLAVES=
    ++ IFS='
    '
    ++ echo ''

  • SLAVES=

  • [[ -n REDIS ]]

  • [[ general == \g\e\n\e\r\a\l ]]

  • generate_redis_stats_report 127.0.0.1 6379 debug

  • HOST=127.0.0.1

  • PORT=6379

  • PASSWORD=debug

  • local REDIS_REPORT_RESULT=/tmp/redis-127.0.0.1-6379

  • local REDIS_REPORT_RESULT_TMP=/tmp/redis-127.0.0.1-6379.tmp
    ++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug info all

  • REDIS_REPORT=

  • REDIS_REPORT_RC=0

  • local REDIS_SLOWLOG_LEN_RESULT=/tmp/redis-127.0.0.1-6379-slowlog-len

  • local REDIS_SLOWLOG_LEN_RESULT_TMP=/tmp/redis-127.0.0.1-6379-slowlog-len.tmp
    ++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug slowlog len
    ++ cut -d ' ' -f2
    ++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug slowlog reset

  • REDIS_SLOWLOG_LEN=

  • REDIS_SLOWLOG_LEN_RC=0

  • local REDIS_SLOWLOG_RAW_RESULT=/tmp/redis-127.0.0.1-6379-slowlog-raw

  • local REDIS_SLOWLOG_RAW_RESULT_TMP=/tmp/redis-127.0.0.1-6379-slowlog-raw.tmp
    ++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug slowlog get

  • REDIS_SLOWLOG_RAW=

  • REDIS_SLOWLOG_RAW_RC=0

  • local REDIS_MAX_CLIENTS_RESULT=/tmp/redis-127.0.0.1-6379-maxclients

  • local REDIS_MAX_CLIENTS_RESULT_TMP=/tmp/redis-127.0.0.1-6379-maxclients.tmp
    ++ /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379 -a debug config get 'maxclients'
    ++ cut -d ' ' -f2
    ++ sed -n 2p

  • REDIS_MAX_CLIENTS=

  • REDIS_MAX_CLIENTS_RC=0

  • [[ -e /tmp/redis-127.0.0.1-6379.tmp ]]

  • [[ 0 -eq 0 ]]
    ++ mv /tmp/redis-127.0.0.1-6379.tmp /tmp/redis-127.0.0.1-6379

  • REDIS_REPORT_DUMP=

  • [[ 0 -ne 0 ]]

  • [[ -e /tmp/redis-127.0.0.1-6379-slowlog-len.tmp ]]

  • [[ '' -eq 0 ]]
    ++ mv /tmp/redis-127.0.0.1-6379-slowlog-len.tmp /tmp/redis-127.0.0.1-6379-slowlog-len

  • REDIS_REPORT_DUMP=

  • [[ 0 -ne 0 ]]

  • [[ -e /tmp/redis-127.0.0.1-6379-maxclients.tmp ]]

  • [[ 0 -eq 0 ]]
    ++ mv /tmp/redis-127.0.0.1-6379-slowlog-raw.tmp /tmp/redis-127.0.0.1-6379-slowlog-raw

  • REDIS_REPORT_DUMP=

  • [[ 0 -ne 0 ]]

  • [[ -e /tmp/redis-127.0.0.1-6379-maxclients.tmp ]]

  • [[ 0 -eq 0 ]]
    ++ mv /tmp/redis-127.0.0.1-6379-maxclients.tmp /tmp/redis-127.0.0.1-6379-maxclients

  • REDIS_REPORT_DUMP=

  • [[ 0 -ne 0 ]]

  • generate_general_discovery_json 127.0.0.1 6379 REDIS //dump.rdb

  • HOST=127.0.0.1

  • PORT=6379

  • INSTANCE=REDIS

  • RDB_PATH=//dump.rdb

  • echo -n '{'

  • echo -n '"{#HOST}":"127.0.0.1",'

  • echo -n '"{#PORT}":"6379",'

  • echo -n '"{#INSTANCE}":"REDIS",'

  • echo -n '"{#RDB_PATH}":"//dump.rdb"'

  • echo -n '},'

  • (( i++ ))

  • (( i<1 ))

  • unset
    {"{#HOST}":"127.0.0.1","{#PORT}":"6379","{#INSTANCE}":"REDIS","{#RDB_PATH}":"//dump.rdb"}+ echo -n ']}'
    ]}+ echo ''

  • unset IFS`

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.