com.mccrory.scott.spumoni
Class StatsCollector

java.lang.Object
  |
  +--com.mccrory.scott.spumoni.StatsCollector
All Implemented Interfaces:
fr.dyade.jdring.AlarmListener, OidHandler

public class StatsCollector
extends java.lang.Object
implements fr.dyade.jdring.AlarmListener, OidHandler

Responsible for obtaining system statistics and storing them in a data file. This is typically done using our main() entry point or manually as such:

 try {
     StatsCollector sc = new StatsCollector(args);
     sc.scheduleRuns();
 }
 catch (Exception e) {
     e.printStackTrace();
     System.exit(1);
 }
 

Version:
CVS $Id: StatsCollector.java,v 1.30 2002/08/04 22:04:53 smccrory Exp $
Author:
Scott McCrory.

Constructor Summary
StatsCollector(java.lang.String[] args)
          StatsCollector constructor.
 
Method Summary
 java.lang.Object clone()
          We override the clone method here to prevent cloning of our class.
 void collectStats()
          Collect all of the stats and write them to the data file.
 StatsProgramList getCollectedStats()
          Returns an object with only the COLLECTED statistics.
 void handleAlarm(fr.dyade.jdring.AlarmEntry entry)
          Invoked when a JDring alarm is triggered.
 org.opennms.protocols.snmp.SnmpVarBind handleGet(org.opennms.protocols.snmp.SnmpVarBind varBind)
          Handles SNMP GET PDUs.
 org.opennms.protocols.snmp.SnmpVarBind handleGetbulk(org.opennms.protocols.snmp.SnmpVarBind varBind)
          Handles SNMP GETBULK PDUs.
 org.opennms.protocols.snmp.SnmpVarBind handleGetnext(org.opennms.protocols.snmp.SnmpVarBind varBind)
          Handles SNMP GETNEXT PDUs.
 org.opennms.protocols.snmp.SnmpVarBind handleInform(org.opennms.protocols.snmp.SnmpVarBind varBind)
          Handles SNMP INFORM PDUs.
 org.opennms.protocols.snmp.SnmpVarBind handleReport(org.opennms.protocols.snmp.SnmpVarBind varBind)
          Handles SNMP REPORT PDUs.
 org.opennms.protocols.snmp.SnmpVarBind handleResponse(org.opennms.protocols.snmp.SnmpVarBind varBind)
          Handles SNMP RESPONSE PDUs.
 org.opennms.protocols.snmp.SnmpVarBind handleSet(org.opennms.protocols.snmp.SnmpVarBind varBind)
          Handles SNMP SET PDUs.
 org.opennms.protocols.snmp.SnmpVarBind handleTrap(org.opennms.protocols.snmp.SnmpVarBind varBind)
          Handles SNMP TRAP PDUs.
 org.opennms.protocols.snmp.SnmpVarBind handleV2Trap(org.opennms.protocols.snmp.SnmpVarBind varBind)
          Handles SNMP V2TRAP PDUs.
static void main(java.lang.String[] args)
          Starts the Spumoni stats collection according to the prefs files' specs.
 void scheduleRuns()
          Run once or schedule ourself on a new alarm manager to run periodically.
 void sendSnmpTrap(java.lang.String oid, java.lang.String message)
          Sends an SNMP trap if all of the required data and conditions are OK.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatsCollector

public StatsCollector(java.lang.String[] args)
               throws java.lang.ExceptionInInitializerError
StatsCollector constructor. We do the following things because they have to only be performed once and are tightly coupled to the creation of the object.

Parameters:
args - an array of command-line arguments
Throws:
java.lang.ExceptionInInitializerError - thrown if a problem occurs
Method Detail

clone

public final java.lang.Object clone()
                             throws java.lang.CloneNotSupportedException
We override the clone method here to prevent cloning of our class.

Overrides:
clone in class java.lang.Object
Returns:
Nothing ever really returned since we throw a CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException - To indicate cloning is not allowed

collectStats

public void collectStats()
Collect all of the stats and write them to the data file. This is typically performed by our main() method, either once or periodically as specified by global.xml. See main() for usage.


getCollectedStats

