SNMP Support APIs

Table 1. SNMP Support APIs

Action

Method

Payload Required

API

To configure communities

POST

Yes

/api/snmp/communities

To enable SNMP traps

POST

Yes

/api/config/snmp/enable/traps

To configure SNMP hosts

POST

Yes

/api/config/snmp/hosts

To configure SNMP users

POST

Yes

/api/config/snmp/users

To configure SNMP groups

POST

Yes

/api/config/snmp/groups

To view SNMP configuration

GET

No

/api/config/snmp/agent

/api/snmp/communities

/api/config/snmp/enable/traps

/api/config/snmp/hosts

/api/config/snmp/users

/api/config/snmp/groups


Note


SNMP Agent is enabled by default.

If the curl command is not working, run the curl commands with -i option. For example:


curl -k -i -v -u <USER>:<PASSWORD> -H Accept:application/vnd.yang.data+xml -H Content-Type:application/vnd.yang.data+xml -X DELETE https://<IP-ADDR>/api/config/snmp/hosts/

Example: POST Configuring SNMP Communities



curl -k -v -u "admin:Cisco123#" -H "Accept:application/vnd.yang.data+xml" -H "Content-Type:application/vnd.yang.data+xml" -X POST https://172.19.162.235/api/snmp/communities -d '
<community>
	<community-name>test3</community-name>
	<community-access>readOnly</community-access>
</community>'
Table 2. Field Descriptions for SNMP Communities

Field

Description

community-name

Upto 32 char alphanumeric string (including _ and -)

community-access

Read-only

Example: POST SNMP Traps



curl -k -v -u "admin:XXX" -H "Accept:application/vnd.yang.data+xml" -H "Content-Type:application/vnd.yang.data+xml" -X POST https://172.19.162.235/api/config/snmp/enable/traps -d '
<trap-type>linkDown</trap-type>'
Table 3. Field Description for SNMP trap API

Field

Description

trap-type

linkUp or linkDown

Example: POST SNMP Host



curl -k -v -u "admin:XXX" -H "Accept:application/vnd.yang.data+xml" -H "Content-Type:application/vnd.yang.data+xml" -X POST https://172.19.162.235/api/config/snmp/hosts -d '
<host>
	<host-name>listen_host7</host-name>
	<host-port>162</host-port>
	<host-ip-address>10.32.172.190</host-ip-address>
	<host-version>2</host-version>
	<host-security-level>noAuthNoPriv</host-security-level>
	<host-user-name>user1</host-user-name>
</host>'

curl -k -v -u "admin:XXX" -H "Accept:application/vnd.yang.data+xml" -H "Content-Type:application/vnd.yang.data+xml" -X POST https://172.19.162.235/api/config/snmp/hosts -d '
<host>
	<host-name>listen_host7</host-name>
	<host-port>162</host-port>
	<host-ip-address>10.32.172.190</host-ip-address>
	<host-version>3</host-version>
	<host-security-level>authPriv</host-security-level>
	<host-user-name>user1</host-user-name>
</host>

Example: POST SNMP Users

curl -k -v -u "admin:XXXX" -H "Accept:application/vnd.yang.data+xml" -H "Content-Type:application/vnd.yang.data+xml" -X POST https://172.19.162.235/api/config/snmp/users -d '
<user>
	<user-name>test_user1</user-name>
	<user-version>2</user-version>
	<user-group>public</user-group>
</user>'
Table 4. Field Description for SNMP User API

Field

Description

passphrase

Alphanumeric string with 8 character mininum length.

auth-protocol

md5 or sha

priv-protocol

aes or des

Example: POST SNMP Groups


curl -k -v -u "admin:XXX" -H "Accept:application/vnd.yang.data+xml" -H "Content-Type:application/vnd.yang.data+xml" -X POST https://172.19.162.235/api/config/snmp/groups -d '
<group>
	<group-name>testgroup2</group-name>
	<group-context-prefix>snmp</group-context-prefix>
	<group-version>2</group-version>
	<security-level>noAuthNoPriv</security-level>
	<read>read-access</read>
	<write>write-access</write>
	<notify>notify-access</notify>
</group>'

Example: GET SNMP Configurations


curl -k -v -u "admin:XXX" -H "Accept:application/vnd.yang.data+xml" -H "Content-Type:application/vnd.yang.data+xml" -X GET https://172.19.162.235/api/config/snmp/hosts