Home > Domino Tips > Developer > Agent > Verify scheduled agent status with Domino Extensible Language (DXL)
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

AGENT

Verify scheduled agent status with Domino Extensible Language (DXL)


Gowri MJ
05.06.2008
Rating: -2.47- (out of 5)


Lotus Notes, Domino, Workplace and WebSphere tips and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


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.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Agent
How to export data from a Lotus Notes database to a CSV file
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax
How to automatically create a backup copy of your Domino Directory
Export Lotus Notes documents to Microsoft Word via Internet Explorer
A bevy of Notes/Domino development tips
Best practices for using the Lotus Notes WebQuerySave agent
A flexible data export agent for Lotus Notes
A single form to view and edit any Lotus Notes document

Lotus Notes Domino Agents
Top 10 Lotus Notes Domino programming and development tips of 2007
How to export data from a Lotus Notes database to a CSV file
Must-know Lotus Notes Domino agents -- 10 tips in 10 minutes
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax
Troubleshooting a scheduled agent not running on a Global Notes Architecture (GNA) server
Can I stop Lotus Domino Server from transforming embedded images into attachments?
How to automatically create a backup copy of your Domino Directory
Export Lotus Notes documents to Microsoft Word via Internet Explorer

XML and Web Services for Lotus Notes Domino
Top 10 Lotus Notes Domino programming and development tips of 2007
A bevy of Notes/Domino development tips
Loading XML from JavaScript
How to apply XSL style sheets to XML views
Top 10 Notes/Domino developer tips of 2006
A smorgasbord of Notes/Domino development tips
Converting XML files into Lotus Notes documents
Finding the properties of a doclinked Lotus Notes document
How to override default Lotus Notes print settings
Workplace Forms add XML future to WebSphere-Domino environments

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts