55 regels
1.3 KiB
JavaScript

/* eslint-disable no-unused-vars */
var snmp = require ("../");
var getopts = require ("getopts");
var options = getopts(process.argv.slice(2));
var providers;
var mibDir = '/var/tmp/mibs/';
var counter64 = function (num) {
var buf = Buffer.alloc (4);
buf.writeUInt32BE (num);
return buf;
};
var snmpOptions = {
disableAuthorization: options.n,
port: options.p,
engineID: options.e,
debug: options.d
};
var callback = function (error, data) {
if ( error ) {
console.error (error);
} else {
console.log (data.pdu.varbinds[0].oid);
}
};
var store = snmp.createModuleStore ();
var agent = snmp.createAgent (snmpOptions, callback);
var mib = agent.getMib ();
var authorizer = agent.getAuthorizer ();
authorizer.addCommunity ("public");
// IF-MIB load and providers registration
store.loadFromFile (mibDir + "IPv6-TC.mib");
store.loadFromFile (mibDir + "IPv6-MIB.mib");
providers = store.getProvidersForModule ("IPV6-MIB");
mib.registerProviders (providers);
// agent.getMib ().dumpProviders ();
// mib.dump ();
var modules = store.getModules (true);
var one = store.getModule ("IPV6-MIB");
var names = store.getModuleNames (true);
// console.log("All modules: ", JSON.stringify(modules, '', 2));
console.log("Modules: ", names);
console.log("Single module definition: ", JSON.stringify(one, '', 2));