<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to calculate total disk size when using freediskspace collection? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217780#M63991</link>
    <description>&lt;P&gt;I stumbled across this post when having the same challenge. This stats-based command was really helpful - but just an FYI to future readers that neither of these searches will work if you're at 0% free space. It's not something you can fix by changing the search - it's just the inherent problem of trying to use freeMB and freePerc to figure out used or total.&lt;/P&gt;

&lt;P&gt;It's possible that hitting 0.000...% free space is super rare - but this is still annoying to me. The problem is simply that perfmon doesn't collect used or total metrics. In my case I think I'll end up using WMI for this.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Sep 2018 20:29:35 GMT</pubDate>
    <dc:creator>Ranazar</dc:creator>
    <dc:date>2018-09-10T20:29:35Z</dc:date>
    <item>
      <title>How to calculate total disk size when using freediskspace collection?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217775#M63986</link>
      <description>&lt;P&gt;I am searching for a 'search' that will give me the following information:&lt;BR /&gt;
Disk usage (C:) in %&lt;BR /&gt;
Total Disk size (C:)&lt;BR /&gt;
Free Disk space (C:)&lt;/P&gt;

&lt;P&gt;I know there is Windows App, but I would like to achieve this &lt;STRONG&gt;without&lt;/STRONG&gt; that &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = "perfmonxx" collection = FreeDiskSpace (counter="% Free Space" OR counter="Free Megabytes") instance=C: host=xx
| eval usage=(100-Value)
| eval GB=(Value/1024)
| eval size=GB*(100/(100-usage)) 
| eval usage1=(ceiling(usage))
| eval GB1=(floor(GB)) | stats max(usage1) as Usage max(size) as Total max(GB1) as Free by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Using this, I get the usage (in %) and the available free space (in GB) correctly, &lt;STRONG&gt;but&lt;/STRONG&gt; the (manual) calculation 'for total size' doesn't show me the correct result.&lt;/P&gt;

&lt;P&gt;When I calculate it manually (using e.g. calculator) it gives me the correct result:  size = 9.x * (100 / (100 - 83.x) ~ 60 GB&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;But&lt;/STRONG&gt; the outcome in Splunk gives me a different result.  I am stuck, please advise.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1694i8E8C7F4177C3BC07/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 07:12:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217775#M63986</guid>
      <dc:creator>edwinmae</dc:creator>
      <dc:date>2016-08-08T07:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate total disk size when using freediskspace collection?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217776#M63987</link>
      <description>&lt;P&gt;Oh dear lord forgive me for this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="perfmonxxx" collection=FreeDiskSPace counter="% Free Space"  
| eval diskInfoA=mvzip(instance,Value) 
| eval diskInfoA1=mvzip(diskInfoA,counter) 
| table diskInfoA1 host instance 
| join host instance
  [
  search index="perfmonxxx" collection=FreeDiskSPace counter="Free Megabytes"
  | eval diskInfoB=mvzip(instance,Value) 
  | eval diskInfoB1=mvzip(diskInfoB,counter) 
  | table diskInfoB1 host instance 
  ]
| makemv diskInfoA1 delim=","
| makemv diskInfoB1 delim=","
| eval freePerc=mvindex(diskInfoA1,1)
| eval freeMegs=mvindex(diskInfoB1,1)
| eval usage=(ceiling(100-freePerc))
| eval GB=(floor(freeMegs/1024))
| eval totalDiskGB=(GB/(freePerc/100))
| stats max(usage) as Usage max(GB) as Free max(totalDiskGB) as diskSizeGB by host instance
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1693i4EE1FC6A2898B6F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 12:26:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217776#M63987</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-08-08T12:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate total disk size when using freediskspace collection?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217777#M63988</link>
      <description>&lt;P&gt;You're forgiven as it worked for me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 06:40:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217777#M63988</guid>
      <dc:creator>edwinmae</dc:creator>
      <dc:date>2016-08-09T06:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate total disk size when using freediskspace collection?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217778#M63989</link>
      <description>&lt;P&gt;Awesome, thanks for marking as the answer and let us know if you ever need help again!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 10:43:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217778#M63989</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-08-09T10:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate total disk size when using freediskspace collection?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217779#M63990</link>
      <description>&lt;P&gt;So obviously this has been answered for a while, but I came across this today with the same question. Here is the same search but using "stats" instead of the "join":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=perfmon host=* object="LogicalDisk" counter="% Free Space" OR counter="Free Megabytes"
| eval diskInfoA = if(counter=="% Free Space",mvzip(instance,Value),null())
| eval diskInfoA1 = if(isnotnull(diskInfoA),mvzip(diskInfoA,counter),null())
| eval diskInfoB = if(counter=="Free Megabytes",mvzip(instance,Value),null())
| eval diskInfoB1 = if(isnotnull(diskInfoB),mvzip(diskInfoB,counter),null())
| stats list(diskInfoA1) AS "diskInfoA1", list(diskInfoB1) AS "diskInfoB1" by host, instance, _time
| makemv diskInfoA1 delim=","
| makemv diskInfoB1 delim=","
| eval freePerc = mvindex(diskInfoA1,1)
| eval freeMB = mvindex(diskInfoB1,1)
| eval usage=round(100-freePerc,2)
| eval GB = round(freeMB/1024,2)
| eval totalDiskGB = GB/(freePerc/100)
| stats max(usage) AS "Disk Usage", max(GB) AS "Disk Free", max(totalDiskGB) AS "Total Disk Size (GB)" by host instance
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 May 2018 16:14:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217779#M63990</guid>
      <dc:creator>bdahlb</dc:creator>
      <dc:date>2018-05-07T16:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate total disk size when using freediskspace collection?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217780#M63991</link>
      <description>&lt;P&gt;I stumbled across this post when having the same challenge. This stats-based command was really helpful - but just an FYI to future readers that neither of these searches will work if you're at 0% free space. It's not something you can fix by changing the search - it's just the inherent problem of trying to use freeMB and freePerc to figure out used or total.&lt;/P&gt;

&lt;P&gt;It's possible that hitting 0.000...% free space is super rare - but this is still annoying to me. The problem is simply that perfmon doesn't collect used or total metrics. In my case I think I'll end up using WMI for this.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 20:29:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-total-disk-size-when-using-freediskspace/m-p/217780#M63991</guid>
      <dc:creator>Ranazar</dc:creator>
      <dc:date>2018-09-10T20:29:35Z</dc:date>
    </item>
  </channel>
</rss>

