How to generate a low disk alert for an Azure virtual machine

♀尐吖头ヾ 提交于 2019-12-11 00:45:53

问题


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.


回答1:


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

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.

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

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

Add it to cron, add it to crontab:

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

Note:

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

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.




回答2:


You can use Azure OMS. There is a example how to use Azure OMS to monitor free disk.



来源:https://stackoverflow.com/questions/47536304/how-to-generate-a-low-disk-alert-for-an-azure-virtual-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!