Linux O & M automation shell script tool, linuxshell

Source: Internet
Author: User

Linux O & M automation shell script tool, linuxshell

Linux O & M shell script gadgets. To share this article, please indicate the source of the article,The following scripts are for reference only. If an error occurs on the server, you are not responsible for the consequences.

1. Check cpu remaining percentage

#!/bin/bash#Inspect CPU#Sun Jul 31 17:25:41 CST 2016PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/binexport PATHTERM=linuxexport TERMCpuResult=$(top -bn 1 | grep "Cpu" | awk '{print $5}' | sed 's/\..*$//g')if [[ $CpuResult < 20 ]];then  echo "CPU WARNING : $CpuResult" > /service/script/.cpu_in.txt  top -bn 1 >> /service/script./cpu_in.txt  mail -s "Inspcet CPU" wl < /service/script/.cpu_in.txtfi

2. Memory Detection

#!/bin/bash#Inspect Memory : If the memory is less than 500 , then send mail to wl#Tue Aug  2 09:13:43 CST 2016PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/binexport PATHMEM=$(free -m | grep "Mem" | awk '{print $4}')if [[ MEM < 500 ]];then  echo -e "Memory Warning : Memory free $MEM" > /service/script/.MemoryWarning  mail -s "Memory Warning" wl < /service/script/.MemoryWarningfi

3. Check the remaining disk space

#!/bin/bash#Insepct Harddisk , If the remaining space is more than 80%, the message is sent to the wl#Tue Aug  2 09:45:56 CST 2016PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/binexport PATHfor RemainingSpace in $(df -h | awk '{print $5}' | grep -v 'Use' | sed -e 's/[%]//g')do  if [[ $RemainingSpace > 80 ]];then    echo -e "$RemainingSpace"    echo -e "$(df -h | grep $RemainingSpace)" > /service/script/.HarddiskWarning    mail -s "disk Warning" wl < /service/script/.HarddiskWarning  fidone

4. Check the remaining Inode

#!/bin/bash#Inspcet Inode : If the free INODE is less than 200, the message is sent to the wl#Tue Aug  2 10:21:29 CST 2016PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/binexport PATHfor FreeInode in $(df -i | grep -v "Filesystem" | awk '{print $4}')do  if [[ $FreeInode < 200 ]];then    echo -e "$(df -i | grep "$FreeInode")" > /service/script/.FreeInode    mail -s "FreeInode Warning" wl < /service/script/.FreeInode  fidone

Time: 10:56:00

Name: Wang Li

Mail: w18030432178@outlook.com

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.