Shell monitors the storage update delay alarm of Fastdfs

Source: Internet
Author: User

Recently, I encountered a sad reminder: a disk in the fastdfs storage server is broken (the storage partition is changed to read only), but zabbix does not monitor this, resulting in client upload failure. It was finally found that it became read-only two days ago. Although data storage is redundant, it has little impact, but it is still quite uncomfortable, not to detect problems in time. In this case, a small script is written to enable an alarm when the storage update latency is higher than the specified value (for example, 2 minutes.
You can use fdfs_monitor to view the storage status and Update Time Delay of all fastdfs instances. The execution result is the uptime value of last_synced_timestamp. Monitors Active status and latency. The script is as follows:

#! /Bin/bash
# Storage synchronous delay alarm scripts
# Richard shen 2012/07/11
# BLOG: http://lxsym.blog.51cto.com
Basedir = 'dirname $0'
Now_time = 'date + % s'
Active = $ Basedir/active.txt
IP = $ Basedir/ip.txt
Syn_time = $ Basedir/syn_time.txt
COMMAND = "/usr/local/webserver/fdfs/bin/fdfs_monitor/usr/local/webserver/fdfs/etc/client. conf"
$ COMMAND | grep "(" | awk '/ip_addr/{print $5}'> $ Active
$ COMMAND | grep "(" | awk '/ip_addr/{print $3}'> $ IP
$ COMMAND | grep last_synced_timestamp | awk '{print $3, $4}'> $ Syn_time
Paste $ Syn_time $ IP $ Active> main. log
Cat main. log | while read day time ip active
Do
Sys_time = 'date-d "$ day $ time" + % s'
Num = 'expr $ Now_time-$ sys_time'
# Stuts alarm
If [$ active! = "ACTIVE"]; then
# Email alarm API,
# Echo "$ ip State is $ active, please check ."
Fi
# Set alarm time (eg 2 m (120 s ))
If [$ num-gt 120]; then
# Mail alarm API, such as wget-q-O-"http://api.abc.com/sendMail.php? Type = abcdG & to = Email Address & subject = [Storage synchronization latency alarm: $ ip latency $ num seconds, please check ~] & Body = RT, please check. Thank you ">/dev/null
# Echo "$ ip Update time delay $ num (s )"
Fi
Done
Rm-rf $ Active $ IP $ Syn_time main. log

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.