Manage Learn to apply best practices and optimize your operations.

Verify scheduled agent status with Domino Extensible Language (DXL)

Discover how to use Domino Extensible Language (DXL) to check the status of active scheduled agents on Lotus Domino servers and in Notes databases.

Related resources from SearchDomino.com:
Featured Topic: Domino Extensible Language (DXL)

Enable or disable scheduled agents without opening the Lotus Notes database design

Monitoring scheduled agents by email

DXL (Domino Extensible Language) allows you to check the status of scheduled agents that are enabled in the Lotus Domino server and/or the local Lotus Notes database.

Follow these steps to set up the DXL to check the status of these enabled agents.

  1. Create a Lotus Notes form called: "XSL Sheet | XSLSheet" with the following text fields:

    • "Title"
    • "Filename"
    • "Comments"
    • Next, create a rich-text field called "XSLBody"

  2. Create a Lotus Notes view called "XSLSheets," with "View Selection" SELECT Form="XSLSheet." "Title" should be listed as the first sorted column.
  3. Create a Lotus Notes document with the Title: "ScheduledAgentDetails," the Filename: "ScheduledAgentDetails.xsl" and your previously created rich-text field: "XSLBody."

    This rich-text field should contain the following extensible style sheet language transformation (XSLT) code to display the data, which refers the DXL of the specified Lotus Notes database.

<<?xml version="1.0" encoding="UTF-8"?>
<<xsl:stylesheet xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform" version="1.0"   
    xmlns:dxl='http://www.lotus.com/dxl'>

<<xsl:output method="html" indent="yes" />

<<!-- To get the Sever Name and Database Name 
entered by the User --> <<xsl:param 
name="ServerName" /> <<xsl:param name="DB" />
<<!-- End -->

<<xsl:template match="dxl:database">
<<html>
<<head>
<<title>Scheduled Agent Details<</title>
<</head>
<<body>
<table border="0" width="100%">
<tr>
<td align="center">
<b>
Details of Scheduled Agents (Enabled) in the Database<br/>
<xsl:value-of select="$ServerName" 
/><xsl:text>/</xsl:text><xsl:value-of select="$DB" />
</b>
</td>
</tr>
</table>
<br/><br/>
<table border="1" width="100%">   
<tr>
<th align="center">Agent Name</th>
<th align="center">Scheduled Type</th>
<th align="center">Agent Last Run</th>
</tr>
<xsl:apply-templates select="dxl:agent" />
</table>
</body>
</html>

</xsl:template>

<xsl:template match="dxl:agent">
  <xsl:param name="lastrun" 
select="dxl:rundata/dxl:agentrun/dxl:datetime" />
  <xsl:param name="scheduleType" 
select="dxl:trigger/dxl:schedule/@type" />
  <xsl:param name="lastruntime" 
select="substring-after($lastrun,'T')" />
  <xsl:param name="lastrunzone" 
select="substring-after($lastrun,',')" />
  <xsl:variable name="str-length" 
select="string-length($lastrunzone)" />
  <xsl:variable name="timezone">
 <xsl:choose>
<xsl:when test="$str-length = '7' ">
<xsl:value-of select="concat(substring
($lastrunzone,3,3), ':', substring($lastrunzone,6,2))" />
</xsl:when>
<xsl:when test="$str-length = '5' ">
<xsl:value-of select="concat(substring
($lastrunzone,3,3), ':00')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$lastrunzone" />
</xsl:otherwise>
      </xsl:choose>
  </xsl:variable>
<tr>
<td><xsl:value-of select="@name" /></td>
<td>
<!-- <xsl:value-of select=
"dxl:trigger/dxl:schedule/@type" /> -->
<xsl:choose>
<xsl:when test="$scheduleType = 
'daily'" >Daily </xsl:when>
<xsl:when test="$scheduleType = 
'weekly'">Weekly </xsl:when>
<xsl:when test="$scheduleType = 
'monthly'">Monthly </xsl:when>
<xsl:when test="$scheduleType = 
'never'">Never </xsl:when>
<xsl:otherwise>More than once
 a day </xsl:otherwise>
