shell监测磁盘使用并发送邮件
[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
#!/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监测磁盘使用并发送邮件的更多相关文章
- Linux Shell之监测磁盘空间
Linux Shell之监测磁盘空间 系统管理员的另一个重要任务就是监测系统磁盘的使用情况.不管运行的是简单Linux台式机还是大型的Linux服务器,我们都要知道还有多少空间可以留给应用程序.事实上 ...
- 通过SSIS监控远程服务器磁盘空间并发送邮件报警!
由于之前ESB是供应商部署的,且部署在C盘(C盘空间很小,还添加了很多ESB的windows服务日志在C盘,很容易把C盘空间占满,导致ESB服务运行宕机,几乎每隔几周发生一次事故,需要人工干预处理,不 ...
- Linux Shell查看磁盘分区,内存使用,CPU使用率
Linux Shell查看磁盘分区,内存使用,CPU使用率 #!/bin/bash #disk_used_rate Location=/dev/xvdb Disk_Used_Rate=$(df -h ...
- shell 监控磁盘使用率【转】
方案一: disks=(`df |sed 1d | awk '{print $1,$5}'|tr -d %`) len=${#disks[@]} ;i<=$len;i=i+));do ];the ...
- Linux系统下如何监测磁盘的使用空间
不管是我们在安装软件还是监测软件的使用性能,我们都要随时掌握系统磁盘的使用情况. 使用df命令 df df命令用于显示磁盘分区上的可使用的磁盘空间.默认显示单位为KB.可以利用该命令来获取硬盘被占用了 ...
- 通过SSIS监控远程服务器磁盘空间并发送邮件报警
本文直接参考了博客园软件人生的文章操作的,写在这里只为做个记录. 到公司这边先把两个报表服务器接收了. 为防止宕机,部署个磁盘警告的SSIS包. Step 1 建立两个变量来接收和写入磁盘容量 Ste ...
- shell之磁盘容量检查,配合crontab可以定时清理磁盘
我的做法: !/bin/bashAvailable=`df -k | sed -n 2p | awk '{print $4}'`if [ $Available -eq 0 ];then ...
- Linux 监测磁盘常用的工具sar iostat vmstat
Linux 检测内存常用的工具sar iostat vmstat #每秒刷新一次显示2次 sar -d 1 2 iostat -kx 1 2 vmstat -d 1 2 磁盘统计信息解释 tps 每秒 ...
- C++ 监测磁盘空间
硬盘管理器 头文件 HardDiskManager.h : #if _MSC_VER > 1000 #pragma once #endif #include <windows.h> ...
随机推荐
- 使用curl / wget命令上传下载FTP
curl可以在shell下轻松上传下载ftp上的文件,相比ftp命令更具有优势,因为它能在单命令条件下,下载或者上传一个ftp文件,甚至可以删除文件. 下面看实例: 1.列出ftp服务器上的目录列表: ...
- Please install Android target
今天在执行ionic build android时出现以下错误: [Error: Please install Android target: "android-22". Hint ...
- Data Structure Array: Maximum sum such that no two elements are adjacent
http://www.geeksforgeeks.org/maximum-sum-such-that-no-two-elements-are-adjacent/ #include <iostre ...
- 高性能js之数据访问性能
js中si中基本数据访问: 直接量, 变量, 数组项, 对象成员 性能问题: 首先要理解作用域链的基本概念,例如,当一个函数被创建时,就会产生一个激活对象(AO对象),AO对象中存储了该函数中所有的属 ...
- OC实现将N个数随机排列
+ (NSMutableArray *)randArray : (NSMutableArray *)arrayM { NSMutableArray *resultM = [[NSMutableArra ...
- 剑指offer——不能被继承的类
方法一:通过将类的构造函数和析构函数声明成private来防止子类继承.声明静态的方法来构造和析构类的对象. 但是用起来不是很方便.只能得到在堆上的实例,而不能得到在栈上的实例. 方法二:构造辅助类C ...
- noVNC
noNVC基础用法: 1.下载noVNC git clone https://github.com/novnc/noVNC.git 2.编辑qemu.conf配置文件 Vim /etc/libvirt ...
- Luogu-2600 [ZJOI2008]瞭望塔
把地面看成半平面,能看到所有位置的点所在的区域即为半平面的交 因为分段函数的极值只会在转折处或边界取到,所以对于半平面上和地面上的每一个交点都求一下距离就好了 #include<cmath> ...
- MySQL部署时Table 'mysql.plugin' doesn't exist的解决
今天部署了免安装版的MySQL,出现了Table 'mysql.plugin' doesn't exist的问题,苦恼了好久,终于在网上找到了解决方案,现整理一下给大家分享: 系统环境:Win10 6 ...
- UOJ71 【WC2015】k小割
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...