GithubHelp home page GithubHelp logo

snmp-query-engine's People

Contributors

dk avatar tobez avatar

Stargazers

 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

snmp-query-engine's Issues

Example for TCP Client, response return "Request is not an array"

I would like to write a TCP Client in nodejs to communicate with snmp-query-engine but the response return:
[ 32, 0, "Request is not an array"]

The TCP Client:

var net = require('net');

var HOST = 'localhost';
var PORT = 7667;

var client = new net.Socket();

client.connect(PORT, HOST, function() {
    console.log('Client connected to: ' + HOST + ':' + PORT);

    //[0, 1, "127.0.0.1", 161, "1.3.6.1.2.1.25.1.1.0"]
    var data = '[149, 0, 1, 169, 49, 50, 55, 46, 48, 46, 48, 46, 49, 204, 161, 180, 49, 46, 51, 46, 54, 46, 49, 46, 50, 46, 49, 46, 50, 53, 46, 49, 46, 49, 46, 48]'
    client.write(data);
});

client.on('data', function(data) {
    console.log("Return: " + data);
     if (data.toString().endsWith('exit')) {
       client.destroy();
    }
});

client.on('close', function() {
    console.log('Client closed');
});

client.on('error', function(err) {
    console.error(err);
});

I encoded the request by this site.
Please help.

Fail to compile with msgpack for C/C++ Version 2.1.5

cc -c -Wall -Wno-unused-function -Werror -O3 -g -I/usr/local/include -I/opt/local/include -o util.o util.c
util.c:16:17: error: use of undeclared identifier 'MSGPACK_OBJECT_RAW'; did you mean 'MSGPACK_OBJECT_MAP'?
        if (o->type != MSGPACK_OBJECT_RAW)
                       ^~~~~~~~~~~~~~~~~~
                       MSGPACK_OBJECT_MAP
/usr/local/include/msgpack/object.h:38:5: note: 'MSGPACK_OBJECT_MAP' declared here
    MSGPACK_OBJECT_MAP                  = 0x07,
    ^
util.c:19:20: error: no member named 'raw' in 'msgpack_object_union'
        s = malloc(o->via.raw.size + 1);
                   ~~~~~~ ^
util.c:21:48: error: no member named 'raw' in 'msgpack_object_union'
                croak(1, "object_strdup: malloc(%d)", o->via.raw.size + 1);
                                                      ~~~~~~ ^
util.c:22:19: error: no member named 'raw' in 'msgpack_object_union'
        memcpy(s, o->via.raw.ptr, o->via.raw.size);
                  ~~~~~~ ^
/usr/include/secure/_string.h:65:33: note: expanded from macro 'memcpy'
  __builtin___memcpy_chk (dest, src, len, __darwin_obsz0 (dest))
                                ^
util.c:22:35: error: no member named 'raw' in 'msgpack_object_union'
        memcpy(s, o->via.raw.ptr, o->via.raw.size);
                                  ~~~~~~ ^
/usr/include/secure/_string.h:65:38: note: expanded from macro 'memcpy'
  __builtin___memcpy_chk (dest, src, len, __darwin_obsz0 (dest))
                                     ^
util.c:23:11: error: no member named 'raw' in 'msgpack_object_union'
        s[o->via.raw.size] = 0;
          ~~~~~~ ^
util.c:31:7: error: use of undeclared identifier 'MSGPACK_OBJECT_RAW'; did you mean 'MSGPACK_OBJECT_MAP'?
        case MSGPACK_OBJECT_RAW:
             ^~~~~~~~~~~~~~~~~~
             MSGPACK_OBJECT_MAP
/usr/local/include/msgpack/object.h:38:5: note: 'MSGPACK_OBJECT_MAP' declared here
    MSGPACK_OBJECT_MAP                  = 0x07,
    ^
util.c:32:14: error: no member named 'raw' in 'msgpack_object_union'
                if (o->via.raw.size >= bufsize)    return NULL;
                    ~~~~~~ ^
util.c:33:20: error: no member named 'raw' in 'msgpack_object_union'
                memcpy(s, o->via.raw.ptr, o->via.raw.size);
                          ~~~~~~ ^
/usr/include/secure/_string.h:65:33: note: expanded from macro 'memcpy'
  __builtin___memcpy_chk (dest, src, len, __darwin_obsz0 (dest))
                                ^
