Monitoring Tridion Publishing with Tridion Application Monitoring

SDL Tridion introduced Application Monitoring from their R5.3 GA release. This functionality allows you to monitor certain aspects of the environment to ensure that essential processes are always running. This new feature can be extended to enable you to monitor more than what is just delivered out of the box.

Why monitor publishing?
Publishing is critical to an organization’s ability to respond to changes in their online presence. It is crucial that the workload of the publisher is monitored for performance and load. In this case we will look at one part of the publishing, the length of the queue.

Backlogged Queue
In the event of a failure the publishing queue is likely to become backlogged with publishing requests; in this case the total number of items waiting will only rise. However, it can also be that allot of items have been submitted to the queue either by mistake or as part of a republish process. In that case we might want to take action (remove or monitor) and in order to take action we need notification.

Application Monitoring allows you to extend the features of its monitoring; one such way it to add a HTTP Service Health Monitor. Basically this calls a URL and processes the response for a known string. This string does not have to say much just it has to be what Application Monitoring is expecting. If the response does not say what it is expected and error is raised. That error can be trapped using SNMP and after that System Administrators can be notified.

So in our example we want to raise an alarm when the number of items in the queue gets above, say, 100. To do this we need to check, through the Tridion API, what the current count on the queue is and then respond accordingly. When everything is fine I want my page to say “Monitoring TestPage”. When the queue is too long I want it to say something else and in this case I want it to tell me what the state is. So something like: “Error, number of items in the queue exceeds limit. Queue is now at: 4000000 of a max of 100 items”.

The code
Using the COM Interop for .NET you can do this from a .NET application. As we are using a webpage to display this result it should be an ASP.NET page but it could equally be written in any language.  For this example I will cover the basics of what you can do. For the complete example, see the download.

I start by importing the namespaces of the COM Interop as well as the XML handler:

<%@ Import namespace="TDS" %>
<%@ Import namespace="System.Xml" %>

Next we want to create a new TDSE object of Tridion, XML Document and Node List:

TDSE tdse = new TDSE();
XmlDocument itemsXmlDoc = new XmlDocument();
XmlNodeList itemNodes;

Next we set the user we want to use for accessing Tridion, in this case the REMOTE_USER and initialize TDSE.


From that we are authorized to Tridion and can then get a ManagementInfo object which will enable us to look into the queue of Tridion:

ManagementInfo managementInfo = tdse.GetManagementInfo();
ListRowFilter filter = tdse.CreateListRowFilter();
filter.SetCondition("InfoType", queue);

List row filters (above) enable us to filter the results, in the case the variable queue specifies a string which is the queue we want to look at. Using the filter we can call GetListPublishTransactions and load the resulting string as XML:

String itemsXml = managementInfo.GetListPublishTransactions(filter);

Once we have done that we can select the elements that represent the publish tasks and display our text:

itemNodes = itemsXmlDoc.SelectNodes("tcm:ListPublishTransactions/tcm:Item", namespaceManager);
int itemsCount = itemNodes.Count;
if (itemsCount > maxItems) {
%>Error, number of items in the queue exceeds limit. Queue is now at: <%=itemsCount%> of a max of <%=maxItems%> items.<%
} else {
%>Monitoring TestPage<%

Once we have created and tested our page we need to add it to Application Monitoring so it monitors this page for changes.

Configuring Application Monitoring
Application Monitoring is configured through the configuration file cd_monitor_conf.xml which is located in the directory %TRIDION_HOME%\bin. To monitor a queue we need to add the following to the ServiceHealthMonitors section:

<HttpServiceHealthMonitor ServiceType="Publishing Queue Length - WaitingForPublish" ServiceInstance="local" PollInterval="5m" TimeoutInterval="30s">
<Request URL="http://localhost/MonitoringView/Monitors/publishqueue.aspx?queue=1&amp;max=100"/>
<Response SuccessPattern="Monitoring TestPage"/>
<Authentication Scheme="NTLM" Host="host" Domain="myhost" Username="administrator" Password="tridion"/>

This element tells Application Monitoring to periodically monitor the URL specified for the specified text. Of particular interest are the ServiceType (the name of the service which you can change) and the PollInterval.

The PollInterval specifies the amount of time between checks of the status of this queue. It should be short enough for you to react to any change in state but long enough not to overload the server.
Our URL can also be configured. The URL has two parameters, queue and max. Queue is the string (actually an integer but this is a URL so it is actually a string) that identified the queue being monitored and is specified as follows:

  • 0 = Scheduled for Publish
  • 1 = Waiting for Publish
  • 2 = In Progress
  • 3 = Scheduled for Deployment
  • 4 = Waiting for Deployment
  • 5 = Failed
  • 6 = Success

The max value simply indicates what the maximum number of items to allow in the queue before the alarm is raised.

Once configured you should restart the Tridion Monitoring Service and check the URL of the Application Monitoring webservice:  http://localhost/monitoring/TridionMonitoringAgent.asmx. If you do this from the localhost you will have the option to invoke the webservice and get a XML response back. In this response you can check your new monitor is responding correctly.

Using this Monitor
There are two basic ways to use this new monitor together with your standard monitors:

  • Write a application to read the Application Monitoring Webservice
  • Setup a monitoring application that can catch SNMP traps

In the case of the latter, all the monitors including the one we have setup will send SNMP traps when the state changes. This allows you to integrate this monitor into any existing infrastructure management processes.

Download the files for this article here.

More information
You can find more information on Application Monitoring by checking the R5.3 documentation or visiting the SDL Tridion Forums or SDL Tridion’s community World. You can also find this article on SDL Tridion World.

Leave a Reply

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