Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #170 Enhance ConnectorStore loading system #176

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,24 @@ This is a multi-module project:
* **/**: The root (parent of all submodules)
* **metricshub-engine**: The brain, the heart of this project. It houses the core logic and essential functionalities that power the entire system.
* **metricshub-agent**: The MetricsHub Agent module includes a Command-Line Interface (CLI) and is responsible for interacting with the MetricsHub engine. It acts as an entry point, collecting and transmitting data to the OpenTelemetry Collector.
* **metricshub-classloader-agent**: Manages class loading for extensions, ensuring that they are loaded correctly within the JVM.
* **metricshub-ipmi-extension**: Provides support for the Intelligent Platform Management Interface (IPMI) to monitor and manage hardware at the firmware level.
* **metricshub-oscommand-extension**: Allows execution of OS-level commands and scripts to gather metrics and other data from the operating system.
* **metricshub-snmp-extension-common**: Contains common functionalities and utilities used by SNMP-based extensions.
* **metricshub-snmp-extension**: Enables Simple Network Management Protocol (SNMP) for monitoring and managing network devices.
* **metricshub-snmpv3-extension**: Adds support for SNMPv3, which includes enhanced security features like authentication and encryption.
* **metricshub-win-extension-common**: Contains common functionalities and utilities used by Windows-specific extensions.
* **metricshub-wmi-extension**: Provides support for Windows Management Instrumentation (WMI) to gather detailed information about Windows systems.
* **metricshub-winrm-extension**: Enables the use of Windows Remote Management (WinRM) for remote management and monitoring of Windows-based systems.
* **metricshub-wbem-extension**: Supports the Web-Based Enterprise Management (WBEM) standard for accessing management information.
* **metricshub-hardware**: Hardware Energy and Sustainability module, dedicated to managing and monitoring hardware-related metrics, focusing on energy consumption and sustainability aspects.
* **metricshub-it-common**: Contains common code and utilities used by integration tests across various modules.
* **metricshub-windows**: Builds the `.zip` package for MetricsHub on Windows platforms.
* **metricshub-linux**: Builds the `.tar.gz` package of MetricsHub on Linux platforms.
* **metricshub-doc**: Houses the documentation for MetricsHub.

> [!TIP]
> Looking for connectors? Check the [MetricsHub Community Connectors](https://github.com/sentrysoftware/metricshub-community-connectors) repository.

## How to build the Project

Expand Down
50 changes: 49 additions & 1 deletion metricshub-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,55 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metricshub-engine</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metricshub-snmp-extension</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metricshub-oscommand-extension</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metricshub-ipmi-extension</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metricshub-http-extension</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metricshub-wmi-extension</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metricshub-wbem-extension</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metricshub-winrm-extension</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<!-- Log4j2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down Expand Up @@ -274,7 +323,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.2</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public void build(final String alternateConfigFile, final boolean createConnecto
pid = findPid();

if (createConnectorStore) {
// Parse the connector store
connectorStore = new ConnectorStore(ConfigHelper.getSubDirectory("connectors", false));
connectorStore = ConfigHelper.buildConnectorStore(extensionManager);
}

// Initialize agent information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1207,4 +1207,26 @@ public static ExtensionManager loadExtensionManager() {
throw new IllegalStateException("Cannot load extensions.", e);
}
}

/**
* Constructs and populates a {@link ConnectorStore} by aggregating connector
* stores from various extensions managed by the provided {@link ExtensionManager}
* and from a specific subdirectory defined for connectors. This method first
* aggregates all extension-based connector stores into one central store and
* then adds additional connectors found in a designated subdirectory.
*
* @param extensionManager The manager responsible for handling all
* extension-based connector stores.
* @return A fully populated {@link ConnectorStore} containing connectors from
* various sources.
*/
public static ConnectorStore buildConnectorStore(final ExtensionManager extensionManager) {
// Get extension connector stores
final ConnectorStore connectorStore = extensionManager.aggregateExtensionConnectorStores();

// Parse and add connectors from a specific subdirectory
connectorStore.addMany(new ConnectorStore(getSubDirectory("connectors", false)).getStore());

return connectorStore;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public Integer call() throws Exception {
// First, process special "list" option
if (listConnectors) {
return listAllConnectors(
new ConnectorStore(ConfigHelper.getSubDirectory("connectors", false)),
ConfigHelper.buildConnectorStore(CliExtensionManager.getExtensionManagerSingleton()),
spec.commandLine().getOut()
);
}
Expand Down Expand Up @@ -263,7 +263,7 @@ public Integer call() throws Exception {
// Create the TelemetryManager using the connector store and the host configuration created above.
final TelemetryManager telemetryManager = TelemetryManager
.builder()
.connectorStore(new ConnectorStore(ConfigHelper.getSubDirectory("connectors", false)))
.connectorStore(ConfigHelper.buildConnectorStore(CliExtensionManager.getExtensionManagerSingleton()))
.hostConfiguration(hostConfiguration)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.sentrysoftware.metricshub.agent.config.ConnectorVariables;
import org.sentrysoftware.metricshub.agent.config.ResourceConfig;
import org.sentrysoftware.metricshub.agent.config.ResourceGroupConfig;
import org.sentrysoftware.metricshub.agent.extension.SnmpTestExtension;
import org.sentrysoftware.metricshub.agent.helper.OtelSdkConfigConstants;
import org.sentrysoftware.metricshub.engine.common.helpers.MapHelper;
import org.sentrysoftware.metricshub.engine.connector.model.common.HttpMethod;
Expand All @@ -44,13 +43,14 @@
import org.sentrysoftware.metricshub.engine.connector.model.monitor.task.source.HttpSource;
import org.sentrysoftware.metricshub.engine.extension.ExtensionManager;
import org.sentrysoftware.metricshub.engine.telemetry.TelemetryManager;
import org.sentrysoftware.metricshub.extension.snmp.SnmpExtension;

class AgentContextTest {

// Initialize the extension manager required by the agent context
final ExtensionManager extensionManager = ExtensionManager
.builder()
.withProtocolExtensions(List.of(new SnmpTestExtension()))
.withProtocolExtensions(List.of(new SnmpExtension()))
.build();

@Test
Expand Down

This file was deleted.

This file was deleted.

Loading