util.c:33:36: error: no member named 'raw' in 'msgpack_object_union'
                memcpy(s, o->via.raw.ptr, o->via.raw.size);
                                          ~~~~~~ ^
/usr/include/secure/_string.h:65:38: note: expanded from macro 'memcpy'
  __builtin___memcpy_chk (dest, src, len, __darwin_obsz0 (dest))
                                     ^
util.c:34:12: error: no member named 'raw' in 'msgpack_object_union'
                s[o->via.raw.size] = 0;
                  ~~~~~~ ^
util.c:51:17: error: use of undeclared identifier 'MSGPACK_OBJECT_RAW'; did you mean 'MSGPACK_OBJECT_MAP'?
        if (o->type != MSGPACK_OBJECT_RAW) return 0;
                       ^~~~~~~~~~~~~~~~~~
                       MSGPACK_OBJECT_MAP
/usr/local/include/msgpack/object.h:38:5: note: 'MSGPACK_OBJECT_MAP' declared here
    MSGPACK_OBJECT_MAP                  = 0x07,
    ^
util.c:53:13: error: no member named 'raw' in 'msgpack_object_union'
        if (o->via.raw.size != l) return 0;
            ~~~~~~ ^
util.c:54:24: error: no member named 'raw' in 'msgpack_object_union'
        return strncmp(o->via.raw.ptr, s, l) == 0;
                       ~~~~~~ ^
14 errors generated.
make: *** [util.o] Error 1

Hello

Your project is really amazing, recently I made my own snmp crawler for 20 million docsis devices, and I was surprised by the similarities of the techniques you applied.
Performing the UDP socket sharing is really the best solution.
I just missed a better control over using the UDP buffer (Linux: /proc/net/udp, Solaris: ioctl FIONREAD).
In the rest yours is superior.
Congratulations!

Response unreadable characters when request OID of MAC Address

Hi, I can get data about CPU load, uptime, disk space,... But when I try to get MAC Address (OID: 1.3.6.1.2.1.2.2.1.6.2), the response is some unreadable characters like below:

[ [ '1.3.6.1.2.1.2.2.1.6.2', '�P����' ] ]

This is my client:

var net = require('net');
var msgpack = require("msgpack-lite");

var SERVER_ADDRESS = 'localhost';
var SERVER_PORT = 7667;
var REMOTE_ADDRESS = '192.168.1.110';
var REMOTE_PORT = 161;

var client = new net.Socket();

client.connect(SERVER_PORT, SERVER_ADDRESS, function() {
    console.log('Client connected to: ' + SERVER_ADDRESS + ':' + SERVER_PORT);

    var buffer = msgpack.encode([4, 1, REMOTE_ADDRESS, REMOTE_PORT, [".1.3.6.1.2.1.2.2.1.6.2"]]);
    console.log("Client send: " + buffer);
    client.write(buffer);
});

client.on('data', function(data) {
    console.log("Client receive:");
    console.log(data);
    console.log(msgpack.decode(data)[2]);
    client.destroy();
});

client.on('close', function() {
    console.log('Client closed');
});

client.on('error', function(err) {
    console.error(err);
});

Checked with snmp command:

snmpwalk -v2c -c public localhost 1.3.6.1.2.1.2.2.1.6.2
IF-MIB::ifPhysAddress.2 = STRING: 0:c:29:cf:ad:48

Documentation for GETTABLE error responses

According to the manual entry for GETTABLE:

Possible errors are the same as in GET request, plus the following ...

However:

(1) When trying to retrieve a non-existent OID it just returns an empty list. Example: query IP-MIB::ipNetToPhysicalTable on a switch which doesn't implement it.

GET returns:
[20, 456, [['1.3.6.1.2.1.4.35', ['no-such-object']]]]

GETTABLE returns:
[21, 456, []]

Looking on the wire: the first case receives a response object which tcpdump decodes as noSuchObject; the second case just gives MIB values starting from the next available entry (in my test 1.3.6.1.2.1.5.1.0)

This suggests that getbulk can't distinguish "empty table" from "non-existent table", in which case the current SQE behaviour is reasonable, but I think this could be clarified in the documentation as the behaviour is different to GET.

(2) Forcing an error by issuing a GETTABLE request for OID "2", I get the following:

[37, 456, 'bad oid']

So the result code is there but not wrapped in an array, as it would be for GET. This conflicts with the manual which says:

The second element will either be a value, or an array with a single element. If it is an array, its only element will be an error description.

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.