Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dtrace.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Copyright 2011 Mark Cavage, Inc. All rights reserved.s
  2. ///--- Globals
  3. var SERVER_PROVIDER;
  4. var DTRACE_ID = 0;
  5. var MAX_INT = 4294967295;
  6. /*
  7. * Args:
  8. * server-*-start:
  9. * 0 -> id
  10. * 1 -> remoteIP
  11. * 2 -> bindDN
  12. * 3 -> req.dn
  13. * 4,5 -> op specific
  14. *
  15. * server-*-done:
  16. * 0 -> id
  17. * 1 -> remoteIp
  18. * 2 -> bindDN
  19. * 3 -> requsetDN
  20. * 4 -> status
  21. * 5 -> errorMessage
  22. *
  23. */
  24. var SERVER_PROBES = {
  25. // 4: attributes.length
  26. 'server-add-start': ['int', 'char *', 'char *', 'char *', 'int'],
  27. 'server-add-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
  28. 'server-bind-start': ['int', 'char *', 'char *', 'char *'],
  29. 'server-bind-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
  30. // 4: attribute, 5: value
  31. 'server-compare-start': ['int', 'char *', 'char *', 'char *',
  32. 'char *', 'char *'],
  33. 'server-compare-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
  34. 'server-delete-start': ['int', 'char *', 'char *', 'char *'],
  35. 'server-delete-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
  36. // 4: requestName, 5: requestValue
  37. 'server-exop-start': ['int', 'char *', 'char *', 'char *', 'char *',
  38. 'char *'],
  39. 'server-exop-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
  40. // 4: changes.length
  41. 'server-modify-start': ['int', 'char *', 'char *', 'char *', 'int'],
  42. 'server-modify-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
  43. // 4: newRdn, 5: newSuperior
  44. 'server-modifydn-start': ['int', 'char *', 'char *', 'char *', 'char *',
  45. 'char *'],
  46. 'server-modifydn-done': ['int', 'char *', 'char *', 'char *', 'int',
  47. 'char *'],
  48. // 4: scope, 5: filter
  49. 'server-search-start': ['int', 'char *', 'char *', 'char *', 'char *',
  50. 'char *'],
  51. 'server-search-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
  52. // Last two are searchEntry.DN and seachEntry.attributes.length
  53. 'server-search-entry': ['int', 'char *', 'char *', 'char *', 'char *', 'int'],
  54. 'server-unbind-start': ['int', 'char *', 'char *', 'char *'],
  55. 'server-unbind-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
  56. 'server-abandon-start': ['int', 'char *', 'char *', 'char *'],
  57. 'server-abandon-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'],
  58. // remote IP
  59. 'server-connection': ['char *']
  60. };
  61. ///--- API
  62. module.exports = function () {
  63. if (!SERVER_PROVIDER) {
  64. try {
  65. var dtrace = require('dtrace-provider');
  66. SERVER_PROVIDER = dtrace.createDTraceProvider('ldapjs');
  67. Object.keys(SERVER_PROBES).forEach(function (p) {
  68. var args = SERVER_PROBES[p].splice(0);
  69. args.unshift(p);
  70. dtrace.DTraceProvider.prototype.addProbe.apply(SERVER_PROVIDER, args);
  71. });
  72. } catch (e) {
  73. SERVER_PROVIDER = {
  74. fire: function () {
  75. },
  76. enable: function () {
  77. },
  78. addProbe: function () {
  79. var p = {
  80. fire: function () {
  81. }
  82. };
  83. return (p);
  84. },
  85. removeProbe: function () {
  86. },
  87. disable: function () {
  88. }
  89. };
  90. }
  91. SERVER_PROVIDER.enable();
  92. SERVER_PROVIDER._nextId = function () {
  93. if (DTRACE_ID === MAX_INT)
  94. DTRACE_ID = 0;
  95. return ++DTRACE_ID;
  96. };
  97. }
  98. return SERVER_PROVIDER;
  99. }();