Autopsy  4.18.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.sleuthkit.autopsy.healthmonitor.HealthMonitor Class Reference

Inherits PropertyChangeListener.

Classes

class  DatabaseTimingResult
 
class  PeriodicHealthMonitorTask
 
class  TimingInfo
 
class  UserData
 
enum  UserEvent
 

Public Member Functions

void propertyChange (PropertyChangeEvent evt)
 

Static Public Member Functions

static TimingMetric getTimingMetric (String name)
 
static void submitNormalizedTimingMetric (TimingMetric metric, long normalization)
 
static void submitTimingMetric (TimingMetric metric)
 

Private Member Functions

 HealthMonitor () throws HealthMonitorException
 
synchronized void activateMonitorLocally () throws HealthMonitorException
 
void addTimingMetric (TimingMetric metric) throws HealthMonitorException
 
void addUserEvent (UserEvent eventType)
 
Connection connect () throws HealthMonitorException
 
void createDatabase () throws HealthMonitorException
 
boolean databaseExists () throws HealthMonitorException
 
boolean databaseIsInitialized () throws HealthMonitorException
 
synchronized void deactivateMonitorLocally () throws HealthMonitorException
 
void gatherTimerBasedMetrics () throws HealthMonitorException
 
CoordinationService.Lock getExclusiveDbLock () throws HealthMonitorException
 
boolean getGlobalEnabledStatusFromDB () throws HealthMonitorException
 
CoordinationService.Lock getSharedDbLock () throws HealthMonitorException
 
CaseDbSchemaVersionNumber getVersion () throws HealthMonitorException
 
void initializeDatabaseSchema () throws HealthMonitorException
 
void performDatabaseQuery () throws HealthMonitorException
 
void setGlobalEnabledStatusInDB (boolean status) throws HealthMonitorException
 
void setupConnectionPool () throws HealthMonitorException
 
void shutdownConnections () throws HealthMonitorException
 
synchronized void startTimer ()
 
synchronized void stopTimer ()
 
void upgradeDatabaseSchema () throws HealthMonitorException
 
void writeCurrentStateToDatabase () throws HealthMonitorException
 

Static Private Member Functions

static void recordMetrics ()
 

Private Attributes

BasicDataSource connectionPool = null
 
CaseDbConnectionInfo connectionSettingsInUse = null
 
ScheduledThreadPoolExecutor healthMonitorOutputTimer
 
String hostName
 
final Map< String, TimingInfotimingInfoMap
 
final List< UserData > userInfoList
 
final String username
 

Static Private Attributes

static final int CONN_POOL_SIZE = 10
 
static final CaseDbSchemaVersionNumber CURRENT_DB_SCHEMA_VERSION = new CaseDbSchemaVersionNumber(1, 2)
 
static final String DATABASE_NAME = "HealthMonitor"
 
static final long DATABASE_WRITE_INTERVAL = 60
 
static HealthMonitor instance
 
static final AtomicBoolean isEnabled = new AtomicBoolean(false)
 
static final Logger logger = Logger.getLogger(HealthMonitor.class.getName())
 

Detailed Description

Class for recording data on the health of the system.

For timing data: Modules will call getTimingMetric() before the code to be timed to get a TimingMetric object Modules will call submitTimingMetric() with the obtained TimingMetric object to log it

Definition at line 63 of file HealthMonitor.java.

Constructor & Destructor Documentation

org.sleuthkit.autopsy.healthmonitor.HealthMonitor.HealthMonitor ( ) throws HealthMonitorException
private

Member Function Documentation

synchronized void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.activateMonitorLocally ( ) throws HealthMonitorException
private
void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.addTimingMetric ( TimingMetric  metric) throws HealthMonitorException
private

Add the timing metric data to the map.

Parameters
metricThe metric to add. stopTiming() should already have been called.

Definition at line 409 of file HealthMonitor.java.

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.submitNormalizedTimingMetric(), and org.sleuthkit.autopsy.healthmonitor.HealthMonitor.submitTimingMetric().

