Returning formatted data from a Task


This post is more a reminder for me than of any utility for someone else. In fact I have no solution to propose for returning formatted data from console tasks. It would e great to return html formatted output, with tables, drill downs and so on, alas today it’s not possible.

The issue is we cannot return formatted data from our tasks, tasks output data is formatted accordingly to its datatype using an XLS stylesheet to transform the xml document into HTML. Alas the standard probes or write actions that we have can only return the following data types:

  • System.CommandOutput (command execs in general and scripts modules)
  • System.PropertyBag.Data (powershell and script probes and write actions)
  • Microsoft.Windows.SerializedObjectData (powershell probes and write actions)

These data types give us plain vanilla formatted output, with the only exception of the PropertyBag data that at least return some sort of table based Property=value output.

For example the powershell output takes into account just the Description xml tag with no formatting at all:

    <Transform type="Microsoft.Windows.SerializedObjectData" locale="enu">
    <xsl:stylesheet version="2.0" xmlns:xsl=http://www.w3.org/1999/XSL/Transform 

xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:xs=http://www.w3.org/2001/XMLSchema 
xmlns:fn="http://www.w3.org/2004/07/xpath-functions" xmlns:xdt=http://www.w3.org/2004/07/xpath-datatypes 
xmlns:DataTypeTransformer="urn:DatatypeTransformer">

      <xsl:template match="DataItem">
        <div class="Section1" marginTop="0">
          <table border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td valign="top" style="width:466.9pt;background:#B3B3B3;padding:0in 5.4pt 0in 5.4pt">
                <p>
                  <pre>
                    <xsl:value-of select="Description" />
                  </pre>
                </p>
              </td>
            </tr>
          </table>
        </div>
      </xsl:template>
    </xsl:stylesheet>

Custom modules (for example Microsoft.SystemCenter.GetWorkflowsReportProbe) return output that is properly formatted.

To get rid of this I can see just two ways:

  1. modify the XSL transforms (I fear they’re embedded in the code)
  2. develop a generic ConditionDetectionModuleType that takes in input a CommandOutput or SerializedObjectData and extracts the embedded <DataItem> document and returns a generic data document (the base data type has an XSL that tries to transform the content in HTML)

The latter can be done in managed code, but at the moment there’s no public documentation on how to extend the builtin OpsMgr modules.

So no solution today and I fear no solution in OM vNext as well.

– Daniele

This posting is provided "AS IS" with no warranties, and confers no rights.

For future reference

Sample CommandOutput embedded document

<DataItem type="System.CommandOutput" time="2010-08-24T18:10:50.7635835+02:00" sourceHealthServiceId="2AE5B44D-0416-B3F7-DDBE-67C8E9FCAB2E"><StdOut>&lt;DataItem type="System.PropertyBagData" time="2010-08-24T18:10:50.1543996+02:00" sourceHealthServiceId="2AE5B44D-0416-B3F7-DDBE-67C8E9FCAB2E"&gt;&lt;Property Name="Module" VariantType="8"&gt;module&lt;/Property&gt;&lt;Property Name="Version" VariantType="8"&gt;fileVersion&lt;/Property&gt;&lt;Property Name="RequiredVersion" VariantType="2"&gt;153&lt;/Property&gt;&lt;Property Name="Compliant" VariantType="2"&gt;1&lt;/Property&gt;&lt;/DataItem&gt;</StdOut><StdErr></StdErr><ExitCode>0</ExitCode><ProcessError></ProcessError></DataItem>

Sample SerializedObjectData

<DataItem type="Microsoft.Windows.SerializedObjectData" time="2010-08-24T15:08:32.8094636Z" sourceHealthServiceId="2ae5b44d-0416-b3f7-ddbe-67c8e9fcab2e"><SerializationSettings Type="OpsMgrSerialization" Depth="3" /><Description /></DataItem>

<DataItem type="Microsoft.Windows.SerializedObjectData" time="2010-08-24T14:39:36.3580807Z" sourceHealthServiceId="2ae5b44d-0416-b3f7-ddbe-67c8e9fcab2e"><SerializationSettings Type="OpsMgrSerialization" Depth="3" /><Property Type="System.__ComObject">System.__ComObject</Property><Description>System.__ComObject  </Description></DataItem>

Task output query

SELECT TOP 1000 [JobId]

      ,[TaskId]

      ,[BatchId]

      ,[SubmittedBy]

      ,[RunningAs]

      ,[TargetEntityId]

      ,[LocationEntityId]

      ,[Status]

      ,[Output]

      ,[ErrorCode]

      ,[ErrorMessage]

      ,[TimeScheduled]

      ,[TimeStarted]

      ,[TimeFinished]

      ,[LastModified]

      ,[LastModifiedTimestamp]

  FROM [OperationsManager1].[dbo].[JobStatus]

  order by TimeScheduled DESC

Advertisements
  1. System.CommandExecuter tasks–how to return meaningful data « Quae Nocent Docent

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: