# How collectd gets which VM it gets the data?

**URL:** <https://forum.opennebula.io/t/how-collectd-gets-which-vm-it-gets-the-data/4722>\
**Category:** Product Support\
**Created:** [August 4, 2017, 6:30am UTC](https://forum.opennebula.io/t/how-collectd-gets-which-vm-it-gets-the-data/4722 "2017-08-04T06:30:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranjith](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ranjith/32/5081_2.png) [@ranjith](https://forum.opennebula.io/u/ranjith)\
**Post date:** [August 4, 2017, 6:30am UTC](https://forum.opennebula.io/t/how-collectd-gets-which-vm-it-gets-the-data/4722/1 "2017-08-04T06:30:04Z")

</div>

I want to know the Opennebula VM id and name from inside a VM. Is Opennebula stores VM information inside VM?

---

<div class="post-metadata">

**Author:** ![atodorov\_storpool](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/atodorov_storpool/32/5327_2.png) [@atodorov\_storpool](https://forum.opennebula.io/u/atodorov_storpool)\
**Post date:** [August 4, 2017, 7:42am UTC](https://forum.opennebula.io/t/how-collectd-gets-which-vm-it-gets-the-data/4722/2 "2017-08-04T07:42:05Z")

</div>

Hi Ranjith,

AFAIK there are two ways to have information in the VM. One is via contextualization variables - you already have VMID in the contextualization probably the VM name could be added too. The other way is to query opennebula from the VM using `opennebula-gate` when configured properly.

BR,  
Anton Todorov

---

<div class="post-metadata">

**Author:** ![ranjith](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ranjith/32/5081_2.png) [@ranjith](https://forum.opennebula.io/u/ranjith)\
**Post date:** [August 9, 2017, 8:20am UTC](https://forum.opennebula.io/t/how-collectd-gets-which-vm-it-gets-the-data/4722/3 "2017-08-09T08:20:16Z")

</div>

I have this VMID in Templates section of VM. I want to use this in my shell script.  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/4/45f7e2c333ddc2040c38ff9677f4fa7b6c16bf05.png)

This is my shell script. But its not printing VMID in VM itself.

#!/bin/sh  
echo 'VMID: '$VMID
