- Install
nc
withapt install netcat
on Ubuntu. - Get the URL and port for Redis.
$ echo -e "*1\r\n\$4\r\nINFO\r\n" | nc redis-server.usw2.cache.amazonaws.com 6379
Sample output
$2117
# Server
redis_version:3.2.4
redis_git_sha1:0
redis_git_dirty:0
redis_build_id:0
redis_mode:standalone
os:Amazon ElastiCache
arch_bits:64
multiplexing_api:epoll
gcc_version:0.0.0
process_id:1
run_id:15f259a2730f9ba27815b1815c0ced122e2c1724
tcp_port:6379
uptime_in_seconds:1892315
uptime_in_days:21
hz:10
lru_clock:2484010
executable:-
config_file:-
# Clients
connected_clients:4
client_longest_output_list:0
client_biggest_input_buf:1
blocked_clients:0
# Memory
used_memory:2612045328
used_memory_human:2.43G
used_memory_rss:3058622464
used_memory_rss_human:2.85G
used_memory_peak:2637946624
used_memory_peak_human:2.46G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:5169444864
maxmemory_human:4.81G
maxmemory_policy:volatile-lru
mem_fragmentation_ratio:1.17
mem_allocator:jemalloc-4.0.3
# Persistence
loading:0
rdb_changes_since_last_save:453956
rdb_bgsave_in_progress:0
rdb_last_save_time:1560872783
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
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:697772
total_commands_processed:2024803
instantaneous_ops_per_sec:0
total_net_input_bytes:18751143842
total_net_output_bytes:289534982081
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:45302
evicted_keys:0
keyspace_hits:185216
keyspace_misses:764
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
# Replication
role:master
connected_slaves:0
master_repl_offset:163908969
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:162860394
repl_backlog_histlen:1048576
# CPU
used_cpu_sys:770.30
used_cpu_user:318.70
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=284942,expires=0,avg_ttl=0
$ cat > test.php
<?php
//Connecting to Redis server on localhost
$redis = new Redis();
$redis->connect('redis-server.usw2.cache.amazonaws.com', 6379);
echo "Connection to server sucessfully";
//check whether server is running or not
echo "Server is running: ".$redis->ping();
?>
< CTRL+D to save >
$# php test.php
Connection to server sucessfullyServer is running: 1