void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.addUserEvent ( UserEvent  eventType)
private

Add a user event to the list.

Parameters
eventType

Definition at line 433 of file HealthMonitor.java.

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.propertyChange().

Connection org.sleuthkit.autopsy.healthmonitor.HealthMonitor.connect ( ) throws HealthMonitorException
private
void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.createDatabase ( ) throws HealthMonitorException
private

Create a new health monitor database.

Exceptions
HealthMonitorException

Definition at line 610 of file HealthMonitor.java.

References org.sleuthkit.autopsy.core.UserPreferences.getDatabaseConnectionInfo().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.activateMonitorLocally().

boolean org.sleuthkit.autopsy.healthmonitor.HealthMonitor.databaseExists ( ) throws HealthMonitorException
private

Check whether the health monitor database exists. Does not check the schema.

Returns
true if the database exists, false otherwise
Exceptions
HealthMonitorException

Definition at line 581 of file HealthMonitor.java.

References org.sleuthkit.autopsy.core.UserPreferences.getDatabaseConnectionInfo().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.activateMonitorLocally().

boolean org.sleuthkit.autopsy.healthmonitor.HealthMonitor.databaseIsInitialized ( ) throws HealthMonitorException
private

Test whether the database schema has been initialized. We do this by looking for the version number.

Returns
True if it has been initialized, false otherwise.
Exceptions
HealthMonitorException

Definition at line 707 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.connect().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.activateMonitorLocally().

synchronized void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.deactivateMonitorLocally ( ) throws HealthMonitorException
private

Deactivate the health monitor. This should only be used when disabling the monitor, not when Autopsy is closing. Clears out any metrics that haven't been written, stops the database write timer, and shuts down the connection pool.

Exceptions
HealthMonitorException

Definition at line 260 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.shutdownConnections().

void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.gatherTimerBasedMetrics ( ) throws HealthMonitorException
private

Collect metrics at a scheduled time.

Exceptions
HealthMonitorException

Definition at line 481 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.performDatabaseQuery().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.recordMetrics().

CoordinationService.Lock org.sleuthkit.autopsy.healthmonitor.HealthMonitor.getExclusiveDbLock ( ) throws HealthMonitorException
private

Get an exclusive lock for the health monitor database. Acquire this before creating, initializing, or updating the database schema.

Returns
The lock
Exceptions
HealthMonitorException

Definition at line 1270 of file HealthMonitor.java.

References org.sleuthkit.autopsy.coordinationservice.CoordinationService.getInstance(), org.sleuthkit.autopsy.coordinationservice.CoordinationService.CategoryNode.HEALTH_MONITOR, and org.sleuthkit.autopsy.coordinationservice.CoordinationService.tryGetExclusiveLock().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.activateMonitorLocally().

boolean org.sleuthkit.autopsy.healthmonitor.HealthMonitor.getGlobalEnabledStatusFromDB ( ) throws HealthMonitorException
private

Read the enabled status from the database. Check that the health monitor database exists before calling this.

Returns
true if the database is enabled, false otherwise
Exceptions
HealthMonitorException

Definition at line 813 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.connect().

CoordinationService.Lock org.sleuthkit.autopsy.healthmonitor.HealthMonitor.getSharedDbLock ( ) throws HealthMonitorException
private
static TimingMetric org.sleuthkit.autopsy.healthmonitor.HealthMonitor.getTimingMetric ( String  name)
static

Get a metric that will measure the time to execute a section of code. Call this before the section of code to be timed and then submit it afterward using submitTimingMetric(). This method is safe to call regardless of whether the health monitor is enabled.

Parameters
nameA short but descriptive name describing the code being timed. This name will appear in the UI.
Returns
The TimingMetric object

Definition at line 353 of file HealthMonitor.java.

