On Wed, Mar 25, 2020 at 09:54:07AM -0700, 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?
This is a little out of scope of this list, so I'll keep it brief.
When you create a filesystem mkfs reserve some block on the device.
df output available block but this value doesn't count the reserved blocks.
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ihs_vg_yt 51466720 8790352 40038956 19% /ihs
Just to illustrate on your df output of /ihs by doing Total - Used - Available
should equal 0 if no blocks was reserved.
51466720 - 8790352 - 40038956 = 82715324
So you have about 82.7 million 1K blocks reserved.
df uses the "Used" / ( "Used" + "Available") to calculate used
8790352 / (8790352 + 40038956) = approx. 0,18002205
So a little over 18 percent which is rounded up to 19%
When you in Ansible do size_total - size_available you are including the
reserved blocks in used and that is why you get a higher number than df.
--
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/20200325191042.cbd5wu7asdjw5o2z%40olstad.com.