Automate Monitoring of Production Capacity Utilization in Frame

By David Horvath

| min

"The Nutanix Frame® Desktop-as-a-Service (DaaS) provides a detailed scheduling capability to ensure that Frame accounts are able to deliver just-in-time production capacity while minimizing the additional cost of having idle cloud capacity. However, Frame does not currently have the built-in feature to alert administrators when an existing production pool is running out of provisioned capacity. This might lead to users not being able to connect to a session because all of the VMs in the production pool are in use at a moment in time. This blog will demonstrate how the Frame Admin API can be used to monitor the actual number of concurrent sessions and send a message to a Slack® channel when the number of active sessions reaches a certain percentage of the provisioned capacity of a Frame production pool.

Solution Architecture

For this solution, I chose to use a Windows® PowerShell® script running on a Frame Utility server. Since I had already developed an elasticity management solution that runs as a scheduled task on a Frame Utility server. As with that script, we need to gather some values in order to successfully run the Frame Admin API on that account.

$clnt_id = "<ClientID>"

$clnt_secret = "<ClientSecret>"

$acct_id = "<AccountID>


We also need a way to send a notification when the threshold is exceeded. For this blog, I chose to use a Slack webhook. The Slack webhook allows you to “Post” data which will then show up as a message in a Slack channel. This Slack article explains how to set up a Slack webhook.

The script I developed will poll at a regular interval over a 24-hour period and send an alert to Slack if the number of active sessions in any production pool associated with the Frame account is greater than a fixed percentage. The full script can be downloaded here but I will break down the individual pieces below (note the snippets below can not be run independently, but are for illustrative purposes only. Download the full script if you wish to use the script as a starting point for your own purposes).

The Script

The script has two environment variables defined.

$session_threshold = 50

$poll_interval = 15


These variables indicate that the script will check every 15 minutes for pools that have active sessions at 50% capacity and alert if it finds any.

With those two parameters, the first thing the script does is to obtain the name of the Frame account and send a message to Slack to confirm it is monitoring the Frame account.

$req_string ="" + $acct_id

$res = Get-FrameAPICall -client_id $clnt_id -client_secret $clnt_secret -api $req_string

$acct_name = $

$the_text = "Starting the monitoring of " +$acct_name + " with a threshold of " + $session_threshold + " percent of published capacity."

$body_text = @{

    text = $the_text

} | ConvertTo-Json

Invoke-RestMethod -uri $slack_webhook -Method Post -body $body_text

We use a Frame Admin API call to get the “common name” for the account to improve readability and since Slack wants the body of the post to be a JSON object so we use the “ConvertTo-JSON” function to make sure it is formatted correctly.

Script Start message in Slack.

Next we start a 24-hour loop and grab a list of production pools for the Frame account.

for (($poll=0), ($poll -lt [int]((60*24)/$poll_interval)), $poll++)


    $req_string ="" + $acct_id + "/pools?kind=production"


$res = Get-FrameAPICall -client_id $clnt_id -client_secret $clnt_secret -api $req_string


Frame accounts can have multiple production pools if different instance types are used and each pool has its own max capacity so we need to count the active sessions from each pool and compare it to the max capacity for that pool to determine the percentage that is in use.


    foreach ($i in $res)


        if ($ -ne $null)


            $req_string = "" + $ + "/elasticity_settings"

            $result1 = Get-FrameAPICall -client_id $clnt_id -client_secret $clnt_secret -api $req_string

            $sessions = Count-ActivePoolSessions -client_id $clnt_id -client_secret $clnt_secret -acct_id $acct_id -ext_pool_id $i.external_id


Now we can check the percentage and send a message to Slack if the threshold was met.

if([int]($sessions*100/$result1.max_servers) -gt $session_threshold)


                $the_text = $acct_name + "'s "+ $ + " pool is at ``" + [int]($sessions*100/$result1.max_servers) + "`` percent of published capacity."

                $body_text = @{

                    text = $the_text

                } | ConvertTo-Json

                Invoke-RestMethod -uri $slack_webhook -Method Post -body $body_text


The message appears as shown below.

Slack alert message

Once all the pools have been checked, the script sleeps for the polling interval.

Start-Sleep -Seconds ($poll_interval*60)

And when the loop is done, we send a closing message to Slack as shown below.

$the_text = "Completed the monitoring of " +$acct_name

$body_text = @{

    text = $the_text

} | ConvertTo-Json

Invoke-RestMethod -uri $slack_webhook -Method Post -body $body_text

Closing Slack message


The script does write output to the shell, if run interactively, for debugging purposes, but that is less useful if run as a scheduled task since those messages will not be displayed. Message customization into Slack can be easily accomplished by modifying the text strings that are sent and more complex formatting can be accomplished by searching Slack’s documentation. Additionally, other non-Slack notification methods could be used as long as a method of triggering them via PowerShell works. The idea of a script that only runs for 24 hours allows for the monitoring period to be customized to meet the needs of the enterprise. For example, maybe a Monday-Friday schedule is appropriate and monitoring on the weekends less so. In the elasticity blog (linked above), I demonstrated how to create .cmd files that can be scheduled via the built-in Windows Task Scheduler.

David Horvath is a Senior Solutions Architect with Nutanix Frame. He has been a part of the Frame team for almost 5 years and prior to that spent 20 years consulting on various Information Technology projects with the US Intelligence Community.

© 2021 Nutanix, Inc. All rights reserved. Nutanix, the Nutanix logo and all Nutanix products, feature names mentioned herein are registered trademarks or trademarks of Nutanix, Inc. in the United States and other countries. All other brand names mentioned herein are for identification purposes only and may be the trademarks of their respective holder(s). This post may contain links to external websites that are not part of Nutanix does not control these sites and disclaims all responsibility for the content or accuracy of any external site. Our decision to link to an external site should not be considered an endorsement of any content on such a site. Certain information contained in this post may relate to or be based on studies, publications, surveys and other data obtained from third-party sources and our own internal estimates and research. While we believe these third-party studies, publications, surveys and other data are reliable as of the date of this post, they have not independently verified, and we make no representation as to the adequacy, fairness, accuracy, or completeness of any information obtained from third-party sources..

This post may contain express and implied forward-looking statements, which are not historical facts and are instead based on our current expectations, estimates and beliefs. The accuracy of such statements involves risks and uncertainties and depends upon future events, including those that may be beyond our control, and actual results may differ materially and adversely from those anticipated or implied by such statements. Any forward-looking statements included herein speak only as of the date hereof and, except as required by law, we assume no obligation to update or otherwise revise any of such forward-looking statements to reflect subsequent events or circumstances.