Tip

Agent run info on the Web

See the state of agents by a browser. Do your scheduled agents run as they should? No need for designer client.

Simply put this code in a 'hidden' java agent in each database and call it by browser: Output is nicely displayed in html.
This agent shows when agent have been running

import lotus.domino.*;
import java.util.Vector;
import java.io.PrintWriter;
public class JavaAgent extends AgentBase {
 
  public void NotesMain() {
    try {
	Session session = getSession();
	AgentContext agentContext = 
	session.getAgentContext();
      // (Your code goes here) 
	PrintWriter pw = getAgentOutput();
     Database db = agentContext.getCurrentDatabase();
     Vector agents = db.getAgents();
     pw.println("<STYLE>BODY TD {font-family:arial; font-size:11} 
</STYLE><H1>AGENT INFO: " + db.getTitle() + " (" + db.getFilePath()
+ ")</H1>"); for (int i=0; i<agents.size(); i++) { Agent agent = (Agent)agents.elementAt(i); // target=""; // trigger=""; String target="", trigger=""; switch (agent.getTarget()) { case Agent.TARGET_ALL_DOCS: if (target=="") target = "all documents"; case Agent.TARGET_ALL_DOCS_IN_VIEW: if (target=="") target = "all documents in view"; case Agent.TARGET_NEW_DOCS: if (target=="") target = "all new documents"; case Agent.TARGET_NEW_OR_MODIFIED_DOCS: if (target=="") target = "all new or modified documents"; case Agent.TARGET_NONE: if (target=="") target = "none"; case Agent.TARGET_SELECTED_DOCS: if (target=="") target = "selected documents"; case Agent.TARGET_UNREAD_DOCS_IN_VIEW: if (target=="") target = "unread documents in view"; case Agent.TARGET_RUN_ONCE: if (target=="") target = "run once";} switch (agent.getTrigger()) { case Agent.TRIGGER_AFTER_MAIL_DELIVERY: if (trigger=="") trigger = "after mail delivery"; case Agent.TRIGGER_BEFORE_MAIL_DELIVERY: if (trigger=="") trigger = "before new mail"; case Agent.TRIGGER_DOC_PASTED: if (trigger=="") trigger = "document pasted"; case Agent.TRIGGER_DOC_UPDATE: if (trigger=="") trigger = "document updated"; case Agent.TRIGGER_NONE: if (trigger=="") trigger = "none"; case Agent.TRIGGER_SCHEDULED: if (trigger=="") trigger = "scheduled"; case Agent.TRIGGER_MANUAL: if (trigger=="") trigger = "manual"; } DateTime date = agent.getLastRun(); pw.println("<TABLE CELLSPACING=1 CELLPADDING=2
WIDTH=100% ><TR BGCOLOR=#CCCCCC><TD WIDTH=100><B>Agent</B></TD><TD>"+agent.getName()
+"</TD></TR>"); if (agent.getLastRun() != null) { pw.println( "<TR VALIGN=TOP BGCOLOR=#EEEEEE><TD>last ran on</TD><TD>" ); pw.println(date.getDateOnly()+" at " + date.getTimeOnly()+"<BR>" ); } else { pw.println( "<TR VALIGN=TOP BGCOLOR=#EEEEEE><TD>hasn't run yet</TD><TD>" ); pw.println("<BR>" ); } pw.println( "<TR VALIGN=TOP BGCOLOR=#EEEEEE><TD>Signer</TD><TD>" ); pw.println(agent.getOwner() +"<BR>" ); pw.println( "<TR VALIGN=TOP BGCOLOR=#EEEEEE><TD>Enabled</TD><TD>" ); pw.println(agent.isEnabled() +"<BR>" ); pw.println( "<TR VALIGN=TOP BGCOLOR=#EEEEEE><TD>Webagent</TD><TD>" ); pw.println(agent.isWebAgent() +"<BR>" ); pw.println( "<TR VALIGN=TOP BGCOLOR=#EEEEEE><TD>Servername</TD><TD>" ); pw.println(agent.getServerName() +"<BR>" ); pw.println( "<TR VALIGN=TOP BGCOLOR=#EEEEEE><TD>Target</TD><TD>" ); pw.println(target +"<BR>" ); pw.println( "<TR VALIGN=TOP BGCOLOR=#EEEEEE><TD>Trigger</TD><TD>" ); pw.println(trigger +"<BR>" ); pw.println("</TD></TR>"); } pw.println("</TABLE><BR>"); } catch(Exception e) { e.printStackTrace(); } } }

This was first published in November 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

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.