{"id":211,"date":"2010-03-01T13:09:18","date_gmt":"2010-03-01T20:09:18","guid":{"rendered":"http:\/\/infinitedisorder.com\/?p=211"},"modified":"2010-06-02T14:45:05","modified_gmt":"2010-06-02T21:45:05","slug":"query-disk-and-memory-usage-on-all-vsphere-hosts","status":"publish","type":"post","link":"https:\/\/infinitedisorder.com\/?p=211","title":{"rendered":"Query Disk and Memory Usage on all vSphere hosts"},"content":{"rendered":"\n<div class=\"gallery\">\n\t<dl class=\"gallery-item gallery-columns-3\">\n\t\t<dt class=\"gallery-icon\"><a href=\"https:\/\/infinitedisorder.com\/?attachment_id=216\" title=\"dm605_usage\" rel=\"attachment\"><img decoding=\"async\" src=\"https:\/\/infinitedisorder.com\/wp-content\/uploads\/\/infinitedisorder.com\/2010\/03\/dm605_usage1.png\" alt=\"dm605_usage\" class=\"gallery-image attachment-thumbnail\" \/><\/a><\/dt>\n\t<\/dl>\n\t<dl class=\"gallery-item gallery-columns-3\">\n\t\t<dt class=\"gallery-icon\"><a href=\"https:\/\/infinitedisorder.com\/?attachment_id=215\" title=\"dm605_usage\" rel=\"attachment\"><img decoding=\"async\" src=\"https:\/\/infinitedisorder.com\/wp-content\/uploads\/\/infinitedisorder.com\/2010\/03\/dm605_usage-150x150.png\" alt=\"dm605_usage\" class=\"gallery-image attachment-thumbnail\" \/><\/a><\/dt>\n\t<\/dl>\n<\/div>\n\n<p>This one leverages the VMWare APIs and queries all your hosts. You&#8217;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.<\/p>\n<p>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:<\/p>\n<div id=\"_mcePaste\">if (defined ($host_view-&gt;summary-&gt;quickStats-&gt;overallMemoryUsage)){<\/div>\n<div id=\"_mcePaste\">print_log(&#8221; &#8220;.(6000 &#8211; $host_view-&gt;summary-&gt;quickStats-&gt;overallMemoryUsage).&#8221; MB&#8221;,<\/div>\n<div id=\"_mcePaste\">&#8220;MemoryUsage&#8221;,&#8221;\\tMemory Available&#8221;);<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<div>I&#8217;ve also modified dsbrowse.pl so it would come out a little better<\/div>\n<div>Examples are available here: <a href=\"http:\/\/storage.the408.com\/esx\/\">http:\/\/storage.the408.com\/infinitedisorder\/<\/a><\/div>\n<div>Once you&#8217;ve modified that perl file, your ready for the good stuff. Make sure each host&#8217;s datastore has a unique name too.<\/div>\n<div>\n<div>#!\/bin\/bash<\/div>\n<div>\n<div>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)<\/div>\n<div>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)<\/div>\n<div>\n<div>DEST_FILE=&#8221;\/var\/www\/lab2.mooo.com\/htdocs\/esx3\/free_space\/esx_free_disk_space.txt&#8221;<\/div>\n<div>\n<div>for (( c=0; c&lt;10; c++ ))<\/div>\n<div>do<\/div>\n<div>perl \/usr\/lib\/vmware-viperl\/apps\/host\/dsbrowse_modified.pl &#8211;url https:\/\/virtcenter.mooo.com\/sdk\/vimService &#8211;username info &#8211;password info<\/div>\n<div>&#8211;attributes freespace &#8211;name ${dm605_stores[$c]} &gt;&gt; $DEST_FILE<\/div>\n<div>perl \/usr\/lib\/vmware-viperl\/apps\/host\/hostinfo_modified_16000.pl &#8211;url https:\/\/virtcenter.mooo.com\/sdk\/vimService &#8211;username info &#8211;password info &#8211;hostname ${dm605_hostnames[$c]} &#8211;fields memoryusage &gt;&gt; $DEST_FILE<\/div>\n<div>done<\/div>\n<\/div>\n<div>\n<div>echo &#8221; &#8221; &gt;&gt; \/var\/www\/lab2.mooo.com\/htdocs\/esx3\/free_space\/esx_free_disk_space.txt<\/div>\n<div>date &gt;&gt; \/var\/www\/lab2.mooo.com\/htdocs\/esx3\/free_space\/esx_free_disk_space.txt<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This one leverages the VMWare APIs and queries all your hosts. You&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-virtualization"],"_links":{"self":[{"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=211"}],"version-history":[{"count":7,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions\/241"}],"wp:attachment":[{"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}