Press "Enter" to skip to content

Http Post Adapter in vCOPS

I was recently asked about the HTTP POST ADAPTER in vCOPS and how to use it specifically in regards to relationship linking, because there is not many real good examples of how to use it. While there is a few that supply scripts that you pass the data into it doesn’t really teach how it works, unless you have the time to go in and tear down their functions.

There is quite a few examples on how to import data but creating relationships there is very little so I thought hey might post something quickly to help out anyone else who might be looking for something similar.

So lets just quickly add in a dummy resource into vCOPS and then make it a child resource of an existing resource in vCenter. Please ignore my poor excuse of a powershell script ive literally just smashed them together to demonstrate how it works, there is very little structure or smarts that have gone into them.
ill insert a object with the following power shell script

 [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
function post-vcops ($custval)
$url = read-host "Enter in the IP for the vCenter Operations UI VM"
 write-host "Enter in the admin account for vCenter Operations"
$cred = get-credential
$resname = ""
$adaptkind = "Http Post"
$reskind = "external"
$resdesc = "virtualise me http post test"
$metname = "blog|posts"
$alrmlev = "0"
$alrmmsg = "alarm message"
$epoch = [decimal]::Round((New-TimeSpan -Start (get-date -date "01/01/1970") -End (get-date)).TotalMilliseconds)
$body = "$resname,$adaptkind,$reskind,,$resdesc`n$metname,$alrmlev,$alrmmsg,$epoch,$custval"
Invoke-WebRequest -Uri "https://$url/HttpPostAdapter/OpenAPIServlet" -Credential $cred -Method Post -Body $body
$myvalue = 15

I will just explain what some of the varibles I have set are.

$resname = "" – this is the resource name so it would be equivilent to a virtual machine name but here I used my blog.

$adaptkind = "Http Post" – This is the adapter we are using this has to be http post.

$reskind = "external" – this is the kind of recource similar to the virtual machine or host system kind you would see in vCOPS.

$resdesc = "virtualise me http post test" This is just the description of the resource make this meaningful

$metname = "blog|posts" – This is the metric name so to put this into context Blog would be the equivalent to CPU Usage and posts would be the same as Usage (%)

From this poor excuse of a power shell script, I am making an object and adding a blog/post metric and just adding in the value of 15. This is used as an example to demonstrate creating relationships.

We get the following output
Screen Shot 2014-08-08 at 11.39.23 pm

Lets check to see if the new data is in vCOPS.

Now that the new object and data has been imported into vCOPS lets link it to one of my hosts and pretend they are related.
I will be using the below Power shell script similar to the one above but I will be writing out the body so that you can see how it should be made up.

 [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

function post-vcops

$url = read-host "Enter in the IP for the vCenter Operations UI VM"
write-host "Enter in the admin account for vCenter Operations"

$cred = get-credential

$body2 = 'action=addRemoveParentChildRelationship&;sourceAdapter=Http Post&;;adapterKindKey=VMWARE&;resourceKindKey=HostSystem&;$$VMEntityObjectID::host-476$$VMEntityVCID::15ED0424-ADAA-4005-9506-A732616CAA97&;,Http Post,siblings&;addFlag=true'

# executes the Http Post Request
Invoke-WebRequest -Uri "https://$url/HttpPostAdapter/OpenAPIServlet" -Credential $cred -Method Post -Body $body2


# calls the post-vcops function and pass the value to it

The most important part of the script is the body, It must not have any mistakes in it or it will not work. even though the response back from the Http Post Adapter will say everything is ok.
Also note you must use single quotes due to the $ signs if using powershell.

$body2 = 'action=addRemoveParentChildRelationship&sourceAdapter=Http Post&$$VMEntityObjectID::host-476$$VMEntityVCID::15ED0424-ADAA-4005-9506-A732616CAA97&,Http Post,external&addFlag=true'

the identifier is the tricky part if you need to know what this is you can view this through the environment overview page in vCOPS. If you are creating a link to an object you have imported into vCOPS manually then you do not need he identifier, its only needed to link to normal vCOPS collected data.

You can see the identifiers if looking at the settings of an object from the environment view in vCOPS as shown in the picture below.

If you want to add multiple children just repeat this,Http Post,external after childResources= for every child resource and separate them with a “;”

The output of running my dodgy script like this is as below.

Now lets see if this has worked and the host is the parent of


All done, A really quick post on linking resources.


Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti SPAM BOT Question * Time limit is exhausted. Please reload CAPTCHA.