SNMP Configuration
Use this interface to edit the community string, SNMP version, etc. for an IP address.
If you make a change that would overlap with an existing snmp-config.xml
, it will automatically create groups of <definition />
entries as necessary.
If no <definition />
entry is created it matches the defaults.
There are different versions of the interface (see below). The following operations are supported:
GETs (Reading Data)
Parameter | Description |
---|---|
|
Get the SNMP configuration for a given IP address. |
|
Get the SNMP configuration for a given IP address at a given location. |
PUTs (Modifying Data)
Parameter | Description |
---|---|
|
Add or update the SNMP configuration for a given IP address. |
Determine API version
To determine the version of the API running in your Meridian type http://localhost:8980/opennms/rest/snmpConfig/1.1.1.1 in your browser and look at the output:
-
Version 1: If the output only has attributes
community
,port
,retries
,timeout
, andversion
. -
Version 2: If there are more attributes than those listed in Version 1 (for example, max Repetitions).
API version 1
Version 1 supports only a few attributes defined in snmp-info.xsd
.
<xs:schema
xmlns:tns="http://xmlns.opennms.org/xsd/config/snmp-info"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
version="1.0"
targetNamespace="http://xmlns.opennms.org/xsd/config/snmp-info">
<xs:element name="snmp-info" type="tns:snmpInfo"/>
<xs:complexType name="snmpInfo">
<xs:sequence>
<xs:element name="community" type="xs:string" minOccurs="0"/>
<xs:element name="port" type="xs:int"/>
<xs:element name="retries" type="xs:int"/>
<xs:element name="timeout" type="xs:int"/>
<xs:element name="version" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
The following table shows all supported attributes, optional restrictions, and the mapping between snmp-info.xsd
and snmp-config.xsd
.
All parameters can be set regardless of the version.
attribute snmp-info.xml | attribute snmp-config.xml | default | restriction |
---|---|---|---|
version |
version |
v1 |
|
port |
port |
161 |
Integer > 0 |
retries |
retry |
1 |
Integer > 0 |
timeout |
timeout |
3000 |
Integer > 0 |
community |
read-community |
public |
any string with a length >= 1 |
curl -v -u admin:admin -X PUT -H "Content-Type: application/xml" \
-H "Accept: application/xml" \
-d "<snmp-info>
<community>yRuSonoZ</community>
<port>161</port>
<retries>1</retries>
<timeout>2000</timeout>
<version>v2c</version>
</snmp-info>" \
http://localhost:8980/opennms/rest/snmpConfig/10.1.1.1
Creates or updates a <definition/>
entry for IP address 10.1.1.1 in snmp-config.xml
.
curl -v -u admin:admin -X GET ://localhost:8980/opennms/rest/snmpConfig/10.1.1.1
Returns the SNMP configuration for IP address 10.1.1.1 as defined in example 1.
API version 2
Since version 2, you can set or get all attributes of a <definition />
entry defined in snmp-config.xsd
(http://xmlns.opennms.org/xsd/config/snmp) can be set or get via the interface, however it is only possible to set the configuration for one IP address per request and not for a range of IP addresses at a time.
This may change in the future.
The interface uses SnmpInfo
objects for communication.
Therefore it is possible to set, for example, v1 and v3 parameters in one request (for example, readCommunity
string and privProtocol
string).
However, Meridian does not allow this.
It lets you set only attributes that have no version restriction (for example, timeout value) or the attributes that are limited to the version (for example, readCommunity
string if version is v1/v2c).
The same is true for getting data from the API, even if it is possible to store v1 and v3 parameters in one definition block in the snmp-config.xml
manually, the REST API will return only the parameters that match the version.
If no version is defined, the default is assumed (both in PUT and GET requests).
The SnmpInfo schema is defined as follows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema
elementFormDefault="qualified"
version="1.0"
targetNamespace="http://xmlns.opennms.org/xsd/config/snmp-info"
xmlns:tns="http://xmlns.opennms.org/xsd/config/snmp-info"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="snmp-info" type="tns:snmpInfo"/>
<xs:complexType name="snmpInfo">
<xs:sequence>
<xs:element name="authPassPhrase" type="xs:string" minOccurs="0"/>
<xs:element name="authProtocol" type="xs:string" minOccurs="0"/>
<xs:element name="community" type="xs:string" minOccurs="0"/>
<xs:element name="contextEngineId" type="xs:string" minOccurs="0"/>
<xs:element name="contextName" type="xs:string" minOccurs="0"/>
<xs:element name="engineId" type="xs:string" minOccurs="0"/>
<xs:element name="enterpriseId" type="xs:string" minOccurs="0"/>
<xs:element name="maxRepetitions" type="xs:int" minOccurs="0"/>
<xs:element name="maxRequestSize" type="xs:int" minOccurs="0"/>
<xs:element name="maxVarsPerPdu" type="xs:int" minOccurs="0"/>
<xs:element name="port" type="xs:int" minOccurs="0"/>
<xs:element name="privPassPhrase" type="xs:string" minOccurs="0"/>
<xs:element name="privProtocol" type="xs:string" minOccurs="0"/>
<xs:element name="proxyHost" type="xs:string" minOccurs="0"/>
<xs:element name="readCommunity" type="xs:string" minOccurs="0"/>
<xs:element name="retries" type="xs:int" minOccurs="0"/>
<xs:element name="securityLevel" type="xs:int" minOccurs="0"/>
<xs:element name="securityName" type="xs:string" minOccurs="0"/>
<xs:element name="timeout" type="xs:int" minOccurs="0"/>
<xs:element name="version" type="xs:string" minOccurs="0"/>
<xs:element name="writeCommunity" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
The following table shows all supported attributes and the mapping between snmp-info.xsd
and snmp-config.xsd
.
It also shows the version limitations, default values, and the restrictions, if any.
attribute snmp-info.xml | attribute snmp-config.xml | default | restricted to version | restriction |
---|---|---|---|---|
version |
version |
v1 |
- |
|
port |
port |
161 |
- |
Integer > 0 |
retries |
retry |
1 |
- |
Integer > 0 |
timeout |
timeout |
3000 |
- |
Integer > 0 |
maxVarsPerPdu |
max-vars-per-pdu |
10 |
- |
Integer > 0 |
maxRepetitions |
max-repetitions |
2 |
- |
Integer > 0 |
maxRequestSize |
max-request-size |
65535 |
- |
Integer > 0 |
proxyHost |
proxy-host |
- |
||
readCommunity |
read-community |
public |
v1, v2c |
|
writeCommunity |
write-community |
private |
v1, v2c |
|
securityName |
security-name |
opennmsUser |
v3 |
|
securityLevel |
security-level |
noAuthNoPriv |
v3 |
Integer value, which can be |
authPassPhrase |
auth-passphrase |
0p3nNMSv3 |
v3 |
|
authProtocol |
auth-protocol |
MD5 |
v3 |
Only |
privPassPhrase |
privacy-passphrase |
0p3nNMSv3 |
v3 |
|
privProtocol |
privacy-protocol |
DES |
v3 |
Only |
engineId |
engine-id |
v3 |
||
contextEngineId |
context-engine-id |
v3 |
||
contextName |
context-name |
v3 |
||
enterpriseId |
enterprise-id |
v3 |
curl -v -u admin:admin -X PUT -H "Content-Type: application/xml" \
-H "Accept: application/xml" \
-d "<snmp-info>
<readCommunity>yRuSonoZ</readCommunity>
<port>161</port>
<retries>1</retries>
<timeout>2000</timeout>
<version>v2c</version>
</snmp-info>" \
http://localhost:8980/opennms/rest/snmpConfig/10.1.1.1
Creates or updates a <definition/>
entry for IP address 10.1.1.1 in snmp-config.xml
.
curl -v -u admin:admin -X GET http://localhost:8980/opennms/rest/snmpConfig/10.1.1.1
Returns the SNMP configuration for IP address 10.1.1.1 as defined in example 1.
curl -v -u admin:admin -X PUT -H "Content-Type: application/xml" \
-H "Accept: application/xml" \
-d "<snmp-info>
<readCommunity>yRuSonoZ</readCommunity>
<port>161</port>
<retries>1</retries>
<timeout>2000</timeout>
<version>v1</version>
<securityName>secret-stuff</securityName>
<engineId>engineId</engineId>
</snmp-info>" \
http://localhost:8980/opennms/rest/snmpConfig/10.1.1.1
Creates or updates a <definition/>
entry for IP address 10.1.1.1 in snmp-config.xml
, ignoring attributes securityName
and engineId
.
curl -v -u admin:admin -X PUT -H "Content-Type: application/xml" \
-H "Accept: application/xml" \
-d "<snmp-info>
<readCommunity>yRuSonoZ</readCommunity>
<port>161</port>
<retries>1</retries>
<timeout>2000</timeout>
<version>v3</version>
<securityName>secret-stuff</securityName>
<engineId>engineId</engineId>
</snmp-info>" \
http://localhost:8980/opennms/rest/snmpConfig/10.1.1.1
Creates or updates a <definition/>
entry for IP address 10.1.1.1 in snmp-config.xml
, ignoring attribute readCommunity
.