Skip to content

Commit

Permalink
Issue #424: Add CLI options for specific query execution - SNMP
Browse files Browse the repository at this point in the history
* Defined default configuration.
  • Loading branch information
CherfaElyes committed Dec 5, 2024
1 parent f1704d2 commit dcdcd50
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
*/

import static org.sentrysoftware.metricshub.cli.service.protocol.SnmpConfigCli.DEFAULT_TIMEOUT;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand Down Expand Up @@ -133,6 +135,23 @@ void validate() throws ParameterException {
);
}

/**
* Builds the default SNMP configuration for the {@code SnmpConfigCli} object.
*/
void buildDefaultConfiguration() {
snmpConfigCli = new SnmpConfigCli();
snmpConfigCli.setSnmpVersion("v2c");
snmpConfigCli.setCommunity("public".toCharArray());
snmpConfigCli.setPort(161);
snmpConfigCli.setTimeout(String.valueOf(DEFAULT_TIMEOUT));
}

/**
* Entry point for the SNMP CLI application. Initializes necessary configurations,
* processes command line arguments, and executes the CLI.
*
* @param args The command line arguments passed to the application.
*/
public static void main(String[] args) {
System.setProperty("log4j2.configurationFile", "log4j2-cli.xml");

Expand Down Expand Up @@ -173,7 +192,7 @@ public Integer call() throws Exception {
.ifPresent(extension -> {
try {
if (snmpConfigCli == null) {
new SnmpConfigCli();
buildDefaultConfiguration();
}
IConfiguration protocol = snmpConfigCli.toConfiguration(null, null);
protocol.setHostname(hostname);
Expand Down

0 comments on commit dcdcd50

Please sign in to comment.