<zz>linux OPS automation shell scripting gadget

Source: Internet
Author: User

From http://www.cnblogs.com/wang-li/p/5728461.html

Linux ops shell script gadget, if you want to share this article, please indicate the source of the article, the following script is for reference only, if the error placed on the server, the consequences please be conceited

1. Detecting CPU percent remaining

#!/bin/Bash#inspect Cpu#sun Jul3117:25:The CST2016path=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/Binexport pathterm=Linuxexport termcpuresult=$ (top-bn1 |Grep"Cpu" |Awk‘{Print $}' |sed  s/\. *$//g ' ) if [[$ Cpuresult < 20]]; then echo  "CPU WARNING: $CpuResult " >/service/script/.cpu_ In.txt top-bn cpu_in.txt Mail-s  "inspcet cpu" WL </service/script/.cpu_in.txtfi    

2. Detecting Memory

#!/bin/Bash#inspect Memory:if the Memory isLess than500,ThenSend mail to Wl#tue209:13:CST2016path=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/Binexport pathmem=$ (free-m |Grep "mem" | awk  {print $4} '  ' 500]]; then echo-e  "memory warning:memory free $MEM " >/service/script/ "memory warning "WL </service/script/. Memorywarningfi          

3. Detecting disk space remaining

#!/bin/bash#insepct harddisk, If the remaining space isMore than90D, the message is sent to the Wl#tue209:45:+ CST2016path=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/Binexport PATHFor RemainingspaceIn $ (df-h |Awk‘{Print $}' |Grep-v‘Use' |Sed-e‘S/[%]//g ' ) do if [[$RemainingSpace > 80]]; Then echo-e  $ Remainingspace "echo-e  "$ (Df-h | grep $RemainingSpace)  "disk warning "WL </service/script/. harddiskwarning fidone      

4. Detecting remaining Inode

#!/bin/Bash#inspcet Inode:if theFree INODE isLess than200, the message is sent to the Wl#tue210:21st:CST2016path=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/Binexport PATHFor FreeinodeIn $ (Df-i |Grep-v"Filesystem" |Awk‘{print $4} ) do if [[$FreeInode < 200]];then echo-e $ (Df-i | grep "  ">/service/script/. Freeinode mail-s  "freeinode warning "WL </service/script/. Freeinode fidone      

<zz>linux OPS automation shell scripting gadget

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.