linux營運自動化shell指令碼小工具,linuxshell

來源:互聯網
上載者:User

linux營運自動化shell指令碼小工具,linuxshell

linux營運shell 指令碼小工具,如要分享此文章,請註明文章出處,以下指令碼僅供參考,若放置在伺服器上出錯,後果請自負

1.檢測cpu剩餘百分比

#!/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.檢測記憶體

#!/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.檢測磁碟剩餘空間

#!/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.檢測剩餘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 : 2016-08-02 10:56:00       

Name: 王                李         

Mail:w18030432178@outlook.com

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.