Monitoring URL

Hansi 116 Reputation points
2021-07-12T05:41:26.83+00:00

Hello!

I am creating a Management Pack and a part of it is requesting an URL with Microsoft.SystemCenter.WebApplication.UrlProbe.

One requirement is to set header objects using configuration file. Therefore, in the discovery, I assemble the string according to the HttpHeadersType and store that in the class under the headers setting.
Example: <HttpHeader><name>Accept</Name><Value>/</Value></HttpHeader><HttpHeader><name>Accept-Language</Name><Value>en-us</Value></HttpHeader><HttpHeader><name>Accept-Encoding</Name><Value>GZIP</Value></HttpHeader>.

My Class:

<ClassType ID="MY.TEST.Class"
                   Accessibility="Public"
                   Abstract="false"
                   Base="Windows!Microsoft.Windows.ApplicationComponent"
                   Hosted="true"
                   Singleton="false">
          <Property ID="ID" Type="string" Key="true" />
          <Property ID="Name" Type="string" Key="false" />
          <Property ID="URL" Type="string" Key="false" />
          <Property ID="Description" Type="string" Key="false" />
          <Property ID="HTTPHeaders" Type="string" Key="false" />
          ...
         </ClassType>
      </ClassTypes>
    </EntityTypes>
  </TypeDefinitions>

Now I want to pass this string to the sample:

<Configuration>
     <xsd:element minOccurs="0" name="Headers" type="xsd:string"/>
</configuration>
...
<Requests>
  <Request>
    <RequestID>1</RequestID>
    <HttpHeaders>$Config/Headers$</HttpHeaders>
    ...
  </request>
</Requests>

But I will get an error on build:
Schema validation failed.
The element 'HttpHeaders' must not contain any text. Expected list of possible elements: 'HttpHeaders'.

Is it possible to implement the requirement this way, or do I have to store the individual header elements as separate properties in the class. I would like to avoid this.

rg
Hansi

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,424 questions
0 comments No comments
{count} votes

Accepted answer
  1. CyrAz 5,181 Reputation points
    2021-07-12T07:49:30.593+00:00

    As you can see in https://learn.microsoft.com/en-us/system-center/scom/url-probe-schema?view=sc-om-2019 , the structure of the <HttpHeaders> block must indeed be in the Name/Value format, you can't pass a string.

    And URLGenie MP which also relies on native urlprobe does indeed have 3 "HeaderName" and 3 "HeaderValue" properties defined in the Http Request Seed class : https://systemcenter.wiki/?GetElement=URLGenie.HttpsRequest.Standard&Type=ClassType&ManagementPack=URLGenie&Version=2.0.0.46

    If you want to avoid this, you'll have to avoid using the native urlprobe. A powershell monitor would be a more flexible solution, using Invoke-WebRequest for example.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful