Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion snmpget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
2 changes: 1 addition & 1 deletion snmpset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
2 changes: 1 addition & 1 deletion snmptrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion snmpwalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});