Skip to content

Instantly share code, notes, and snippets.

@centminmod
Last active July 29, 2022 10:00
Show Gist options
  • Save centminmod/7d3e562fb87fa8ef263a to your computer and use it in GitHub Desktop.
Save centminmod/7d3e562fb87fa8ef263a to your computer and use it in GitHub Desktop.
redis server info and stats for Centmin Mod installs centminmod.com. If redis password is set in /etc/redis.conf, edit the variable REDISPASSWORD='your_redis_password'
#!/bin/bash
VER=0.0.2
#########################################################
# redis server info script for CentminMod.com
# written by George Liu (eva2000) vbtechsupport.com
#########################################################
# redis password set by requirepass in /etc/redis.conf
REDISPASSWORD=''
SOCKET=n
TRINSICTIME=10
#########################################################
if [[ "$SOCKET" = [yY] ]]; then
SOPT=' -s /tmp/redis.sock'
else
SOPT=""
fi
# if [[ -z "$REDISPASSWORD" && "$SOCKET" = [nN] ]]; then
if [[ -z "$REDISPASSWORD" ]]; then
RPASS=""
else
RPASS=" -a $REDISPASSWORD"
fi
#########################################################
RPID=$(redis-cli${RPASS}${SOPT} info | awk -F ":" '/process_id/ {print $2}')
#########################################################
# Setup Colours
black='\E[30;40m'
red='\E[31;40m'
green='\E[32;40m'
yellow='\E[33;40m'
blue='\E[34;40m'
magenta='\E[35;40m'
cyan='\E[36;40m'
white='\E[37;40m'
boldblack='\E[1;30;40m'
boldred='\E[1;31;40m'
boldgreen='\E[1;32;40m'
boldyellow='\E[1;33;40m'
boldblue='\E[1;34;40m'
boldmagenta='\E[1;35;40m'
boldcyan='\E[1;36;40m'
boldwhite='\E[1;37;40m'
Reset="tput sgr0" # Reset text attributes to normal
#+ without clearing screen.
cecho () # Coloured-echo.
# Argument $1 = message
# Argument $2 = color
{
message=$1
color=$2
echo -e "$color$message" ; $Reset
return
}
#########################################################
# functions
smeminstall() {
if [[ ! -f /usr/bin/smem ]]; then
cd /usr/local/src
wget -cnv http://centminmod.com/smem/smem-1.4.tar.gz
tar xzf smem-1.4.tar.gz
cp smem /usr/bin
chmod 0700 /usr/bin/smem
rm -rf ../smem-1*
fi
}
#########################################################
smeminstall
cecho "--------------------------------------------------------------------------" $boldgreen
redis-cli${RPASS}${SOPT} --version
cecho "--------------------------------------------------------------------------" $boldgreen
cecho "redis-cli${SOPT} info" $boldyellow
redis-cli${RPASS}${SOPT} info
echo
cecho "--------------------------------------------------------------------------" $boldgreen
cecho "redis-cli${SOPT} --intrinsic-latency $TRINSICTIME" $boldyellow
redis-cli${RPASS}${SOPT} --intrinsic-latency $TRINSICTIME
echo
cecho "--------------------------------------------------------------------------" $boldgreen
# echo
# cecho "--------------------------------------------------------------------------" $boldgreen
# cecho "redis-cli${SOPT} --latency-history" $boldyellow
# redis-cli${RPASS}${SOPT} --latency-history
# echo
# cecho "--------------------------------------------------------------------------" $boldgreen
cecho "vmstat 1 10" $boldyellow
vmstat 1 10
cecho "--------------------------------------------------------------------------" $boldgreen
# cecho "cat /proc/${RPID}/smaps | grep '^Swap'" $boldyellow
# cat /proc/${RPID}/smaps | grep '^Swap'
# cecho "--------------------------------------------------------------------------" $boldgreen
# cecho "cat /proc/${RPID}/smaps | egrep '^Swap|^Size'" $boldyellow
# cat /proc/${RPID}/smaps | egrep '^Swap|^Size'
# cecho "--------------------------------------------------------------------------" $boldgreen
echo
cecho "smem -kU redis" $boldyellow
smem -kU redis
cecho "--------------------------------------------------------------------------" $boldgreen
echo
cecho "--------------------------------------------------------------------------" $boldgreen
cecho "smem -kmU redis" $boldyellow
smem -kmU redis
cecho "--------------------------------------------------------------------------" $boldgreen
echo
cecho "--------------------------------------------------------------------------" $boldgreen
cecho "smem -tpk" $boldyellow
smem -tpk
cecho "--------------------------------------------------------------------------" $boldgreen
echo
cecho "--------------------------------------------------------------------------" $boldgreen
cecho "free -mlt" $boldyellow
free -mlt
cecho "--------------------------------------------------------------------------" $boldgreen
@centminmod
Copy link
Author

