简体   繁体   中英

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

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM