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

NETIO 4x electrical sockets (PDU) can be monitored and controlled over LAN/WiFi using SNMP. In this way, it is possible to measure the immediate consumption (NETIO 4All only) or to switch individual 110/230V sockets on or off. This AN11 Application Note shows how to perform SNMP v3 read and write operations in MS Windows or Linux. 

Do you have any questions?

All NETIO 4x devices (NETIO 4 / 4All / 4C) support SNMP v1 and v3. However, SNMP v1 can be only used to read values. SNMP allows checking the states of individual sockets, measuring the immediate consumption, or (in case of SNMP v3) controlling individual sockets. SNMP is a standard protocol supported by numerous third-party monitoring software.

For SNMP communication, NETIO 4x uses the default port 161. This can be changed in the web administration. MIB with Object descriptions can be downloaded in the NETIO 4x administration, too.

NETIO 4x supports the following SNMP versions:

  • v1,2c – SNMP v1 and v2c can be used for monitoring (reading of states) only
  • v3 – SNMP v3 uses authentication and encryption, and can be used to monitor as well as control the sockets

 

Supported devices: NETIO 4All, NETIO 4C, NETIO 4

 

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 SnmpSoft Company (https://syslogwatcher.com/cmd-tools/) can be used for SNMP communication. The utilities are free-of-charge for non-commercial use. These utilities don’t work with MIBs, only with OIDs.

 

Usage examples:

  • Remote monitoring of the socket states
  • Controlling the sockets from a remote computer

 



Quick navigation in Application Note AN11:

 

Examples of using SNMP v1/v2c

Listing all states/values (SNMP v1 / v2c)

Linux - using MIB

Windows

Displaying a specific value (SNMP v1 / v2c)

Linux - using MIB and object name

Linux - using OID

Windows - using OID

 

Examples of using SNMP v3

Listing all states/values (SNMP v3)

Linux - using MIB

Windows

Displaying a specific value (SNMP v3)

Linux - using MIB and object name

Linux -using OID

Windows - using OID

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

Linux - using MIB and object name

Linux - using OID

Windows - using OID


 

Objects in NETIO 4x SNMP MIB

Monitoring (read access)

Object

OID

x – stands for the outlet number (1, 2, 3, 4)
Type Example value Note

netioOutputID.x

1.3.6.1.4.1.47952.1.1.1.1.x
INTEGER 1  

netioOutputName.x

1.3.6.1.4.1.47952.1.1.1.2.x
STRING output_1 According to user settings

netioOutputState.x

1.3.6.1.4.1.47952.1.1.1.3.x
INTEGER off(0), on(1)  

netioOutputStateString.x

1.3.6.1.4.1.47952.1.1.1.4.x
STRING "off", "on"  

netioOutputLoad.x

1.3.6.1.4.1.47952.1.1.1.25.x
INTEGER 24 [W]

netioOutputEnergy.x

1.3.6.1.4.1.47952.1.1.1.26.x
INTEGER 13 [Wh]

netioOutputEnergyStart.x

1.3.6.1.4.1.47952.1.1.1.27.x
DateAndTime 2017-6-23,5:47:3.0,+0:0 Start time for “netioOutputEnergy”. UTC *1

netioOutputCurrent.x

1.3.6.1.4.1.47952.1.1.1.28.x
INTEGER 195 [mA]

netioOutputCurrentPowerFactor.x

1.3.6.1.4.1.47952.1.1.1.29.x
INTEGER 534 Current power factor * 1000

netioVoltage

1.3.6.1.4.1.47952.1.2.1
INTEGER 239100 Grid voltage [mV]

netioFrequency

1.3.6.1.4.1.47952.1.2.2
INTEGER 49900 Grid frequency [mHz]

netioTotalCurrent

1.3.6.1.4.1.47952.1.2.3
INTEGER 195 [mA]

netioOverallPowerFactor

1.3.6.1.4.1.47952.1.2.4

INTEGER 534 Current power factor * 1000

netioTotalLoad

1.3.6.1.4.1.47952.1.2.5
INTEGER 24 [W]

netioTotalEnergy

1.3.6.1.4.1.47952.1.2.6
INTEGER 13 [Wh]

netioEnergyStart

1.3.6.1.4.1.47952.1.2.7
DateAndTime 2017-6-23,5:47:3.0,+0:0 Start time for  “netioTotalEnergy”. UTC *1

 

*1: Start time for the metering of accumulated consumption. This value is the same for all outputs/sockets.

NoteMeasurements (voltage, frequency, current, power factor, load and energy) are available only in NETIO 4All. Other NETIO models return “0”.

 

Control (write access)

Object

OID

x – stands for the outlet number (1, 2, 3, 4)
Type Value Action

netioOutputAction.x

1.3.6.1.4.1.47952.1.1.1.5.x
INTEGER (i)

0

1

2

3

4

5

turn off

turn on

turn off for a short time * (restart)

turn on for a short time **

toggles the current state

no change

 

* If the socket was off, the command turns it on.

** If the socket was on, the command turns it 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)

 

This Application Note is compatible with:

Smart power socket NETIO

 

NETIO 4

NETIO 4 is smart power socket (smart power strip) with four 230V/8A sockets, connected to LAN and WiFi. Each of the four power sockets can be individually switched on/off using various M2M API protocols. NETIO 4 is a unique product designed for IT, industry, smart homes, multimedia installations and other applications. Use the product whenever you need 230V sockets controlled by a mobile app, by a computer program (via M2M API) or by a custom script (Lua), and featuring a timer (Scheduler) or auto reboot functionality (IP WatchDog). 

More about NETIO 4

 

Smart power socket NETIO 4All

 

NETIO 4All

NETIO 4All is a PDU module featuring four 230V/8A power sockets with consumption metering for each socket as well as LAN and WiFi connectivity. Each of the four sockets can be individually switched on/off over the Web or using various M2M API protocols. Electricity consumption (A, W, kWh) can be measured at each power socket. NETIO 4All smart sockets are designed for remote measurement and control of electrical sockets. Use the product whenever you need 230V sockets controlled by a mobile app, by a computer program (via M2M API) or by a custom script (Lua) that runs directly in the NETIO 4All smart socket device.

More about NETIO 4All

Smart power socket NETIO

 

NETIO 4C

NETIO 4C is a small 110/230V PDU (Power Distribution Unit) with four controlled IEC-320 C13 (max 8A) power outlets. It includes an Ethernet switch and two LAN ports for network connections. Each of the four power outputs can be individually switched on/off over the web, from a mobile app, or using various M2M APIs (SNMP, MQTT, XML, Modbus/TCP, ..). Custom Lua scripts can run directly in the NETIO 4C device. As a distinctive feature, NETIO 4C provides a RS-232 serial port (3-pin) that can be controlled with a Lua script or used as a remote serial port.

More about NETIO 4C

 

Ask for a price or technical parameters

For device testing use name/password demo/demo