How to install redisinfo.sh

mkdir -p /root/tools
cd /root/tools
wget --no-check-certificate https://gist.github.com/centminmod/7d3e562fb87fa8ef263a/raw/734a199d20e2967fa370565a779f6dd0896708f6/redisinfo.sh
chmod 0700 redisinfo.sh

If redis password is set in /etc/redis.conf, edit redisinfo.sh variable REDISPASSWORD='your_redis_password'

Run command

cd /root/tools
./redisinfo.sh       

Sample script output below

./redisinfo.sh       
--------------------------------------------------------------------------
redis-cli 2.8.9
--------------------------------------------------------------------------
redis-cli info
# Server
redis_version:2.8.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:b548a658a720fb3e
redis_mode:standalone
os:Linux 2.6.32-431.el6.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:31142
run_id:a1bde5d043367ae6de1d6ea462ed12801e8cc58c
tcp_port:6379
uptime_in_seconds:5960
uptime_in_days:0
hz:10
lru_clock:8155044
config_file:/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:3669672
used_memory_human:3.50M
used_memory_rss:18681856
used_memory_peak:225820744
used_memory_peak_human:215.36M
used_memory_lua:33792
mem_fragmentation_ratio:5.09
mem_allocator:jemalloc-3.2.0

# Persistence
loading:0
rdb_changes_since_last_save:19033236
rdb_bgsave_in_progress:0
rdb_last_save_time:1400663949
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok

# Stats
total_connections_received:2944
total_commands_processed:23709308
instantaneous_ops_per_sec:0
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:5961843
keyspace_misses:539709
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:586

# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:97.93
used_cpu_user:71.73
used_cpu_sys_children:0.00
used_cpu_user_children:0.02

# Keyspace

--------------------------------------------------------------------------
redis-cli --intrinsic-latency 10
Max latency so far: 4 microseconds.
Max latency so far: 6 microseconds.
Max latency so far: 13 microseconds.
Max latency so far: 16 microseconds.
Max latency so far: 32 microseconds.

3214753 total runs (avg 3 microseconds per run).
Worst run took 10.67x times the avarege.

--------------------------------------------------------------------------
vmstat 1 10
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 15453032 140484 407852    0    0     0     0   16   24  4  5 91  0  0
 0  0      0 15453032 140484 407852    0    0     0     0  188  150  0  0 100  0  0
 0  0      0 15453032 140484 407852    0    0     0     0  126  138  0  0 100  0  0
 0  0      0 15453032 140484 407852    0    0     0     2  151  188  0  0 100  0  0
 1  0      0 15453032 140484 407852    0    0     0     0  129  146  0  0 100  0  0
 0  0      0 15453032 140484 407852    0    0     0     0  132  154  0  0 100  0  0
 0  0      0 15453032 140484 407852    0    0     0     0  125  142  0  0 100  0  0
 0  0      0 15453032 140484 407852    0    0     0     0  136  150  0  0 100  0  0
 0  0      0 15453032 140484 407852    0    0     0     0  124  138  0  0 100  0  0
 0  0      0 15453040 140484 407852    0    0     0     0  137  164  0  0 100  0  0
--------------------------------------------------------------------------

smem -kU redis
  PID User     Command                         Swap      USS      PSS      RSS 
31142 redis    /usr/sbin/redis-server 127.        0    19.1M    19.2M    19.7M 
--------------------------------------------------------------------------

--------------------------------------------------------------------------
smem -kmU redis
Map                                       PIDs   AVGPSS      PSS 
/usr/lib/locale/locale-archive               1        0        0 
[vdso]                                       1        0        0 
[vsyscall]                                   1        0        0 
/lib64/libdl-2.12.so                         1     8.0K     8.0K 
/lib64/libm-2.12.so                          1     8.0K     8.0K 
/lib64/ld-2.12.so                            1     9.0K     9.0K 
/lib64/libpthread-2.12.so                    1    12.0K    12.0K 
[stack]                                      1    16.0K    16.0K 
/lib64/libc-2.12.so                          1    49.0K    49.0K 
[heap]                                       1    52.0K    52.0K 
/usr/sbin/redis-server                       1   476.0K   476.0K 
<anonymous>                                  1    18.5M    18.5M 
--------------------------------------------------------------------------

