diff --git a/lib/agent.js b/lib/agent.js index 3074bb3..21c19e9 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -40,6 +40,31 @@ AgentMIBDecor.prototype.instancePossible = function () { return (this._scalar || this._column); }; +function +Agent(options) +{ + var self = this; + + Listener.call(this, options); + + if (typeof (options.dtrace) !== 'object') + throw new TypeError('options.dtrace (object) is required'); + + this._dtrace = options.dtrace; + + Object.keys(AGENT_PROBES).forEach(function (p) { + var args = AGENT_PROBES[p].splice(0); + args.unshift(p); + + self._dtrace.addProbe.apply(self._dtrace, args); + }); + + this._dtrace.enable(); + + this._mib = new MIB(); +} +util.inherits(Agent, Listener); + Agent.prototype._add_provider = function _add_provider(prov) { var self = this; var decor; @@ -84,31 +109,6 @@ Agent.prototype.addProviders = function addProviders(prov) { } }; -function -Agent(options) -{ - var self = this; - - Listener.call(this, options); - - if (typeof (options.dtrace) !== 'object') - throw new TypeError('options.dtrace (object) is required'); - - this._dtrace = options.dtrace; - - Object.keys(AGENT_PROBES).forEach(function (p) { - var args = AGENT_PROBES[p].splice(0); - args.unshift(p); - - self._dtrace.addProbe.apply(self._dtrace, args); - }); - - this._dtrace.enable(); - - this._mib = new MIB(); -} -util.inherits(Agent, Listener); - /* * The provider is expected to provide one of three things for each iteration * requested of it: diff --git a/snmpget.js b/snmpget.js index 79603bf..6ad3034 100644 --- a/snmpget.js +++ b/snmpget.js @@ -24,5 +24,5 @@ var oid = process.argv[4]; client.get(ip, community, 0, oid, function (snmpmsg) { print_get_response(snmpmsg); - client.unref(); + client.close(); }); diff --git a/snmpset.js b/snmpset.js index 077217b..85d8f69 100644 --- a/snmpset.js +++ b/snmpset.js @@ -20,5 +20,5 @@ client.set(ip, community, 0, oid, snmp.data.createData({ type: 'Integer', value: parseInt(value, 10) }), function (snmpmsg) { // console.log(snmp.pdu.strerror(snmpmsg.pdu.error_status)); process.exitCode = snmpmsg.pdu.error_status; - client.unref(); + client.close(); }); diff --git a/snmptrap.js b/snmptrap.js index 7c1067c..9d7a69f 100644 --- a/snmptrap.js +++ b/snmptrap.js @@ -14,7 +14,7 @@ if ('snmpinform' == path.basename(process.argv[1]).split('.')[0]) console.log(util.inspect(snmp.message.serializer(snmpmsg), false, null, true)); process.exitCode = snmpmsg.pdu.error_status; - client.unref(); + client.close(); }; var client = snmp.createClient({ diff --git a/snmpwalk.js b/snmpwalk.js index 53e89d2..d6f0d8f 100644 --- a/snmpwalk.js +++ b/snmpwalk.js @@ -41,5 +41,5 @@ var community = process.argv[3]; var oid = process.argv[4]; snmpwalk(ip, community, 0, oid, print_get_response, function () { - client.unref(); + client.close(); });