Referenced by org.sleuthkit.autopsy.modules.hashdatabase.HashDbIngestModule.calculateHashes(), org.sleuthkit.autopsy.keywordsearch.Server.connectToEmbeddedSolrServer(), org.sleuthkit.autopsy.keywordsearch.Server.connectToSolrServer(), and org.sleuthkit.autopsy.healthmonitor.HealthMonitor.performDatabaseQuery().

CaseDbSchemaVersionNumber org.sleuthkit.autopsy.healthmonitor.HealthMonitor.getVersion ( ) throws HealthMonitorException
private

Get the current schema version

Returns
the current schema version
Exceptions
HealthMonitorException

Definition at line 850 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.connect().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.activateMonitorLocally(), and org.sleuthkit.autopsy.healthmonitor.HealthMonitor.upgradeDatabaseSchema().

void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.initializeDatabaseSchema ( ) throws HealthMonitorException
private

Initialize the database.

Exceptions
HealthMonitorException

Definition at line 904 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.connect().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.activateMonitorLocally().

void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.performDatabaseQuery ( ) throws HealthMonitorException
private

Time a database query. Database queries are hard to test in normal processing because the time is so dependent on the size of the tables being queried. We use getImages here because every table it queries is the same size (one entry for each image) so we a) know the size of the tables and b) can use that table size to do normalization.

Exceptions
HealthMonitorException

Definition at line 449 of file HealthMonitor.java.

References org.sleuthkit.autopsy.casemodule.Case.getCurrentCaseThrows(), org.sleuthkit.autopsy.casemodule.Case.getSleuthkitCase(), org.sleuthkit.autopsy.healthmonitor.HealthMonitor.getTimingMetric(), and org.sleuthkit.autopsy.healthmonitor.HealthMonitor.submitNormalizedTimingMetric().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.gatherTimerBasedMetrics().

void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.propertyChange ( PropertyChangeEvent  evt)
static void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.recordMetrics ( )
staticprivate

Perform all periodic tasks: - Check if monitoring has been enabled / disabled in the database - Gather any additional metrics - Write current metric data to the database Do not run this from a new thread if the case/application is closing.

Definition at line 979 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.gatherTimerBasedMetrics(), and org.sleuthkit.autopsy.healthmonitor.HealthMonitor.writeCurrentStateToDatabase().

void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.setGlobalEnabledStatusInDB ( boolean  status) throws HealthMonitorException
private

Set the global enabled status in the database.

Exceptions
HealthMonitorException

Definition at line 833 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.connect().

void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.setupConnectionPool ( ) throws HealthMonitorException
private

Setup a connection pool for db connections.

Exceptions
HealthMonitorException

Definition at line 631 of file HealthMonitor.java.

References org.sleuthkit.autopsy.core.UserPreferences.getDatabaseConnectionInfo().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.connect().

void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.shutdownConnections ( ) throws HealthMonitorException
private

Shut down the connection pool

Exceptions
HealthMonitorException

Definition at line 665 of file HealthMonitor.java.

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.activateMonitorLocally(), and org.sleuthkit.autopsy.healthmonitor.HealthMonitor.deactivateMonitorLocally().

synchronized void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.startTimer ( )
private

Start the ScheduledThreadPoolExecutor that will handle the database writes.

Definition at line 275 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.stopTimer().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.HealthMonitor().

synchronized void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.stopTimer ( )
private

Stop the ScheduledThreadPoolExecutor to prevent further database writes.

Definition at line 286 of file HealthMonitor.java.

References org.sleuthkit.autopsy.coreutils.ThreadUtils.shutDownTaskExecutor().

Referenced by org.sleuthkit.autopsy.healthmonitor.HealthMonitor.startTimer().

static void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.submitNormalizedTimingMetric ( TimingMetric  metric,
long  normalization 
)
static

Submit the metric that was previously obtained through getTimingMetric(), incorporating a count that the time should be divided by. Call this immediately after the section of code being timed. This method is safe to call regardless of whether the health monitor is enabled.

Parameters
metricThe TimingMetric object obtained from getTimingMetric()
normalizationThe number to divide the time by (a zero here will be treated as a one)

