Skip to content

Commit

Permalink
Improve doc for snmp-host (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui Liu committed Aug 7, 2024
1 parent ee59ece commit 742d999
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 18 deletions.
58 changes: 42 additions & 16 deletions host/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,48 @@ nohup ./bin/otel-dc-host

## Specific Parameters for Host Data Collectors

| Parameter | Scope | Description | Example |
|--------------------|-----------------------|-----------------------------------------------------------------------------|---------------------------|
| host.system | global | The engine of this host data collector | snmp_host or mq_appliance |
| snmp.host | instance/snmp_host | The endpoint of SNMP host | udp:9.112.252.102/161 |
| host.name | instance/snmp_host | Optional: use this to overwrite the value got by SNMP | stantest0.fyre.ibm.com |
| os.type | instance/snmp_host | Optional: use this to overwrite the value got by SNMP | linux |
| community | instance/snmp_host | Optional: The community string (default: public) | public |
| retries | instance/snmp_host | Optional: times to retry (default: 3) | 3 |
| timeout | instance/snmp_host | Optional: timesout in ms (default: 450) | 450 |
| version | instance/snmp_host | Optional: version of SNMP (0:version1, 1:version2c, 3:version3) (default:1) | 1 |
| securityLevel | instance/snmp_host | Optional: Choose 1:NOAUTH_NOPRIV 2:AUTH_NOPRIV 3:AUTH_PRIV (default: 1) | 3 |
| authPassword | instance/snmp_host | Optional: Auth password (version 3) (default: "") | password |
| privacyPassword | instance/snmp_host | Optional: Privacy password (version 3) (default: "") | password |
| appliance.host | instance/mq_appliance | host name for MQ appliance | testbox1.mqappliance.com |
| appliance.user | instance/mq_appliance | user name for MQ appliance | admin |
| appliance.password | instance/mq_appliance | password for MQ appliance | xxxx |
| Parameter | Scope | Description | Example values |
|--------------------|--------------|-------------------------------------------------------------------------|---------------------------|
| host.system | global | The engine of this host data collector | snmp_host or mq_appliance |
| snmp.host | snmp_host | The endpoint of SNMP host | udp:9.112.252.102/161 |
| host.name | snmp_host | Optional: use this to overwrite the value got by SNMP | stantest0.fyre.ibm.com |
| os.type | snmp_host | Optional: use this to overwrite the value got by SNMP | linux |
| community | snmp_host | Optional: The community string (SNMP v1 or v2c) (default: public) | public |
| retries | snmp_host | Optional: times to retry (default: 3) | 3 |
| timeout | snmp_host | Optional: timeout in ms (default: 450) | 450 |
| version | snmp_host | Optional: version of SNMP (default:2c) | 1, 2, 2c, 3 |
| securityLevel | snmp_host | Optional: Choose 1:NOAUTH_NOPRIV 2:AUTH_NOPRIV 3:AUTH_PRIV (default: 1) | 1, 2, 3 |
| authPassword | snmp_host | Optional: Auth password (version 3) | password1 |
| privacyPassword | snmp_host | Optional: Privacy password (version 3) | password1 |
| securityName | snmp_host | Optional: Security name (user) (version 3) | user1 |
| authType | snmp_host | Optional: OID of the Protocol for Auth (version 3) | 1.3.6.1.6.3.10.1.1.3 |
| privacyType | snmp_host | Optional: OID of the Protocol for Privacy (version 3) | 1.3.6.1.6.3.10.1.2.2 |
| appliance.host | mq_appliance | host name for MQ appliance | testbox1.mqappliance.com |
| appliance.user | mq_appliance | user name for MQ appliance | admin |
| appliance.password | mq_appliance | password for MQ appliance | password1 |

#### OID of the Protocol for Authentication (SNMP version 3)

| Protocol | OID |
|-------------------|----------------------|
| Auth-NONE | 1.3.6.1.6.3.10.1.1.1 |
| AuthMD5 | 1.3.6.1.6.3.10.1.1.2 |
| AuthSHA | 1.3.6.1.6.3.10.1.1.3 |
| AuthHMAC128SHA224 | 1.3.6.1.6.3.10.1.1.4 |
| AuthHMAC192SHA256 | 1.3.6.1.6.3.10.1.1.5 |
| AuthHMAC256SHA384 | 1.3.6.1.6.3.10.1.1.6 |
| AuthHMAC384SHA512 | 1.3.6.1.6.3.10.1.1.7 |

#### OID of the Protocol for Privacy (SNMP version 3)

| Protocol | OID |
|------------|----------------------------|
| Priv-NONE | 1.3.6.1.6.3.10.1.2.1 |
| PrivDES | 1.3.6.1.6.3.10.1.2.2 |
| Priv3DES | 1.3.6.1.6.3.10.1.2.3 |
| PrivAES128 | 1.3.6.1.6.3.10.1.2.4 |
| PrivAES192 | 1.3.6.1.4.1.4976.2.2.1.1.1 |
| PrivAES256 | 1.3.6.1.4.1.4976.2.2.1.1.2 |


## Build & Run (for developers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,52 @@ public class SnmpHostDc extends AbstractHostDc {
private final String hostName;
private final String osType;

private static int parseVersion(Object version0) {
if (version0 == null) {
version0 = "2c";
}
String version1 = version0.toString().trim();
switch (version1) {
case "0":
case "1":
logger.info("SNMP version-1");
return SnmpConstants.version1;
case "3":
logger.info("SNMP version-3");
return SnmpConstants.version3;
default:
logger.info("SNMP version-2c");
return SnmpConstants.version2c;
}
}

private static int parseSecurityLevel(Object level0) {
if (level0 == null) {
level0 = "1";
}
String level1 = level0.toString().trim();
switch (level1) {
case "2":
logger.info("SNMP AUTH_NOPRIV");
return SecurityLevel.AUTH_NOPRIV;
case "3":
logger.info("SNMP AUTH_PRIV");
return SecurityLevel.AUTH_PRIV;
default:
logger.info("SNMP NOAUTH_NOPRIV");
return SecurityLevel.NOAUTH_NOPRIV;
}
}

public SnmpHostDc(Map<String, Object> properties, String hostSystem) throws IOException {
super(properties, hostSystem);
String snmpHost = (String) properties.getOrDefault(SnmpHostUtil.SNMP_HOST, "udp:127.0.0.1/161");
SnmpOption option = new SnmpOption();
option.setCommunity((String) properties.getOrDefault("community", "public"));
option.setRetries((Integer) properties.getOrDefault("retries", 3));
option.setTimeout((Integer) properties.getOrDefault("timeout", 450));
option.setVersion((Integer) properties.getOrDefault("version", SnmpConstants.version2c)); //1
option.setSecurityLevel((Integer) properties.getOrDefault("securityLevel", SecurityLevel.NOAUTH_NOPRIV)); //1
option.setVersion(parseVersion(properties.get("version")));
option.setSecurityLevel(parseSecurityLevel(properties.get("securityLevel")));
option.setSecurityName((String) properties.get("securityName"));
option.setAuthPassword((String) properties.get("authPassword"));
option.setPrivacyPassword((String) properties.get("privacyPassword"));
Expand Down

0 comments on commit 742d999

Please sign in to comment.