# How to receive VM monitoring data via ZeroMQ?

**URL:** <https://forum.opennebula.io/t/how-to-receive-vm-monitoring-data-via-zeromq/8461>\
**Category:** Integration Support\
**Created:** [May 21, 2020, 9:26am UTC](https://forum.opennebula.io/t/how-to-receive-vm-monitoring-data-via-zeromq/8461 "2020-05-21T09:26:42Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [May 21, 2020, 9:26am UTC](https://forum.opennebula.io/t/how-to-receive-vm-monitoring-data-via-zeromq/8461/1 "2020-05-21T09:26:42Z")

</div>

Hello,

I’ve asked the question when the Hook Manager was introduced on last OpenNebula Conf and left with the understanding that the VM monitoring data is published on the ZeroMQ.

I am looking for an interface to listen for the VM monitoring updates. I can see that I could drop a monitoring probe in `...im/kvm_probes.d/vm/monitor` (testing on 5.12-beta but it is same on 5.10) and could see the monitoring data in the `oned.log` file.

Reading the [hooks docs](http://docs.opennebula.io/5.11/integration/infrastructure_integration/hooks.html) it is not clear should I register a hook in the hook manager to start receiving the VM monitoring data? Couldn’t find pair of STATE/LCM\_STATE that define the update of the monitoring data too.

Tried subscribing to the ZeroMQ but there I could see the VM API events but no the monitoring updates.

I believe that the following script is hooking to the HookManagerEvents and that the hook manager is just a “service” that subscribes to ZeroMQ itself.

I am using the following ZeroMQ example script to monitor all events:

```auto
#!/usr/bin/ruby
#

RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
GEMS_LOCATION = '/usr/share/one/gems'

if File.directory?(GEMS_LOCATION)
    Gem.use_paths(GEMS_LOCATION)
end

$LOAD_PATH << RUBY_LIB_LOCATION

require 'ffi-rzmq'
require 'base64'

@context = ZMQ::Context.new(1)
@subscriber = @context.socket(ZMQ::SUB)

@subscriber.setsockopt(ZMQ::SUBSCRIBE, "EVENT")
@subscriber.connect("tcp://localhost:2101")

key = ''
content = ''

loop do
    @subscriber.recv_string(key)
    @subscriber.recv_string(content)
    puts "Key: #{key}"
# puts "Key: #{key}\nContent: #{Base64.decode64(content)}"
    puts "\n===================================================================\n"
end

```

What am I missing?

Best Regards,  
Anton Todorov

---

<div class="post-metadata">

**Author:** ![cgonzalez](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cgonzalez/32/7096_2.png) [@cgonzalez](https://forum.opennebula.io/u/cgonzalez)\
**Post date:** [May 22, 2020, 9:40am UTC](https://forum.opennebula.io/t/how-to-receive-vm-monitoring-data-via-zeromq/8461/2 "2020-05-22T09:40:05Z")

</div>

Hello @atodorov_storpool,

Maybe there was a misunderstood during the OpenNebula Conf, currently you can use ZeroMQ to subscribes either API calls or VM/HOST state changes, the monitoring update does not trigger any of those so there’s no way for you to directly subscribe to monitoring changes.

Regarding your question:

> it is not clear should I register a hook in the hook manager to start receiving the VM monitoring data?

As you said the Hook Execution Manager (HEM) is just a service which subscribes to the needed events via ZeroMQ, you can set a Hook for execute some script when the event arrives or you can also just subscribe yourself to ZeroMQ events ant process the data by your own. But as I said above currently there is no event generated for monitoring updates.

If you just want to retrieve the monitoring information maybe you can periodically retrieve the information via API ([XML-RPC API — OpenNebula 5.11.90 documentation](http://docs.opennebula.io/5.11/integration/system_interfaces/api.html#one-vm-monitoring)). Note that you know the frequency of the monitoring updates as this can be configured.
