Giter Club home page Giter Club logo

Comments (2)

markabrahams avatar markabrahams commented on July 28, 2024

Hi @ypzen - you can learn about table augmentation here:
https://www.rfc-editor.org/rfc/rfc2578.html#section-7.8

And I'd recommend looking in the interfaces MIB IF-MIB at ifTable and ifXTable to observe how ifXTable augments the base table ifTable as a simple example of table augmentation.

Here's a working example of table augmentation with this library. It implements cut-down versions of ifTable and ifXTable, but all of the indexing information is included to fully illustrate the use of table augmentation:

const snmp = require ("net-snmp");

const snmpOptions = {
    port: 1161
}

const callback = function (error, data) {
    if ( error ) {
        console.error (error);
    } else {
        console.log (JSON.stringify(data.pdu.varbinds, null, 2));
    }
};

const agent = snmp.createAgent(snmpOptions, callback);
const authorizer = agent.getAuthorizer ();
authorizer.addCommunity ("public");

const baseTableProvider = {
    name: "ifTable",
    type: snmp.MibProviderType.Table,
    oid: "1.3.6.1.2.1.2.2.1",
    tableColumns: [
        {
            number: 1,
            name: "ifIndex",
            type: snmp.ObjectType.Integer,
            maxAccess: snmp.MaxAccess['read-only']
        },
        {
            number: 2,
            name: "ifDescr",
            type: snmp.ObjectType.OctetString,
            maxAccess: snmp.MaxAccess['read-write']
        }
    ],
    tableIndex: [
        {
            columnName: "ifIndex"
        }
    ]
};
agent.registerProvider (baseTableProvider);

const augmentedTableProvider = {
    name: "ifXTable",
    type: snmp.MibProviderType.Table,
    oid: "1.3.6.1.2.1.31.1.1.1",
    tableColumns: [
        {
            number: 1,
            name: "ifName",
            type: snmp.ObjectType.OctetString,
            maxAccess: snmp.MaxAccess['read-write']
        }
    ],
    tableAugments: "ifTable"
}
agent.registerProvider (augmentedTableProvider);

const mib = agent.getMib ();

mib.addTableRow ("ifTable", [0, "lo"]);
mib.addTableRow ("ifTable", [2, "eth0"]);

mib.addTableRow ("ifXTable", [0, "Loopback"]);
mib.addTableRow ("ifXTable", [2, "LAN 1"]);

mib.dump ({
    leavesOnly: true,
    showProviders: true,
    showValues: true,
    showTypes: true
});

from node-net-snmp.

ypzen avatar ypzen commented on July 28, 2024

Hi @markabrahams
Thanks for about table augmentation ,

But i can't found solution using table augmentation for below example.

I need dynamic table tree.

root: 1.3.6.1.4.1.5333.2.3.2

first device - 1.3.6.1.4.1.5333.2.3.2.1
first detail first device - 1.3.6.1.4.1.5333.2.3.2.1.1
second detail first device - 1.3.6.1.4.1.5333.2.3.2.1.2

second device - 1.3.6.1.4.1.5333.2.3.2.2
first detail second device - 1.3.6.1.4.1.5333.2.3.2.2.1
second detail second device - 1.3.6.1.4.1.5333.2.3.2.2.2

n devices - 1.3.6.1.4.1.5333.2.3.2.n
first detail n device - 1.3.6.1.4.1.5333.2.3.2.n.1
second detail n device - 1.3.6.1.4.1.5333.2.3.2.n.2

Please suggest appropriate example for above example

from node-net-snmp.

Related Issues (20)

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.