node-ldapjs/lib/dtrace.js

73 lines
1.6 KiB
JavaScript
Raw Normal View History

2011-08-30 00:24:50 +00:00
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
var dtrace = require('dtrace-provider');
///--- Globals
var SERVER_PROVIDER;
/* Args:
* 0 -> RequestId (<ip>:<src port>:<msgID>)
* 1 -> remoteIP
* 2 -> bindDN
* 3 -> req.dn
* 4,5 -> op specific
2011-08-30 00:24:50 +00:00
*/
var SERVER_PROBES = {
// 4: attributes.length
add: ['char *', 'char *', 'char *', 'char *', 'int'],
2011-08-30 00:24:50 +00:00
bind: ['char *', 'char *', 'char *', 'char *'],
2011-08-30 04:48:05 +00:00
// 4: attribute, 5: value
compare: ['char *', 'char *', 'char *', 'char *', 'char *', 'char *'],
2011-08-30 04:48:05 +00:00
'delete': ['char *', 'char *', 'char *', 'char *'],
2011-08-30 04:48:05 +00:00
// 4: requestName, 5: requestValue
exop: ['char *', 'char *', 'char *', 'char *', 'char *', 'char *'],
2011-08-30 04:48:05 +00:00
// 4: changes.length
modify: ['char *', 'char *', 'char *', 'char *', 'int'],
2011-08-30 04:48:05 +00:00
// 4: newRdn, 5: newSuperior
modifyDN: ['char *', 'char *', 'char *', 'char *', 'char *', 'char *'],
2011-08-30 04:48:05 +00:00
// 4: filter, 5: scope
search: ['char *', 'char *', 'char *', 'char *', 'char *', 'char *'],
2011-08-30 04:48:05 +00:00
unbind: ['char *', 'char *', 'char *', 'char *'],
2011-08-30 04:48:05 +00:00
// remote IP
connection: ['char *'],
request: ['char *', 'char *', 'char *', 'char *'],
// requestId, remoteIp, bindDN, request.dn, statusCode, errorMessage
response: ['char *', 'char *', 'char *', 'char *', 'int', 'char *']
2011-08-30 00:24:50 +00:00
};
///--- API
module.exports = function() {
if (!SERVER_PROVIDER) {
SERVER_PROVIDER = dtrace.createDTraceProvider('ldapjs');
2011-08-30 00:24:50 +00:00
Object.keys(SERVER_PROBES).forEach(function(p) {
var args = SERVER_PROBES[p].splice(0);
args.unshift(p);
2011-08-30 04:48:05 +00:00
dtrace.DTraceProvider.prototype.addProbe.apply(SERVER_PROVIDER, args);
});
2011-08-30 00:24:50 +00:00
SERVER_PROVIDER.enable();
2011-08-30 00:24:50 +00:00
}
return SERVER_PROVIDER;
}();