public StatsProgramList getCollectedStats()
Returns an object with only the COLLECTED statistics. This is done by returning a StatsProgramList object which in turn contains StatsProgram (containing StatsValue) objects.

Returns:
a StatsProgramList object containing the collected statistics.

handleAlarm

public void handleAlarm(fr.dyade.jdring.AlarmEntry entry)
Invoked when a JDring alarm is triggered.

Specified by:
handleAlarm in interface fr.dyade.jdring.AlarmListener
Parameters:
entry - The JDring AlarmEntry which has been triggered.

main

public static void main(java.lang.String[] args)
Starts the Spumoni stats collection according to the prefs files' specs.

Parameters:
args - an array of command-line arguments

scheduleRuns

public void scheduleRuns()
Run once or schedule ourself on a new alarm manager to run periodically.


sendSnmpTrap

public void sendSnmpTrap(java.lang.String oid,
                         java.lang.String message)
Sends an SNMP trap if all of the required data and conditions are OK.

Parameters:
oid - The SNMP OID of the triggering value
message - A message about the trap

handleGet

public org.opennms.protocols.snmp.SnmpVarBind handleGet(org.opennms.protocols.snmp.SnmpVarBind varBind)
Handles SNMP GET PDUs.

Specified by:
handleGet in interface OidHandler
Parameters:
varBind - The request SnmpVarBind
Returns:
The response SnmpVarBind.

handleGetbulk

public org.opennms.protocols.snmp.SnmpVarBind handleGetbulk(org.opennms.protocols.snmp.SnmpVarBind varBind)
Handles SNMP GETBULK PDUs.

Specified by:
handleGetbulk in interface OidHandler
Parameters:
varBind - The request SnmpVarBind
Returns:
The response SnmpVarBind.

handleGetnext

public org.opennms.protocols.snmp.SnmpVarBind handleGetnext(org.opennms.protocols.snmp.SnmpVarBind varBind)
Handles SNMP GETNEXT PDUs.

Specified by:
handleGetnext in interface OidHandler
Parameters:
varBind - The request SnmpVarBind
Returns:
The response SnmpVarBind.

handleInform

public org.opennms.protocols.snmp.SnmpVarBind handleInform(org.opennms.protocols.snmp.SnmpVarBind varBind)
Handles SNMP INFORM PDUs.

Specified by:
handleInform in interface OidHandler
Parameters:
varBind - The request SnmpVarBind
Returns:
The response SnmpVarBind.

handleReport

public org.opennms.protocols.snmp.SnmpVarBind handleReport(org.opennms.protocols.snmp.SnmpVarBind varBind)
Handles SNMP REPORT PDUs.

Specified by:
handleReport in interface OidHandler
Parameters:
varBind - The request SnmpVarBind
Returns:
The response SnmpVarBind.

handleResponse

public org.opennms.protocols.snmp.SnmpVarBind handleResponse(org.opennms.protocols.snmp.SnmpVarBind varBind)
Handles SNMP RESPONSE PDUs.

Specified by:
handleResponse in interface OidHandler
Parameters:
varBind - The request SnmpVarBind
Returns:
The response SnmpVarBind.

handleSet

public org.opennms.protocols.snmp.SnmpVarBind handleSet(org.opennms.protocols.snmp.SnmpVarBind varBind)
Handles SNMP SET PDUs.

Specified by:
handleSet in interface OidHandler
Parameters:
varBind - The request SnmpVarBind
Returns:
The response SnmpVarBind.

handleTrap

public org.opennms.protocols.snmp.SnmpVarBind handleTrap(org.opennms.protocols.snmp.SnmpVarBind varBind)
Handles SNMP TRAP PDUs.

Specified by:
handleTrap in interface OidHandler
Parameters:
varBind - The request SnmpVarBind
Returns:
The response SnmpVarBind.

handleV2Trap

public org.opennms.protocols.snmp.SnmpVarBind handleV2Trap(org.opennms.protocols.snmp.SnmpVarBind varBind)
Handles SNMP V2TRAP PDUs.

Specified by:
handleV2Trap in interface OidHandler
Parameters:
varBind - The request SnmpVarBind
Returns:
The response SnmpVarBind.


Copyright © 2002 Scott McCrory as part of the Spumoni project. All Rights Reserved.