{"id":203,"date":"2009-09-04T16:25:29","date_gmt":"2009-09-04T21:25:29","guid":{"rendered":"http:\/\/nukeitmike.com\/blog\/2009\/09\/04\/monitoring-drive-space\/%20"},"modified":"2009-09-04T16:25:29","modified_gmt":"2009-09-04T21:25:29","slug":"monitoring-drive-space","status":"publish","type":"post","link":"https:\/\/blog.nukeitmike.com\/index.php\/2009\/09\/04\/monitoring-drive-space\/","title":{"rendered":"Monitoring drive space"},"content":{"rendered":"<p>One of the things that we spend a lot of time on is trying to keep track of what servers have enough free space.&#160; We have a lot of different tools to check drive space, and we even use some of them from time to time.&#160; We have a pretty complicated system created by <a href=\"http:\/\/www.whitworth.org\/\" target=\"_blank\" rel=\"noopener\">Rickey<\/a> that creates a nice webpage, with highlighting for problem areas (percentage change from day to day, current percent free, etc.)&#160; It even puts the info into a database for historical reporting.<\/p>\n<p>We don\u2019t store or report on VMs currently, mainly because we were trying to keep track of total REAL disk used.&#160; VMs often don\u2019t use as much as they think they do, so that would skew the results, as well as the fact that we are reporting on the hosts.&#160; <\/p>\n<p>All of that is the reason that <a href=\"http:\/\/pburch.com\/blog\" target=\"_blank\" rel=\"noopener\">Patrick<\/a> asked me to come up with some other tool to use for the VMs so I happened to find a few pieces of PowerShell script that I managed to put together to do a pretty good job of providing some of the info we wanted, and I thought I would share that with the 2 people who read my blog.&#160; \ud83d\ude42<\/p>\n<p>&#160;<\/p>\n<blockquote>\n<p>$servers = Get-Content servers.txt <\/p>\n<p>#Open Excel and create a new workbook and worksheet     <br \/>$ExcelSheet=New-Object -comobject Excel.application&#160;&#160;&#160; <br \/>$WorkBook=$ExcelSheet.WorkBooks.add(1)&#160;&#160;&#160;&#160; <br \/>$WorkSheet=$WorkBook.WorkSheets.item(1)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/p>\n<p>#Header row     <br \/>$WorkSheet.cells.item(1,1)=\u201dComputer Name\u201d&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/>$WorkSheet.cells.item(1,2)=\u201dDisk Device ID\u201d&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/>$WorkSheet.cells.item(1,3)=\u201dVolume Name\u201d&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/>$WorkSheet.cells.item(1,4)=\u201dSize (GB)\u201d&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/>$WorkSheet.cells.item(1,5)=\u201dFree Space (GB)\u201d      <br \/>$WorkSheet.cells.item(1,6)=\u201dSpace Used (GB)\u201d      <br \/>$WorkSheet.cells.item(1,7)=\u201dPercent Used\u201d <\/p>\n<p>$i=2 <\/p>\n<p>ForEach ($ComputerName in $servers)     <br \/>{&#160;&#160;&#160; <br \/>&#160;&#160;&#160; echo &quot;Server Name : &quot;, $ComputerName      <br \/>&#160;&#160;&#160; $Disks = gwmi \u2013computername $ComputerName win32_logicaldisk -filter &quot;drivetype=3&quot; <\/p>\n<p>&#160;&#160;&#160; foreach ($Disk in $Disks)      <br \/>&#160;&#160;&#160; {      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Size = &quot;{0:0.0}&quot; -f ($Disk.Size\/1GB)      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $FreeSpace = &quot;{0:0.0}&quot; -f ($Disk.FreeSpace\/1GB)      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Used = ([int64]$Disk.size &#8211; [int64]$Disk.freespace)      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $SpaceUsed = &quot;{0:0.0}&quot; -f ($Used\/1GB)      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Percent = ($Used * 100.0)\/$Disk.Size      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Percent = &quot;{0:N0}&quot; -f $Percent      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,1)=$ComputerName      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,2)=$Disk.deviceid      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,3)=$Disk.volumename      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,4)=$Size      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,5)=$FreeSpace      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,6)=$SpaceUsed      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,7)=$Percent <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $i=$i+1&#160;&#160;&#160;&#160;&#160; <br \/>&#160;&#160;&#160; }      <br \/>}      <br \/>#Show the results      <br \/>$ExcelSheet.visible=$true<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>One of the things that we spend a lot of time on is trying to keep track of what servers have enough free space.&#160; We have a lot of different tools to check drive space, and we even use some of them from time to time.&#160; We have a pretty complicated system created by Rickey&hellip; <a class=\"more-link\" href=\"https:\/\/blog.nukeitmike.com\/index.php\/2009\/09\/04\/monitoring-drive-space\/\">Continue reading <span class=\"screen-reader-text\">Monitoring drive space<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10,20,25],"tags":[135,154,170,180],"class_list":["post-203","post","type-post","status-publish","format-standard","hentry","category-general-info","category-operational-excellence","category-scripting","tag-powershell","tag-scripting","tag-storage","tag-tools","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pcW544-3h","_links":{"self":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/posts\/203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/comments?post=203"}],"version-history":[{"count":0,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/posts\/203\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/media?parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/categories?post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/tags?post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}