ARIA Operations – Bulk API Commands

While ARIA Operations is a robust & complex infra monitoring application, not every tool or functionality you’d need can be found. But via the ARIA Operations API, you can close that gap. Pictured below is the built-in Swagger interface which can be found by appending “/suite-api” to your Aria Operations URL example:

vr83-bpeterson.tvs.vmware.com/suite-api

My colleague Brock Peterson has a great blog on authentication and understanding the hundreds of objects you can run Get/Post/Put/Patch/Delete actions against.

In this article, I’m going to feature a method for how to run bulk commands using some Python in your CLI. The scenario is that we’re looking to monitor a specific service running in Windows OS that isn’t already natively monitored by ARIA Operations.

We’ll leverage Telegraf (built into ARIA Ops), an open source agent for monitoring Windows, by first installing Telegraf on each VM that is running Windows OS. This can be done in bulk easily (using filters) as pictured below. FYI, VMware Tools will need to be installed prior to Telegraf agent installation.

After the Telegraf agent is installed, we’ll need to enter each service we want to monitor…one at a time… for EVERY OS instance.

What if you need to enter 3 services for 1000 instances? That’s 3000 entries. That would take a lot of time. Time to break out the Swagger API interface.

Before we go there though….

Let’s create a custom group and pull vm’s into that group by relying on a filter: Guest OS contains “win”…

Then let’s open our INVENTORY menu, scroll to FOLDER, select WIN OS which is populated by 70 vm’s now….

Click on the matrix and CTRL-A to select all, right-click to copy rows, and paste in Excel where we can isolate column A as our list of resource IDs.

NOW we can go to the Swagger API and select the APPLICATIONS category, then select the POST command.

After clicking the “Try it out” button on the right, you’ll be able to edit the JSON model. (You might first need to click the LOCK icon right above the button and enter credentials for your ARIA Ops instance). Delete the current JSON model and copy/paste this block of code into the field.

{
  "services" : [{
    "serviceName": "serviceavailability",
    "configurations": [
      {
        "configName": "Mps Svc",
        "isActivated": true,
        "parameters": [
          {
            "key": "FILTER_VALUE",
            "value": "MpsSvc"
          }
        ]
      },
		{
          "configName": "VMware Tools",
          "isActivated": true,
          "parameters": [
            {
              "key": "FILTER_VALUE",
              "value": "VMTools"
            }
          ]
        },
        {
          "configName": "Windows Connection Manager",
          "isActivated": true,
          "parameters": [
            {
              "key": "FILTER_VALUE",
              "value": "Wcmsvc"
            }
          ]
        }
    ]
  }
 ]
}

So this JSON code enables us to monitor the availability of 3 services on our Windows OS: MpsSvc, VMTools, and Wcmsvc. You can replicate the blocks to add as many services as you like. For the sake of simplicity, we’ll limit to just these 3.

Now, after you click EXECUTE, you should get back a code 200 indicating the action was successful.

…But while we were able to enter 3 services at one time, we’ll still have to do this for many more vm’s…in fact, every single vm running Windows OS. Here’s where Python will help us. Before we leave this screen, copy the CURL command (see above pic).

list = [
"b9dcadc0-3f22-40a8-b55c-d606a05ecdcc",
"ba8868df-d2da-487e-9b2a-3525b2699039",
"bb2f65bb-e302-4128-bf8e-24d1d2f980a6"
         ]
        
for i in list:
	print(
		 """curl -X POST \"curl -X POST "https://vr83-bpeterson.tvs.vmware.com/suite-api/api/applications/agents/""" 
+ i +
		 """/services?_no_links=true" -H "accept: application/json" -H "Authorization: vRealizeOpsToken 287ed085-c6ca-4255-b69c-956f1665ed51::4c2cc341-0f9f-4143-bb90-ea6f06e9e75f" -H "Content-Type: application/json" -d "{ \"services\" : [{ \"serviceName\": \"serviceavailability\", \"configurations\": [ { \"configName\": \"MpsSvc\", \"isActivated\": true, \"parameters\": [ { \"key\": \"FILTER_VALUE\", \"value\": \"MpsSvc\" } ] } ] } ]}";""")

I’ve written the simple python code above to combine the objects we’ve harvested up to this point:

The list of Resource IDs (list)

and the CURL command you just copied.

You’ll need to separate your CURL command in half (like below) and plug those snippets into the python code above…

curl -X POST \”curl -X POST “https://localhost.ariaops.com/suite-api/api/applications/agents/

and

/services?_no_links=true” -H “accept: application/json” -H “Authorization: vRealizeOpsToken 287ed085-c6ca-4255-b69c-956f1665ed51::4c2cc341-0f9f-4143-bb90-ea6f06e9e75f” -H “Content-Type: application/json” -d “{ \”services\” : [{ \”serviceName\”: \”serviceavailability\”, \”configurations\”: [ { \”configName\”: \”MpsSvc\”, \”isActivated\”: true, \”parameters\”: [ { \”key\”: \”FILTER_VALUE\”, \”value\”: \”MpsSvc\” } ] } ] } ]}”

Now just open a python sandbox, just google one, or use pythonsandbox.com…and paste the python code into the editor window on the left…and your output window on the right will contain a list of curl commands, one for each vm (containing the API/JSON instructions to add the 3 services).

You now know how to harness the power of the ARIA Ops built-in API Swagger interface in conjunction with Python to add hundreds of services to monitor across thousands of vm’s in 5 – 30 minutes.

+ There are no comments

Add yours