Skip to content

Instantly share code, notes, and snippets.

@dijeesh
Created November 7, 2016 07:22
Show Gist options
  • Select an option

  • Save dijeesh/cd5de2d846d3c0eaec2388abe2a11e4b to your computer and use it in GitHub Desktop.

Select an option

Save dijeesh/cd5de2d846d3c0eaec2388abe2a11e4b to your computer and use it in GitHub Desktop.
#!/bin/bash
# XenServer Disk Monitoring and post message to XenCenter
# Get this host's UUID
thisUUID=`xe host-list name-label=$HOSTNAME params=uuid --minimal`
# Threshold of disk usage to report on
threshold=75 # an example of how much disk can be used before alerting
# Get disk usage
diskUsage=`df -h | grep "/$" | head -n 1 | awk {' print $5 '} | sed -n -e "s/%//p"`
# Check
if [ $diskUsage -gt $threshold ]; then
xe message-create host-uuid=$thisUUID name="ROOT DISK USAGE" body="Disk space use has exceeded $diskUsage on `echo $HOSTNAME`!" priority="1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment