【发布时间】:2021-08-10 13:53:01
【问题描述】:
我编写了一个脚本,我在其中存储了前 10 个进程的名称,这些进程使用了一个命令:
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head >/etc/tmp/file.txt
现在我在 mailx 命令中附加此文件,以使用以下命令发送邮件,其正文作为内容:
echo -e "Warning, server memory is running low!\n\nFree memory: $free MB\n$file" | mailx -a "ALERT" -s "$subject" -r "$from" -c "$also_to" "$to"
this "subject" , "from", "also_to", "to" 是一些变量,并在 shell 脚本中定义了实际的 mailid。
当我收到邮件时,我会以非常粗略的顺序收到内容,如下图所示。that mail's pic
我希望文件的此内容采用正确的格式,或者如果我可以将此 txt 文件作为附件发送,我对使用 mailx 命令将文件作为附件发送但无济于事。
【问题讨论】:
标签: linux server alert monitoring