• 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 172.17.111.0/24


#!/bin/bash
 
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"
    else
       echo "172.17.111.$i error"
    fi
done

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


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

  

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


Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+