SNMP

Content

  • Introduction

  • Windows 10 1809

  • Ubuntu 20.04.3

  • Run Device Service

Introduction

The SNMP device service retrieves information from a Windows/Linux device via SNMP agent. It also provides the several basic functions for development.

  • Windows 10 1809

  • Ubuntu 20.04.3

Windows 10 1809

Requirements

To enable the Windows SNMP agent and configure the agents. There is a simple setup installation process.

Installing SNMP agents on Windows 10 1809

The SNMP service is not listed in the Windows features list in the Control Panel on Windows 10. Install the SNMP service directly from Microsoft servers using the steps below:

  • Open the PowerShell with administrator privileges.

  • Run the following command:

Add-WindowsCapability -Online -Name "SNMP.Client~~~~0.0.1.0"

  • Use the following command to check installed status:

Get-WindowsCapability -Online -Name "SNMP*"

Configuring SNMP agents on Windows 10 1809

  • To verify SNMP agents are running. Press Win + R, type services.msc, and press Enter to launch the Services panel. Look for both SNMP services and check if they appear in the list.

  • Switch to the Agent Tab and fill in your Contact and Location fields with your name and location. In the Service section, check the boxes for services from which you want to collect data for forwarding it to the monitoring device. An example setting as below:

  • Move over to the Security Tab. Add the community name: public to Accepted community names list and make sure the Accept SNMP packets from these hosts radio button is selected.

  • Device PC setup

Device PC still also follow below steps to install SNMP agent. Select Accept SNMP packets from these hosts and click Add… to add the IP address of device PC.

Ubuntu 20.04.3

Installing SNMP agents on Ubuntu 20.04 LTS

  • Input the commands with the Terminal: sudo apt update sudo apt install snmp snmpd snmp-mibs-downloader sudo snap install net-snmp

Configuring SNMP agents on Ubuntu 20.04 LTS

  • Run the following commands with the current setting of agent checking:

snmpget -v2c -cpublic 127.0.0.1 1.3.6.1.2.1.1.1.0 SNMPv2-MIB::sysDescr.0 = STRING: Linux advantech 5.4.0-91-generic #102~18.04.1-Ubuntu SMP Thu Nov 11 14:46:36 UTC 2021 x86_64

snmpget -v2c -cpublic 127.0.0.1 1.3.6.1.2.1.1.3.0 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (281857) 0:46:58.57

snmpget -v2c -cpublic 127.0.0.1 1.3.6.1.2.1.1.4.0 SNMPv2-MIB::sysContact.0 = STRING: Advantech

snmpget -v2c -cpublic 127.0.0.1 1.3.6.1.2.1.1.5.0 SNMPv2-MIB::sysName.0 = STRING: advantech

snmpget -v2c -cpublic 127.0.0.1 1.3.6.1.2.1.1.6.0 SNMPv2-MIB::sysLocation.0 = STRING: Taiwan

  • Edit the file: /etc/snmp/snmpd.conf Set the SNMP v2 Read-Only Community String as 'public' by adding the line in the Access section:

Change a custom settings as below:

sysLocation Taiwan sysContact Advantech

Allow SNMP ports in firewall, and reboot for enabling:

sudo ufw allow 161/udp sudo ufw allow 162/udp reboot

Run Device Service

1. The SNMP device service running on port number 50009 with administrator privilege. In Windows, open the command prompt and input netstat -na | find "50009" to find no one using it.

Device Service

Port

System Information

50009

2. You could request to hit the ping endpoint to check if device service is available. If yes, it returns a string: pong.

curl http://hostip:50009/api/v1/ping pong

REST API Reference

SNMP - System description

URI pattern

http://hostip:50009/api/v1/device/name/snmp-basic/sysDescr

Properties

This collection command ID has the following properties:

Command ID

Type

Read/Write

Description

sysDescr

String

R

  1. The full name and version identification of the system's hardware type, software operating-system, and networking software.

  2. It’s mapping to OID: 1.3.6.1.2.1.1.1.0 and community string is public.

