linux sendEmail工具的安装使用
 
 1.下载文件
  #wget  http://files.cnblogs.com/files/sunziying/sendEmail-v1.56.tar.gz
2.安装
  #yum install sendemail
3.命令参数详解
[root@li229- scripts]# sendEmail --help
sendEmail-1.56 by Brandon Zehm <caspian@dotconf.net>
Synopsis: sendEmail -f ADDRESS [options] Required:
-f ADDRESS from (sender) email address(发送人邮箱)
* At least one recipient required via -t, -cc, or -bcc
* Message body required via -m, STDIN, or -o message-file=FILE Common:
-t ADDRESS [ADDR ...] to email address(es)(接收人邮箱)
-u SUBJECT message subject(主题)
-m MESSAGE message body(正文)
-s SERVER[:PORT] smtp mail relay, default is localhost:25(发件人邮箱的SMTP服务器) Optional:
-a FILE [FILE ...] file attachment(s)(附件)
-cc ADDRESS [ADDR ...] cc email address(es)
-bcc ADDRESS [ADDR ...] bcc email address(es)
-xu USERNAME username for SMTP authentication(发件人邮箱的用户名)
-xp PASSWORD password for SMTP authentication(发件人邮箱的密码) Paranormal:
-b BINDADDR[:PORT] local host bind address
-l LOGFILE log to the specified file
-v verbosity, use multiple times for greater effect
-q be quiet (i.e. no STDOUT output)
-o NAME=VALUE advanced options, for details try: --help misc
-o message-content-type=<auto|text|html>
-o message-file=FILE -o message-format=raw
-o message-header=HEADER -o message-charset=CHARSET
-o reply-to=ADDRESS -o timeout=SECONDS
-o username=USERNAME -o password=PASSWORD
-o tls=<auto|yes|no> -o fqdn=FQDN Help:
--help the helpful overview you're reading now
--help addressing explain addressing and related options
--help message explain message body input and related options
--help networking explain -s, -b, etc
--help output explain logging and other output options
--help misc explain -o options, TLS, SMTP auth, and more
4.实例:Linux下监控磁盘使用量并在超过阀值后自动发送报警邮件。
例:

#!/bin/bash
partition_list=(`df -h | awk 'NF>3&&NR>1{sub(/%/,"",$(NF-1));print $NF,$(NF-1)}'`)

notification_email()
{
  emailfrom='sunzy@163.com'
  sendto='7589457343@qq.com'
  emailsmtp='smtp.163.com'
  title='Disk Space Alarm'
  emailuser='sunzy@163.com'
  emailpasswd='*****'
  /usr/sbin/sendmail -f $emailfrom -t $sendto -s $emailsmtp -u $title -xu $emailuser -xp $emailpasswd
}

