linux - 如何在一个脚本中为磁盘和内存使用编写 shell 脚本并创建电子邮件警报
问题描述
我正在尝试一起编写一个用于磁盘使用和内存使用的 shell 脚本。但是我不能一起写磁盘和内存,但我可以单独写,那些脚本是成功的[
#!/bin/bash
diskusage=$(df -Ph | grep '/webm9' | awk {'print $5'})
memusage=$(free | grep Mem | awk {'print $3/$2 * 100.0}')
a=80%
b=50%
if [ "diskusage" > a ]; then
echo "The Mount Point "/DB" on $(hostname) has used $diskusage at $(date)" | mail -s "Disk space alert on $(hostname): $diskusage used" xy@gmail.com
if [ "memusage" > b]; then
echo "The Mount Point "/DB" on $(hostname) has used $memusage at $(date)" | mail -s "memory space alert on $(hostname): $memusage used" xy@gmail.com
fi
任何人都可以请帮助与一个脚本一起编写。
解决方案
推荐阅读
- python - 清理用户输入以插入 Python SQLite 表的正确方法?
- r - 匹配函数中可重现的基础 R 崩溃 (R 4.1.1)
- node.js - 将 TestCafe 与 Azure 发布管道集成时出错
- python - 无法使用 for 循环更改矩阵的值
- azure - Azure 应用服务客户端证书排除路径
- jquery - 如何向 wp 管理菜单添加标题属性?
- r - 当我在 R 中运行我的代码时,它可以工作,但是如果我尝试将它编织成 pdf,它就会失败
- php - 将图像转换为视频 Laravel-FFMPEG
- java - Hadoop MapReduce 复制连接
- python - 修改影响所有数据框,而不是选择的列