Class TelemetryManager

java.lang.Object
org.sentrysoftware.metricshub.engine.telemetry.TelemetryManager

public class TelemetryManager extends Object
The `TelemetryManager` class manages telemetry-related operations, monitors, and strategies.
  • Constructor Details

    • TelemetryManager

      public TelemetryManager()
  • Method Details

    • run

      public void run(IStrategy... strategies)
      Executes the given IStrategy instances.
      Parameters:
      strategies - The IStrategy instances to be executed.
    • toJson

      public String toJson()
      Convert monitors to JSON format
      Returns:
      String value
    • getVo

      public MonitorsVo getVo()
      Get the current monitors as MonitorsVo
      Returns:
      MonitorsVo object
    • findMonitorByTypeAndId

      public Monitor findMonitorByTypeAndId(String type, String id)
      Finds a monitor using its type and its id attribute
      Parameters:
      type - monitor's type
      id - monitor's id
      Returns:
      Monitor instance
    • findMonitorById

      public Monitor findMonitorById(String id, Map<String,Monitor> monitorsMap)
      Finds a monitor using its id attribute
      Parameters:
      id - monitorId
      monitorsMap - a map of monitors having the same type
      Returns:
      Monitor instance
    • findMonitorsByType

      public Map<String,Monitor> findMonitorsByType(String type)
      Finds a monitor using its type
      Parameters:
      type - type of the monitor. E.g. host, enclosure, network, etc.
      Returns:
      Monitor instance
    • addNewMonitor

      public Monitor addNewMonitor(@NonNull @NonNull Monitor monitor, @NonNull @NonNull String monitorType, @NonNull @NonNull String id)
      Add a new monitor instance
      Parameters:
      monitor - Monitor instance we wish to add
      monitorType - The type of the monitor
      id - The monitor's identifier
      Returns:
      added Monitor instance
    • getEndpointHostMonitor

      public Monitor getEndpointHostMonitor()
      Return the root host monitor instance
      Returns:
      Monitor object representing the root instance
    • getHostname

      public String getHostname()
      Return the configured hostname
      Returns:
      String value
    • findParentMonitor

      public Monitor findParentMonitor(Monitor monitor)
      This method finds the parent of a given monitor
      Parameters:
      monitor - a given monitor
      Returns:
      the parent monitor which is a Monitor instance
    • findMonitorById

      public Monitor findMonitorById(String monitorId)
      This method finds a monitor having a given id regardless of its type
      Parameters:
      monitorId - monitor id
      Returns:
      Monitor
    • isConnectorStatusOk

      public boolean isConnectorStatusOk(Monitor currentMonitor)
      This method checks whether a connector status was set to "ok"
      Parameters:
      currentMonitor - the current monitor
      Returns:
      boolean whether the connector status is ok
    • getHostname

      public String getHostname(List<Class<? extends IConfiguration>> configurations)
      Retrieves the hostname from the provided list of configuration classes, considering the order of the list. This method searches through the user's configurations, as specified by the list of `IConfiguration` classes, to find and return the first non-null hostname. The order of the configurations in the list is significant. For example, calling `getHostname(SshConfiguration.class, OsCommandConfiguration.class)` may yield a different result compared to `getHostname(OsCommandConfiguration.class, SshConfiguration.class)` if both configurations exist. If the list of configurations is empty or none of the configurations provide a non-null hostname, the method will return the telemetry manager's hostname as a fallback.
      Parameters:
      configurations - A list of `IConfiguration` classes to search for the hostname.
      Returns:
      the first non-null hostname from the provided configurations, or the telemetry manager's hostname if none are found.
    • getEmbeddedFiles

      public Map<Integer,EmbeddedFile> getEmbeddedFiles(String connectorId)
      Retrieves a map of EmbeddedFile objects indexed by their unique integer identifiers, associated with a specific connector identified by connectorId.
      Parameters:
      connectorId - The unique identifier of the connector whose embedded files are to be retrieved.
      Returns:
      A non-null Map of integer IDs to EmbeddedFile instances.