This one leverages the VMWare APIs and queries all your hosts. You’ll need the VMWare Perl APIs installed on the system. It outputs to a web page so you can crontab it to run once a day and then just check the website when you need to see what memory or disk space is available on each host.
For accurate memory usage, modify /usr/lib/vmware-viperl/apps/host/hostinfo.pl with however much memory you have installed. For example, if you have 6GB of memory then it would look like:
if (defined ($host_view->summary->quickStats->overallMemoryUsage)){
print_log(” “.(6000 – $host_view->summary->quickStats->overallMemoryUsage).” MB”,
“MemoryUsage”,”\tMemory Available”);
}
I’ve also modified dsbrowse.pl so it would come out a little better
Examples are available here: http://storage.the408.com/infinitedisorder/
Once you’ve modified that perl file, your ready for the good stuff. Make sure each host’s datastore has a unique name too.
#!/bin/bash
dm605_hostnames=(dm605-01.mooo.com dm605-02.mooo.com dm605-03.mooo.com dm605-04.mooo.com dm605-05.mooo.com dm605-06.mooo.com dm605-07.mooo.com dm605-08.mooo.com dm605-09.mooo.com dm605-10.mooo.com)
dm605_stores=(dm605-01:storage1 dm605-02:storage1 dm605-03:storage1 dm605-04:storage1 dm605-05:storage1 dm605-06:storage1 dm605-07:storage1 dm605-08:storage1 dm605-09:storage1 dm605-10:storage1)
DEST_FILE=”/var/www/lab2.mooo.com/htdocs/esx3/free_space/esx_free_disk_space.txt”
for (( c=0; c<10; c++ ))
do
perl /usr/lib/vmware-viperl/apps/host/dsbrowse_modified.pl –url https://virtcenter.mooo.com/sdk/vimService –username info –password info
–attributes freespace –name ${dm605_stores[$c]} >> $DEST_FILE
perl /usr/lib/vmware-viperl/apps/host/hostinfo_modified_16000.pl –url https://virtcenter.mooo.com/sdk/vimService –username info –password info –hostname ${dm605_hostnames[$c]} –fields memoryusage >> $DEST_FILE
done
echo ” ” >> /var/www/lab2.mooo.com/htdocs/esx3/free_space/esx_free_disk_space.txt
date >> /var/www/lab2.mooo.com/htdocs/esx3/free_space/esx_free_disk_space.txt
Post a Comment