Giter Club home page Giter Club logo

device-snmp-go's Introduction

edgexfoundry/device-snmp-go

Build Status Code Coverage Go Report Card GitHub Latest Dev Tag) GitHub Latest Stable Tag) GitHub License GitHub go.mod Go version GitHub Pull Requests GitHub Contributors GitHub Committers GitHub Commit Activity

Overview:

A generic SNMP device service. Included is a sample for a network switch device driver. Additionally, a Patlite profile is included in the profiles director.

This device service facilitates via the configuration, accessing the TrendNet TEG-082WS 10 port switch. You can send and receive event readings from the network switch. Currently this device service is tailored specifically to the TrendNET TEG-082WS switch but refactoring could take place to abstract the device type and provde a myrida of device profiles. You would need to interrogate the network switch and then determine the appropriate device profile. This particular device service uses the SNMP (Simple Network Management Protocol). SNMP communication with the switch permits the device service to create events based on the Network Switch data. For further information on the Simple Network Management Protocol SNMP Wiki

TODOS

Async callbacks not supported SNMP Traps are currently not implemented but will be completed at a future date. Network Switch Type abstraction

Pre-Requisites

device-snmp-go requires Go language. Download the current release if you don't have it already. Have access to the EdgeX Foundry project github site.

EdgeX-Go (The EdgeX Platform and Services)

This service requires the EdgeX-Go platform and several of its services to be up and running if you want to test the device service full integration. However, you can run this service as a standalone with the following minium services up and running either a) natively (.exe) or b) as Docker image containers.

Detailed instructions on how to use the various Edgex-Foundry service(s) are linked below.

Service README
core-data core/core-data/README.md
core-command core/core-command/README.md
core-metadata core/core-metadata/README.md

EdgeX Foundry Images and Containers

If you choose to run the required services or all services as Docker containers you will need to use the Delhi version 0.7.1 of the Edgex-Go Services.

Download from GitHub the EdgeXFoundry developer-scripts project. I download all of my EdgeX Foundry repositories into a parent 'edgexfoundry' directory. The following docker commands assume you have that parent directory in place.

To download the required Delhi versions of the Edgex-Go services perform the following from the console.

cd .../edgexfoundry/developer-scripts/compose-files/
docker-compose up -d 

Now to stop all of the services you and do the following:

cd .../edgexfoundry/developer-scripts/compose-files/
docker-compose down  

Now to stop all of the services and remove the docker volumes do the following:

cd .../edgexfoundry/developer-scripts/compose-files/
docker-compose down -v 

You would want to remove the docker image volumes for anything you persisted. The volumes contain all the data you have published to your edgex-go-mongo as an example. As a general practice I routinely remove my docker volumes. For more information on docker commands see ref Docker Commands

Note: docker-compose.yml is going to be the latest release version of the edgex-foundry project.
For future versions please use the docker-compose-delhi-0.7.1.yml file

GET calls (REST)

For device service get calls we will use our configured static IP address for our network card. You can find this by executing the following: osx. Note you will need to ensure you select your working machine's ethernet static and not any other devices you have on your local network. I have included the SNMP MIB table OID entry(s) so you can see what OID's the device service is using.

arp -a
cheese.attlocal.net (192.168.1.69) [ethernet] ...
...

This is the IP address you will substitute for localhost in the following commands. Verify the deployment by navigating to your server address in your preferred browser or Postman REST test harness. Or you can use the curl command from your console if your on linux or OSX. If you choose to use Postman just use the address less the curl command.

$ curl http://localhost:59993/api/v2/ping

Reboot

The current state of the Network Switch reboot

(SNMP OID) { oid: "1.3.6.1.4.1.28866.2.37.24.5.1.0", community: "private" }
$ curl http://localhost:59993/api/v2/trendnet01/Reboot

UpTime

The switch uptime since last reboot in TimeTicks

(SNMP OID) { oid: "1.3.6.1.4.1.28866.2.37.16.1.1.0", community: "private" }
$ curl http://localhost:59993/api/v2/trendnet01/Uptime

Firmware

The switch firmware version

(SNMP OID) { oid: "1.3.6.1.4.1.28866.2.37.16.1.2.0", community: "private" }
$ curl http://localhost:59993/api/v2/trendnet01/Firmware

MACAddress

The switch MAC Address

(SNMP OID) { oid: "1.3.6.1.4.1.28866.2.37.16.2.1.0", community: "private" }
$ curl http://localhost:59993/api/v2/trendnet01/MacAddress

IPV4Address

The switch IPV4 Address

(SNMP OID) { oid: "1.3.6.1.4.1.28866.2.37.16.1.2.0", community: "private" }
$ curl http://localhost:59993/api/v2/trendnet01/IPV4Address

IPV4SubnetMask

The switch Subnet Mask

(SNMP OID) { oid: "1.3.6.1.4.1.28866.2.37.16.3.3.0", community: "private" }
$ curl http://localhost:59993/api/v2/trendnet01/IPV4SubnetMask

IPV4GatewayAddress

The switch IPV4 Gateway Address

(SNMP OID) { oid: "1.3.6.1.4.1.28866.2.37.16.3.4.0", community: "private" }
$ curl http://localhost:59993/api/v2/trendnet01/IPV4GatewayAddress

PUT calls (REST)

For the set commands we presently just have one. I have included the SNMP MIB OID table entry(s) so you can see what OID's the device service is using.

Reboot

Restarts the switch

(SNMP OID) { oid: "1.3.6.1.4.1.28866.2.37.24.5.1.0", community: "private" }
Parameter Value Description
RebootControlState 1 Restarts the switch
RebootControlState 2 Factory reset and restarts switch
RebootControlState 3 Factory reset, restarts switch with no IP Address
$ curl -H 'Content-Type: application/json' -X PUT -d '{"RebootControlState":"1"}' http://localhost:59993/api/v2/Reboot

Configuration

This service is driven by a configuration.toml TOML-based file that resides in the directory the application is executed from. See cmd/res/configuration.toml for default configuration.

References

Website: Dillinger.io "A great README.md file editor"

device-snmp-go's People

Contributors

akramtexas avatar bnevis-i avatar chr1shung avatar cloudxxx8 avatar dependabot[bot] avatar ernestojeda avatar farshidtz avatar felixting avatar iain-anderson avatar jamesrgregg avatar jim-wang-intel avatar jinlinguan avatar jpwhitemn avatar lenny-intel avatar monicaisher avatar soda480 avatar tmpowers avatar tobiasmo1 avatar tonyespy avatar venkata-subbareddyk avatar weichou1229 avatar xmlviking avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.