<?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 add disk sizes in splunk? in Security</title>
    <link>https://community.splunk.com/t5/Security/How-to-add-disk-sizes-in-splunk/m-p/41815#M13803</link>
    <description>&lt;P&gt;You could probably use &lt;CODE&gt;eval&lt;/CODE&gt; to work out the data quantities in bytes, for example (assuming field being extracted as "Size" and "Used" from &lt;CODE&gt;df -h&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | rex field=Size "(?P&amp;lt;Size&amp;gt;\d+[\.,\d]*)G" | rex field=Used "(?P&amp;lt;Used&amp;gt;\d+[\.,\d]*)M" | eval Size=Size*1024*1024*1024 | eval Used=Used*1024*1024 | 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you the &lt;CODE&gt;Size&lt;/CODE&gt; field and the &lt;CODE&gt;Used&lt;/CODE&gt; field in bytes instead of GigaBytes and Megabytes (respectively).&lt;/P&gt;

&lt;P&gt;This obviously gets messy very quickly... I would rather change the script to not use GB or MB or KB (or whatever) and use just a &lt;CODE&gt;df&lt;/CODE&gt; instead of &lt;CODE&gt;df -h&lt;/CODE&gt;... if you really want to handle larger block sizes, make sure to define the size in the command, e.g. &lt;CODE&gt;df -m&lt;/CODE&gt; for MB.&lt;/P&gt;

&lt;P&gt;EDIT: To complete the answer... then to work out the total of each column/field you would pipe to a &lt;CODE&gt;stats&lt;/CODE&gt; command and then use the &lt;CODE&gt;sum()&lt;/CODE&gt; function on your fields. e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats sum(Size) as totalSize sum(Used) as totalUsed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
    <pubDate>Wed, 21 Nov 2012 16:01:50 GMT</pubDate>
    <dc:creator>MHibbin</dc:creator>
    <dc:date>2012-11-21T16:01:50Z</dc:date>
    <item>
      <title>How to add disk sizes in splunk?</title>
      <link>https://community.splunk.com/t5/Security/How-to-add-disk-sizes-in-splunk/m-p/41814#M13802</link>
      <description>&lt;P&gt;Hello &lt;/P&gt;

&lt;P&gt;I need to compute a table which needs to add allocated spaces for different servers. And the data is being grabbed by doing a df command. Now how do we add 2.1G 100M etc? Or the only way is to change the way the data is actually coming into splunk by changing the command used? &lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;

&lt;P&gt;theou&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2012 15:49:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-add-disk-sizes-in-splunk/m-p/41814#M13802</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2012-11-21T15:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to add disk sizes in splunk?</title>
      <link>https://community.splunk.com/t5/Security/How-to-add-disk-sizes-in-splunk/m-p/41815#M13803</link>
      <description>&lt;P&gt;You could probably use &lt;CODE&gt;eval&lt;/CODE&gt; to work out the data quantities in bytes, for example (assuming field being extracted as "Size" and "Used" from &lt;CODE&gt;df -h&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | rex field=Size "(?P&amp;lt;Size&amp;gt;\d+[\.,\d]*)G" | rex field=Used "(?P&amp;lt;Used&amp;gt;\d+[\.,\d]*)M" | eval Size=Size*1024*1024*1024 | eval Used=Used*1024*1024 | 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you the &lt;CODE&gt;Size&lt;/CODE&gt; field and the &lt;CODE&gt;Used&lt;/CODE&gt; field in bytes instead of GigaBytes and Megabytes (respectively).&lt;/P&gt;

&lt;P&gt;This obviously gets messy very quickly... I would rather change the script to not use GB or MB or KB (or whatever) and use just a &lt;CODE&gt;df&lt;/CODE&gt; instead of &lt;CODE&gt;df -h&lt;/CODE&gt;... if you really want to handle larger block sizes, make sure to define the size in the command, e.g. &lt;CODE&gt;df -m&lt;/CODE&gt; for MB.&lt;/P&gt;

&lt;P&gt;EDIT: To complete the answer... then to work out the total of each column/field you would pipe to a &lt;CODE&gt;stats&lt;/CODE&gt; command and then use the &lt;CODE&gt;sum()&lt;/CODE&gt; function on your fields. e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats sum(Size) as totalSize sum(Used) as totalUsed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2012 16:01:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-add-disk-sizes-in-splunk/m-p/41815#M13803</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2012-11-21T16:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to add disk sizes in splunk?</title>
      <link>https://community.splunk.com/t5/Security/How-to-add-disk-sizes-in-splunk/m-p/41816#M13804</link>
      <description>&lt;P&gt;Thanks. Will probably change the command itself&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2012 16:08:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-add-disk-sizes-in-splunk/m-p/41816#M13804</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2012-11-21T16:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to add disk sizes in splunk?</title>
      <link>https://community.splunk.com/t5/Security/How-to-add-disk-sizes-in-splunk/m-p/41817#M13805</link>
      <description>&lt;P&gt;okay cool, would probably be easier, if it is not too much trouble, you could also convert the byte values to KB etc, using the eval command to make it human readable in Splunk. I updated answer with stats to answer the question fully.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2012 16:14:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-add-disk-sizes-in-splunk/m-p/41817#M13805</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2012-11-21T16:14:47Z</dc:date>
    </item>
  </channel>
</rss>