--------------------------------------------------------------------------
smem -tpk
  PID User     Command                         Swap      USS      PSS      RSS 
 2628 root     /sbin/mingetty /dev/tty4           0    80.0K    99.0K   576.0K 
 2622 root     /sbin/mingetty /dev/tty1           0    84.0K   103.0K   580.0K 
 2624 root     /sbin/mingetty /dev/tty2           0    84.0K   103.0K   580.0K 
 2626 root     /sbin/mingetty /dev/tty3           0    84.0K   103.0K   580.0K 
 2630 root     /sbin/mingetty /dev/tty5           0    84.0K   103.0K   580.0K 
 2632 root     /sbin/mingetty /dev/tty6           0    84.0K   103.0K   580.0K 
 1295 nsd      /usr/local/sbin/nsd -c /etc        0    92.0K   234.0K   960.0K 
 1341 root     mdadm --monitor --scan -f -        0   284.0K   297.0K   628.0K 
 1298 nsd      /usr/local/sbin/nsd -c /etc        0   184.0K   302.0K   708.0K 
 1244 root     auditd                             0   352.0K   372.0K   860.0K 
  608 root     /sbin/udevd -d                     0   136.0K   374.0K     1.1M 
 2634 root     /sbin/udevd -d                     0   116.0K   378.0K     1.1M 
 2635 root     /sbin/udevd -d                     0   116.0K   378.0K     1.1M 
22942 root     nginx: master process /usr/        0   176.0K   407.0K     1.6M 
31771 root     /bin/bash /root/tools/redis        0   200.0K   429.0K     1.4M 
 1361 dbus     dbus-daemon --system               0   504.0K   519.0K   868.0K 
 1427 root     /bin/sh /usr/bin/mysqld_saf        0   320.0K   558.0K     1.6M 
 2609 root     crond                              0   648.0K   684.0K     1.2M 
 2498 nobody   /usr/local/bin/memcached -d        0   752.0K   771.0K     1.1M 
    1 root     /sbin/init                         0   736.0K   779.0K     1.5M 
 1405 root     /usr/sbin/sshd                     0   716.0K   807.0K     1.2M 
 1260 root     /sbin/rsyslogd -i /var/run/        0     1.1M     1.1M     1.7M 
 1413 ntp      ntpd -u ntp:ntp -p /var/run        0   960.0K     1.1M     2.1M 
 2586 root     /usr/libexec/postfix/master        0     1.1M     1.2M     2.1M 
22944 nginx    nginx: worker process              0     1.5M     1.8M     3.4M 
31413 postfix  pickup -l -t unix -u               0     1.1M     1.8M     3.8M 
22943 nginx    nginx: worker process              0     1.5M     1.8M     3.4M 
22946 nginx    nginx: worker process              0     1.5M     1.8M     3.5M 
22945 nginx    nginx: worker process              0     1.5M     1.8M     3.5M 
 2588 postfix  qmgr -l -t unix -u                 0     1.3M     1.9M     4.0M 
29348 root     sshd: root@pts/0                   0     1.9M     2.4M     4.1M 
29351 root     -bash                              0     2.6M     2.9M     4.0M 
 2487 root     /usr/sbin/haveged -w 3072 -        0     3.1M     3.1M     3.5M 
 1297 nsd      /usr/local/sbin/nsd -c /etc        0     4.2M     4.3M     4.8M 
22960 root     php-fpm: master process (/u        0     5.3M     5.4M     6.0M 
31796 root     python /usr/bin/smem -tpk          0     5.9M     6.0M     6.7M 
 1335 root     /sbin/mdmon --takeover md0         0    11.4M    11.5M    12.4M 
26528 root     lfd - sleepin                      0    14.0M    14.0M    14.6M 
31142 redis    /usr/sbin/redis-server 127.        0    19.1M    19.2M    19.7M 
 2474 mysql    /usr/sbin/mysqld --basedir=        0    38.2M    38.5M    40.1M 
-------------------------------------------------------------------------------
   40 9                                           0   122.9M   129.3M   163.6M 
--------------------------------------------------------------------------

--------------------------------------------------------------------------
free -mlt
             total       used       free     shared    buffers     cached
Mem:         15941        851      15090          0        137        398
Low:         15941        851      15090
High:            0          0          0
-/+ buffers/cache:        315      15625
Swap:         8039          0       8039
Total:       23981        851      23130
--------------------------------------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment