<?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: Some byte values not converting to GB, while others are. in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222124#M24366</link>
    <description>&lt;P&gt;If the above macro is defined in VMWare App and not created by you, then this is a bug in VMWare app, as evidently it is not handling &amp;gt;1GB&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2017 16:56:53 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-07-11T16:56:53Z</dc:date>
    <item>
      <title>Some byte values not converting to GB, while others are.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222118#M24360</link>
      <description>&lt;P&gt;Here is a report I run monthly to get each virtual machine's provisioned, committed, and uncommitted storage, using the excellent VMware app.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=vmware:inv:vm 'HandleFourHourWindowEndConditional' host="&amp;lt;our vcenter hostname&amp;gt;" | spath moid output=vmmoid | spath changeSet.name output=vmname | spath changeSet.layoutEx.file{}.name output=filelist | spath changeSet.layoutEx.file{}.size output=filesizes | spath changeSet.layoutEx.file{}.type output=filetypes | spath changeSet.storage.perDatastoreUsage{}.committed output=committed | spath changeSet.storage.perDatastoreUsage{}.uncommitted output=uncommitted | spath changeSet.summary.runtime.host.moid output=vmhost | search NOT (&amp;lt;an esxi host we want to exclude&amp;gt; OR &amp;lt;another esxi host we want to exclude) | dedup vmname, vmmoid, host | eval provisioned=committed+uncommitted | rex field=filelist "\[(?&amp;lt;datastore&amp;gt;.*)\] .+/(?&amp;lt;filenames&amp;gt;[^/]+)" | eval dsname=mvindex(datastore,0) | search dsname=* host="&amp;lt;our vcenter server&amp;gt;" | eval uncommitted='format_bytes(uncommitted)' | eval committed='format_bytes(committed)' | eval provisioned='format_bytes(provisioned)' | rename vmhost as HIDE-HostSystem-moid, vmmoid as HIDE-VirtualMachine-moid, vmname as "VirtualMachine", filenames as "Individual Files", filesizes as "Individual File Sizes", filetypes as "File Types", uncommitted as "Uncommitted Space", committed as "Committed Space", provisioned as "Provisioned Space" | table _time HIDE-HostSystem-moid host HIDE-VirtualMachine-moid "HostSystem" "VirtualMachine" "Provisioned Space" "Committed Space" "Uncommitted Space" "Individual Files" "Individual File Sizes" "File Types" | lookup FullHierarchy host, moid AS HIDE-HostSystem-moid, host AS host OUTPUT name AS HostSystem | fields - _time, HIDE*, Ind*, host, File* | sort +VirtualMachine&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This report runs fine, but the calculations for storage space, which should be in GB, output in bytes on some of the machines. See screenshot:&lt;BR /&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/2297iBEAF0FE9CB3A04FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I wonder if there's a way to say &lt;/P&gt;

&lt;P&gt;IF "Provisioned Space" = "Null Bytes" THEN convert Committed Space and Uncommitted Space to GB&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2017 17:48:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222118#M24360</guid>
      <dc:creator>HCadmins</dc:creator>
      <dc:date>2017-01-07T17:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Some byte values not converting to GB, while others are.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222119#M24361</link>
      <description>&lt;P&gt;Can you confirm whether committed and uncommitted fields are numeric prior to being fed to format_bytes or not? If format_bytes appends GB and Bytes to the end of numeric value then the It would be better to handle in format_bytes macro, if not you can use &lt;STRONG&gt;if()&lt;/STRONG&gt; condition to handle GB and Bytes. Otherwise, you would need to share the &lt;STRONG&gt;format_bytes&lt;/STRONG&gt; macro code from Splunk Knowledge Object.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:19:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222119#M24361</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T12:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Some byte values not converting to GB, while others are.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222120#M24362</link>
      <description>&lt;P&gt;Here's the code for the &lt;CODE&gt;format_bytes&lt;/CODE&gt; macro&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;if($bytes$&amp;gt;1073741824, tostring(round($bytes$/1073741824,2))+" GB", if($bytes$&amp;gt;1048576, tostring(round($bytes$/1048576,2))+" MB", if($bytes$&amp;gt;1024, tostring(round($bytes$/1024))+" KB", tostring($bytes$)+" Bytes")))&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2017 03:54:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222120#M24362</guid>
      <dc:creator>HCadmins</dc:creator>
      <dc:date>2017-01-08T03:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Some byte values not converting to GB, while others are.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222121#M24363</link>
      <description>&lt;P&gt;I'm not sure how to confirm whether the committed and uncommitted fields are numeric prior to being fed to &lt;CODE&gt;format_bytes&lt;/CODE&gt;, but I would assume they are since it's taking them from vCenter (which I am only assuming).&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2017 03:56:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222121#M24363</guid>
      <dc:creator>HCadmins</dc:creator>
      <dc:date>2017-01-08T03:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Some byte values not converting to GB, while others are.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222122#M24364</link>
      <description>&lt;P&gt;Your macro is getting inputs as bytes, however, you existing default case treats any value greater than 1 GB as bytes, which is incorrect. Try the following &lt;STRONG&gt;case&lt;/STRONG&gt; statements instead of nested if. I have account for Tera Byte and Zeta Byte on top of your existing case. Anything greater that 1024 TB will show up as ZB through final case statement.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval $bytes$=case($bytes$&amp;gt;=1125899906842624 AND $bytes$&amp;gt;1152921504606846976, tostring(round($bytes$/1152921504606846976,2))+" ZB",$bytes$&amp;gt;=1099511627776 AND committed&amp;lt;1125899906842624,tostring(round($bytes$/1073741824,2))+" TB",$bytes$&amp;gt;=1073741824 AND $bytes$&amp;lt;1099511627776, tostring(round($bytes$/1073741824,2))+" GB", $bytes$&amp;gt;=1048576 AND $bytes$&amp;lt;1073741824, tostring(round($bytes$/1048576,2))+" MB", $bytes$&amp;gt;1024 AND $bytes$&amp;lt;1073741824, tostring(round($bytes$/1024,2))+" KB", $bytes$&amp;lt;1024,tostring($bytes$+" Bytes"),1=1,tostring(round($bytes$/1152921504606846976,2))+" ZB")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Based on the same you have provided, where your &lt;STRONG&gt;if&lt;/STRONG&gt; statement starts my example will start with &lt;STRONG&gt;case&lt;/STRONG&gt; statement. So replace macro definition accordingly.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2017 05:58:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222122#M24364</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-01-08T05:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Some byte values not converting to GB, while others are.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222123#M24365</link>
      <description>&lt;P&gt;Thank you niketnilay!&lt;/P&gt;

