NB: Also see my more generic Linux disk space post.
When XenServer runs out of disk space it just croaks, so big thanks to this post for pointing out this script which checks it and sends a message to the admin via the System Alerts in the XenCenter UI:
When XenServer runs out of disk space it just croaks, so big thanks to this post for pointing out this script which checks it and sends a message to the admin via the System Alerts in the XenCenter UI:
- Add a script to monitor disk space and report it to the XenCenter UI\
#!/bin/bash
# Quick And Dirty Disk Monitoring Utility
# Get this host's UUID
thisUUID='<YOUR SERVER UUID HERE>'
# 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 - Make it executable:
chmod +x /root/diskmonitor.sh - Amend crontab to run the monitor periodically:
- crontab -e
- Paste in the following:
00 00,06,12,18 * * * ./root/diskmonitor.sh
See where space is being used
df -h
sudo du -xm / | sort -rn
sudo du -xm / | sort -rn
Freeing up Disk Space
- Delete log files in tmp
cd /tmp/
rm -rf *.log - Delete archived log files in tmp:rm -rf /var/log/*gz
or to do this recursively:
To see what it will delete: find . -name "*log*.gz" -type f
find . -name "*log*.gz" -type f -delete - Destroy patches
cd /var/patch; for p in ????????-????-????-????-????????????; do xe patch-destroy uuid=$p; done - Amend /etc/logrotate.conf e.g. using a guide like this one on thegeekstuff.com
No comments:
Post a Comment