check_fastdfs_status.sh

 #/bin/bash

status[0]="ok:"
status[1]="WARNING:"
status[2]="CRITICAL:"
status[3]="UNKNOWN:"
#模拟上传图片
url=$(curl --silent -F "upload1=@/data/test.jpg" http://192.168.0.49/upload.php | grep  href="*"|awk -F" " '{print $3}'|awk -F'"' '{print $2}';)
#得到图片路径
picture_path=$(echo $url|awk -F"/" '{print $3"/"$4}')
#得到图片名
picture_name=$(echo $url|awk -F"/" '{print $5}'|awk -F"&" '{print $1}')
#上传后的图片路径
picture_url="http://192.168.0.49${url}"
httpcode=`curl -o /dev/null -s -w %{http_code} ${picture_url}`
 
if [ $httpcode -eq "200" ]
then
status=0
echo "OK - picture status OK  $httpcode."
rm -f /data/fdfs_data/data/${picture_path}/${picture_name}
exit 0
else
status=2
echo "Critical - picture status error  $httpcode."
exit 2
fi

你可能感兴趣的:(fastDFS,监控)