如何为Azure虚拟机生成磁盘不足警报 [英] How to generate a low disk alert for an Azure virtual machine

查看:93
本文介绍了如何为Azure虚拟机生成磁盘不足警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个虚拟机(正在用作构建服务器),该磁盘经常堆积并且正在修复该问题,这意味着我正在寻找选项来设置警报,当我的磁盘空间变大时将触发该警报.

i have an virtual machine (which am using as build server) which disk gets piled up frequently and am working on fixing that, mean while am looking for options to setup an alert to be fired when my disk space gets high.

我检查了监视下的可用指标,但只能找到对我没有帮助的磁盘写入字节"和磁盘读取字节".

i checked the available metrics under monitoring but could only find "disk write bytes" and "disk read bytes" which are not helpful for me.

在设置要发送到我的电子邮件的磁盘空间警报时,我将需要帮助.

i will need help on setting a disk space alert to be sent to my email.

在此方面的任何帮助都非常感激.

Any help on this is really appreciated.

推荐答案

在设置要发送到我的电子邮件的磁盘空间警报时,我将需要帮助.

i will need help on setting a disk space alert to be sent to my email.

目前,Azure 不支持监视Azure VM磁盘空间,我们可以使用shellPowerShell监视VM磁盘空间并向您发送电子邮件.

For now, Azure does not support monitor Azure VM disk space, we can use shell or PowerShell to monitor VM disk space and send email to you.

这里有一个关于Linux VM( ubuntu )的示例,我们可以创建一个sample.sh并将其添加到cron.

Here a example about Linux VM(ubuntu), we can create a sample.sh then add it to cron.

sample.sh:

sample.sh:

#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=90

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
    mail -s 'Disk Space Alert' youremail@domainname.com << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%
EOF
fi

将其添加到cron,将其添加到crontab:

Add it to cron, add it to crontab:

*/60 * * * * /home/jason/sample.sh

注意:

我们应该使用以下脚本在该VM上安装邮件:apt install mailutils.

we should install mail on this VM with this script:apt install mailutils.

顺便说一句,如果您不想在VM上安装邮件并且不想使用VM来监视自身,我们可以创建另一个VM并安装Zabbix或其他监视工具来监视Azure VM磁盘空间.

By the way, if you don't want to install mail on your VM and don't want to use VM to monitor itself, we can create another VM and install Zabbix or other monitor tools to monitor Azure VMs disks space.

这篇关于如何为Azure虚拟机生成磁盘不足警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