I'd suggest putting a debug showing you the three numbers Ansible is using 
for item.size_total and item.size_available.  As @klingac mentioned, it 
could be that the values that ""df -k" reports or uses in it's computation 
aren't the exact same ones that Ansible uses.

For instance, using the numbers shown in the sample "df -k" output - 
(51466720 -  40038956) / 51466720 - I calculate "22.2% not the 19% that 
"df" reports.

On Wednesday, March 25, 2020 at 11:54:07 AM UTC-5, Shifa Shaikh wrote:
>
> @Kia Hi, 
>
> As suggested I tried 
>
> item.size_total instead of item.size_available
>
>  "{{ ansible_host }}_{{ item.mount }}: {{ (100 * ((item.size_total - 
> item.size_available) / item.size_total)) | round(1, 'common') }}" 
>
>
>
> but it still gives me 22.2 % value instead of 19%
>
> Can you please let me know what's wrong and why the difference?
>
> On Wednesday, March 25, 2020 at 10:10:24 PM UTC+5:30, Kai Stian Olstad 
> wrote:
>>
>> On Wed, Mar 25, 2020 at 07:15:51AM -0700, Shifa Shaikh wrote: 
>> > 
>> >     "{{ ansible_host }}_{{ item.mount }}: {{ (100 * ((item.size_total - 
>> item.size_available) / item.size_available)) | round(1, 'common') }}" 
>>
>> That is not how you calculate percentage, you need to divide on 
>> item.size_total 
>> and not item.size_available. 
>>
>> -- 
>> Kai Stian Olstad 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a30b45e0-4ef4-4ec3-b854-bc7f290dc627%40googlegroups.com.

Reply via email to