cisco-perfmon 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.js +253 -231
- package/package.json +5 -3
- package/test/tests.js +35 -37
package/main.js
CHANGED
|
@@ -89,29 +89,43 @@ var XML_REMOVE_COUNTER_ENVELOPE = `<soapenv:Envelope xmlns:soapenv="http://schem
|
|
|
89
89
|
*
|
|
90
90
|
*
|
|
91
91
|
* @class perfMonService
|
|
92
|
+
* @param {string} host - The host to collect data from. This is usually the IP address/FQDN of the CUCM publisher.
|
|
93
|
+
* @param {string} username - The username to authenticate with. This is usually an AXL user. Can leave this blank if using JESSIONSSO cookie.
|
|
94
|
+
* @param {string} password - The password to authenticate with. This is usually an AXL user. Can leave this blank if using JESSIONSSO cookie.
|
|
95
|
+
* @param {object} options - Additional headers to add to the request. Useful for adding cookies for SSO sessions.
|
|
96
|
+
* @returns {object} returns constructor object.
|
|
92
97
|
*/
|
|
93
98
|
class perfMonService {
|
|
94
|
-
constructor(host, username, password) {
|
|
99
|
+
constructor(host, username, password, options) {
|
|
95
100
|
this._OPTIONS = {
|
|
96
101
|
method: "POST",
|
|
97
102
|
headers: {
|
|
98
|
-
Authorization:
|
|
99
|
-
"Basic " + Buffer.from(username + ":" + password).toString("base64"),
|
|
103
|
+
Authorization: "Basic " + Buffer.from(username + ":" + password).toString("base64"),
|
|
100
104
|
"Content-Type": "text/xml;charset=UTF-8",
|
|
105
|
+
Connection: "keep-alive",
|
|
101
106
|
},
|
|
102
107
|
};
|
|
108
|
+
|
|
109
|
+
// Adds additional headers if they are provided. Useful for adding cookies for SSO sessions
|
|
110
|
+
if (options) {
|
|
111
|
+
this._OPTIONS.headers = Object.assign(this._OPTIONS.headers, options);
|
|
112
|
+
}
|
|
113
|
+
|
|
103
114
|
this._HOST = host;
|
|
104
115
|
}
|
|
105
116
|
/**
|
|
106
117
|
* Post Fetch using Cisco PerfMon API
|
|
107
118
|
*
|
|
108
119
|
* @collectCounterData
|
|
109
|
-
|
|
110
|
-
service
|
|
111
|
-
|
|
112
|
-
|
|
120
|
+
* @example
|
|
121
|
+
* var service = new perfMonService();
|
|
122
|
+
* service.collectCounterData().then((results => {
|
|
123
|
+
* console.log(results.Results);
|
|
124
|
+
* }))
|
|
113
125
|
* @memberof perfMonService
|
|
114
|
-
* @
|
|
126
|
+
* @param {string} host - The host to collect data from
|
|
127
|
+
* @param {string} object - The object to collect data about. Example: Cisco CallManager
|
|
128
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
115
129
|
*/
|
|
116
130
|
collectCounterData(host, object) {
|
|
117
131
|
var XML;
|
|
@@ -125,14 +139,17 @@ class perfMonService {
|
|
|
125
139
|
options.body = soapBody;
|
|
126
140
|
|
|
127
141
|
return new Promise((resolve, reject) => {
|
|
142
|
+
// Set up our promise results
|
|
143
|
+
var promiseResults = {
|
|
144
|
+
Cookie: "",
|
|
145
|
+
Results: "",
|
|
146
|
+
};
|
|
128
147
|
// We fetch the API endpoint
|
|
129
|
-
fetch(
|
|
130
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
131
|
-
options
|
|
132
|
-
)
|
|
148
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
133
149
|
.then(async (response) => {
|
|
134
150
|
try {
|
|
135
151
|
var data = []; // create an array to save chunked data from server
|
|
152
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
136
153
|
// response.body is a ReadableStream
|
|
137
154
|
const reader = response.body.getReader();
|
|
138
155
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -145,22 +162,16 @@ class perfMonService {
|
|
|
145
162
|
removeKeys(output, "$");
|
|
146
163
|
|
|
147
164
|
if (keyExists(output, "perfmonCollectCounterDataReturn")) {
|
|
148
|
-
var returnResults =
|
|
149
|
-
output.Body.perfmonCollectCounterDataResponse
|
|
150
|
-
.perfmonCollectCounterDataReturn;
|
|
165
|
+
var returnResults = output.Body.perfmonCollectCounterDataResponse.perfmonCollectCounterDataReturn;
|
|
151
166
|
if (returnResults) {
|
|
152
167
|
var newOutput;
|
|
153
168
|
if (Array.isArray(returnResults)) {
|
|
154
169
|
newOutput = returnResults.map((item) => {
|
|
155
|
-
let arr = item.Name.split("\\").filter(
|
|
156
|
-
(element) => element
|
|
157
|
-
);
|
|
170
|
+
let arr = item.Name.split("\\").filter((element) => element);
|
|
158
171
|
|
|
159
|
-
let instanceArr = arr[1]
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return e;
|
|
163
|
-
});
|
|
172
|
+
let instanceArr = arr[1].split(/[()]+/).filter(function (e) {
|
|
173
|
+
return e;
|
|
174
|
+
});
|
|
164
175
|
|
|
165
176
|
return {
|
|
166
177
|
host: arr[0],
|
|
@@ -172,9 +183,7 @@ class perfMonService {
|
|
|
172
183
|
};
|
|
173
184
|
});
|
|
174
185
|
} else {
|
|
175
|
-
let arr = returnResults.Name.split("\\").filter(
|
|
176
|
-
(element) => element
|
|
177
|
-
);
|
|
186
|
+
let arr = returnResults.Name.split("\\").filter((element) => element);
|
|
178
187
|
|
|
179
188
|
let instanceArr = arr[1].split(/[()]+/).filter(function (e) {
|
|
180
189
|
return e;
|
|
@@ -189,19 +198,24 @@ class perfMonService {
|
|
|
189
198
|
cstatus: returnResults.CStatus,
|
|
190
199
|
};
|
|
191
200
|
}
|
|
192
|
-
|
|
201
|
+
promiseResults.Results = clean(newOutput);
|
|
202
|
+
resolve(promiseResults);
|
|
193
203
|
} else {
|
|
194
|
-
|
|
204
|
+
promiseResults.Results = output.Body.Fault;
|
|
205
|
+
reject(promiseResults);
|
|
195
206
|
}
|
|
196
207
|
} else {
|
|
197
|
-
|
|
208
|
+
promiseResults.Results = { response: "empty" };
|
|
209
|
+
resolve(promiseResults);
|
|
198
210
|
}
|
|
199
211
|
} catch (e) {
|
|
200
|
-
|
|
212
|
+
promiseResults.Results = e;
|
|
213
|
+
reject(promiseResults);
|
|
201
214
|
}
|
|
202
215
|
})
|
|
203
216
|
.catch((error) => {
|
|
204
|
-
|
|
217
|
+
promiseResults.Results = error;
|
|
218
|
+
reject(promiseResults);
|
|
205
219
|
}); // catches the error and logs it
|
|
206
220
|
});
|
|
207
221
|
}
|
|
@@ -209,12 +223,14 @@ class perfMonService {
|
|
|
209
223
|
* Post Fetch using Cisco PerfMon API
|
|
210
224
|
*
|
|
211
225
|
* @collectSessionData
|
|
212
|
-
|
|
213
|
-
service
|
|
214
|
-
|
|
215
|
-
|
|
226
|
+
* @example
|
|
227
|
+
* var service = new perfMonService();
|
|
228
|
+
* service.collectSessionData().then((results => {
|
|
229
|
+
* console.log(results.Results);
|
|
230
|
+
* }))
|
|
216
231
|
* @memberof perfMonService
|
|
217
|
-
* @
|
|
232
|
+
* @param {string} SessionHandle - A unique session ID from the client, of type SessionHandleType. The session handle that the perfmonOpenSession request previously opened.
|
|
233
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
218
234
|
*/
|
|
219
235
|
collectSessionData(SessionHandle) {
|
|
220
236
|
var XML;
|
|
@@ -228,14 +244,17 @@ class perfMonService {
|
|
|
228
244
|
options.body = soapBody;
|
|
229
245
|
|
|
230
246
|
return new Promise((resolve, reject) => {
|
|
247
|
+
// Set up our promise results
|
|
248
|
+
var promiseResults = {
|
|
249
|
+
Cookie: "",
|
|
250
|
+
Results: "",
|
|
251
|
+
};
|
|
231
252
|
// We fetch the API endpoint
|
|
232
|
-
fetch(
|
|
233
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
234
|
-
options
|
|
235
|
-
)
|
|
253
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
236
254
|
.then(async (response) => {
|
|
237
255
|
try {
|
|
238
256
|
var data = []; // create an array to save chunked data from server
|
|
257
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
239
258
|
// response.body is a ReadableStream
|
|
240
259
|
const reader = response.body.getReader();
|
|
241
260
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -248,23 +267,17 @@ class perfMonService {
|
|
|
248
267
|
removeKeys(output, "$");
|
|
249
268
|
|
|
250
269
|
if (keyExists(output, "perfmonCollectSessionDataReturn")) {
|
|
251
|
-
var returnResults =
|
|
252
|
-
output.Body.perfmonCollectSessionDataResponse
|
|
253
|
-
.perfmonCollectSessionDataReturn;
|
|
270
|
+
var returnResults = output.Body.perfmonCollectSessionDataResponse.perfmonCollectSessionDataReturn;
|
|
254
271
|
|
|
255
272
|
if (returnResults) {
|
|
256
273
|
var newOutput;
|
|
257
274
|
if (Array.isArray(returnResults)) {
|
|
258
275
|
newOutput = returnResults.map((item) => {
|
|
259
|
-
let arr = item.Name.split("\\").filter(
|
|
260
|
-
(element) => element
|
|
261
|
-
);
|
|
276
|
+
let arr = item.Name.split("\\").filter((element) => element);
|
|
262
277
|
|
|
263
|
-
let instanceArr = arr[1]
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return e;
|
|
267
|
-
});
|
|
278
|
+
let instanceArr = arr[1].split(/[()]+/).filter(function (e) {
|
|
279
|
+
return e;
|
|
280
|
+
});
|
|
268
281
|
|
|
269
282
|
return {
|
|
270
283
|
host: arr[0],
|
|
@@ -276,9 +289,7 @@ class perfMonService {
|
|
|
276
289
|
};
|
|
277
290
|
});
|
|
278
291
|
} else {
|
|
279
|
-
let arr = returnResults.Name.split("\\").filter(
|
|
280
|
-
(element) => element
|
|
281
|
-
);
|
|
292
|
+
let arr = returnResults.Name.split("\\").filter((element) => element);
|
|
282
293
|
|
|
283
294
|
let instanceArr = arr[1].split(/[()]+/).filter(function (e) {
|
|
284
295
|
return e;
|
|
@@ -293,19 +304,24 @@ class perfMonService {
|
|
|
293
304
|
cstatus: returnResults.CStatus,
|
|
294
305
|
};
|
|
295
306
|
}
|
|
296
|
-
|
|
307
|
+
promiseResults.Results = clean(newOutput);
|
|
308
|
+
resolve(promiseResults);
|
|
297
309
|
} else {
|
|
298
|
-
|
|
310
|
+
promiseResults.Results = output.Body.Fault;
|
|
311
|
+
reject(promiseResults);
|
|
299
312
|
}
|
|
300
313
|
} else {
|
|
301
|
-
|
|
314
|
+
promiseResults.Results = { response: "empty" };
|
|
315
|
+
resolve(promiseResults);
|
|
302
316
|
}
|
|
303
317
|
} catch (e) {
|
|
304
|
-
|
|
318
|
+
promiseResults.Results = e;
|
|
319
|
+
reject(promiseResults);
|
|
305
320
|
}
|
|
306
321
|
})
|
|
307
322
|
.catch((error) => {
|
|
308
|
-
|
|
323
|
+
promiseResults.Results = error;
|
|
324
|
+
reject(promiseResults);
|
|
309
325
|
}); // catches the error and logs it
|
|
310
326
|
});
|
|
311
327
|
}
|
|
@@ -313,12 +329,14 @@ class perfMonService {
|
|
|
313
329
|
* Post Fetch using Cisco PerfMon API
|
|
314
330
|
*
|
|
315
331
|
* @listCounter
|
|
316
|
-
|
|
317
|
-
service
|
|
318
|
-
|
|
319
|
-
|
|
332
|
+
* @example
|
|
333
|
+
* var service = new perfMonService();
|
|
334
|
+
* service.listCounter().then((results => {
|
|
335
|
+
* console.log(results.Results);
|
|
336
|
+
* }))
|
|
320
337
|
* @memberof perfMonService
|
|
321
|
-
* @
|
|
338
|
+
* @param {string} host - The host to collect data from.
|
|
339
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
322
340
|
*/
|
|
323
341
|
listCounter(host) {
|
|
324
342
|
var XML;
|
|
@@ -332,14 +350,17 @@ class perfMonService {
|
|
|
332
350
|
options.body = soapBody;
|
|
333
351
|
|
|
334
352
|
return new Promise((resolve, reject) => {
|
|
353
|
+
// Set up our promise results
|
|
354
|
+
var promiseResults = {
|
|
355
|
+
Cookie: "",
|
|
356
|
+
Results: "",
|
|
357
|
+
};
|
|
335
358
|
// We fetch the API endpoint
|
|
336
|
-
fetch(
|
|
337
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
338
|
-
options
|
|
339
|
-
)
|
|
359
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
340
360
|
.then(async (response) => {
|
|
341
361
|
try {
|
|
342
362
|
var data = []; // create an array to save chunked data from server
|
|
363
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
343
364
|
// response.body is a ReadableStream
|
|
344
365
|
const reader = response.body.getReader();
|
|
345
366
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -352,23 +373,27 @@ class perfMonService {
|
|
|
352
373
|
removeKeys(output, "$");
|
|
353
374
|
|
|
354
375
|
if (keyExists(output, "perfmonListCounterReturn")) {
|
|
355
|
-
var returnResults =
|
|
356
|
-
output.Body.perfmonListCounterResponse.perfmonListCounterReturn;
|
|
376
|
+
var returnResults = output.Body.perfmonListCounterResponse.perfmonListCounterReturn;
|
|
357
377
|
|
|
358
378
|
if (returnResults) {
|
|
359
|
-
|
|
379
|
+
promiseResults.Results = clean(returnResults);
|
|
380
|
+
resolve(promiseResults);
|
|
360
381
|
} else {
|
|
361
|
-
|
|
382
|
+
promiseResults.Results = output.Body.Fault;
|
|
383
|
+
reject(promiseResults);
|
|
362
384
|
}
|
|
363
385
|
} else {
|
|
364
|
-
|
|
386
|
+
promiseResults.Results = { response: "empty" };
|
|
387
|
+
resolve(promiseResults);
|
|
365
388
|
}
|
|
366
389
|
} catch (e) {
|
|
367
|
-
|
|
390
|
+
promiseResults.Results = e;
|
|
391
|
+
reject(promiseResults);
|
|
368
392
|
}
|
|
369
393
|
})
|
|
370
394
|
.catch((error) => {
|
|
371
|
-
|
|
395
|
+
promiseResults.Results = error;
|
|
396
|
+
reject(promiseResults);
|
|
372
397
|
}); // catches the error and logs it
|
|
373
398
|
});
|
|
374
399
|
}
|
|
@@ -376,12 +401,15 @@ class perfMonService {
|
|
|
376
401
|
* Post Fetch using Cisco PerfMon API
|
|
377
402
|
*
|
|
378
403
|
* @listInstance
|
|
379
|
-
|
|
380
|
-
service
|
|
381
|
-
|
|
382
|
-
|
|
404
|
+
* @example
|
|
405
|
+
* var service = new perfMonService();
|
|
406
|
+
* service.listInstance().then((results => {
|
|
407
|
+
* console.log(results.Results);
|
|
408
|
+
* }))
|
|
383
409
|
* @memberof perfMonService
|
|
384
|
-
* @
|
|
410
|
+
* @param {string} host - The host to collect data from.
|
|
411
|
+
* @param {string} object - The object to collect data about. Example: Cisco CallManager
|
|
412
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
385
413
|
*/
|
|
386
414
|
listInstance(host, object) {
|
|
387
415
|
var XML;
|
|
@@ -395,14 +423,17 @@ class perfMonService {
|
|
|
395
423
|
options.body = soapBody;
|
|
396
424
|
|
|
397
425
|
return new Promise((resolve, reject) => {
|
|
426
|
+
// Set up our promise results
|
|
427
|
+
var promiseResults = {
|
|
428
|
+
Cookie: "",
|
|
429
|
+
Results: "",
|
|
430
|
+
};
|
|
398
431
|
// We fetch the API endpoint
|
|
399
|
-
fetch(
|
|
400
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
401
|
-
options
|
|
402
|
-
)
|
|
432
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
403
433
|
.then(async (response) => {
|
|
404
434
|
try {
|
|
405
435
|
var data = []; // create an array to save chunked data from server
|
|
436
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
406
437
|
// response.body is a ReadableStream
|
|
407
438
|
const reader = response.body.getReader();
|
|
408
439
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -415,24 +446,27 @@ class perfMonService {
|
|
|
415
446
|
removeKeys(output, "$");
|
|
416
447
|
|
|
417
448
|
if (keyExists(output, "perfmonListInstanceReturn")) {
|
|
418
|
-
var returnResults =
|
|
419
|
-
output.Body.perfmonListInstanceResponse
|
|
420
|
-
.perfmonListInstanceReturn;
|
|
449
|
+
var returnResults = output.Body.perfmonListInstanceResponse.perfmonListInstanceReturn;
|
|
421
450
|
|
|
422
451
|
if (returnResults) {
|
|
423
|
-
|
|
452
|
+
promiseResults.Results = clean(returnResults);
|
|
453
|
+
resolve(promiseResults);
|
|
424
454
|
} else {
|
|
425
|
-
|
|
455
|
+
promiseResults.Results = output.Body.Fault;
|
|
456
|
+
reject(promiseResults);
|
|
426
457
|
}
|
|
427
458
|
} else {
|
|
428
|
-
|
|
459
|
+
promiseResults.Results = { response: "empty" };
|
|
460
|
+
resolve(promiseResults);
|
|
429
461
|
}
|
|
430
462
|
} catch (e) {
|
|
431
|
-
|
|
463
|
+
promiseResults.Results = e;
|
|
464
|
+
reject(promiseResults);
|
|
432
465
|
}
|
|
433
466
|
})
|
|
434
467
|
.catch((error) => {
|
|
435
|
-
|
|
468
|
+
promiseResults.Results = error;
|
|
469
|
+
reject(promiseResults);
|
|
436
470
|
}); // catches the error and logs it
|
|
437
471
|
});
|
|
438
472
|
}
|
|
@@ -440,12 +474,13 @@ class perfMonService {
|
|
|
440
474
|
* Post Fetch using Cisco PerfMon API
|
|
441
475
|
*
|
|
442
476
|
* @openSession
|
|
443
|
-
|
|
444
|
-
service
|
|
445
|
-
|
|
446
|
-
|
|
477
|
+
* @example
|
|
478
|
+
* var service = new perfMonService();
|
|
479
|
+
* service.openSession().then((results => {
|
|
480
|
+
* console.log(results.Results);
|
|
481
|
+
* }))
|
|
447
482
|
* @memberof perfMonService
|
|
448
|
-
* @returns {
|
|
483
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
449
484
|
*/
|
|
450
485
|
openSession() {
|
|
451
486
|
var XML;
|
|
@@ -458,14 +493,17 @@ class perfMonService {
|
|
|
458
493
|
options.body = soapBody;
|
|
459
494
|
|
|
460
495
|
return new Promise((resolve, reject) => {
|
|
496
|
+
// Set up our promise results
|
|
497
|
+
var promiseResults = {
|
|
498
|
+
Cookie: "",
|
|
499
|
+
Results: "",
|
|
500
|
+
};
|
|
461
501
|
// We fetch the API endpoint
|
|
462
|
-
fetch(
|
|
463
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
464
|
-
options
|
|
465
|
-
)
|
|
502
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
466
503
|
.then(async (response) => {
|
|
467
504
|
try {
|
|
468
505
|
var data = []; // create an array to save chunked data from server
|
|
506
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
469
507
|
// response.body is a ReadableStream
|
|
470
508
|
const reader = response.body.getReader();
|
|
471
509
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -478,23 +516,27 @@ class perfMonService {
|
|
|
478
516
|
removeKeys(output, "$");
|
|
479
517
|
|
|
480
518
|
if (keyExists(output, "perfmonOpenSessionReturn")) {
|
|
481
|
-
var returnResults =
|
|
482
|
-
output.Body.perfmonOpenSessionResponse.perfmonOpenSessionReturn;
|
|
519
|
+
var returnResults = output.Body.perfmonOpenSessionResponse.perfmonOpenSessionReturn;
|
|
483
520
|
|
|
484
521
|
if (returnResults) {
|
|
485
|
-
|
|
522
|
+
promiseResults.Results = clean(returnResults);
|
|
523
|
+
resolve(promiseResults);
|
|
486
524
|
} else {
|
|
487
|
-
|
|
525
|
+
promiseResults.Results = output.Body.Fault;
|
|
526
|
+
reject(promiseResults);
|
|
488
527
|
}
|
|
489
528
|
} else {
|
|
490
|
-
|
|
529
|
+
promiseResults.Results = { response: "empty" };
|
|
530
|
+
resolve(promiseResults);
|
|
491
531
|
}
|
|
492
532
|
} catch (e) {
|
|
493
|
-
|
|
533
|
+
promiseResults.Results = e;
|
|
534
|
+
reject(promiseResults);
|
|
494
535
|
}
|
|
495
536
|
})
|
|
496
537
|
.catch((error) => {
|
|
497
|
-
|
|
538
|
+
promiseResults.Results = error;
|
|
539
|
+
reject(promiseResults);
|
|
498
540
|
}); // catches the error and logs it
|
|
499
541
|
});
|
|
500
542
|
}
|
|
@@ -502,12 +544,14 @@ class perfMonService {
|
|
|
502
544
|
* Post Fetch using Cisco PerfMon API
|
|
503
545
|
*
|
|
504
546
|
* @closeSession
|
|
505
|
-
|
|
506
|
-
service
|
|
507
|
-
|
|
508
|
-
|
|
547
|
+
* @example
|
|
548
|
+
* var service = new perfMonService();
|
|
549
|
+
* service.closeSession().then((results => {
|
|
550
|
+
* console.log(results.Results);
|
|
551
|
+
* }))
|
|
509
552
|
* @memberof perfMonService
|
|
510
|
-
* @
|
|
553
|
+
* @param {string} sessionHandle - A unique session ID from the client, of type SessionHandleType. The session handle that the perfmonOpenSession request previously opened.
|
|
554
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
511
555
|
*/
|
|
512
556
|
closeSession(sessionHandle) {
|
|
513
557
|
var XML;
|
|
@@ -520,14 +564,17 @@ class perfMonService {
|
|
|
520
564
|
options.body = soapBody;
|
|
521
565
|
|
|
522
566
|
return new Promise((resolve, reject) => {
|
|
567
|
+
// Set up our promise results
|
|
568
|
+
var promiseResults = {
|
|
569
|
+
Cookie: "",
|
|
570
|
+
Results: "",
|
|
571
|
+
};
|
|
523
572
|
// We fetch the API endpoint
|
|
524
|
-
fetch(
|
|
525
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
526
|
-
options
|
|
527
|
-
)
|
|
573
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
528
574
|
.then(async (response) => {
|
|
529
575
|
try {
|
|
530
576
|
var data = []; // create an array to save chunked data from server
|
|
577
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
531
578
|
// response.body is a ReadableStream
|
|
532
579
|
const reader = response.body.getReader();
|
|
533
580
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -542,19 +589,24 @@ class perfMonService {
|
|
|
542
589
|
if (keyExists(output, "perfmonCloseSessionResponse")) {
|
|
543
590
|
var returnResults = output.Body.perfmonCloseSessionResponse;
|
|
544
591
|
if (returnResults) {
|
|
545
|
-
|
|
592
|
+
promiseResults.Results = { response: "success" };
|
|
593
|
+
resolve(promiseResults);
|
|
546
594
|
} else {
|
|
547
|
-
|
|
595
|
+
promiseResults.Results = output.Body.Fault;
|
|
596
|
+
reject(promiseResults);
|
|
548
597
|
}
|
|
549
598
|
} else {
|
|
550
|
-
|
|
599
|
+
promiseResults.Results = { response: "empty" };
|
|
600
|
+
resolve(promiseResults);
|
|
551
601
|
}
|
|
552
602
|
} catch (e) {
|
|
553
|
-
|
|
603
|
+
promiseResults.Results = e;
|
|
604
|
+
reject(promiseResults);
|
|
554
605
|
}
|
|
555
606
|
})
|
|
556
607
|
.catch((error) => {
|
|
557
|
-
|
|
608
|
+
promiseResults.Results = error;
|
|
609
|
+
reject(promiseResults);
|
|
558
610
|
}); // catches the error and logs it
|
|
559
611
|
});
|
|
560
612
|
}
|
|
@@ -562,12 +614,15 @@ class perfMonService {
|
|
|
562
614
|
* Post Fetch using Cisco PerfMon API
|
|
563
615
|
*
|
|
564
616
|
* @addCounter
|
|
565
|
-
|
|
566
|
-
service
|
|
567
|
-
|
|
568
|
-
|
|
617
|
+
* @example
|
|
618
|
+
* var service = new perfMonService();
|
|
619
|
+
* service.addCounter().then((results => {
|
|
620
|
+
* console.log(results.Results);
|
|
621
|
+
* }))
|
|
569
622
|
* @memberof perfMonService
|
|
570
|
-
* @
|
|
623
|
+
* @param {string} sessionHandle - A unique session ID from the client, of type SessionHandleType. The session handle that the perfmonOpenSession request previously opened.
|
|
624
|
+
* @param {object} counter - The counter to add. Example: Memory
|
|
625
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
571
626
|
*/
|
|
572
627
|
addCounter(sessionHandle, counter) {
|
|
573
628
|
var XML;
|
|
@@ -577,32 +632,9 @@ class perfMonService {
|
|
|
577
632
|
var server = this._HOST;
|
|
578
633
|
|
|
579
634
|
if (Array.isArray(counter)) {
|
|
580
|
-
counter.forEach(
|
|
581
|
-
(item) =>
|
|
582
|
-
(counterStr +=
|
|
583
|
-
"<soap:Counter>" +
|
|
584
|
-
"<soap:Name>" +
|
|
585
|
-
"\\\\" +
|
|
586
|
-
item.host +
|
|
587
|
-
"\\" +
|
|
588
|
-
item.object +
|
|
589
|
-
"\\" +
|
|
590
|
-
item.counter +
|
|
591
|
-
"</soap:Name>" +
|
|
592
|
-
"</soap:Counter>")
|
|
593
|
-
);
|
|
635
|
+
counter.forEach((item) => (counterStr += "<soap:Counter>" + "<soap:Name>" + "\\\\" + item.host + "\\" + item.object + "\\" + item.counter + "</soap:Name>" + "</soap:Counter>"));
|
|
594
636
|
} else {
|
|
595
|
-
counterStr =
|
|
596
|
-
"<soap:Counter>" +
|
|
597
|
-
"<soap:Name>" +
|
|
598
|
-
"\\\\" +
|
|
599
|
-
counter.host +
|
|
600
|
-
"\\" +
|
|
601
|
-
counter.object +
|
|
602
|
-
"\\" +
|
|
603
|
-
counter.counter +
|
|
604
|
-
"</soap:Name>" +
|
|
605
|
-
"</soap:Counter>";
|
|
637
|
+
counterStr = "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + counter.object + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>";
|
|
606
638
|
}
|
|
607
639
|
|
|
608
640
|
XML = util.format(XML_ADD_COUNTER_ENVELOPE, sessionHandle, counterStr);
|
|
@@ -611,11 +643,13 @@ class perfMonService {
|
|
|
611
643
|
options.body = soapBody;
|
|
612
644
|
|
|
613
645
|
return new Promise((resolve, reject) => {
|
|
646
|
+
// Set up our promise results
|
|
647
|
+
var promiseResults = {
|
|
648
|
+
Cookie: "",
|
|
649
|
+
Results: "",
|
|
650
|
+
};
|
|
614
651
|
// We fetch the API endpoint
|
|
615
|
-
fetch(
|
|
616
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
617
|
-
options
|
|
618
|
-
)
|
|
652
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
619
653
|
.then(async (response) => {
|
|
620
654
|
try {
|
|
621
655
|
var data = []; // create an array to save chunked data from server
|
|
@@ -633,19 +667,24 @@ class perfMonService {
|
|
|
633
667
|
if (keyExists(output, "perfmonAddCounterResponse")) {
|
|
634
668
|
var returnResults = output.Body.perfmonAddCounterResponse;
|
|
635
669
|
if (returnResults) {
|
|
636
|
-
|
|
670
|
+
promiseResults.Results = { response: "success" };
|
|
671
|
+
resolve(promiseResults);
|
|
637
672
|
} else {
|
|
638
|
-
|
|
673
|
+
promiseResults.Results = output.Body.Fault;
|
|
674
|
+
reject(promiseResults);
|
|
639
675
|
}
|
|
640
676
|
} else {
|
|
641
|
-
|
|
677
|
+
promiseResults.Results = { response: "empty" };
|
|
678
|
+
resolve(promiseResults);
|
|
642
679
|
}
|
|
643
680
|
} catch (e) {
|
|
644
|
-
|
|
681
|
+
promiseResults.Results = e;
|
|
682
|
+
reject(promiseResults);
|
|
645
683
|
}
|
|
646
684
|
})
|
|
647
685
|
.catch((error) => {
|
|
648
|
-
|
|
686
|
+
promiseResults.Results = error;
|
|
687
|
+
reject(promiseResults);
|
|
649
688
|
}); // catches the error and logs it
|
|
650
689
|
});
|
|
651
690
|
}
|
|
@@ -653,12 +692,15 @@ class perfMonService {
|
|
|
653
692
|
* Post Fetch using Cisco PerfMon API
|
|
654
693
|
*
|
|
655
694
|
* @removeCounter
|
|
656
|
-
|
|
657
|
-
service
|
|
658
|
-
|
|
659
|
-
|
|
695
|
+
* @example
|
|
696
|
+
* var service = new perfMonService();
|
|
697
|
+
* service.removeCounter().then((results => {
|
|
698
|
+
* console.log(results.Results);
|
|
699
|
+
* }))
|
|
660
700
|
* @memberof perfMonService
|
|
661
|
-
* @
|
|
701
|
+
* @param {string} sessionHandle - A unique session ID from the client, of type SessionHandleType. The session handle that the perfmonOpenSession request previously opened.
|
|
702
|
+
* @param {object} counter - The counter to remove. Example: Memory
|
|
703
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
662
704
|
*/
|
|
663
705
|
removeCounter(sessionHandle, counter) {
|
|
664
706
|
var XML;
|
|
@@ -668,32 +710,9 @@ class perfMonService {
|
|
|
668
710
|
var server = this._HOST;
|
|
669
711
|
|
|
670
712
|
if (Array.isArray(counter)) {
|
|
671
|
-
counter.forEach(
|
|
672
|
-
(item) =>
|
|
673
|
-
(counterStr +=
|
|
674
|
-
"<soap:Counter>" +
|
|
675
|
-
"<soap:Name>" +
|
|
676
|
-
"\\\\" +
|
|
677
|
-
item.host +
|
|
678
|
-
"\\" +
|
|
679
|
-
item.object +
|
|
680
|
-
"\\" +
|
|
681
|
-
item.counter +
|
|
682
|
-
"</soap:Name>" +
|
|
683
|
-
"</soap:Counter>")
|
|
684
|
-
);
|
|
713
|
+
counter.forEach((item) => (counterStr += "<soap:Counter>" + "<soap:Name>" + "\\\\" + item.host + "\\" + item.object + "\\" + item.counter + "</soap:Name>" + "</soap:Counter>"));
|
|
685
714
|
} else {
|
|
686
|
-
counterStr =
|
|
687
|
-
"<soap:Counter>" +
|
|
688
|
-
"<soap:Name>" +
|
|
689
|
-
"\\\\" +
|
|
690
|
-
counter.host +
|
|
691
|
-
"\\" +
|
|
692
|
-
counter.object +
|
|
693
|
-
"\\" +
|
|
694
|
-
counter.counter +
|
|
695
|
-
"</soap:Name>" +
|
|
696
|
-
"</soap:Counter>";
|
|
715
|
+
counterStr = "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + counter.object + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>";
|
|
697
716
|
}
|
|
698
717
|
|
|
699
718
|
XML = util.format(XML_REMOVE_COUNTER_ENVELOPE, sessionHandle, counterStr);
|
|
@@ -702,11 +721,13 @@ class perfMonService {
|
|
|
702
721
|
options.body = soapBody;
|
|
703
722
|
|
|
704
723
|
return new Promise((resolve, reject) => {
|
|
724
|
+
// Set up our promise results
|
|
725
|
+
var promiseResults = {
|
|
726
|
+
Cookie: "",
|
|
727
|
+
Results: "",
|
|
728
|
+
};
|
|
705
729
|
// We fetch the API endpoint
|
|
706
|
-
fetch(
|
|
707
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
708
|
-
options
|
|
709
|
-
)
|
|
730
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
710
731
|
.then(async (response) => {
|
|
711
732
|
try {
|
|
712
733
|
var data = []; // create an array to save chunked data from server
|
|
@@ -724,19 +745,24 @@ class perfMonService {
|
|
|
724
745
|
if (keyExists(output, "perfmonRemoveCounterResponse")) {
|
|
725
746
|
var returnResults = output.Body.perfmonRemoveCounterResponse;
|
|
726
747
|
if (returnResults) {
|
|
727
|
-
|
|
748
|
+
promiseResults.Results = { response: "success" };
|
|
749
|
+
resolve(promiseResults);
|
|
728
750
|
} else {
|
|
729
|
-
|
|
751
|
+
promiseResults.Results = output.Body.Fault;
|
|
752
|
+
reject(promiseResults);
|
|
730
753
|
}
|
|
731
754
|
} else {
|
|
732
|
-
|
|
755
|
+
promiseResults.Results = { response: "empty" };
|
|
756
|
+
resolve(promiseResults);
|
|
733
757
|
}
|
|
734
758
|
} catch (e) {
|
|
735
|
-
|
|
759
|
+
promiseResults.Results = e;
|
|
760
|
+
reject(promiseResults);
|
|
736
761
|
}
|
|
737
762
|
})
|
|
738
763
|
.catch((error) => {
|
|
739
|
-
|
|
764
|
+
promiseResults.Results = error;
|
|
765
|
+
reject(promiseResults);
|
|
740
766
|
}); // catches the error and logs it
|
|
741
767
|
});
|
|
742
768
|
}
|
|
@@ -744,12 +770,14 @@ class perfMonService {
|
|
|
744
770
|
* Post Fetch using Cisco PerfMon API
|
|
745
771
|
*
|
|
746
772
|
* @queryCounterDescription
|
|
747
|
-
|
|
748
|
-
service
|
|
749
|
-
|
|
750
|
-
|
|
773
|
+
* @example
|
|
774
|
+
* var service = new perfMonService();
|
|
775
|
+
* service.queryCounterDescription().then((results => {
|
|
776
|
+
* console.log(results.Results);
|
|
777
|
+
* }))
|
|
751
778
|
* @memberof perfMonService
|
|
752
|
-
* @
|
|
779
|
+
* @param {object} counter - The counter to query. Example: Memory
|
|
780
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
753
781
|
*/
|
|
754
782
|
queryCounterDescription(counter) {
|
|
755
783
|
var XML;
|
|
@@ -757,15 +785,7 @@ class perfMonService {
|
|
|
757
785
|
options.SOAPAction = `perfmonQueryCounterDescription`;
|
|
758
786
|
var server = this._HOST;
|
|
759
787
|
|
|
760
|
-
var counterStr =
|
|
761
|
-
"<soap:Counter>" +
|
|
762
|
-
"\\\\" +
|
|
763
|
-
counter.host +
|
|
764
|
-
"\\" +
|
|
765
|
-
counter.object +
|
|
766
|
-
"\\" +
|
|
767
|
-
counter.counter +
|
|
768
|
-
"</soap:Counter>";
|
|
788
|
+
var counterStr = "<soap:Counter>" + "\\\\" + counter.host + "\\" + counter.object + "\\" + counter.counter + "</soap:Counter>";
|
|
769
789
|
|
|
770
790
|
XML = util.format(XML_QUERY_COUNTER_ENVELOPE, counterStr);
|
|
771
791
|
|
|
@@ -773,14 +793,17 @@ class perfMonService {
|
|
|
773
793
|
options.body = soapBody;
|
|
774
794
|
|
|
775
795
|
return new Promise((resolve, reject) => {
|
|
796
|
+
// Set up our promise results
|
|
797
|
+
var promiseResults = {
|
|
798
|
+
Cookie: "",
|
|
799
|
+
Results: "",
|
|
800
|
+
};
|
|
776
801
|
// We fetch the API endpoint
|
|
777
|
-
fetch(
|
|
778
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
779
|
-
options
|
|
780
|
-
)
|
|
802
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
781
803
|
.then(async (response) => {
|
|
782
804
|
try {
|
|
783
805
|
var data = []; // create an array to save chunked data from server
|
|
806
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
784
807
|
// response.body is a ReadableStream
|
|
785
808
|
const reader = response.body.getReader();
|
|
786
809
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -794,23 +817,26 @@ class perfMonService {
|
|
|
794
817
|
removeKeys(output, "$");
|
|
795
818
|
|
|
796
819
|
if (keyExists(output, "perfmonQueryCounterDescriptionReturn")) {
|
|
797
|
-
var returnResults =
|
|
798
|
-
output.Body.perfmonQueryCounterDescriptionResponse
|
|
799
|
-
.perfmonQueryCounterDescriptionReturn;
|
|
820
|
+
var returnResults = output.Body.perfmonQueryCounterDescriptionResponse.perfmonQueryCounterDescriptionReturn;
|
|
800
821
|
if (returnResults) {
|
|
801
|
-
|
|
822
|
+
promiseResults.Results = clean(returnResults);
|
|
823
|
+
resolve(promiseResults);
|
|
802
824
|
} else {
|
|
803
|
-
|
|
825
|
+
promiseResults.Results = output.Body.Fault;
|
|
826
|
+
reject(promiseResults);
|
|
804
827
|
}
|
|
805
828
|
} else {
|
|
806
|
-
|
|
829
|
+
promiseResults.Results = { response: "empty" };
|
|
830
|
+
resolve(promiseResults);
|
|
807
831
|
}
|
|
808
832
|
} catch (e) {
|
|
809
|
-
|
|
833
|
+
promiseResults.Results = e;
|
|
834
|
+
reject(promiseResults);
|
|
810
835
|
}
|
|
811
836
|
})
|
|
812
837
|
.catch((error) => {
|
|
813
|
-
|
|
838
|
+
promiseResults.Results = error;
|
|
839
|
+
reject(promiseResults);
|
|
814
840
|
}); // catches the error and logs it
|
|
815
841
|
});
|
|
816
842
|
}
|
|
@@ -887,11 +913,7 @@ const clean = (object) => {
|
|
|
887
913
|
if (v && typeof v === "object") {
|
|
888
914
|
clean(v);
|
|
889
915
|
}
|
|
890
|
-
if (
|
|
891
|
-
(v && typeof v === "object" && !Object.keys(v).length) ||
|
|
892
|
-
v === null ||
|
|
893
|
-
v === undefined
|
|
894
|
-
) {
|
|
916
|
+
if ((v && typeof v === "object" && !Object.keys(v).length) || v === null || v === undefined) {
|
|
895
917
|
if (Array.isArray(object)) {
|
|
896
918
|
object.splice(k, 1);
|
|
897
919
|
} else {
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cisco-perfmon",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A library to pull Perfmon data from Cisco VOS applications via SOAP",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=test node ./test/tests.js"
|
|
7
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=test node ./test/tests.js",
|
|
8
|
+
"development": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=development node ./test/tests.js"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"dotenv": "*",
|
|
32
|
-
"envalid": "^8.0.0"
|
|
33
|
+
"envalid": "^8.0.0",
|
|
34
|
+
"jsdoc-to-markdown": "^9.0.4"
|
|
33
35
|
}
|
|
34
36
|
}
|
package/test/tests.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const perfMonService = require("../main");
|
|
2
|
-
const path = require(
|
|
2
|
+
const path = require("path");
|
|
3
3
|
const { cleanEnv, str, host } = require("envalid");
|
|
4
4
|
|
|
5
5
|
// If not production load the local env file
|
|
6
|
-
if(process.env.NODE_ENV === "development"){
|
|
7
|
-
require(
|
|
8
|
-
}else if(process.env.NODE_ENV === "test"){
|
|
9
|
-
require(
|
|
10
|
-
}else if(process.env.NODE_ENV === "staging"){
|
|
11
|
-
require(
|
|
6
|
+
if (process.env.NODE_ENV === "development") {
|
|
7
|
+
require("dotenv").config({ path: path.join(__dirname, "..", "env", "development.env") });
|
|
8
|
+
} else if (process.env.NODE_ENV === "test") {
|
|
9
|
+
require("dotenv").config({ path: path.join(__dirname, "..", "env", "test.env") });
|
|
10
|
+
} else if (process.env.NODE_ENV === "staging") {
|
|
11
|
+
require("dotenv").config({ path: path.join(__dirname, "..", "env", "staging.env") });
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const env = cleanEnv(process.env, {
|
|
@@ -19,7 +19,7 @@ const env = cleanEnv(process.env, {
|
|
|
19
19
|
CUCM_HOSTNAME: host({ desc: "Cisco CUCM Hostname or IP Address to send the perfmon request to. Typically the publisher." }),
|
|
20
20
|
CUCM_USERNAME: str({ desc: "Cisco CUCM AXL Username." }),
|
|
21
21
|
CUCM_PASSWORD: str({ desc: "Cisco CUCM AXL Password." }),
|
|
22
|
-
CUCM_SERVER_NAME: str({ desc: "The CUCM name or IP address of the target server from which the client wants to retrieve the counter information from. Note this could be any node in the cluster."
|
|
22
|
+
CUCM_SERVER_NAME: str({ desc: "The CUCM name or IP address of the target server from which the client wants to retrieve the counter information from. Note this could be any node in the cluster.", example: "hq-cucm-pub or hq-cucm-sub" }),
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
let service = new perfMonService(env.CUCM_HOSTNAME, env.CUCM_USERNAME, env.CUCM_PASSWORD);
|
|
@@ -34,45 +34,47 @@ var counterObj = {
|
|
|
34
34
|
counter: "% CPU Time",
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
var serviceSSO = "";
|
|
38
|
+
|
|
37
39
|
(async () => {
|
|
38
40
|
console.log("Let's get a description of our counter.");
|
|
39
41
|
await service
|
|
40
42
|
.queryCounterDescription(counterObj)
|
|
41
43
|
.then((results) => {
|
|
42
|
-
console.log("queryCounterDescription: ", results);
|
|
44
|
+
console.log("queryCounterDescription: ", results.Results);
|
|
45
|
+
if (results.Cookie) {
|
|
46
|
+
serviceSSO = new perfMonService(env.CUCM_HOSTNAME, "", "", { Cookie: results.Cookie });
|
|
47
|
+
}
|
|
43
48
|
})
|
|
44
49
|
.catch((error) => {
|
|
45
50
|
console.log(error);
|
|
46
51
|
});
|
|
47
52
|
|
|
48
|
-
console.log(
|
|
49
|
-
|
|
50
|
-
);
|
|
51
|
-
await service
|
|
53
|
+
console.log("Let's open a session, add a counter, wait 30 seconds, collect the session data, remove the counter and finally close the session");
|
|
54
|
+
await serviceSSO
|
|
52
55
|
.openSession()
|
|
53
56
|
.then(async (results) => {
|
|
54
|
-
console.log("SessionID", results);
|
|
57
|
+
console.log("SessionID", results.Results);
|
|
55
58
|
SessionID = results;
|
|
56
|
-
await
|
|
59
|
+
await serviceSSO
|
|
57
60
|
.addCounter(SessionID, counterObj)
|
|
58
61
|
.then(async (results) => {
|
|
59
|
-
console.log("addCounter", results);
|
|
60
|
-
const delay = (ms) =>
|
|
61
|
-
new Promise((resolve) => setTimeout(resolve, ms));
|
|
62
|
+
console.log("addCounter", results.Results);
|
|
63
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
62
64
|
console.log("Wait 30 seconds");
|
|
63
65
|
await delay(30000); /// waiting 30 second.
|
|
64
|
-
await
|
|
66
|
+
await serviceSSO
|
|
65
67
|
.collectSessionData(SessionID)
|
|
66
68
|
.then(async (results) => {
|
|
67
|
-
console.log("collectSessionData", results);
|
|
68
|
-
await
|
|
69
|
-
.removeCounter(SessionID,
|
|
69
|
+
console.log("collectSessionData", results.Results);
|
|
70
|
+
await serviceSSO
|
|
71
|
+
.removeCounter(SessionID, results.Results)
|
|
70
72
|
.then(async (results) => {
|
|
71
|
-
console.log("removeCounter", results);
|
|
72
|
-
await
|
|
73
|
+
console.log("removeCounter", results.Results);
|
|
74
|
+
await serviceSSO
|
|
73
75
|
.closeSession(SessionID)
|
|
74
76
|
.then((results) => {
|
|
75
|
-
console.log("closeSession", results);
|
|
77
|
+
console.log("closeSession", results.Results);
|
|
76
78
|
})
|
|
77
79
|
.catch((error) => {
|
|
78
80
|
console.log(error);
|
|
@@ -95,34 +97,30 @@ var counterObj = {
|
|
|
95
97
|
});
|
|
96
98
|
|
|
97
99
|
console.log("Let's collect some non session counter data.");
|
|
98
|
-
await
|
|
100
|
+
await serviceSSO
|
|
99
101
|
.collectCounterData(cucmServerName, "Cisco CallManager")
|
|
100
102
|
.then((results) => {
|
|
101
|
-
console.log("collectCounterData", results);
|
|
103
|
+
console.log("collectCounterData", results.Results);
|
|
102
104
|
})
|
|
103
105
|
.catch((error) => {
|
|
104
106
|
console.log(error);
|
|
105
107
|
});
|
|
106
108
|
|
|
107
|
-
console.log(
|
|
108
|
-
|
|
109
|
-
);
|
|
110
|
-
await service
|
|
109
|
+
console.log("Let's returns the list of available PerfMon objects and counters on a particular host");
|
|
110
|
+
await serviceSSO
|
|
111
111
|
.listCounter(cucmServerName)
|
|
112
112
|
.then((results) => {
|
|
113
|
-
console.log("listCounter", results);
|
|
113
|
+
console.log("listCounter", results.Results);
|
|
114
114
|
})
|
|
115
115
|
.catch((error) => {
|
|
116
116
|
console.log(error);
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
console.log(
|
|
120
|
-
|
|
121
|
-
);
|
|
122
|
-
await service
|
|
119
|
+
console.log("Let's return a list of instances of a PerfMon object on a particular host. Instances of an object can dynamically change. This operation returns the most recent list.");
|
|
120
|
+
await serviceSSO
|
|
123
121
|
.listInstance(cucmServerName, "Processor")
|
|
124
122
|
.then((results) => {
|
|
125
|
-
console.log("listInstance", results);
|
|
123
|
+
console.log("listInstance", results.Results);
|
|
126
124
|
})
|
|
127
125
|
.catch((error) => {
|
|
128
126
|
console.log(error);
|