</xsl:choose>
</td>
<td>
<xsl:choose>
<xsl:when test="$lastrun != '' " >
<xsl:value-of select="concat(substring
($lastrun,7,2),'/',substring($lastrun,5,2),'/',
substring($lastrun,1,4),
' Time ', substring($lastruntime,1,2), ':',
substring($lastruntime,3,2), 
':',substring($lastruntime,5,2), '.', 
substring($lastruntime,8,2), 
' Zone ', $timezone )" />
</xsl:when>
<xsl:otherwise>---</xsl:otherwise>
</xsl:choose>  
    </td>
 </tr> 
</xsl:template>
</xsl:stylesheet>
  1. Create a LotusScript agent called "ScheduledAgentStatus," and copy the following code.
Option Public
Option Explicit
%INCLUDE "LSCONST"

Sub Initialize
 
On Error Goto oops

Dim session As New NotesSession
Dim servername As String
Dim dbstring As String
Dim db As NotesDatabase
Dim Out As String
Dim filenum As Integer
Dim filename As String
Dim agent As NotesAgent
Dim stream As NotesStream
Dim nc As NotesNoteCollection
Dim exporter As NotesDXLExporter
Dim path As String
Dim nccount As Integer
Dim currdb As NotesDatabase
Dim xslview As NotesView
Dim xsldoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim stylesheet As NotesStream
Dim transformer As NotesXSLTransformer  
Dim htmlout As NotesStream

Set currdb = session.CurrentDatabase

Server:
servername = Inputbox$("Enter the 
Server Name", "Server Name", "")
Database:  
dbstring = Inputbox$("Enter the complete 
path of the Database", "Database Path", "")

If dbstring <> "" Then   
Set db = New NotesDatabase(servername, dbstring)
If db.IsOpen  Then
path = "C:"
filename = servername & "-" & Left(db.FileName, 
Len(db.FileName) - 3) 
   
Set nc = db.CreateNoteCollection(False)
Call nc.BuildCollection 
 
nccount = nc.Count

Forall a In db.Agents
If a.Trigger = TRIGGER_SCHEDULED Then
Set agent = a
If agent.IsEnabled Then
Call nc.Add(agent)
End If
End If
End Forall

If nc.Count > 0 Then    
Set stream = session.CreateStream
If Not stream.Open(path & filename & "dxl") Then
Messagebox "Cannot open " & filename & "dxl",, "Error"
Exit Sub
End If
Call stream.Truncate
Set exporter = session.CreateDXLExporter(nc, stream)
exporter.OutputDOCTYPE = False
Call exporter.Process       

If nc.Count - nccount > 0 Then
Messagebox Cstr(nc.Count - nccount ) 
& "  Enabled Scheduled  Agents found", , _
filename
End If   

Set xslview = currdb.GetView("XSLSheets")
Set xsldoc = xslview.GetDocumentByKey
("ScheduledAgentDetails", True)
Set rtitem = xsldoc.GetFirstItem("XSLBody")
Set stylesheet = session.CreateStream
stylesheet.WriteText(rtitem.GetUnformattedText())   
    
If Dir$(path & filename & "html",16) <> "" Then
Kill path & filename & "html"    
End If
  
Set htmlout = session.CreateStream
Call htmlout.Open(path & filename & "html")
 
Set transformer=session.CreateXSLTransformer
(stream, stylesheet, htmlout)   
Call transformer.AddParameter("ServerName", servername)
Call transformer.AddParameter("DB", dbstring)
Call transformer.Process
Else
Messagebox "Scheduled Agents (Enabled) not 
found in the specified Database"
Exit Sub
End If
Else
Messagebox "Specified database " & 
servername & "/" & dbstring & " doesnot exists."
Exit Sub
End If  
Else
If Messagebox("Invalid Database path! 
Do you want to try again?", _
MB_YESNO + MB_ICONQUESTION) = 
IDYES Then Goto _
Database
Exit Sub  
End If
Goto done

oops:
Messagebox " Error " & Error() & " at " & Erl()
done:
Messagebox " File " &  path & filename & 
"html" & " created successfully"
End Sub

Note: This agent is designed for use with Lotus Notes and Domino only. In this agent, inputbox will prompt the Lotus Notes user to obtain details of the complete path for which the "Status of Enabled Scheduled Agent(s)" is known for the Lotus Domino server and Lotus Notes database.

If the specified Lotus Notes database exists, it will create the DXL for the Lotus Notes database in C://. Using the created DXL and the "ScheduledAgentDetails style sheet" creates the HTML file in C:// with the scheduled agent(s) status.

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Gowri MJ. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

This was last published in May 2008

Dig Deeper on Lotus Notes Domino Agents

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close