critical=80
crit_info=""
for (( i=0;i<${#partition_list[@]};i+=2 ))
  do
  if [ "${partition_list[((i+1))]}" -lt "$critical" ];then
    echo "OK! ${partition_list[i]} used ${partition_list[((i+1))]}%"
  else if [ "${partition_list[((i+1))]}" -gt "$critical" ];then
    crit_info=$crit_info"Warning!!! ${partition_list[i]} used ${partition_list[((i+1))]}%\n"
          echo -e $crit_info | notification_email
  fi
  done

shell监测磁盘使用并发送邮件的更多相关文章

  1. Linux Shell之监测磁盘空间

    Linux Shell之监测磁盘空间 系统管理员的另一个重要任务就是监测系统磁盘的使用情况.不管运行的是简单Linux台式机还是大型的Linux服务器,我们都要知道还有多少空间可以留给应用程序.事实上 ...

  2. 通过SSIS监控远程服务器磁盘空间并发送邮件报警!

    由于之前ESB是供应商部署的,且部署在C盘(C盘空间很小,还添加了很多ESB的windows服务日志在C盘,很容易把C盘空间占满,导致ESB服务运行宕机,几乎每隔几周发生一次事故,需要人工干预处理,不 ...

  3. Linux Shell查看磁盘分区,内存使用,CPU使用率

    Linux Shell查看磁盘分区,内存使用,CPU使用率 #!/bin/bash #disk_used_rate Location=/dev/xvdb Disk_Used_Rate=$(df -h ...

  4. shell 监控磁盘使用率【转】

    方案一: disks=(`df |sed 1d | awk '{print $1,$5}'|tr -d %`) len=${#disks[@]} ;i<=$len;i=i+));do ];the ...

  5. Linux系统下如何监测磁盘的使用空间

    不管是我们在安装软件还是监测软件的使用性能,我们都要随时掌握系统磁盘的使用情况. 使用df命令 df df命令用于显示磁盘分区上的可使用的磁盘空间.默认显示单位为KB.可以利用该命令来获取硬盘被占用了 ...

  6. 通过SSIS监控远程服务器磁盘空间并发送邮件报警

    本文直接参考了博客园软件人生的文章操作的,写在这里只为做个记录. 到公司这边先把两个报表服务器接收了. 为防止宕机,部署个磁盘警告的SSIS包. Step 1 建立两个变量来接收和写入磁盘容量 Ste ...

  7. shell之磁盘容量检查,配合crontab可以定时清理磁盘

    我的做法: !/bin/bashAvailable=`df -k | sed -n 2p | awk '{print $4}'`if [ $Available -eq 0 ];then        ...

  8. Linux 监测磁盘常用的工具sar iostat vmstat

    Linux 检测内存常用的工具sar iostat vmstat #每秒刷新一次显示2次 sar -d 1 2 iostat -kx 1 2 vmstat -d 1 2 磁盘统计信息解释 tps 每秒 ...

  9. C++ 监测磁盘空间

    硬盘管理器 头文件 HardDiskManager.h : #if _MSC_VER > 1000 #pragma once #endif #include <windows.h> ...

随机推荐

  1. Django中的Cookie和Session操作以及CBV

    1.Cookie 平常我们在浏览网页的时候,在需要输入密码的地方,如果已经登陆了一次,并且时间间隔比较近的话,是不需要登陆的,为什么了?这就是Cookie的作用. Cookie(或Cookies)指某 ...

  2. OJ 之 FATE

                                            - FATE Crawling in process... Crawling failed Time Limit:100 ...

  3. mysql 在windows server下发生系统错误 1067, 进程意外终止的解决方法

    mysql 在windows server下发生系统错误 1067, 进程意外终止,请检查系统盘下的windows目录下是否存在mysql的配置文件my.ini,如存在,将其删除或改名即可.

  4. 在Delphi2007下安装ReportMachine6.5

    如何在Delphi2007下安装ReportMachine6.5: 一.在安装ReportMachine6.5之前要安装如下组件: (1).llPdfLib3.6,用于导出PDF文件: (2).Ehl ...

  5. adobe flash player 下载地址

    1. https://www.adobe.com/cn/products/flashplayer/distribution3.html

  6. Javascript函数的参数arguments

    arguments Description 在所有的函数中有一个arguments对象,arguments对象指向函数的参数,arguments object is an Array-like obj ...

  7. 一致性问题和Raft一致性算法——一致性问题是无法彻底解决的,可以说一个分布式系统可靠性达到99.99…%,但不能说它达到了100%

    一致性问题 一致性算法是用来解决一致性问题的,那么什么是一致性问题呢? 在分布式系统中,一致性问题(consensus problem)是指对于一组服务器,给定一组操作,我们需要一个协议使得最后它们的 ...

  8. BEC listen and translation exercise 34

    In a busy classroom filled with nearly 20 children, Sabriye Tenberken lectures her pupils to always ...

  9. typedarrays splice

    TypedArrays 不是一个典型的 数组类型,所以不存在 splice 方法.但是可以模拟实现 function splice(arr, starting, deleteCount, elemen ...

  10. codeforces 707B B. Bakery(水题)

    题目链接: B. Bakery 题意: 是否存在一条连接特殊和不特殊的边,存在最小值是多少; 思路: 扫一遍所有边: AC代码: #include <iostream> #include ...