&lt;P&gt;Would you say this is a bug in the VMware app?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 22:39:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222123#M24365</guid>
      <dc:creator>HCadmins</dc:creator>
      <dc:date>2017-01-10T22:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Some byte values not converting to GB, while others are.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222124#M24366</link>
      <description>&lt;P&gt;If the above macro is defined in VMWare App and not created by you, then this is a bug in VMWare app, as evidently it is not handling &amp;gt;1GB&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 16:56:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222124#M24366</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-11T16:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Some byte values not converting to GB, while others are.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222125#M24367</link>
      <description>&lt;P&gt;The &lt;CODE&gt;format_bytes&lt;/CODE&gt; code yields gibibytes (GiB), not gigabytes (GB). Use either: &lt;CODE&gt;if($bytes$&amp;gt;1073741824, tostring(round($bytes$/1073741824,2))+" GiB", if($bytes$&amp;gt;1048576, tostring(round($bytes$/1048576,2))+" MiB", if($bytes$&amp;gt;1024, tostring(round($bytes$/1024))+" KiB", tostring($bytes$)+" Bytes")))&lt;/CODE&gt; or &lt;CODE&gt;if($bytes$&amp;gt;1000000000, tostring(round($bytes$/1000000000,2))+" GB", if($bytes$&amp;gt;1000000, tostring(round($bytes$/1000000,2))+" MB", if($bytes$&amp;gt;1000, tostring(round($bytes$/1000))+" kB", tostring($bytes$)+" Bytes")))&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 18:16:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222125#M24367</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2018-01-25T18:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Some byte values not converting to GB, while others are.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222126#M24368</link>
      <description>&lt;P&gt;The niketnilay code is incorrect. A zebibyte is not 1152921504606846976 bytes (that's an exbibyte) but rather 1180591620717411303424 bytes. This code should be closer:&lt;BR /&gt;
&lt;CODE&gt;eval $bytes$=case($bytes$&amp;gt;=1152921504606846976, tostring(round($bytes$/1152921504606846976,2))+" EiB",$bytes$&amp;gt;=1125899906842624 AND $bytes$&amp;lt;1152921504606846976,tostring(round($bytes$/1125899906842624,2))+" PiB",$bytes$&amp;gt;=1099511627776 AND $bytes$&amp;lt;1125899906842624,tostring(round($bytes$/1099511627776,2))+" TiB",$bytes$&amp;gt;=1073741824 AND $bytes$&amp;lt;1099511627776, tostring(round($bytes$/1073741824,2))+" GiB", $bytes$&amp;gt;=1048576 AND $bytes$&amp;lt;1073741824, tostring(round($bytes$/1048576,2))+" MiB", $bytes$&amp;gt;=1024 AND $bytes$&amp;lt;1048576, tostring(round($bytes$/1024,2))+" KiB", $bytes$&amp;lt;1024,tostring($bytes$+" Bytes"),1=1,tostring(round($bytes$/1180591620717411303424,2))+" ZiB")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 18:33:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Some-byte-values-not-converting-to-GB-while-others-are/m-p/222126#M24368</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2018-01-25T18:33:41Z</dc:date>
    </item>
  </channel>
</rss>

