# Odd results from query of /proc/meminfo?

**URL:** <https://forum.ansible.com/t/odd-results-from-query-of-proc-meminfo/36204>\
**Category:** Ansible Project\
**Created:** [January 14, 2022, 5:23pm UTC](https://forum.ansible.com/t/odd-results-from-query-of-proc-meminfo/36204 "2022-01-14T17:23:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jibun\_no\_Kage](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@Jibun\_no\_Kage](https://forum.ansible.com/u/Jibun_no_Kage)\
**Post date:** [January 14, 2022, 5:23pm UTC](https://forum.ansible.com/t/odd-results-from-query-of-proc-meminfo/36204/1 "2022-01-14T17:23:12Z")

</div>

Odd results from query of /proc/meminfo?

When I do the following from shell...  
# cat /proc/meminfo | grep MemTotal  
MemTotal: 8087276 kB

But when I do the same via Ansible...  
ok: [192.168.1.212] =\> {  
"msg": "Pi Memory Total: MemTotal: 957160 kB"  
}

Ansible Source...  
- name: Memory Total  
#shell: "cat /proc/meminfo | grep MemTotal | cut -d ':' -f2 | cut -d 'k' -f1 | tr -d ' '"  
shell: "cat /proc/meminfo | grep MemTotal"  
register: m  
changed\_when: False

```
 \- name: Memory Total
   debug:
     msg: &quot;Memory Total: \{\{ m\.stdout \}\}&quot;

```

Returned value is greater than physical memory size!

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [January 14, 2022, 7:22pm UTC](https://forum.ansible.com/t/odd-results-from-query-of-proc-meminfo/36204/2 "2022-01-14T19:22:17Z")

</div>

> Odd results from query of /proc/meminfo?
> 
> When I do the following from shell...  
> # cat /proc/meminfo | grep MemTotal  
> MemTotal: 8087276 kB
> 
> But when I do the same via Ansible...  
> ok: [192.168.1.212] =\> {  
> "msg": "Pi Memory Total: MemTotal: 957160 kB"  
> }

Why messing with the shell when the information is already present in the facts?

&nbsp;&nbsp;- name: Show memory  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "{{ ansible\_memory\_mb }}"

TASK [Show memory] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [bullseye-test-box] =\>  
&nbsp;&nbsp;&nbsp;msg:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nocache:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free: 828  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used: 1154  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;real:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free: 82  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total: 1982  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used: 1900  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;swap:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cached: 0  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free: 0  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total: 0  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used: 0

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke
