Skip to content

Commit

Permalink
Merge pull request #94 from sentrysoftware/feature/issue-80-remove-ha…
Browse files Browse the repository at this point in the history
…rdware-module

Issue #80: Remove hardware module
  • Loading branch information
NassimBtk committed Mar 8, 2024
2 parents 9703bbb + db9bbfa commit a805573
Show file tree
Hide file tree
Showing 87 changed files with 16,241 additions and 28,106 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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-hardware**: Hardware Energy and Sustainability module, dedicated to managing and monitoring hardware-related metrics, focusing on energy consumption and sustainability aspects.
* **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-windows**: Builds the `.zip` package for MetricsHub on Windows platforms.
* **metricshub-linux**: Builds the `.tar.gz` package of MetricsHub on Linux platforms.
Expand Down
7 changes: 0 additions & 7 deletions metricshub-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@
<version>${project.version}</version>
</dependency>

<!-- MetricsHub Hardware -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metricshub-hardware</artifactId>
<version>${project.version}</version>
</dependency>

<!-- MetricsHub Community Connectors -->
<dependency>
<groupId>org.sentrysoftware</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
import org.sentrysoftware.metricshub.engine.telemetry.Monitor;
import org.sentrysoftware.metricshub.engine.telemetry.TelemetryManager;
import org.sentrysoftware.metricshub.engine.telemetry.metric.AbstractMetric;
import org.sentrysoftware.metricshub.hardware.strategy.HardwarePostCollectStrategy;
import org.sentrysoftware.metricshub.hardware.strategy.HardwarePostDiscoveryStrategy;
import org.sentrysoftware.metricshub.hardware.strategy.HardwareStrategy;

/**
* Task responsible for running the monitoring process, including detection, discovery, and collection strategies.
Expand Down Expand Up @@ -107,8 +104,7 @@ public void run() {
telemetryManager.run(
new DetectionStrategy(telemetryManager, discoveryTime, clientsExecutor),
new DiscoveryStrategy(telemetryManager, discoveryTime, clientsExecutor),
new SimpleStrategy(telemetryManager, discoveryTime, clientsExecutor),
new HardwarePostDiscoveryStrategy(telemetryManager, discoveryTime, clientsExecutor)
new SimpleStrategy(telemetryManager, discoveryTime, clientsExecutor)
);

// Initialize the OpenTelemetry observers and LogEmitter after the discovery
Expand All @@ -125,13 +121,9 @@ public void run() {
new PrepareCollectStrategy(telemetryManager, collectTime, clientsExecutor),
new ProtocolHealthCheckStrategy(telemetryManager, collectTime, clientsExecutor),
new CollectStrategy(telemetryManager, collectTime, clientsExecutor),
new SimpleStrategy(telemetryManager, collectTime, clientsExecutor),
new HardwarePostCollectStrategy(telemetryManager, collectTime, clientsExecutor)
new SimpleStrategy(telemetryManager, collectTime, clientsExecutor)
);

// Run the hardware strategy
telemetryManager.run(new HardwareStrategy(telemetryManager, collectTime));

// Initialize metric observers
initAllObservers(telemetryManager);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
import org.sentrysoftware.metricshub.engine.strategy.simple.SimpleStrategy;
import org.sentrysoftware.metricshub.engine.telemetry.Monitor;
import org.sentrysoftware.metricshub.engine.telemetry.TelemetryManager;
import org.sentrysoftware.metricshub.hardware.strategy.HardwarePostCollectStrategy;
import org.sentrysoftware.metricshub.hardware.strategy.HardwarePostDiscoveryStrategy;
import org.sentrysoftware.metricshub.hardware.strategy.HardwareStrategy;
import picocli.CommandLine;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
Expand All @@ -91,8 +88,7 @@
description = "This tool is the CLI version of the @|italic MetricsHub|@ engine. " +
"MetricsHub monitors diverse technologies, encompassing applications, servers, and devices, particularly those without readily available monitoring solutions.%n%n" +
"It natively leverages various system management protocols to discover the hardware components of a system " +
"and report their operational status.%n%n" +
"Additionally, MetricsHub measures the power consumption of the system, or makes an estimation if no power sensor is detected.",
"and report their operational status.",
parameterListHeading = "%n@|bold,underline Parameters|@:%n",
optionListHeading = "%n@|bold,underline Options|@:%n",
customSynopsis = {
Expand Down Expand Up @@ -322,8 +318,7 @@ public Integer call() throws Exception {
}
telemetryManager.run(
new DiscoveryStrategy(telemetryManager, discoveryTime, clientsExecutor),
new SimpleStrategy(telemetryManager, discoveryTime, clientsExecutor),
new HardwarePostDiscoveryStrategy(telemetryManager, discoveryTime, clientsExecutor)
new SimpleStrategy(telemetryManager, discoveryTime, clientsExecutor)
);

// Perform the collect operation "iterations" times
Expand All @@ -348,13 +343,9 @@ public Integer call() throws Exception {
new PrepareCollectStrategy(telemetryManager, collectTime, clientsExecutor),
new ProtocolHealthCheckStrategy(telemetryManager, collectTime, clientsExecutor),
new CollectStrategy(telemetryManager, collectTime, clientsExecutor),
new SimpleStrategy(telemetryManager, collectTime, clientsExecutor),
new HardwarePostCollectStrategy(telemetryManager, collectTime, clientsExecutor)
new SimpleStrategy(telemetryManager, collectTime, clientsExecutor)
);

// Run the hardware strategy
telemetryManager.run(new HardwareStrategy(telemetryManager, collectTime));

// If iterations > 1, add a sleep time between iterations
if (i != iterations - 1 && sleepIteration > 0) {
printWriter.println(String.format("Pausing for %d seconds before the next iteration...", sleepIteration));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
import org.sentrysoftware.metricshub.engine.telemetry.TelemetryManager;
import org.sentrysoftware.metricshub.engine.telemetry.metric.AbstractMetric;
import org.sentrysoftware.metricshub.engine.telemetry.metric.NumberMetric;
import org.sentrysoftware.metricshub.hardware.strategy.HardwarePostCollectStrategy;
import org.sentrysoftware.metricshub.hardware.strategy.HardwarePostDiscoveryStrategy;
import org.sentrysoftware.metricshub.hardware.strategy.HardwareStrategy;

@ExtendWith(MockitoExtension.class)
class MonitoringTaskTest {
Expand Down Expand Up @@ -150,21 +147,14 @@ void testRun() {
monitoringTask.run(); // Collect

verify(telemetryManagerMock, times(1))
.run(
any(DetectionStrategy.class),
any(DiscoveryStrategy.class),
any(SimpleStrategy.class),
any(HardwarePostDiscoveryStrategy.class)
);
.run(any(DetectionStrategy.class), any(DiscoveryStrategy.class), any(SimpleStrategy.class));
verify(telemetryManagerMock, times(4))
.run(
any(PrepareCollectStrategy.class),
any(ProtocolHealthCheckStrategy.class),
any(CollectStrategy.class),
any(SimpleStrategy.class),
any(HardwarePostCollectStrategy.class)
any(SimpleStrategy.class)
);
verify(telemetryManagerMock, times(4)).run(any(HardwareStrategy.class));
}
}

Expand Down
33 changes: 33 additions & 0 deletions metricshub-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
<artifactId>opentelemetry-instrumentation-annotations</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.snmp4j</groupId>
<artifactId>snmp4j-agent</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -179,6 +184,9 @@
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/it/resources</directory>
</testResource>
</testResources>

<plugins>
Expand Down Expand Up @@ -265,6 +273,31 @@
</executions>
</plugin>

<!-- failsafe -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<argLine>@{argLine}</argLine>
<includes>
<include>**/*IT.java</include>
</includes>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>

<!-- MetricsHub Engine Jar -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sentrysoftware.metricshub.hardware.it;
package org.sentrysoftware.metricshub.engine.it;

import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -13,8 +13,8 @@
import org.sentrysoftware.metricshub.engine.configuration.SnmpConfiguration.SnmpVersion;
import org.sentrysoftware.metricshub.engine.connector.model.ConnectorStore;
import org.sentrysoftware.metricshub.engine.connector.model.common.DeviceKind;
import org.sentrysoftware.metricshub.engine.it.job.SnmpITJob;
import org.sentrysoftware.metricshub.engine.telemetry.TelemetryManager;
import org.sentrysoftware.metricshub.hardware.it.job.SnmpITJob;

class DellOpenManageIT {
static {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sentrysoftware.metricshub.hardware.it;
package org.sentrysoftware.metricshub.engine.it;

import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -12,8 +12,8 @@
import org.sentrysoftware.metricshub.engine.configuration.OsCommandConfiguration;
import org.sentrysoftware.metricshub.engine.connector.model.ConnectorStore;
import org.sentrysoftware.metricshub.engine.connector.model.common.DeviceKind;
import org.sentrysoftware.metricshub.engine.it.job.SuperConnectorITJob;
import org.sentrysoftware.metricshub.engine.telemetry.TelemetryManager;
import org.sentrysoftware.metricshub.hardware.it.job.SuperConnectorITJob;

class SuperConnectorOsIT {
static {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sentrysoftware.metricshub.hardware.it.job;
package org.sentrysoftware.metricshub.engine.it.job;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -24,8 +24,6 @@
import org.sentrysoftware.metricshub.engine.telemetry.Resource;
import org.sentrysoftware.metricshub.engine.telemetry.TelemetryManager;
import org.sentrysoftware.metricshub.engine.telemetry.metric.AbstractMetric;
import org.sentrysoftware.metricshub.hardware.strategy.HardwarePostCollectStrategy;
import org.sentrysoftware.metricshub.hardware.strategy.HardwarePostDiscoveryStrategy;

@Data
public abstract class AbstractITJob implements ITJob {
Expand Down Expand Up @@ -363,31 +361,29 @@ public ITJob verifyExpected(final String expectedPath) throws Exception {
public ITJob executeDiscoveryStrategy() {
final Long discoveryTime = System.currentTimeMillis();

assertTrue(isServerStarted(), () -> "Server not started.");

telemetryManager.run(
new DetectionStrategy(telemetryManager, discoveryTime, clientsExecutor),
new DiscoveryStrategy(telemetryManager, discoveryTime, clientsExecutor),
new SimpleStrategy(telemetryManager, discoveryTime, clientsExecutor),
new HardwarePostDiscoveryStrategy(telemetryManager, discoveryTime, clientsExecutor)
new SimpleStrategy(telemetryManager, discoveryTime, clientsExecutor)
);

assertTrue(isServerStarted(), () -> "Server not started.");

return this;
}

@Override
public ITJob executeCollectStrategy() {
final Long collectTime = System.currentTimeMillis();

assertTrue(isServerStarted(), () -> "Server not started.");

telemetryManager.run(
new PrepareCollectStrategy(telemetryManager, collectTime, clientsExecutor),
new CollectStrategy(telemetryManager, collectTime, clientsExecutor),
new SimpleStrategy(telemetryManager, collectTime, clientsExecutor),
new HardwarePostCollectStrategy(telemetryManager, collectTime, clientsExecutor)
new SimpleStrategy(telemetryManager, collectTime, clientsExecutor)
);

assertTrue(isServerStarted(), () -> "Server not started.");

return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sentrysoftware.metricshub.hardware.it.job;
package org.sentrysoftware.metricshub.engine.it.job;

import java.io.IOException;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sentrysoftware.metricshub.hardware.it.job;
package org.sentrysoftware.metricshub.engine.it.job;

import java.io.File;
import java.io.FileInputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.sentrysoftware.metricshub.hardware.it.job;
package org.sentrysoftware.metricshub.engine.it.job;

import lombok.NonNull;
import org.sentrysoftware.metricshub.engine.client.ClientsExecutor;
import org.sentrysoftware.metricshub.engine.configuration.SnmpConfiguration;
import org.sentrysoftware.metricshub.engine.it.snmp.SnmpAgent;
import org.sentrysoftware.metricshub.engine.telemetry.TelemetryManager;
import org.sentrysoftware.metricshub.hardware.it.snmp.SnmpAgent;

public class SnmpITJob extends AbstractITJob {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sentrysoftware.metricshub.hardware.it.job;
package org.sentrysoftware.metricshub.engine.it.job;

import lombok.NonNull;
import org.sentrysoftware.metricshub.engine.client.ClientsExecutor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sentrysoftware.metricshub.hardware.it.snmp;
package org.sentrysoftware.metricshub.engine.it.snmp;

import org.snmp4j.MessageDispatcher;
import org.snmp4j.agent.AgentConfigManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sentrysoftware.metricshub.hardware.it.snmp;
package org.sentrysoftware.metricshub.engine.it.snmp;

import org.snmp4j.agent.MOQuery;
import org.snmp4j.agent.MOScope;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sentrysoftware.metricshub.hardware.it.snmp;
package org.sentrysoftware.metricshub.engine.it.snmp;

import java.io.BufferedReader;
import java.io.File;
Expand All @@ -17,7 +17,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import lombok.Getter;
import org.sentrysoftware.metricshub.hardware.it.job.ITJobUtils;
import org.sentrysoftware.metricshub.engine.it.job.ITJobUtils;
import org.snmp4j.CommandResponder;
import org.snmp4j.MessageDispatcher;
import org.snmp4j.MessageDispatcherImpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;
import java.util.NoSuchElementException;
import javax.management.Query;
import org.sentrysoftware.metricshub.hardware.it.snmp.SnmpAgent;
import org.sentrysoftware.metricshub.engine.it.snmp.SnmpAgent;
import org.snmp4j.CommandResponderEvent;
import org.snmp4j.PDU;
import org.snmp4j.SNMP4JSettings;
Expand Down
Loading

0 comments on commit a805573

Please sign in to comment.