Definition at line 390 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.addTimingMetric().

Referenced by org.sleuthkit.autopsy.modules.hashdatabase.HashDbIngestModule.calculateHashes(), and org.sleuthkit.autopsy.healthmonitor.HealthMonitor.performDatabaseQuery().

static void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.submitTimingMetric ( TimingMetric  metric)
static

Submit the metric that was previously obtained through getTimingMetric(). Call this immediately after the section of code being timed. This method is safe to call regardless of whether the health monitor is enabled.

Parameters
metricThe TimingMetric object obtained from getTimingMetric()

Definition at line 367 of file HealthMonitor.java.

References org.sleuthkit.autopsy.healthmonitor.HealthMonitor.addTimingMetric().

Referenced by org.sleuthkit.autopsy.modules.hashdatabase.HashDbIngestModule.calculateHashes(), org.sleuthkit.autopsy.keywordsearch.Server.connectToEmbeddedSolrServer(), and org.sleuthkit.autopsy.keywordsearch.Server.connectToSolrServer().

void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.upgradeDatabaseSchema ( ) throws HealthMonitorException
private
void org.sleuthkit.autopsy.healthmonitor.HealthMonitor.writeCurrentStateToDatabase ( ) throws HealthMonitorException
private

Member Data Documentation

final int org.sleuthkit.autopsy.healthmonitor.HealthMonitor.CONN_POOL_SIZE = 10
staticprivate

Definition at line 76 of file HealthMonitor.java.

BasicDataSource org.sleuthkit.autopsy.healthmonitor.HealthMonitor.connectionPool = null
private

Definition at line 77 of file HealthMonitor.java.

CaseDbConnectionInfo org.sleuthkit.autopsy.healthmonitor.HealthMonitor.connectionSettingsInUse = null
private

Definition at line 78 of file HealthMonitor.java.

final CaseDbSchemaVersionNumber org.sleuthkit.autopsy.healthmonitor.HealthMonitor.CURRENT_DB_SCHEMA_VERSION = new CaseDbSchemaVersionNumber(1, 2)
staticprivate

Definition at line 68 of file HealthMonitor.java.

final String org.sleuthkit.autopsy.healthmonitor.HealthMonitor.DATABASE_NAME = "HealthMonitor"
staticprivate
final long org.sleuthkit.autopsy.healthmonitor.HealthMonitor.DATABASE_WRITE_INTERVAL = 60
staticprivate

Definition at line 67 of file HealthMonitor.java.

ScheduledThreadPoolExecutor org.sleuthkit.autopsy.healthmonitor.HealthMonitor.healthMonitorOutputTimer
private

Definition at line 73 of file HealthMonitor.java.

String org.sleuthkit.autopsy.healthmonitor.HealthMonitor.hostName
private

Definition at line 79 of file HealthMonitor.java.

HealthMonitor org.sleuthkit.autopsy.healthmonitor.HealthMonitor.instance
staticprivate

Definition at line 71 of file HealthMonitor.java.

final AtomicBoolean org.sleuthkit.autopsy.healthmonitor.HealthMonitor.isEnabled = new AtomicBoolean(false)
staticprivate

Definition at line 70 of file HealthMonitor.java.

final Logger org.sleuthkit.autopsy.healthmonitor.HealthMonitor.logger = Logger.getLogger(HealthMonitor.class.getName())
staticprivate

Definition at line 65 of file HealthMonitor.java.

final Map<String, TimingInfo> org.sleuthkit.autopsy.healthmonitor.HealthMonitor.timingInfoMap
private
final List<UserData> org.sleuthkit.autopsy.healthmonitor.HealthMonitor.userInfoList
private
final String org.sleuthkit.autopsy.healthmonitor.HealthMonitor.username
private

Definition at line 80 of file HealthMonitor.java.


The documentation for this class was generated from the following file:

Copyright © 2012-2021 Basis Technology. Generated on: Thu Jul 8 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.