Write a simple alarm system with the shell

Source: Internet
Author: User
Write a simple alarm system with the shell

  • Create a directory structure
mkdir -p /usr/local/sbin/mon/{bin,conf,shares,mail,log}mon  //主目录bin   //主程序目录shares //子程序目录mail //发邮件目录log //日志目录

Program Main entry File/mon/bin/main.sh

#!/bin/bashexport send=1export addr=`/usr/sbin/ifconfig | grep -A1 ‘ens33‘|awk ‘/inet/{print $2}‘`dir=`pwd`last_dir=`echo $dir|awk -F‘/‘ ‘{print $NF}‘`if [ $last_dir == "bin" ] || [ $last_dir == "bin/" ]; then        conf_file="../conf/mon.conf"else        echo "you should cd bin dir."        exitfi#exec 1>>../log/mon.log 2>>../log/err.logecho "`date +‘%F %T‘` load average"/bin/bash ../shares/load.shif grep -q ‘to_mon_502=1‘ $conf_file; then        export log=`grep ‘logfile=‘ $conf_file | awk -F ‘=‘ ‘{print $2}‘ | sed ‘[email protected] @@g‘`        /bin/bash ../shares/502.shfi

Write a simple alarm system with the shell

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.