com.cometway.httpd
Class LogViewerPage

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.ak.ServiceAgent
              extended by com.cometway.ak.RequestAgent
                  extended by com.cometway.httpd.LogViewerPage
All Implemented Interfaces:
AgentInterface, RequestAgentInterface, HasStateMachineModel, java.lang.Runnable

public class LogViewerPage
extends RequestAgent
implements java.lang.Runnable

This agent registers itself into the ServiceManager and accepts http requests to view information stored in log files. Given a directory, this agent will look for all the files in that directory and treat them as log files. The agent uses a mapping which provides information about how these files should be displayed. The logfile mapping maps a name to a text pattern. The agent will display the names and the matching lines of the log files.


Field Summary
 
Fields inherited from class com.cometway.ak.Agent
agent_id, agentController, CREATING_STATE, debugReporter, DESTROYED_STATE, DESTROYING_STATE, errorReporter, FAILED_STATE, printlnReporter, props, RUNNING_STATE, STARTING_STATE, STOPPED_STATE, STOPPING_STATE, warningReporter
 
Constructor Summary
LogViewerPage()
           
 
Method Summary
protected  java.lang.String convert(java.lang.String in)
          Converts a String to HTML text.
protected  java.lang.String getForm()
          Displays log file information in a form.
 void handleRequest(AgentRequest request)
          Handles request and gets log file information and displays as HTML data.
 void initProps()
          Initializes this agent's properties by providing default values for each of the following missing properties: "log_dir" specifies the directory where the log file is located (default: ./), "log_map_file" specifies the file to map the logs to (default: ./log.maps), "log_file_suffix" specifies the suffix of the log file (default: httpd.log), "check_interval" specifies the time between checks (default: 600000), "service_name" specifies the name to register this agent as with the Object Manager (default: /logviewer.agent), "is_logger_output" (default: TRUE), "max_show_log_length" (default: 50000), "show memory_usage" (default: false).
 void parseInfo(java.util.Hashtable matches, java.util.Hashtable patterns, boolean storeMatches)
          Parses log file information in hash table, searches for patterns and stores matches.
protected  void readLogMapping()
          Reads Log file Mappings and outputs maps read.
 void run()
          Runs log parsing routines.
 void start()
          Starts new thread, gets new logMaps, counts, names list and registers this service with the Object Manager.
 void stop()
          Unregisters this instance with the service manager using the service_name property.
 void updateLogCache()
           
 
Methods inherited from class com.cometway.ak.Agent
currentStateEquals, debug, destroy, error, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, toString, unregister, unregisterService, warning, warning
 
Methods inherited from class com.cometway.props.Props
addListener, append, copy, copyFrom, copyTo, decrementInteger, dump, enableListeners, enumerateKeys, format, getBoolean, getByteArray, getCharacter, getDate, getDate, getDateString, getDouble, getFloat, getHexString, getInteger, getKeys, getLong, getNextKey, getProperty, getProperty, getPropsContainer, getSize, getString, getString, getTokens, getTokens, getTrimmedString, getVector, hasProperty, incrementInteger, insertProps, loadProps, notifyPropsChanged, notifyPropsChangedIgnore, notifyPropsChangedIgnore, parse, propertyMatchesRegEx, readFromFile, regExPropertyMatches, removeAll, removeListener, removeProperty, resumeNotify, saveProps, set, setBoolean, setCharacter, setDefault, setDouble, setFloat, setInteger, setLong, setProperty, setProperty, setProperty, setPropsContainer, suspendNotify, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LogViewerPage

public LogViewerPage()
Method Detail

initProps

public void initProps()
Initializes this agent's properties by providing default values for each of the following missing properties: "log_dir" specifies the directory where the log file is located (default: ./), "log_map_file" specifies the file to map the logs to (default: ./log.maps), "log_file_suffix" specifies the suffix of the log file (default: httpd.log), "check_interval" specifies the time between checks (default: 600000), "service_name" specifies the name to register this agent as with the Object Manager (default: /logviewer.agent), "is_logger_output" (default: TRUE), "max_show_log_length" (default: 50000), "show memory_usage" (default: false).

Specified by:
initProps in interface AgentInterface
Overrides:
initProps in class Agent

start

public void start()
Starts new thread, gets new logMaps, counts, names list and registers this service with the Object Manager.

Specified by:
start in interface AgentInterface
Overrides:
start in class ServiceAgent

stop

public void stop()
Description copied from class: ServiceAgent
Unregisters this instance with the service manager using the service_name property.

Specified by:
stop in interface AgentInterface
Overrides:
stop in class ServiceAgent

handleRequest

public void handleRequest(AgentRequest request)
Handles request and gets log file information and displays as HTML data.

Specified by:
handleRequest in interface RequestAgentInterface

convert

protected java.lang.String convert(java.lang.String in)
Converts a String to HTML text.


getForm

protected java.lang.String getForm()
Displays log file information in a form.


run

public void run()
Runs log parsing routines.

Specified by:
run in interface java.lang.Runnable

updateLogCache

public void updateLogCache()

parseInfo

public void parseInfo(java.util.Hashtable matches,
                      java.util.Hashtable patterns,
                      boolean storeMatches)
Parses log file information in hash table, searches for patterns and stores matches.


readLogMapping

protected void readLogMapping()
Reads Log file Mappings and outputs maps read.