# Get memory info using Ansible

**URL:** <https://forum.ansible.com/t/get-memory-info-using-ansible/36302>\
**Category:** Ansible Project\
**Created:** [February 8, 2022, 2:46pm UTC](https://forum.ansible.com/t/get-memory-info-using-ansible/36302 "2022-02-08T14:46:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dip\_Giri](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@Dip\_Giri](https://forum.ansible.com/u/Dip_Giri)\
**Post date:** [February 8, 2022, 2:46pm UTC](https://forum.ansible.com/t/get-memory-info-using-ansible/36302/1 "2022-02-08T14:46:58Z")

</div>

Whatever ansible give a memory info in ansible\_fact it doesn’t match with memory info  
that we get from **free -m** command. Why this problem happened for that if have any solution plz give me

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [February 8, 2022, 4:11pm UTC](https://forum.ansible.com/t/get-memory-info-using-ansible/36302/2 "2022-02-08T16:11:43Z")

</div>

FWIW. Quoting from 'Performance Data Collection Settings for Runner'  
[https://ansible-runner.readthedocs.io/en/stable/intro/#performance-data-collection-settings-for-runner](https://ansible-runner.readthedocs.io/en/stable/intro/#performance-data-collection-settings-for-runner)

&nbsp;&nbsp;"Runner is capable of collecting performance data (namely  
&nbsp;&nbsp;&nbsp;cpu usage, memory usage, and pid count) during the execution of a  
&nbsp;&nbsp;&nbsp;playbook run. Resource profiling is made possible by the use of  
&nbsp;&nbsp;&nbsp;control groups ..."

---

<div class="post-metadata">

**Author:** ![Rilindo\_Foster1](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@Rilindo\_Foster1](https://forum.ansible.com/u/Rilindo_Foster1)\
**Post date:** [February 8, 2022, 5:16pm UTC](https://forum.ansible.com/t/get-memory-info-using-ansible/36302/3 "2022-02-08T17:16:11Z")

</div>

Hi Dip!

Assuming that you are referring to this code, note that that Ansible will run python on the target node - Python the interpreter itself will consume memory. And then if you run the shell module under Ansible, it will spawn a shell which itself will consume memory as well.

- Rilindo

---

<div class="post-metadata">

**Author:** ![user52](https://avatars.discourse-cdn.com/v4/letter/u/ba9def/32.png) [@user52](https://forum.ansible.com/u/user52)\
**Post date:** [September 21, 2023, 10:38am UTC](https://forum.ansible.com/t/get-memory-info-using-ansible/36302/4 "2023-09-21T10:38:59Z")

</div>

Hi, All!  
My code:

- name: ===== Блок отримання інформації про виділену RAM ==========================================  
block:
- name: ===== Вівід інформації про виділену, використану та залишок пам’яті ===================  
ansible.builtin.debug:  
msg: “Виділена пам’ять: {{ ansible\_memory\_mb.real.total }} | Використана: {{ ansible\_memory\_mb.real.used }} | Залишилось: {{ ansible\_memory\_mb.real.total - ansible\_memory\_mb.real.used }} ({{ ((1-ansible\_memory\_mb.real.used/ansible\_memory\_mb.real.total)\*100)|int }}%)”

**stdout:**  
ok: **[vl-nr-app1]** =\> {  
“msg”: “Виділена пам’ять: **2619** | Використана: **2004** | Залишилось: **615** (23%)”  
}  
ok: **[vl-nr-app2]** =\> {  
“msg”: “Виділена пам’ять: **2619** | Використана: **1983** | Залишилось: **636** (24%)”  
}  
ok: **[al-nr-app1]** =\> {  
“msg”: “Виділена пам’ять: **2619** | Використана: **2073** | Залишилось: 546 (**20%)**”  
}

вторник, 8 февраля 2022 г. в 19:16:40 UTC+2, Rilindo Foster:
