linux运维shell 脚本小工具,如要分享此文章,请注明文章出处,以下脚本仅供参考,若放置在服务器上出错,后果请自负

1.检测cpu剩余百分比

#!/bin/bash

#Inspect CPU

#Sun Jul  :: CST 

PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/bin
export PATH

TERM=linux
export TERM

CpuResult=$(top -bn  | grep "Cpu" | awk '{print $5}' | sed 's/\..*$//g')

 ]];then
  echo "CPU WARNING : $CpuResult" > /service/script/.cpu_in.txt
  top -bn  >> /service/script./cpu_in.txt
  mail -s "Inspcet CPU" wl < /service/script/.cpu_in.txt
fi

2.检测内存

#!/bin/bash

#Inspect Memory : If the memory is  , then send mail to wl

#Tue Aug   :: CST 

PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/bin

export PATH

MEM=$(free -m | grep "Mem" | awk '{print $4}')

 ]];then
  echo -e "Memory Warning : Memory free $MEM" > /service/script/.MemoryWarning
  mail -s "Memory Warning" wl < /service/script/.MemoryWarning
fi

3.检测磁盘剩余空间

#!/bin/bash

#Insepct Harddisk , If the remaining space is %, the message is sent to the wl

#Tue Aug   :: CST 

PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/bin

export PATH

for RemainingSpace in $(df -h | awk '{print $5}' | grep -v 'Use' | sed -e 's/[%]//g')
do
   ]];then
    echo -e "$RemainingSpace"
    echo -e "$(df -h | grep $RemainingSpace)" > /service/script/.HarddiskWarning
    mail -s "disk Warning" wl < /service/script/.HarddiskWarning
  fi
done

4.检测剩余Inode

#!/bin/bash

#Inspcet Inode : If the , the message is sent to the wl

#Tue Aug   :: CST 

PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/bin

export PATH

for FreeInode in $(df -i | grep -v "Filesystem" | awk '{print $4}')
do
   ]];then
    echo -e "$(df -i | grep "$FreeInode")" > /service/script/.FreeInode
    mail -s "FreeInode Warning" wl < /service/script/.FreeInode
  fi
done

Time : 2016-08-02 10:56:00

Name: 王                李

Mail:w18030432178@outlook.com

linux运维自动化shell脚本小工具的更多相关文章

  1. CentOS 下运维自动化 Shell 脚本之 expect

    CentOS 下运维自动化 Shell脚本之expect 一.预备知识: 1.在 Terminal 中反斜杠,即 "" 代表转义符,或称逃脱符.("echo -e与pri ...

  2. Linux运维之shell脚本进阶篇

    一.if语句的使用 1)语法规则 if [条件] then 指令 fi 或 if [条件];then 指令 fi 提示:分号相当于命令换行,上面两种语法等同特殊写法:if[ -f"$file ...

  3. Linux运维之shell脚本

    一.bash漏洞 1)bash漏洞 bash漏洞是控制Linux计算机命令提示符的软件中存在的漏洞. bash是一个为GNU计划编写的Unix shell.它的名字是一系列缩写:Bourne-Agai ...

  4. Linux运维之shell脚本基础知识

    1.bash中的算术运算 let运算符 [root@:vg_adn_tidbCkhsTest ~/tidb-bench/sysbench]#echo $i [root@:vg_adn_tidbCkhs ...

  5. linux运维/自动化开发__目录

    服务器软件安装 nginx apache php mysql oracle tomcat memcached mongodb sqlserver 常用pc端工具安装使用 Xshell         ...

  6. 转 如何不耍流氓的做运维之——SHELL脚本

    家都是文明人,尤其是做运维的,那叫一个斯文啊.怎么能耍流氓呢?赶紧看看,编写 SHELL 脚本如何能够不耍流氓. 下面的案例,我们以 MySQL 数据库备份 SHELL 脚本的案例来进行阐述. 不记录 ...

  7. 如何不耍流氓的做运维之-SHELL脚本

    前言 大家都是文明人,尤其是做运维的,那叫一个斯文啊.怎么能耍流氓呢?赶紧看看,编写SHELL脚本如何能够不耍流氓. 下面的案例,我们以MySQL数据库备份SHELL脚本的案例来进行阐述: 不记录日志 ...

  8. 运维常用shell脚本一(系统指标巡检、自动创建用户、跳板机)

    一.系统指标巡检脚本 #!/bin/bash menu(){ cat <<EOF +---------------------------------------------+ | 日常巡 ...

  9. 运维常用shell脚本之日志清理

    1.创建一个日志清理脚本 #/bin/bash for i in `find /root/.pm2/logs -name "*.log"` do cat /dev/null > ...

随机推荐

  1. thinkphp pathinfo nginx 无法加载模块:Index

    thinkphp 报了 无法加载模块:Index 错误位置 FILE: /var/multrix/wxactivity_archive/ThinkPHP/Library/Think/Dispatche ...

  2. sql server 权限体系

    --给sql server添加一个新用户[账号,密码,数据库名] execute  sp_addlogin 'baishi', '123','db'; execute  sp_addlogin 'wx ...

  3. Java并发编程底层实现原理 - volatile

    Java语言规范第三版中对volatile的定义如下: Java编程语言允许线程访问共享变量,为了确保共享变量能被准确和一致性的更新,线程应该确保通过排他锁 单独获得这个变量. volatile有时候 ...

  4. 错误信息:attempt to create saveOrUpdate event with null entity

    错误信息:attempt to create saveOrUpdate event with null entity; 这个错误网上答案比较多,我也不多说了. 我遇到的问题是在前台传过来的参数是nul ...

  5. Struts2+jQuery+Json零配置实现ajax

    (一)Jsp页面代码 <%@ page language="java" import="java.util.*" pageEncoding="U ...

  6. openstack-keystone

    preparation: config: /etc/keystone/keystone.conf log: /var/log/keystone.log 1. change log level: vi ...

  7. vim正则表达式~转

    vim正则表达式(转) Vim中的正则表达式功能很强大,如果能自由运用,则可以完成很多难以想象的操作. 如果你比较熟悉Perl的正规表达式,可以直接参照与Perl正则表达式的区别一节. 一.使用正则表 ...

  8. iOS WKWebView的javascript alert 不弹的解决方案

    - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiate ...

  9. (TODO:)下载图片,报错:warning: could not load any Objective-C class information from the dyld shared cache. This will significantly reduce the quality of type information available.

    想使用NSInvocationOperation下载图片,然而并没有下载下来, NSData为nil, 还有报错:(打断点就报错) warning: could not load any Object ...

  10. Python 中的urlencode和urldecode

    python中的urlencode与urldecode 发表于2013/11/13 16:04:09  79983人阅读 分类: python 当url地址含有中文,或者参数有中文的时候,这个算是很正 ...