• notice
  • Congratulations on the launch of the Sought Tech site

Redis lpop key returns nil when the key does not exist , monitors whether the redis execution statement is executing properly

Lpop key  

return value:

      The head element of the list.

      Returns nil when key does not exist.   

Requirement: When the development is executing the lpop key, there is a problem, the execution statement is stuck, and it cannot be executed. It is necessary to monitor this. 


Since the return value is nil (here, the nil of redis is similar to null), we cannot use grep to filter, then think of ping ip in the local area network, if the execution is successful $? Return 0, if unsuccessful, return other ideas and make a script.

Script to detect whether ip exists in LAN

Write a script to determine which IPs can be pinged in the network of

for i in `seq 1 255`;do
    ping -c 1 172.17.111.$i &>/dev/null
    if [ $? -eq 0 ]; then
       echo "172.17.111.$i OK"
       echo "172.17.111.$i error"

Based on the above script idea, write a script to determine if the lpop test is executed successfully

/usr/local/bin/redis-cli -h r-b******.com  -p 6379 -a z********3 lpop 'test' &> /dev/null
if [ $? -eq 0 ]; then
echo $redis_lpop_test


Then add item , trigger , graphs and other settings in the zabbix interface.  


Technical otaku

Sought technology together

Related Topic


Leave a Reply