vRops vMotion Super Metric

Were onsite at a customer, and they were discussing if it was possible to see in vRops when a vMotion occurred. I told them that there were no such metric or property in vRops, but I knew a way to see when ever a vMotion had occurred. The way it works is by looking, on a virtual machine at the “OS Uptime” and “System Uptime” metrics. The rule is rather simple.

If “OS uptime” is not below 300, ie. the OS has not been started/rebooted within the last 300 seconds and the “System uptime” is 300 or less the VM has been vMotioned. Instead of looking at these two graphs on a per virtual machine basis, lets create a Super Metric instead!

How does it work

Before we create the Super Metric, let me first explain why this works. The counter “OS Uptime”, is incremented with one second for each second the OS is running. So we know that if this counter is more than 300, the OS has not been started/rebooted within the last 300 seconds. This brings me to the next metric “System Uptime”, which counts the seconds of which the virtual machine has been running that instance or world.

So if I were to power on a virtual machine which was previously powered off. The “OS uptime” and “System uptime” counters would be the same, fx. 3.890.948 seconds of OS/System uptime. If I were to them reboot the virtual machine that counter would start counting from zero was again, whereas the “System uptime” counter would continue to count onwards from 3.890.948, as the virtual machine world has not been restarted only the OS within.

If we go back to both “OS uptime” and “System uptime” having the same counter of 3.890.948 (just to simplify the examples) and I where to do a vMotion of the virtual machine to another host, the “OS uptime” counter would continue to count incrementally onwards from 3.890.948, whereas the “System uptime” counter would start all over again counting from zero.

But there’s a catch

But its now all rainbows and sunshine. Lets say I, first asked the OS to reboots and then right after, before the OS had a chance to boot again, vMotioned the virtual machine to another host. Depending on how long time the OS takes to boot up it might still work. If it is fast booting like most virtual machines are today, with no hardware or OS slowdowns to talk of, you might come into a situation where a vMotion is not captured by the Super Metric, as the above laid out rules does not apply. I think this is a corner case, but just know that it could happen.

vRops vMotion Super Metric

Simply put if sys|osUptime_latest is more than 300 and sys|uptime_latest is 300 or less this metric will be one, meaning a vMotion has happened.

To create the Super Metric, go to “Administration” -> “Configuration” -> “Super Metrics” and click on the green plus sign. Now paste the above into the Super Metric, give it a name and save it.

Under “Object Types”, click on the green plus. Type “Virtual Machine” in the text box and click select. This makes the Super Metric apply to virtual machines.

Next, the Super Metric needs to be enabled in policy. Go to “Policies” -> “Policy Library”, mark and select edit of the policy. Under “5. Collect Metrics and Properties”, in the filter box type the name of the Super Metric. Click on “state” and change it to local for the Super Metric which is object type is virtual machine.

That’s all, now just sit back a relax, from now on you are tracking vMotions on a per VM basis.

Thanks to Michael Monberg, for showing me this trick back in the vCops days.