Example

Get the basic system information:

curl http://hostip:50009/api/v1/device/name/snmp-basic/sysDescr

{"id":"","pushed":0,"device":"snmp-basic","created":0,"modified":0,"origin":1641883097173,"schedule":null,"event":null,"readings":[{"id":"","pushed":0,"created":0,"origin":1641883097172,"modified":0,"device":"snmp-basic","name":"sysDescr","value":"Hardware: Intel64 Family 6 Model 158 Stepping 13 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 17763 Multiprocessor Free)","raw":{}}]}

SNMP - System Uptime

URI pattern

http://hostip:50009/api/v1/device/name/snmp-basic/sysUpTimeInstance

Properties

This collection command ID has the following properties:

Command ID

Type

Read/Write

Description

sysUpTimeInstance

Int32

R

  1. The system uptime that usually the same as the boot time, unless the SNMP service has been restarted.

  2. It’s mapping to OID: 1.3.6.1.2.1.1.3.0 and community string is public.

Example

Get system uptime:

curl http://hostip:50009/api/v1/device/name/snmp-basic/ sysUpTimeInstance

{"id":"","pushed":0,"device":"snmp-basic","created":0,"modified":0,"origin":1641883145112,"schedule":null,"event":null,"readings":[{"id":"","pushed":0,"created":0,"origin":1641883145111,"modified":0,"device":"snmp-basic","name":"sysUpTimeInstance","value":"285350","raw":285350}]}

SNMP - Contact Name

URI pattern

http://hostip:50009/api/v1/device/name/snmp-basic/sysContact

Properties

This collection command ID has the following properties:

Command ID

Type

Read/Write

Description

sysContact

String

R

1. The contact name for this managed node, as well as information about how to contact this person.

2. It’s mapping to OID: 1.3.6.1.2.1.1.4.0 and community string is public.

Example

Get contact name of managed node:

curl http://hostip:50009/api/v1/device/name/snmp-basic/sysContact

{"id":"","pushed":0,"device":"snmp-basic","created":0,"modified":0,"origin":1641883177778,"schedule":null,"event":null,"readings":[{"id":"","pushed":0,"created":0,"origin":1641883177777,"modified":0,"device":"snmp-basic","name":"sysContact","value":"Advantech","raw":{}}]}

SNMP - System Name

URI pattern

http://hostip:50009/api/v1/device/name/snmp-basic/sysName

Properties

This collection resource name has the following properties:

Command ID

Type

Read/Write

Description

sysName

String

R

  1. An administratively-assigned name for this managed node.

  2. It’s mapping to OID: 1.3.6.1.2.1.1.5.0 and community string is public.

Example

Get CPU model name:

curl http://hostip:50009/api/v1/device/name/snmp-basic/sysName

{"id":"","pushed":0,"device":"snmp-basic","created":0,"modified":0,"origin":1641883231917,"schedule":null,"event":null,"readings":[{"id":"","pushed":0,"created":0,"origin":1641883231915,"modified":0,"device":"snmp-basic","name":"sysName","value":"DESKTOP-4L1KT16","raw":{}}]}

SNMP - Physical location

URI pattern

http://hostip:50009/api/v1/device/name/snmp-basic/sysLocation

Properties

This collection resource name has the following properties:

Command ID

Type

Read/Write

Description

sysLocation

String

R

1. The physical location of this node.

2. It’s mapping to OID: 1.3.6.1.2.1.1.6.0 and community string is public.

Example

Get the amount of available hard disk space:

curl http://hostip:50009/api/v1/device/name/snmp-basic/sysLocation {"id":"","pushed":0,"device":"snmp-basic","created":0,"modified":0,"origin":1641883354407,"schedule":null,"event":null,"readings":[{"id":"","pushed":0,"created":0,"origin":1641883354407,"modified":0,"device":"snmp-basic","name":"sysLocation","value":"Taiwan","raw":{}}]}

Last updated