2014-04-02 14:51:10 +00:00
|
|
|
// Copyright 2011 Mark Cavage, Inc. All rights reserved.s
|
2011-08-30 00:24:50 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
/// --- Globals
|
2011-08-30 00:24:50 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
var SERVER_PROVIDER
|
|
|
|
var DTRACE_ID = 0
|
|
|
|
var MAX_INT = 4294967295
|
2011-08-30 00:24:50 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
/*
|
|
|
|
* Args:
|
2011-11-15 18:49:23 +00:00
|
|
|
* server-*-start:
|
|
|
|
* 0 -> id
|
2011-08-30 18:12:34 +00:00
|
|
|
* 1 -> remoteIP
|
|
|
|
* 2 -> bindDN
|
|
|
|
* 3 -> req.dn
|
|
|
|
* 4,5 -> op specific
|
2011-11-15 18:49:23 +00:00
|
|
|
*
|
|
|
|
* server-*-done:
|
|
|
|
* 0 -> id
|
|
|
|
* 1 -> remoteIp
|
|
|
|
* 2 -> bindDN
|
|
|
|
* 3 -> requsetDN
|
|
|
|
* 4 -> status
|
|
|
|
* 5 -> errorMessage
|
|
|
|
*
|
2011-08-30 00:24:50 +00:00
|
|
|
*/
|
|
|
|
var SERVER_PROBES = {
|
|
|
|
|
2011-08-30 18:12:34 +00:00
|
|
|
// 4: attributes.length
|
2011-11-15 18:49:23 +00:00
|
|
|
'server-add-start': ['int', 'char *', 'char *', 'char *', 'int'],
|
|
|
|
'server-add-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
|
2011-08-30 00:24:50 +00:00
|
|
|
|
2011-11-15 18:49:23 +00:00
|
|
|
'server-bind-start': ['int', 'char *', 'char *', 'char *'],
|
|
|
|
'server-bind-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
|
2011-08-30 04:48:05 +00:00
|
|
|
|
2011-08-30 18:12:34 +00:00
|
|
|
// 4: attribute, 5: value
|
2011-11-22 21:29:19 +00:00
|
|
|
'server-compare-start': ['int', 'char *', 'char *', 'char *',
|
2019-08-27 21:11:49 +00:00
|
|
|
'char *', 'char *'],
|
2011-11-15 18:49:23 +00:00
|
|
|
'server-compare-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
|
2011-08-30 04:48:05 +00:00
|
|
|
|
2011-11-15 18:49:23 +00:00
|
|
|
'server-delete-start': ['int', 'char *', 'char *', 'char *'],
|
|
|
|
'server-delete-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
|
2011-08-30 04:48:05 +00:00
|
|
|
|
2011-08-30 18:12:34 +00:00
|
|
|
// 4: requestName, 5: requestValue
|
2011-11-22 21:29:19 +00:00
|
|
|
'server-exop-start': ['int', 'char *', 'char *', 'char *', 'char *',
|
2019-08-27 21:11:49 +00:00
|
|
|
'char *'],
|
2011-11-15 18:49:23 +00:00
|
|
|
'server-exop-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
|
2011-08-30 04:48:05 +00:00
|
|
|
|
2011-08-30 18:12:34 +00:00
|
|
|
// 4: changes.length
|
2011-11-15 18:49:23 +00:00
|
|
|
'server-modify-start': ['int', 'char *', 'char *', 'char *', 'int'],
|
|
|
|
'server-modify-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
|
2011-08-30 04:48:05 +00:00
|
|
|
|
2011-08-30 18:12:34 +00:00
|
|
|
// 4: newRdn, 5: newSuperior
|
2011-11-22 21:29:19 +00:00
|
|
|
'server-modifydn-start': ['int', 'char *', 'char *', 'char *', 'char *',
|
2019-08-27 21:11:49 +00:00
|
|
|
'char *'],
|
2011-11-22 21:29:19 +00:00
|
|
|
'server-modifydn-done': ['int', 'char *', 'char *', 'char *', 'int',
|
2019-08-27 21:11:49 +00:00
|
|
|
'char *'],
|
2011-08-30 04:48:05 +00:00
|
|
|
|
2011-11-17 19:56:19 +00:00
|
|
|
// 4: scope, 5: filter
|
2011-11-22 21:29:19 +00:00
|
|
|
'server-search-start': ['int', 'char *', 'char *', 'char *', 'char *',
|
2019-08-27 21:11:49 +00:00
|
|
|
'char *'],
|
2011-11-15 18:49:23 +00:00
|
|
|
'server-search-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
|
|
|
|
// Last two are searchEntry.DN and seachEntry.attributes.length
|
|
|
|
'server-search-entry': ['int', 'char *', 'char *', 'char *', 'char *', 'int'],
|
2011-08-30 04:48:05 +00:00
|
|
|
|
2011-11-15 18:49:23 +00:00
|
|
|
'server-unbind-start': ['int', 'char *', 'char *', 'char *'],
|
|
|
|
'server-unbind-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
|
2011-08-30 04:48:05 +00:00
|
|
|
|
2015-02-18 15:17:23 +00:00
|
|
|
'server-abandon-start': ['int', 'char *', 'char *', 'char *'],
|
|
|
|
'server-abandon-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
|
|
|
|
|
2011-08-30 04:48:05 +00:00
|
|
|
// remote IP
|
2011-11-22 21:29:19 +00:00
|
|
|
'server-connection': ['char *']
|
2019-08-27 21:11:49 +00:00
|
|
|
}
|
2011-08-30 00:24:50 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
/// --- API
|
2011-08-30 00:24:50 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
module.exports = (function () {
|
2011-08-30 18:12:34 +00:00
|
|
|
if (!SERVER_PROVIDER) {
|
2014-04-02 03:02:11 +00:00
|
|
|
try {
|
2019-08-27 21:11:49 +00:00
|
|
|
var dtrace = require('dtrace-provider')
|
|
|
|
SERVER_PROVIDER = dtrace.createDTraceProvider('ldapjs')
|
2014-04-02 14:51:10 +00:00
|
|
|
|
|
|
|
Object.keys(SERVER_PROBES).forEach(function (p) {
|
2019-08-27 21:11:49 +00:00
|
|
|
var args = SERVER_PROBES[p].splice(0)
|
|
|
|
args.unshift(p)
|
2014-04-02 14:51:10 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
dtrace.DTraceProvider.prototype.addProbe.apply(SERVER_PROVIDER, args)
|
|
|
|
})
|
2014-04-02 03:02:11 +00:00
|
|
|
} catch (e) {
|
|
|
|
SERVER_PROVIDER = {
|
2019-08-27 21:11:49 +00:00
|
|
|
fire: function () {
|
|
|
|
},
|
|
|
|
enable: function () {
|
|
|
|
},
|
|
|
|
addProbe: function () {
|
|
|
|
var p = {
|
|
|
|
fire: function () {
|
|
|
|
}
|
2014-04-02 03:02:11 +00:00
|
|
|
}
|
2019-08-27 21:11:49 +00:00
|
|
|
return (p)
|
|
|
|
},
|
|
|
|
removeProbe: function () {
|
|
|
|
},
|
|
|
|
disable: function () {
|
|
|
|
}
|
|
|
|
}
|
2014-04-02 03:02:11 +00:00
|
|
|
}
|
2011-08-30 00:24:50 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
SERVER_PROVIDER.enable()
|
2011-11-15 18:49:23 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
SERVER_PROVIDER._nextId = function () {
|
2019-08-27 21:11:49 +00:00
|
|
|
if (DTRACE_ID === MAX_INT) { DTRACE_ID = 0 }
|
2011-11-15 18:49:23 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
return ++DTRACE_ID
|
|
|
|
}
|
2011-08-30 00:24:50 +00:00
|
|
|
}
|
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
return SERVER_PROVIDER
|
|
|
|
}())
|