Giter Site home page Giter Site logo

smithsnmp's Introduction

SmithSNMP -- Customize your private MIBs in Lua

Build Status

SmithSNMP is a fork from SmartSNMP with more advanced features ahead such as SNMPv3, encryption and SNMPv2 trap. Just like the character in the famous science fiction movie Matrix, Agent Smith, with great power and is programmed to keep the system in order.

SmithSNMP is an easy-config agent supporting SNMP v1/v2c/v3 and AgentX protocol. It is written in C99 and Lua5.1. It can be run on general Linux and BSD platforms as well as embedded systems like OpenWRT. The agent can not only be compatible with command utilities but also SNMPv2 trap daemon of Net-SNMP.

License

SmithSNMP is licensed under GPLv2 with "PRIVATE MIB" EXCEPTION, see LICENSE file for more details.

Configuration

The biggest bonus of this agent is that private MIBs in Lua are allowed to be customized and in hot-loading in config and mibs directory.

Build

As for Ubuntu, you should install libraries such as:

# lua5.1
sudo apt-get install -y lua5.1 liblua5.1-0-dev

# scons
sudo apt-get install -y scons

# luarocks
sudo apt-get install -y luarocks

# clone with git
git clone https://github.com/begeekmyfriend/smithsnmp.git

For more build options, type:

scons --help

You will get:

... SCons Options ...
Local Options:
  --with-agentx               enable agentx feature you want to use
  --without-trap              disable trap feature you do not want to use
  --without-crypto            disable crypto feature you do not want to use
  --without-md5               disable MD5 feature you do not want to use
  --without-sha               disable SHA feature you do not want to use
  --without-aes               disable AES feature you do not want to use
  --evloop=[select|kqueue|epoll]
                              select event loop model
  --with-cflags=CFLAGS        use CFLAGS as compile time arguments (will
                                ignore CFLAGS env)
  --with-ldflags=LDFLAGS      use LDFLAGS as link time arguments to ld (will
                                ignore LDFLAGS env)
  --with-libs=LIBS            use LIBS as link time arguments to ld
  --with-liblua=DIR           use liblua in DIR

You can specify options above you need to build the project.

For luarocks build, type:

sudo luarocks build smithsnmp-scm-1.rockspec

Test

There are three test modes.

SNMP Agent Mode

In this mode the agent is running as an independent agent and process SNMP datagrams from the clients.

Any SNMP daemon installed in your system should be shut down before testing.

sudo /etc/init.d/snmpd stop

We start SmithSNMP as a daemon:

cd /usr/local/lib/luarocks/rocks/smithsnmp/scm-1
sudo ./tests/snmp_daemon.sh

And then run the testcases:

./tests/testcases.sh

AgentX agent mode

In this mode the agent is running as a sub-agent while Net-SNMP as the master agent from which AgentX datagrams will be received. So we need to download NET-SNMP-5.7.3 source and build out the images under tests directory:

cd /usr/local/lib/luarocks/rocks/smithsnmp/scm-1
sudo ./tests/netsnmp_build.sh

And then start Net-SNMP as the master agent:

sudo ./tests/netsnmpd.sh

And then start SmithSNMP as a sub-agent:

sudo ./tests/agentx_daemon.sh

And then run the testcases:

./tests/testcases.sh

SNMP Trap Mode

Especially if you want to test SNMP trap feature, start snmptrapd on the default port 162:

cd /usr/local/lib/luarocks/rocks/smithsnmp/scm-1
sudo ./tests/netsnmptrapd.sh

Now enable the trap feature when SmithSNMP is running as an agent on the default port 161):

snmpset -v2c -cprivate localhost .1.3.6.1.6.3.1.1.4.42.0 t 100

And you can disable the trap feature any time as you like:

snmpset -v2c -cprivate localhost .1.3.6.1.6.3.1.1.4.42.0 t 0

smithsnmp's People

Contributors

begeekmyfriend avatar dragoncheng avatar maxzerker avatar pravynandas avatar t-x avatar woong-choi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

smithsnmp's Issues

