network.detectors
Class ProcessMonitoringEventDetector

java.lang.Object
  extended bynetwork.detectors.EventDetector
      extended bynetwork.detectors.ProcessMonitoringEventDetector
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable

public class ProcessMonitoringEventDetector
extends EventDetector
implements java.io.Serializable

Detects the processes that are currently running. This is accomplished by running the ps command

See Also:
Serialized Form

Field Summary
 
Fields inherited from class network.detectors.EventDetector
agentURN, cred, dbModule, eventIDGenerator, eventTable, host, localTriggeringEvents, remoteTriggeringEvents, reportTable
 
Constructor Summary
ProcessMonitoringEventDetector(ConfigObject configObj)
          Creates an instance of ProcessMonitoringEventDetector with the default triggering events
 
Method Summary
 java.util.Vector executeSystemCommand(java.lang.String command)
          Executes a command.
 CPUMonitorEvent generateCPUMonitorEvent(Event triggeredEvent)
          Executes the ps command, parses the output, and returns a CPUMonitorEvent based on the output of the ps command
 java.util.Vector generateEvent(Event triggeredEvent)
          Runs the ps command and parses the output.
 java.util.Vector generateProcessMonitorEvent(Event triggeredEvent)
          Generates a ProcessMonitoringEvent for each running process.
 java.lang.String getGeneratingEventClassName()
          Returns the name of the event this detector triggers
 java.util.Vector parseCommandResults(java.util.Vector results)
          This function parses the output from the command in this class' generateEvent method and returns a vector of Object arrays that represents the elements of the string seperated.
static long stringTimeToMillis(java.lang.String date)
          takes in the string date from the ps command and returns the millis this method expects commands in the following format 28-19:56:08 or 19:56:08 or 56:08
 
Methods inherited from class network.detectors.EventDetector
getAlarmLevel, getAlertLevel, getLocalTriggeringEventClassNames, getRemoteTriggeringEventClassNames, getSynchronizer, InitializeFields, modifyDetector, populatePatterns, printRunningThreads, run, setAgentURN, setAlarmLevel, setAlertLevel, setDB, setEventIDGenerator, setEventTable, setLocalTriggeringEvents, setRemoteTriggeringEvents, setReportTable, stopDetector, switchOffPrintRunningThreads
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessMonitoringEventDetector

public ProcessMonitoringEventDetector(ConfigObject configObj)
Creates an instance of ProcessMonitoringEventDetector with the default triggering events

Method Detail

getGeneratingEventClassName

public java.lang.String getGeneratingEventClassName()
Returns the name of the event this detector triggers

Specified by:
getGeneratingEventClassName in class EventDetector
Returns:
A string containing the name of the event this detector triggers

executeSystemCommand

public java.util.Vector executeSystemCommand(java.lang.String command)
Executes a command. Parses the output of the command by line.

Parameters:
command - The command line to execute
Returns:
A vector of string, each corresponding to a single line of the program output

parseCommandResults

public java.util.Vector parseCommandResults(java.util.Vector results)
This function parses the output from the command in this class' generateEvent method and returns a vector of Object arrays that represents the elements of the string seperated.

Parameters:
results - A vector of strings containing the results of running a ps command
Returns:
A vector containing instance of ProcessData. Each element contains information for one process

generateCPUMonitorEvent

public CPUMonitorEvent generateCPUMonitorEvent(Event triggeredEvent)
Executes the ps command, parses the output, and returns a CPUMonitorEvent based on the output of the ps command

Parameters:
triggeredEvent - The event that triggers this detector
Returns:
A CPUMonitorEvent containing information from the ps command

generateEvent

public java.util.Vector generateEvent(Event triggeredEvent)
Runs the ps command and parses the output. Creates an event for each running process

Specified by:
generateEvent in class EventDetector
Parameters:
triggeredEvent - The event that triggers this detector
Returns:
A vector of events. Each element corresponds to a running process.

generateProcessMonitorEvent

public java.util.Vector generateProcessMonitorEvent(Event triggeredEvent)
Generates a ProcessMonitoringEvent for each running process. Processes are taken from the given CPUMonitorEvent

Parameters:
triggeredEvent - A CPUMonitorEvent that contains information about currently running processes
Returns:
A vector of ProcessMonitoringEvents. Each entry corresponds to a process.

stringTimeToMillis

public static long stringTimeToMillis(java.lang.String date)
takes in the string date from the ps command and returns the millis this method expects commands in the following format 28-19:56:08 or 19:56:08 or 56:08

Parameters:
date - The date string to parse
Returns:
The millisecond representation of the date