# vRealize Operations VM Uptime in Days, Hours, Minutes, Seconds

Categories Monitoring, vRealize Operations, vRealize SuiteOne of my customers had a rather interesting use case for a vRealize Operations (vROps) Dashboard where they needed to provide Virtual Machine visibility to the Windows patching team to ensure the Guest OSes were indeed getting rebooted after applying updates. This is the same customer use case I reached out to John Dias (@johnddias) about regarding rebooting Guest VMs directly from vROps with the new vRO Management Pack… check out his blog here.

### Dashboard Design

We started by adding a Heatmap widget to the Dashboard design canvas and configured it to display VMs. We sized and colored them based on “System|OS Uptime”. This proved to be an interesting way to look at all their VMs because we could quickly determine which ones had not been rebooted for a long time.

We then added a Scoreboard widget and added the “System|OS Uptime” metric and created an interaction from the Heatmap to the Scoreboard. This way, when you click on a VM ‘square’ in the Heatmap widget, the Guest OS Uptime will be displayed in the Scoreboard widget. Unfortunately, we quickly discovered that humans do not think about VM uptime in terms of hundreds of thousands of seconds.

“Hey Louis, when was the last time you rebooted that SQL Server? Oh, about 8,749,231 seconds ago…” Yeah right! So clearly, we needed to convert this into something a little more user friendly… Super Metrics to the rescue!

### Math is Hard

Here’s where things go down the mathematical rabbit hole real quick… if you are not interested in the logic and only care about the solution, then I suggest you skip ahead a bit. First, let’s break this down into the following four variables: “TotalSeconds”, “TotalMinutes”, “TotalHours”, and “TotalDays”.

**TotalSeconds** = The total number of seconds since the Guest VM rebooted. Essentially, this is equivalent to the “System|OS Uptime” metric already provided by vROps. This equates to the following Super Metric formula: **${this, metric=sys|osUptime_latest}**

**TotalMinutes** = The total number of minutes since the Guest VM rebooted. Since there are 60 seconds in each minute, we simply need to divide the TotalSeconds by 60; however, we also need to round this value down to the nearest whole number. We can leverage the “floor” function to round down. Super Metric formula: **floor(${this, metric=sys|osUptime_latest}/60)**

**TotalHours** = The total number of hours since the Guest VM rebooted. This is similar to TotalMinutes but we are dividing by 3600 since that is how many seconds are in an hour. We also need to round this down to the nearest whole number. Super Metric formula: **floor(${this, metric=sys|osUptime_latest}/3600)**

**TotalDays** = The total number of days since the Guest VM rebooted. Similar to the last two except we are dividing by 86,400 since that is how many seconds are in a day… also, round down to the nearest whole number. Super Metric formula: **floor(${this, metric=sys|osUptime_latest}/86400)**

### Super Metric Formulas

That part was relatively easy but now we need to modify the seconds, minutes, and hours so that their values reset after 60 seconds, 60 minutes, & 24 hours respectively. The equations for our four Super Metrics now become:

**Custom-GuestOSUptime-Days** = TotalDays

**Custom-GuestOSUptime-Hours** = TotalHours-(TotalDays*24)

**Custom-GuestOSUptime-Minutes** = TotalMinutes-(TotalHours*60)

**Custom-GuestOSUptime-Seconds** = TotalSeconds-(TotalMinutes*60)

and if we substitute our variable values we get the following Super Metric formulas:

**Custom-GuestOSUptime-Days** = floor(${this, metric=sys|osUptime_latest}/86400)

**Custom-GuestOSUptime-Hours** = floor(${this, metric=sys|osUptime_latest}/3600)-(floor(${this, metric=sys|osUptime_latest}/86400)*24)

**Custom-GuestOSUptime-Minutes** = floor(${this, metric=sys|osUptime_latest}/60)-(floor(${this, metric=sys|osUptime_latest}/3600)*60)

**Custom-GuestOSUptime-Seconds** = ${this, metric=sys|osUptime_latest}-(floor(${this, metric=sys|osUptime_latest}/60)*60)

Actual footage of me building these Super Metrics…

### Final Configuration

So after creating our new Super Metrics we need to associate each one with the appropriate Object Type… Virtual Machines in this case. This way vROps will calculate the Super Metrics for the target objects and display it as a metric for the Object Type. To do this, select one of our newly created Super Metrics and then click the Add button in the “Object Types” tab below. Then expand the “vCenter Adapter” and select “Virtual Machine”. Do this for all four Super Metrics.

The final step is to add our new Super Metrics to the Policy (or policies) so that our VMs start collecting values for these new metrics. Here is the link to the official VMware documentation if you need additional assistance with configuring Super Metrics.

After at least one collection cycles these new Super Metrics will become available to add to our Scoreboard widget.

Now when we click on a VM ‘square’ in the Heatmap widget we are provided with a meaningful System Uptime representation.

Hello Steve, I am newbie on vROPS found your SLA VM uptime super metric is helpful, can upload a link to download and import those packages will be highly appreciated.

Thank you,

regards,

Chua

Hi Chua, Check out this link to find my code as well as MANY other community shared vROps dashboards… https://vrealize.vmware.com/sample-exchange/

Steve,

Is there a metric that would allow the same dashboards for hosts–minus maintenance mode time?

Hi Steve, I do not believe there is an out of the box metric that tracks the host uptime minus the maintenance mode time; however, you could potentially follow some of the same logic and methodology used here to create a Super Metric that would accomplish the desired result. Let me know if you want to tag team this together in my lab.

Hi Steve,

Let me check with our customer.

Thank you for the quick response.

Steve

hi ,i am mukesh , can it is possible to trace the VM history for duration like for a month if vm start stop how many time and total up time for the month .