Trap trigger method ( need help )

In smithsnmp, there is just only method which is triggered by oid of .1.3.6.1.6.3.1.1.4.42.0.
It works fine.
But, I think this is the remote trigger, not local

Is there any local trigger or application such as snmptrap in package of NET-SNMP?

OID hierarchy in MIB file( need help )

Goal : the following oid hierarchy should be implement.

image

modemCommon.lua was added in "mibs" directory as below

image

If without unitModemTrapTable, It works well.
but when start with unitModemTrapTable, failed "modemCommon MIB module "
I consider this MIB seperate into 2 pieces, but failed.

I hope help from others

Help for OID numbering

Hi all,
while playing around with a concrete request for an own MIB I ran into following problem:

In agentx mode I want to create an OID numbering like below:

iso.3.6.1.4.1.9999.4.2.5.1.1 = STRING: "Test value 1"
iso.3.6.1.4.1.9999.4.2.5.1.2 = STRING: "Test value 2"
iso.3.6.1.4.1.9999.4.2.5.1.3 = STRING: "Test value 3"
iso.3.6.1.4.1.9999.4.2.5.1.4 = STRING: "Test value 4"
iso.3.6.1.4.1.9999.4.2.5.1.5 = STRING: "Test value 5"
iso.3.6.1.4.1.9999.4.2.5.2.1 = STRING: "1"
iso.3.6.1.4.1.9999.4.2.5.2.2 = STRING: "2"
iso.3.6.1.4.1.9999.4.2.5.2.3 = STRING: "3"
iso.3.6.1.4.1.9999.4.2.5.2.4 = STRING: "4"
iso.3.6.1.4.1.9999.4.2.5.2.5 = STRING: "5"

but with smithsnmpd I only succeed in generating OIDs in the following form:

so.3.6.1.4.1.9999.4.2.5.1.1.1 = STRING: "Test value 1"
iso.3.6.1.4.1.9999.4.2.5.1.2.1 = STRING: "Test value 2"
iso.3.6.1.4.1.9999.4.2.5.1.3.1 = STRING: "Test value 3"
...

What I mean is the last sub OID always results in 1 into difference to the first example.
Any idea how this can be solved?

I think the problem is within the table structure which always MUST have the form

[1] = {
	[1] = {
		indexes = entry_cache,
		[1] = mib.ConstOctString(function (i) return entry_get(i, 'line_state_detail') 
                }
            }

Any help would be aprreciated.

Big Endian Problem with Agentx

Hi all,
I ran into a seriously problem and after two days of searching in code, reading RFCs, tracing the interface with tcpdump, ... I'm really running out of options.

I'm running smithsnmp on two openwrt machines, the one is a liitle endian, the other is a big endian (and so each smithsnmp is compiled with the right endianess option). Each master is net-snmp and the AgentX is smithsnmp. No problem on the little endian, every thing works fine and answers to my remote snmget/snmpwalks.

On the big endian one if I try to start the smithsnmpd as AgentX I get the following output and it finishes:

ERR(-202): AgentX varbind oid length exceeds!
ERR(-202): AgentX varbind oid length exceeds!
Parse agentX open response PDU error!

Any help would be appreciated.
Thanks in advance
Helge

Review following code (maybe bug patch)

In snmptrap.lua

local trap_generic_reg = function (oid)
    assert(type(oid) == 'string')
    trap_generic_oid = {}
    for i in string.gmatch(oid, "%d+") do
        table.insert(trap_generic_oid, tonumber(i))
    end
    -- Register snmpTrapOID as a default SNMP trap varbind.
    trap.object_register(".1.3.6.1.6.3.1.1.4.1.0", trapGroup[snmpTrapOID], function() return true end)
end

Original src is as below
for i in string.gmatch(oid, "%d") do
With this code, some OID can not be parsed correctly, for example "1.3.6.1.4.1.29408.11.6.11.1.1.4.0"

Fixed src is as below
for i in string.gmatch(oid, "%d+") do

There is same defect in trap_specific_reg()

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.