AN11 SNMP management of 110/230V power outlets from the command line in Windows and Linux | NETIO products: Smart power sockets controlled over LAN and WiFi
Tags: 
M2M API
3rd party HW-SW

NETIO devices allow reading of outputs states and values of electrical measurements via SNMPv3 (SNMP get) and controlof PDU outputs (SNMP set). AN11 describes how to implement reading and writing using SNMP v1, v2c in MS Windows and Linux.

Do you have any questions?

SNMP v1, v2c is supported by following NETIO devices:

Using the SNMP protocol, it is possible to get states of individual sockets, measure current consumption or control outputs. SNMP is a standard protocol for many third-party application monitoring software.

NETIO devices use default port 161 for communication via SNMP. The MIB file with objects descriptions can be downloaded from the web administration in the SNMP protocol settings.

 

Linux:

In Linux, utilities such as snmpwalk, snmpget or snmpset from the snmp package (http://www.net-snmp.org/) can be used for SNMP communication. For a brief installation manual, see the “Installing the Net-SNMP utility in Linux” section at the end of this document.

 

Windows:

In Windows, utilities such as SnmpWalk, SnmpGet or SnmpSet by the EZ Systems (https://ezfive.com/snmpsoft-tools) can be used for SNMP communication. The utilities are free-of-charge for non-commercial use. These utilities do not work with MIBs, only with OIDs.

 

Objects in NETIO SNMP MIB

Monitoring (read access)

 

Object

OID

x – output number (1 - 8)

Type

Value example

Note

netioOutputID.x.0

1.3.6.1.4.1.47952.1.1.1.1.x.0

INTEGER

1

 

netioOutputName.x.0

1.3.6.1.4.1.47952.1.1.1.2.x.0

STRING

output_1

Based on user defined name

netioOutputState.x.0

1.3.6.1.4.1.47952.1.1.1.3.x.0

INTEGER

off(0), on(1)

 

netioOutputStateString.x.0

1.3.6.1.4.1.47952.1.1.1.4.x.0

STRING

"off", "on"

 

netioOutputLoad.x.0

1.3.6.1.4.1.47952.1.1.1.25.x.0

INTEGER

24

[W]

netioOutputEnergy.x.0

1.3.6.1.4.1.47952.1.1.1.26.x.0

INTEGER

13

[Wh]

netioOutputEnergyStart.x.0

1.3.6.1.4.1.47952.1.1.1.27.x.0

DateTime

2017-6-23,5:47:3.0,+0:0

Initial date and time. UTC based*

netioOutputCurrent.x.0

1.3.6.1.4.1.47952.1.1.1.28.x.0

INTEGER

195

[mA]

netioOutputPowerFactor.x.0

1.3.6.1.4.1.47952.1.1.1.29.x.0

INTEGER

534

Current power factor * 1000

netioOutputPhase.x.0

1.3.6.1.4.1.47952.1.1.1.30.x.0

INTEGER

120

Phase shift in range 0-360 [°]

netioOutputEnergyNR.x.0

1.3.6.1.4.1.47952.1.1.1.31.x.0

INTEGER

255

[Wh]

netioOutputReverseEnergy.x.0

1.3.6.1.4.1.47952.1.1.1.32.x.0

INTEGER

140

[Wh]

netioOutputReverseEnergyNR.x.0

1.3.6.1.4.1.47952.1.1.1.33.x.0

INTEGER

620

[Wh]

netioVoltage

1.3.6.1.4.1.47952.1.2.1.0

INTEGER

239100

Voltage in the power grid [mV]

netioFrequency

1.3.6.1.4.1.47952.1.2.2.0

INTEGER

49900

Frequency in the power grid [mHz]

netioTotalCurrent

1.3.6.1.4.1.47952.1.2.3.0

INTEGER

195

[mA]

netioOverallPowerFactor

1.3.6.1.4.1.47952.1.2.4.0

INTEGER

534

Current power factor * 1000

netioTotalLoad

1.3.6.1.4.1.47952.1.2.5.0

INTEGER

24

[W]

netioTotalEnergy

1.3.6.1.4.1.47952.1.2.6.0

INTEGER

13

[Wh]

netioEnergyStart

1.3.6.1.4.1.47952.1.2.7.0

DateTime

2017-6-23,5:47:3.0,+0:0

Initial date and time. UTC based

netioTotalPhase

1.3.6.1.4.1.47952.1.2.8.0

INTEGER

120

[°]

netioTotalReverseEnergy

1.3.6.1.4.1.47952.1.2.9.0

INTEGER

420

[Wh]

netioTotalEnergyNR

1.3.6.1.4.1.47952.1.2.10.0

INTEGER

3200

[Wh]

netioTotalReverseEnergyNR

1.3.6.1.4.1.47952.1.2.1.1.0

INTEGER

1020

[Wh]

netioInputID.x.0

1.3.6.1.4.1.47952.1.3.1.1.x.0

INTEGER

1

 

netioInputName.x.0

1.3.6.1.4.1.47952.1.3.1.2.x.0

STRING

Input 1

Based on user defined name

netioInputState.x.0

1.3.6.1.4.1.47952.1.3.1.3.x.0

INTEGER

off(0), on(1)

 

netioInputStateString.x.0

1.3.6.1.4.1.47952.1.3.1.4.x.0

STRING

"off", "on"

 

netioInputS0Counter.x.0

1.3.6.1.4.1.47952.1.3.1.5.x.0

INTEGER

30

Number of S0 pulses

*: The start time that Energy (cumulated consumption) is counted from. The value is the same for all outputs.

Note: Metered values are available only for device with metering support. Other devices return value “0”.

 

 

Control (write access)

Object

OID

x – output number (1 - 8)

Type

Value

Action

netioOutputAction.x.0

1.3.6.1.4.1.47952.1.1.1.5.x.0

INTEGER

0

1

2

3

4

5

Turn OFF

Turn ON

Short OFF delay (restart)

Short ON delay

Toggle (invert the state)

No change

Examples:

SET 1.3.6.1.4.1.47952.1.1.1.5.2.0 = 1           Output 2 = ON

SET 1.3.6.1.4.1.47952.1.1.1.5.1.0 = 4           Toggle Output 1

SET 1.3.6.1.4.1.47952.1.1.1.5.8.0 = 0           Output 8 = OFF

 

Net-SNMP utility for Linux

The following examples use the Net-SNMP utility. If you don’t have it already, you can easily install – see the “Installing the Net-SNMP utility for Linux” section at the end of this document.

Default MIB directories are: /root/.snmp/mibs, /usr/share/snmp/mibs/, /usr/share/snmp/mibs/iana/, /usr/share/snmp/mibs/ietf/, /usr/share/mibs/site/, /usr/share/snmp/mibs/, /usr/share/mibs/iana/, /usr/share/mibs/ietf/, /usr/share/mibs/netsnmp

We recommend to rename the NETIO MIB downloaded from the NETIO web administration to NETIO-PRODUCTS-NETIO-MIB and store it to /usr/share/snmp/mibs/ (the recommended default directory), in order to be consistent with the following examples.

Besides the NETIO MIB, the following MIBs are also required:

SNMPv2-SMI

SNMPv2-TC

For details about getting them, see the “Installing the Net-SNMP utility for Linux” section at the end of this document.

 

SNMP utility for Windows

The examples use SnmpWalk, SnmpGet and SnmpSet by SnmpSoft Company (https://syslogwatcher.com/cmd-tools/). The utilities are free-of-charge for non-commercial use.

It is sufficient to download the individual utilities, unpack them and use them. For correct function, the utilities should be run from the directory where they are stored (or the directory added to the PATH).

These utilities don’t work with MIBs, only with OIDs.

 

Configuring NETIO 4x – SNMP v1/v2c

In the NETIO 4x web administration, go to the M2M API Protocols section and enable SNMP. If necessary, modify the Port number. Select the v1,2c SNMP version. If necessary, modify the Community. Click Save Changes. To download the MIB for NETIO, click Download MIB.

 

Examples of using SNMP v1/v2c

1.Listing all states/values (SNMP v1 / v2c)

Linux – using MIB

snmpwalk -m <NETIO MIB name> [optionally -M <path to MIBs>] -v <SNMP version: 1 or 2c> -c <Community> <NETIO IP address> <subtree specification: NETIOProducts>

Example: snmpwalk -m NETIO-PRODUCTS-NETIO-MIB -v 1 -c public 192.168.120.135 NETIOProducts

 

In a similar way, for SNMP v2c: snmpwalk -m NETIO-PRODUCTS-NETIO-MIB -v 2c -c public 192.168.120.135 NETIOProducts

If the MIBs are stored in other than the default directory (see above), the -M option with the path needs to be specified, too. E.g.: snmpwalk -m NETIO-PRODUCTS-NETIO-MIB -M /usr/share/snmp/mibs/ -v 1 -c public 192.168.120.135 NETIOProducts

 

Windows

SnmpWalk.exe -r:<IP address NETIO> -v:<version SNMP: 1 or 2c> -c:<Comunity>

Example: SnmpWalk.exe -r:192.168.120.135 -v:1 -c:"public"

or: SnmpWalk.exe -r:192.168.120.135 -c:"public"

 

In a similar way, for SNMP v2c: SnmpWalk.exe -r:192.168.120.135 -v:2c -c:"public"

 

Displaying a specific value (SNMP v1 / v2c)

Linux – using MIB and object name

snmpget -m <NETIO MIB name> [optionally -M <path to MIBs>] -v <SNMP version: 1 or 2c> -c <Community> <NETIO IP address> <Object to read according to the table above>

Example – displaying the status of socket No. 1: snmpget -m NETIO-PRODUCTS-NETIO-MIB -v 1 -c public 192.168.120.135 netioOutputState.1

 

In a similar way, for SNMP v2c: snmpget -m NETIO-PRODUCTS-NETIO-MIB -v 2c -c public 192.168.120.135 netioOutputState.1

If the MIBs are stored in other than the default directory (see above), the -M option with the path needs to be specified, too.

Example: snmpget -m NETIO-PRODUCTS-NETIO-MIB -M /usr/share/snmp/mibs/ -v 1 -c public 192.168.120.135 netioOutputState.1

 

 

Linux - using OID

snmpget -v <SNMP version: 1 or 2c> -c <Community> <NETIO IP address> <OID to read according to the table above>

Example – displaying the status of socket No. 1: snmpget -v 1 -c public 192.168.120.135 1.3.6.1.4.1.47952.1.1.1.3.1

In a similar way, for SNMP v2c: snmpget -v 2c -c public 192.168.120.135 1.3.6.1.4.1.47952.1.1.1.3.1

 

Windows - using OID

SnmpGet.exe -r:<NETIO IP address> -v:<SNMP version: 1 or 2c> -c:<Community>

Example: SnmpGet.exe -r:192.168.120.135 -v:1 -c:"public" -o:1.3.6.1.4.1.47952.1.1.1.3.1

or: SnmpGet.exe -r:192.168.120.135 -c:"public" -o:1.3.6.1.4.1.47952.1.1.1.3.1

In a similar way, for SNMP v2c: SnmpGet.exe -r:192.168.120.135 -v:1 -c:"public" -o:1.3.6.1.4.1.47952.1.1.1.3.1

 

Configuring NETIO 4x - SNMP v3

In the NETIO 4x web administration, go to the M2M API Protocols section and enable SNMP. If necessary, modify the Port number. Select SNMP v3.

There are two SNMP users available in SNMP v3 – one with read/write access rights (Allow READ-WRITE access), the other with read-only access rights (Allow READ-ONLY access). For each user, access and security can be set individually, or the user disabled.

Enable/disable individual SNMP users (one or both), set the individual parameters and click Save Changes.

To download the MIB for NETIO, click Download MIB.

 

Note: NETIO uses the specified Password as the “authentication protocol pass phrase” as well as the “privacy protocol pass phrase”.

 

Examples of using SNMPv3

 

1.   Listing all statues/values (SNMP v3)

 

Linux - using MIB

snmpwalk -m <NETIO MIB name> [optionally -M <path to MIB>] -v <SNMP version: 3> -a <protocol: MD5|SHA> -A <Password> -I <Security: authNoPriv|authPriv> -u <Username> -x <Encryption: DES|AES> -X <Password> <NETIO IP address> <subtree specification: NETIOProducts>

Example: snmpwalk -m NETIO-PRODUCTS-NETIO-MIB -v 3 -a SHA -A mypassword -l authPriv -u user -x AES -X mypassword 192.168.120.135 NETIOProducts

 

If the MIBs are stored in other than the default directory (see above), the -M option with the path needs to be specified, too.

Example: snmpwalk -m NETIO-PRODUCTS-NETIO-MIB -M /usr/share/snmp/mibs/ -v 3 -a SHA -A mypassword -l authPriv -u user -x AES -X mypassword 192.168.120.135 NETIOProducts

 

Windows

SnmpWalk.exe -r:<NETIO IP address> -v:<SNMP version: 3> -sn:<Username> -ap:<protocol: MD5|SHA> -aw:<Password> -pp:<Encryption: DES|AES128> -pw:<Password>

Example:  SnmpWalk.exe -r:192.168.120.135 -v:3 -sn:user -ap:SHA -aw:mypassword -pp:AES128 -pw:mypassword

 

2.   Displaying a specific value (SNMP v3)

 

Linux - using MIB and object name

snmpget  -m <NETIO MIB name> [optionally -M <path to MIBs>] -v <SNMP version: 3> -a <protocol: MD5|SHA> -A <Password> -I <Security: authNoPriv|authPriv> -u <Username> -x <Encryption: DES|AES> -X <Password> <NETIO IP address> <Object to read according to the table above>

Example – displaying the status of socket No. 1: snmpget -m NETIO-PRODUCTS-NETIO-MIB -v 3 -a SHA -A mypassword -l authPriv -u user -x AES -X mypassword 192.168.120.135 netioOutputState.1

 

If the MIBs are stored in other than the default directory (see above), the -M option with the path needs to be specified, too.

Example: snmpget -m NETIO-PRODUCTS-NETIO-MIB -M /usr/share/snmp/mibs/ -v 3 -a SHA -A a1234567 -l authPriv -u admin -x AES -X a1234567 192.168.120.135 netioOutputState.1

 

Linux - using OID

snmpget -v <SNMP version: 3> -a <protocol: MD5|SHA> -A <Password> -I <Security: authNoPriv|authPriv> -u <Username> -x <Encryption: DES|AES> -X <Password> <NETIO IP address> <OID to read according to the table above>

Example – displaying the status of socket No. 1: snmpget -v 3 -a SHA -A mypassword -l authPriv -u user -x AES -X mypassword 192.168.120.135 1.3.6.1.4.1.47952.1.1.1.3.1

 

Windows - using OID

SnmpGet.exe -r:<NETIO IP address> -v:<SNMP version: 3> -sn:<Username> -ap:<protocol: MD5|SHA> -aw:<Password> -pp:<Encryption: DES|AES128> -pw:<Password> -o:<OID to read according to the table above>

Example: SnmpGet.exe -r:192.168.120.135 -v:3 -sn:user -ap:SHA -aw:mypassword -pp:AES128 -pw:mypassword -o:1.3.6.1.4.1.47952.1.1.1.3.1

 

3.   Controlling a socket using MIB and object name (SNMP v3)

 

Linux - using MIB and object name

snmpset -m <NETIO MIB name> [optionally -M <path to MIB>] -v <SNMP version: 3> -a <protocol: MD5|SHA> -A <Password> -I <Security: authNoPriv|authPriv> -u <Username> -x <Encryption: DES|AES> -X <Password> <NETIO IP address> <Object to write according to the table above> <corresponding Type> <Value>

Example – turn on socket 1: snmpset -m NETIO-PRODUCTS-NETIO-MIB -v 3 -a SHA -A a1234567 -l authPriv -u admin -x AES -X a1234567 192.168.120.135 netioOutputAction.1 i 1

 

If the MIBs are stored in other than the default directory (see above), the -M option with the path needs to be specified, too.

Example: snmpset -m NETIO-PRODUCTS-NETIO-MIB -M /usr/share/snmp/mibs/ -v 3 -a SHA -A a1234567 -l authPriv -u admin -x AES -X a1234567 192.168.120.135 netioOutputAction.1 i 1

 

Linux - using OID

snmpset -v <SNMP version: 3> -a <protocol: MD5|SHA> -A <Password> -I <Security: authNoPriv|authPriv> -u <Username> -x <Encryption: DES|AES> -X <Password> <NETIO IP address> <OID to write according to the table above> <corresponding Type> <Value>

Example – turn on socket 1: snmpset -v 3 -a SHA -A a1234567 -l authPriv -u admin -x AES -X a1234567 192.168.120.135 1.3.6.1.4.1.47952.1.1.1.5.1 i 1

 

Windows - using OID

SnmpSet.exe -r:<NETIO IP address> -v:<SNMP version: 3> -sn:<Username> -ap:<protocol: MD5|SHA> -aw:<Password> -pp:<Encryption: DES|AES128> -pw:<Password> -o:<OID to read according to the table above> -val:<Value> -tp:<corresponding Type>

Example – turn on socket 1: SnmpSet.exe -r:192.168.120.135 -v:3 -sn:admin -ap:SHA -aw:a1234567 -pp:AES128 -pw:a1234567 -o:1.3.6.1.4.1.47952.1.1.1.5.1 -val:1 -tp:int

 

FAQ:

1) What happens if I change the SNMP Port?

Linux: If the Port is set to something other than the default 161, simply specify the port number after the IP address, separated with a colon. E.g. 192.168.120.135:1111 to use port No. 1111.

Windows: If the Port is set to something other than the default 161, add a “-p:<port>” parameter to the command. E.g. SnmpWalk.exe -r:192.168.120.135 -p:1111 -c:"public" to use port No. 1111.

 

2) Why the sockets cannot be controlled with SNMP v1 / v2c ?

SNMP v1 and v2c do not use authentication. Therefore, writing over this protocol is not secured in any way. It is impossible to restrict write access to authorized devices/software/systems only. As a result, SNMP v1 and v3 can be used for reading, but only SNMP v3 can be used for writing (control).

 


Supported FW versions:

3.1.0 and higher (Archive firmwware)


 

Installing the Net-SNMP utility for Linux

Tested on Debian GNU/Linux 8.

 

-> Install the snmp package

http://net-snmp.sourceforge.net/wiki/

https://wiki.debian.org/SNMP

 

Then, the following two MIBs are needed:

SNMPv2-SMI

SNMPv2-TC

-> Install the snmp-mibs-downloader package

-> Run download-mibs

MIBs are stored to /var/lib/mibs/ietf

-> Copy the two above-mentioned MIBs to /usr/share/snmp/mibs/ (recommended default directory)

 

NETIO MIB – downloaded from the NETIO web administration interface

-> Rename to NETIO-PRODUCTS-NETIO-MIB (recommended in order to simplify the use of our examples)

-> Store to /usr/share/snmp/mibs/ (recommended default directory)

Supported devices:

Ask for a price or technical parameters

For device testing use name/password demo/demo