question

hansi4711 avatar image
0 Votes"
hansi4711 asked CyrAz edited

Monitoring URL

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














msc-operations-manager
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

CyrAz avatar image
1 Vote"
CyrAz answered CyrAz edited

As you can see in https://docs.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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.