cisco-perfmon 1.2.3 → 1.3.1
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 +265 -231
- package/package.json +3 -2
- 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,36 @@ 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
|
+
// Error checking. If the response contains a fault, we return the fault.
|
|
209
|
+
if (keyExists(output, "Fault")) {
|
|
210
|
+
if (output.Body.Fault.faultcode.includes("RateControl")) {
|
|
211
|
+
promiseResults.Results = { faultcode: "RateControl", faultstring: output.Body.Fault.faultstring };
|
|
212
|
+
} else if (output.Body.Fault.faultcode.includes("generalException")) {
|
|
213
|
+
promiseResults.Results = { faultcode: "generalException", faultstring: output.Body.Fault.faultstring };
|
|
214
|
+
} else {
|
|
215
|
+
promiseResults.Results = { faultcode: output.Body.Fault.faultcode, faultstring: output.Body.Fault.faultstring };
|
|
216
|
+
}
|
|
217
|
+
resolve(promiseResults);
|
|
218
|
+
} else {
|
|
219
|
+
// Error unknown. Return the response status instead.
|
|
220
|
+
reject(response.status);
|
|
221
|
+
}
|
|
198
222
|
}
|
|
199
223
|
} catch (e) {
|
|
200
|
-
|
|
224
|
+
promiseResults.Results = e;
|
|
225
|
+
reject(promiseResults);
|
|
201
226
|
}
|
|
202
227
|
})
|
|
203
228
|
.catch((error) => {
|
|
204
|
-
|
|
229
|
+
promiseResults.Results = error;
|
|
230
|
+
reject(promiseResults);
|
|
205
231
|
}); // catches the error and logs it
|
|
206
232
|
});
|
|
207
233
|
}
|
|
@@ -209,12 +235,14 @@ class perfMonService {
|
|
|
209
235
|
* Post Fetch using Cisco PerfMon API
|
|
210
236
|
*
|
|
211
237
|
* @collectSessionData
|
|
212
|
-
|
|
213
|
-
service
|
|
214
|
-
|
|
215
|
-
|
|
238
|
+
* @example
|
|
239
|
+
* var service = new perfMonService();
|
|
240
|
+
* service.collectSessionData().then((results => {
|
|
241
|
+
* console.log(results.Results);
|
|
242
|
+
* }))
|
|
216
243
|
* @memberof perfMonService
|
|
217
|
-
* @
|
|
244
|
+
* @param {string} SessionHandle - A unique session ID from the client, of type SessionHandleType. The session handle that the perfmonOpenSession request previously opened.
|
|
245
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
218
246
|
*/
|
|
219
247
|
collectSessionData(SessionHandle) {
|
|
220
248
|
var XML;
|
|
@@ -228,14 +256,17 @@ class perfMonService {
|
|
|
228
256
|
options.body = soapBody;
|
|
229
257
|
|
|
230
258
|
return new Promise((resolve, reject) => {
|
|
259
|
+
// Set up our promise results
|
|
260
|
+
var promiseResults = {
|
|
261
|
+
Cookie: "",
|
|
262
|
+
Results: "",
|
|
263
|
+
};
|
|
231
264
|
// We fetch the API endpoint
|
|
232
|
-
fetch(
|
|
233
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
234
|
-
options
|
|
235
|
-
)
|
|
265
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
236
266
|
.then(async (response) => {
|
|
237
267
|
try {
|
|
238
268
|
var data = []; // create an array to save chunked data from server
|
|
269
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
239
270
|
// response.body is a ReadableStream
|
|
240
271
|
const reader = response.body.getReader();
|
|
241
272
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -248,23 +279,17 @@ class perfMonService {
|
|
|
248
279
|
removeKeys(output, "$");
|
|
249
280
|
|
|
250
281
|
if (keyExists(output, "perfmonCollectSessionDataReturn")) {
|
|
251
|
-
var returnResults =
|
|
252
|
-
output.Body.perfmonCollectSessionDataResponse
|
|
253
|
-
.perfmonCollectSessionDataReturn;
|
|
282
|
+
var returnResults = output.Body.perfmonCollectSessionDataResponse.perfmonCollectSessionDataReturn;
|
|
254
283
|
|
|
255
284
|
if (returnResults) {
|
|
256
285
|
var newOutput;
|
|
257
286
|
if (Array.isArray(returnResults)) {
|
|
258
287
|
newOutput = returnResults.map((item) => {
|
|
259
|
-
let arr = item.Name.split("\\").filter(
|
|
260
|
-
(element) => element
|
|
261
|
-
);
|
|
288
|
+
let arr = item.Name.split("\\").filter((element) => element);
|
|
262
289
|
|
|
263
|
-
let instanceArr = arr[1]
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return e;
|
|
267
|
-
});
|
|
290
|
+
let instanceArr = arr[1].split(/[()]+/).filter(function (e) {
|
|
291
|
+
return e;
|
|
292
|
+
});
|
|
268
293
|
|
|
269
294
|
return {
|
|
270
295
|
host: arr[0],
|
|
@@ -276,9 +301,7 @@ class perfMonService {
|
|
|
276
301
|
};
|
|
277
302
|
});
|
|
278
303
|
} else {
|
|
279
|
-
let arr = returnResults.Name.split("\\").filter(
|
|
280
|
-
(element) => element
|
|
281
|
-
);
|
|
304
|
+
let arr = returnResults.Name.split("\\").filter((element) => element);
|
|
282
305
|
|
|
283
306
|
let instanceArr = arr[1].split(/[()]+/).filter(function (e) {
|
|
284
307
|
return e;
|
|
@@ -293,19 +316,24 @@ class perfMonService {
|
|
|
293
316
|
cstatus: returnResults.CStatus,
|
|
294
317
|
};
|
|
295
318
|
}
|
|
296
|
-
|
|
319
|
+
promiseResults.Results = clean(newOutput);
|
|
320
|
+
resolve(promiseResults);
|
|
297
321
|
} else {
|
|
298
|
-
|
|
322
|
+
promiseResults.Results = output.Body.Fault;
|
|
323
|
+
reject(promiseResults);
|
|
299
324
|
}
|
|
300
325
|
} else {
|
|
301
|
-
|
|
326
|
+
promiseResults.Results = { response: "empty" };
|
|
327
|
+
resolve(promiseResults);
|
|
302
328
|
}
|
|
303
329
|
} catch (e) {
|
|
304
|
-
|
|
330
|
+
promiseResults.Results = e;
|
|
331
|
+
reject(promiseResults);
|
|
305
332
|
}
|
|
306
333
|
})
|
|
307
334
|
.catch((error) => {
|
|
308
|
-
|
|
335
|
+
promiseResults.Results = error;
|
|
336
|
+
reject(promiseResults);
|
|
309
337
|
}); // catches the error and logs it
|
|
310
338
|
});
|
|
311
339
|
}
|
|
@@ -313,12 +341,14 @@ class perfMonService {
|
|
|
313
341
|
* Post Fetch using Cisco PerfMon API
|
|
314
342
|
*
|
|
315
343
|
* @listCounter
|
|
316
|
-
|
|
317
|
-
service
|
|
318
|
-
|
|
319
|
-
|
|
344
|
+
* @example
|
|
345
|
+
* var service = new perfMonService();
|
|
346
|
+
* service.listCounter().then((results => {
|
|
347
|
+
* console.log(results.Results);
|
|
348
|
+
* }))
|
|
320
349
|
* @memberof perfMonService
|
|
321
|
-
* @
|
|
350
|
+
* @param {string} host - The host to collect data from.
|
|
351
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
322
352
|
*/
|
|
323
353
|
listCounter(host) {
|
|
324
354
|
var XML;
|
|
@@ -332,14 +362,17 @@ class perfMonService {
|
|
|
332
362
|
options.body = soapBody;
|
|
333
363
|
|
|
334
364
|
return new Promise((resolve, reject) => {
|
|
365
|
+
// Set up our promise results
|
|
366
|
+
var promiseResults = {
|
|
367
|
+
Cookie: "",
|
|
368
|
+
Results: "",
|
|
369
|
+
};
|
|
335
370
|
// We fetch the API endpoint
|
|
336
|
-
fetch(
|
|
337
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
338
|
-
options
|
|
339
|
-
)
|
|
371
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
340
372
|
.then(async (response) => {
|
|
341
373
|
try {
|
|
342
374
|
var data = []; // create an array to save chunked data from server
|
|
375
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
343
376
|
// response.body is a ReadableStream
|
|
344
377
|
const reader = response.body.getReader();
|
|
345
378
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -352,23 +385,27 @@ class perfMonService {
|
|
|
352
385
|
removeKeys(output, "$");
|
|
353
386
|
|
|
354
387
|
if (keyExists(output, "perfmonListCounterReturn")) {
|
|
355
|
-
var returnResults =
|
|
356
|
-
output.Body.perfmonListCounterResponse.perfmonListCounterReturn;
|
|
388
|
+
var returnResults = output.Body.perfmonListCounterResponse.perfmonListCounterReturn;
|
|
357
389
|
|
|
358
390
|
if (returnResults) {
|
|
359
|
-
|
|
391
|
+
promiseResults.Results = clean(returnResults);
|
|
392
|
+
resolve(promiseResults);
|
|
360
393
|
} else {
|
|
361
|
-
|
|
394
|
+
promiseResults.Results = output.Body.Fault;
|
|
395
|
+
reject(promiseResults);
|
|
362
396
|
}
|
|
363
397
|
} else {
|
|
364
|
-
|
|
398
|
+
promiseResults.Results = { response: "empty" };
|
|
399
|
+
resolve(promiseResults);
|
|
365
400
|
}
|
|
366
401
|
} catch (e) {
|
|
367
|
-
|
|
402
|
+
promiseResults.Results = e;
|
|
403
|
+
reject(promiseResults);
|
|
368
404
|
}
|
|
369
405
|
})
|
|
370
406
|
.catch((error) => {
|
|
371
|
-
|
|
407
|
+
promiseResults.Results = error;
|
|
408
|
+
reject(promiseResults);
|
|
372
409
|
}); // catches the error and logs it
|
|
373
410
|
});
|
|
374
411
|
}
|
|
@@ -376,12 +413,15 @@ class perfMonService {
|
|
|
376
413
|
* Post Fetch using Cisco PerfMon API
|
|
377
414
|
*
|
|
378
415
|
* @listInstance
|
|
379
|
-
|
|
380
|
-
service
|
|
381
|
-
|
|
382
|
-
|
|
416
|
+
* @example
|
|
417
|
+
* var service = new perfMonService();
|
|
418
|
+
* service.listInstance().then((results => {
|
|
419
|
+
* console.log(results.Results);
|
|
420
|
+
* }))
|
|
383
421
|
* @memberof perfMonService
|
|
384
|
-
* @
|
|
422
|
+
* @param {string} host - The host to collect data from.
|
|
423
|
+
* @param {string} object - The object to collect data about. Example: Cisco CallManager
|
|
424
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
385
425
|
*/
|
|
386
426
|
listInstance(host, object) {
|
|
387
427
|
var XML;
|
|
@@ -395,14 +435,17 @@ class perfMonService {
|
|
|
395
435
|
options.body = soapBody;
|
|
396
436
|
|
|
397
437
|
return new Promise((resolve, reject) => {
|
|
438
|
+
// Set up our promise results
|
|
439
|
+
var promiseResults = {
|
|
440
|
+
Cookie: "",
|
|
441
|
+
Results: "",
|
|
442
|
+
};
|
|
398
443
|
// We fetch the API endpoint
|
|
399
|
-
fetch(
|
|
400
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
401
|
-
options
|
|
402
|
-
)
|
|
444
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
403
445
|
.then(async (response) => {
|
|
404
446
|
try {
|
|
405
447
|
var data = []; // create an array to save chunked data from server
|
|
448
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
406
449
|
// response.body is a ReadableStream
|
|
407
450
|
const reader = response.body.getReader();
|
|
408
451
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -415,24 +458,27 @@ class perfMonService {
|
|
|
415
458
|
removeKeys(output, "$");
|
|
416
459
|
|
|
417
460
|
if (keyExists(output, "perfmonListInstanceReturn")) {
|
|
418
|
-
var returnResults =
|
|
419
|
-
output.Body.perfmonListInstanceResponse
|
|
420
|
-
.perfmonListInstanceReturn;
|
|
461
|
+
var returnResults = output.Body.perfmonListInstanceResponse.perfmonListInstanceReturn;
|
|
421
462
|
|
|
422
463
|
if (returnResults) {
|
|
423
|
-
|
|
464
|
+
promiseResults.Results = clean(returnResults);
|
|
465
|
+
resolve(promiseResults);
|
|
424
466
|
} else {
|
|
425
|
-
|
|
467
|
+
promiseResults.Results = output.Body.Fault;
|
|
468
|
+
reject(promiseResults);
|
|
426
469
|
}
|
|
427
470
|
} else {
|
|
428
|
-
|
|
471
|
+
promiseResults.Results = { response: "empty" };
|
|
472
|
+
resolve(promiseResults);
|
|
429
473
|
}
|
|
430
474
|
} catch (e) {
|
|
431
|
-
|
|
475
|
+
promiseResults.Results = e;
|
|
476
|
+
reject(promiseResults);
|
|
432
477
|
}
|
|
433
478
|
})
|
|
434
479
|
.catch((error) => {
|
|
435
|
-
|
|
480
|
+
promiseResults.Results = error;
|
|
481
|
+
reject(promiseResults);
|
|
436
482
|
}); // catches the error and logs it
|
|
437
483
|
});
|
|
438
484
|
}
|
|
@@ -440,12 +486,13 @@ class perfMonService {
|
|
|
440
486
|
* Post Fetch using Cisco PerfMon API
|
|
441
487
|
*
|
|
442
488
|
* @openSession
|
|
443
|
-
|
|
444
|
-
service
|
|
445
|
-
|
|
446
|
-
|
|
489
|
+
* @example
|
|
490
|
+
* var service = new perfMonService();
|
|
491
|
+
* service.openSession().then((results => {
|
|
492
|
+
* console.log(results.Results);
|
|
493
|
+
* }))
|
|
447
494
|
* @memberof perfMonService
|
|
448
|
-
* @returns {
|
|
495
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
449
496
|
*/
|
|
450
497
|
openSession() {
|
|
451
498
|
var XML;
|
|
@@ -458,14 +505,17 @@ class perfMonService {
|
|
|
458
505
|
options.body = soapBody;
|
|
459
506
|
|
|
460
507
|
return new Promise((resolve, reject) => {
|
|
508
|
+
// Set up our promise results
|
|
509
|
+
var promiseResults = {
|
|
510
|
+
Cookie: "",
|
|
511
|
+
Results: "",
|
|
512
|
+
};
|
|
461
513
|
// We fetch the API endpoint
|
|
462
|
-
fetch(
|
|
463
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
464
|
-
options
|
|
465
|
-
)
|
|
514
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
466
515
|
.then(async (response) => {
|
|
467
516
|
try {
|
|
468
517
|
var data = []; // create an array to save chunked data from server
|
|
518
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
469
519
|
// response.body is a ReadableStream
|
|
470
520
|
const reader = response.body.getReader();
|
|
471
521
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -478,23 +528,27 @@ class perfMonService {
|
|
|
478
528
|
removeKeys(output, "$");
|
|
479
529
|
|
|
480
530
|
if (keyExists(output, "perfmonOpenSessionReturn")) {
|
|
481
|
-
var returnResults =
|
|
482
|
-
output.Body.perfmonOpenSessionResponse.perfmonOpenSessionReturn;
|
|
531
|
+
var returnResults = output.Body.perfmonOpenSessionResponse.perfmonOpenSessionReturn;
|
|
483
532
|
|
|
484
533
|
if (returnResults) {
|
|
485
|
-
|
|
534
|
+
promiseResults.Results = clean(returnResults);
|
|
535
|
+
resolve(promiseResults);
|
|
486
536
|
} else {
|
|
487
|
-
|
|
537
|
+
promiseResults.Results = output.Body.Fault;
|
|
538
|
+
reject(promiseResults);
|
|
488
539
|
}
|
|
489
540
|
} else {
|
|
490
|
-
|
|
541
|
+
promiseResults.Results = { response: "empty" };
|
|
542
|
+
resolve(promiseResults);
|
|
491
543
|
}
|
|
492
544
|
} catch (e) {
|
|
493
|
-
|
|
545
|
+
promiseResults.Results = e;
|
|
546
|
+
reject(promiseResults);
|
|
494
547
|
}
|
|
495
548
|
})
|
|
496
549
|
.catch((error) => {
|
|
497
|
-
|
|
550
|
+
promiseResults.Results = error;
|
|
551
|
+
reject(promiseResults);
|
|
498
552
|
}); // catches the error and logs it
|
|
499
553
|
});
|
|
500
554
|
}
|
|
@@ -502,12 +556,14 @@ class perfMonService {
|
|
|
502
556
|
* Post Fetch using Cisco PerfMon API
|
|
503
557
|
*
|
|
504
558
|
* @closeSession
|
|
505
|
-
|
|
506
|
-
service
|
|
507
|
-
|
|
508
|
-
|
|
559
|
+
* @example
|
|
560
|
+
* var service = new perfMonService();
|
|
561
|
+
* service.closeSession().then((results => {
|
|
562
|
+
* console.log(results.Results);
|
|
563
|
+
* }))
|
|
509
564
|
* @memberof perfMonService
|
|
510
|
-
* @
|
|
565
|
+
* @param {string} sessionHandle - A unique session ID from the client, of type SessionHandleType. The session handle that the perfmonOpenSession request previously opened.
|
|
566
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
511
567
|
*/
|
|
512
568
|
closeSession(sessionHandle) {
|
|
513
569
|
var XML;
|
|
@@ -520,14 +576,17 @@ class perfMonService {
|
|
|
520
576
|
options.body = soapBody;
|
|
521
577
|
|
|
522
578
|
return new Promise((resolve, reject) => {
|
|
579
|
+
// Set up our promise results
|
|
580
|
+
var promiseResults = {
|
|
581
|
+
Cookie: "",
|
|
582
|
+
Results: "",
|
|
583
|
+
};
|
|
523
584
|
// We fetch the API endpoint
|
|
524
|
-
fetch(
|
|
525
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
526
|
-
options
|
|
527
|
-
)
|
|
585
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
528
586
|
.then(async (response) => {
|
|
529
587
|
try {
|
|
530
588
|
var data = []; // create an array to save chunked data from server
|
|
589
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
531
590
|
// response.body is a ReadableStream
|
|
532
591
|
const reader = response.body.getReader();
|
|
533
592
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -542,19 +601,24 @@ class perfMonService {
|
|
|
542
601
|
if (keyExists(output, "perfmonCloseSessionResponse")) {
|
|
543
602
|
var returnResults = output.Body.perfmonCloseSessionResponse;
|
|
544
603
|
if (returnResults) {
|
|
545
|
-
|
|
604
|
+
promiseResults.Results = { response: "success" };
|
|
605
|
+
resolve(promiseResults);
|
|
546
606
|
} else {
|
|
547
|
-
|
|
607
|
+
promiseResults.Results = output.Body.Fault;
|
|
608
|
+
reject(promiseResults);
|
|
548
609
|
}
|
|
549
610
|
} else {
|
|
550
|
-
|
|
611
|
+
promiseResults.Results = { response: "empty" };
|
|
612
|
+
resolve(promiseResults);
|
|
551
613
|
}
|
|
552
614
|
} catch (e) {
|
|
553
|
-
|
|
615
|
+
promiseResults.Results = e;
|
|
616
|
+
reject(promiseResults);
|
|
554
617
|
}
|
|
555
618
|
})
|
|
556
619
|
.catch((error) => {
|
|
557
|
-
|
|
620
|
+
promiseResults.Results = error;
|
|
621
|
+
reject(promiseResults);
|
|
558
622
|
}); // catches the error and logs it
|
|
559
623
|
});
|
|
560
624
|
}
|
|
@@ -562,12 +626,15 @@ class perfMonService {
|
|
|
562
626
|
* Post Fetch using Cisco PerfMon API
|
|
563
627
|
*
|
|
564
628
|
* @addCounter
|
|
565
|
-
|
|
566
|
-
service
|
|
567
|
-
|
|
568
|
-
|
|
629
|
+
* @example
|
|
630
|
+
* var service = new perfMonService();
|
|
631
|
+
* service.addCounter().then((results => {
|
|
632
|
+
* console.log(results.Results);
|
|
633
|
+
* }))
|
|
569
634
|
* @memberof perfMonService
|
|
570
|
-
* @
|
|
635
|
+
* @param {string} sessionHandle - A unique session ID from the client, of type SessionHandleType. The session handle that the perfmonOpenSession request previously opened.
|
|
636
|
+
* @param {object} counter - The counter to add. Example: Memory
|
|
637
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
571
638
|
*/
|
|
572
639
|
addCounter(sessionHandle, counter) {
|
|
573
640
|
var XML;
|
|
@@ -577,32 +644,9 @@ class perfMonService {
|
|
|
577
644
|
var server = this._HOST;
|
|
578
645
|
|
|
579
646
|
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
|
-
);
|
|
647
|
+
counter.forEach((item) => (counterStr += "<soap:Counter>" + "<soap:Name>" + "\\\\" + item.host + "\\" + item.object + "\\" + item.counter + "</soap:Name>" + "</soap:Counter>"));
|
|
594
648
|
} 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>";
|
|
649
|
+
counterStr = "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + counter.object + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>";
|
|
606
650
|
}
|
|
607
651
|
|
|
608
652
|
XML = util.format(XML_ADD_COUNTER_ENVELOPE, sessionHandle, counterStr);
|
|
@@ -611,11 +655,13 @@ class perfMonService {
|
|
|
611
655
|
options.body = soapBody;
|
|
612
656
|
|
|
613
657
|
return new Promise((resolve, reject) => {
|
|
658
|
+
// Set up our promise results
|
|
659
|
+
var promiseResults = {
|
|
660
|
+
Cookie: "",
|
|
661
|
+
Results: "",
|
|
662
|
+
};
|
|
614
663
|
// We fetch the API endpoint
|
|
615
|
-
fetch(
|
|
616
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
617
|
-
options
|
|
618
|
-
)
|
|
664
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
619
665
|
.then(async (response) => {
|
|
620
666
|
try {
|
|
621
667
|
var data = []; // create an array to save chunked data from server
|
|
@@ -633,19 +679,24 @@ class perfMonService {
|
|
|
633
679
|
if (keyExists(output, "perfmonAddCounterResponse")) {
|
|
634
680
|
var returnResults = output.Body.perfmonAddCounterResponse;
|
|
635
681
|
if (returnResults) {
|
|
636
|
-
|
|
682
|
+
promiseResults.Results = { response: "success" };
|
|
683
|
+
resolve(promiseResults);
|
|
637
684
|
} else {
|
|
638
|
-
|
|
685
|
+
promiseResults.Results = output.Body.Fault;
|
|
686
|
+
reject(promiseResults);
|
|
639
687
|
}
|
|
640
688
|
} else {
|
|
641
|
-
|
|
689
|
+
promiseResults.Results = { response: "empty" };
|
|
690
|
+
resolve(promiseResults);
|
|
642
691
|
}
|
|
643
692
|
} catch (e) {
|
|
644
|
-
|
|
693
|
+
promiseResults.Results = e;
|
|
694
|
+
reject(promiseResults);
|
|
645
695
|
}
|
|
646
696
|
})
|
|
647
697
|
.catch((error) => {
|
|
648
|
-
|
|
698
|
+
promiseResults.Results = error;
|
|
699
|
+
reject(promiseResults);
|
|
649
700
|
}); // catches the error and logs it
|
|
650
701
|
});
|
|
651
702
|
}
|
|
@@ -653,12 +704,15 @@ class perfMonService {
|
|
|
653
704
|
* Post Fetch using Cisco PerfMon API
|
|
654
705
|
*
|
|
655
706
|
* @removeCounter
|
|
656
|
-
|
|
657
|
-
service
|
|
658
|
-
|
|
659
|
-
|
|
707
|
+
* @example
|
|
708
|
+
* var service = new perfMonService();
|
|
709
|
+
* service.removeCounter().then((results => {
|
|
710
|
+
* console.log(results.Results);
|
|
711
|
+
* }))
|
|
660
712
|
* @memberof perfMonService
|
|
661
|
-
* @
|
|
713
|
+
* @param {string} sessionHandle - A unique session ID from the client, of type SessionHandleType. The session handle that the perfmonOpenSession request previously opened.
|
|
714
|
+
* @param {object} counter - The counter to remove. Example: Memory
|
|
715
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
662
716
|
*/
|
|
663
717
|
removeCounter(sessionHandle, counter) {
|
|
664
718
|
var XML;
|
|
@@ -668,32 +722,9 @@ class perfMonService {
|
|
|
668
722
|
var server = this._HOST;
|
|
669
723
|
|
|
670
724
|
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
|
-
);
|
|
725
|
+
counter.forEach((item) => (counterStr += "<soap:Counter>" + "<soap:Name>" + "\\\\" + item.host + "\\" + item.object + "\\" + item.counter + "</soap:Name>" + "</soap:Counter>"));
|
|
685
726
|
} 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>";
|
|
727
|
+
counterStr = "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + counter.object + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>";
|
|
697
728
|
}
|
|
698
729
|
|
|
699
730
|
XML = util.format(XML_REMOVE_COUNTER_ENVELOPE, sessionHandle, counterStr);
|
|
@@ -702,11 +733,13 @@ class perfMonService {
|
|
|
702
733
|
options.body = soapBody;
|
|
703
734
|
|
|
704
735
|
return new Promise((resolve, reject) => {
|
|
736
|
+
// Set up our promise results
|
|
737
|
+
var promiseResults = {
|
|
738
|
+
Cookie: "",
|
|
739
|
+
Results: "",
|
|
740
|
+
};
|
|
705
741
|
// We fetch the API endpoint
|
|
706
|
-
fetch(
|
|
707
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
708
|
-
options
|
|
709
|
-
)
|
|
742
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
710
743
|
.then(async (response) => {
|
|
711
744
|
try {
|
|
712
745
|
var data = []; // create an array to save chunked data from server
|
|
@@ -724,19 +757,24 @@ class perfMonService {
|
|
|
724
757
|
if (keyExists(output, "perfmonRemoveCounterResponse")) {
|
|
725
758
|
var returnResults = output.Body.perfmonRemoveCounterResponse;
|
|
726
759
|
if (returnResults) {
|
|
727
|
-
|
|
760
|
+
promiseResults.Results = { response: "success" };
|
|
761
|
+
resolve(promiseResults);
|
|
728
762
|
} else {
|
|
729
|
-
|
|
763
|
+
promiseResults.Results = output.Body.Fault;
|
|
764
|
+
reject(promiseResults);
|
|
730
765
|
}
|
|
731
766
|
} else {
|
|
732
|
-
|
|
767
|
+
promiseResults.Results = { response: "empty" };
|
|
768
|
+
resolve(promiseResults);
|
|
733
769
|
}
|
|
734
770
|
} catch (e) {
|
|
735
|
-
|
|
771
|
+
promiseResults.Results = e;
|
|
772
|
+
reject(promiseResults);
|
|
736
773
|
}
|
|
737
774
|
})
|
|
738
775
|
.catch((error) => {
|
|
739
|
-
|
|
776
|
+
promiseResults.Results = error;
|
|
777
|
+
reject(promiseResults);
|
|
740
778
|
}); // catches the error and logs it
|
|
741
779
|
});
|
|
742
780
|
}
|
|
@@ -744,12 +782,14 @@ class perfMonService {
|
|
|
744
782
|
* Post Fetch using Cisco PerfMon API
|
|
745
783
|
*
|
|
746
784
|
* @queryCounterDescription
|
|
747
|
-
|
|
748
|
-
service
|
|
749
|
-
|
|
750
|
-
|
|
785
|
+
* @example
|
|
786
|
+
* var service = new perfMonService();
|
|
787
|
+
* service.queryCounterDescription().then((results => {
|
|
788
|
+
* console.log(results.Results);
|
|
789
|
+
* }))
|
|
751
790
|
* @memberof perfMonService
|
|
752
|
-
* @
|
|
791
|
+
* @param {object} counter - The counter to query. Example: Memory
|
|
792
|
+
* @returns {object} returns JSON via a Promise. JSON contains Session Cookie (If availible) and Results.
|
|
753
793
|
*/
|
|
754
794
|
queryCounterDescription(counter) {
|
|
755
795
|
var XML;
|
|
@@ -757,15 +797,7 @@ class perfMonService {
|
|
|
757
797
|
options.SOAPAction = `perfmonQueryCounterDescription`;
|
|
758
798
|
var server = this._HOST;
|
|
759
799
|
|
|
760
|
-
var counterStr =
|
|
761
|
-
"<soap:Counter>" +
|
|
762
|
-
"\\\\" +
|
|
763
|
-
counter.host +
|
|
764
|
-
"\\" +
|
|
765
|
-
counter.object +
|
|
766
|
-
"\\" +
|
|
767
|
-
counter.counter +
|
|
768
|
-
"</soap:Counter>";
|
|
800
|
+
var counterStr = "<soap:Counter>" + "\\\\" + counter.host + "\\" + counter.object + "\\" + counter.counter + "</soap:Counter>";
|
|
769
801
|
|
|
770
802
|
XML = util.format(XML_QUERY_COUNTER_ENVELOPE, counterStr);
|
|
771
803
|
|
|
@@ -773,14 +805,17 @@ class perfMonService {
|
|
|
773
805
|
options.body = soapBody;
|
|
774
806
|
|
|
775
807
|
return new Promise((resolve, reject) => {
|
|
808
|
+
// Set up our promise results
|
|
809
|
+
var promiseResults = {
|
|
810
|
+
Cookie: "",
|
|
811
|
+
Results: "",
|
|
812
|
+
};
|
|
776
813
|
// We fetch the API endpoint
|
|
777
|
-
fetch(
|
|
778
|
-
`https://${server}:8443/perfmonservice2/services/PerfmonService/`,
|
|
779
|
-
options
|
|
780
|
-
)
|
|
814
|
+
fetch(`https://${server}:8443/perfmonservice2/services/PerfmonService/`, options)
|
|
781
815
|
.then(async (response) => {
|
|
782
816
|
try {
|
|
783
817
|
var data = []; // create an array to save chunked data from server
|
|
818
|
+
promiseResults.Cookie = response.headers.get("set-cookie") ? response.headers.get("set-cookie") : "";
|
|
784
819
|
// response.body is a ReadableStream
|
|
785
820
|
const reader = response.body.getReader();
|
|
786
821
|
for await (const chunk of readChunks(reader)) {
|
|
@@ -794,23 +829,26 @@ class perfMonService {
|
|
|
794
829
|
removeKeys(output, "$");
|
|
795
830
|
|
|
796
831
|
if (keyExists(output, "perfmonQueryCounterDescriptionReturn")) {
|
|
797
|
-
var returnResults =
|
|
798
|
-
output.Body.perfmonQueryCounterDescriptionResponse
|
|
799
|
-
.perfmonQueryCounterDescriptionReturn;
|
|
832
|
+
var returnResults = output.Body.perfmonQueryCounterDescriptionResponse.perfmonQueryCounterDescriptionReturn;
|
|
800
833
|
if (returnResults) {
|
|
801
|
-
|
|
834
|
+
promiseResults.Results = clean(returnResults);
|
|
835
|
+
resolve(promiseResults);
|
|
802
836
|
} else {
|
|
803
|
-
|
|
837
|
+
promiseResults.Results = output.Body.Fault;
|
|
838
|
+
reject(promiseResults);
|
|
804
839
|
}
|
|
805
840
|
} else {
|
|
806
|
-
|
|
841
|
+
promiseResults.Results = { response: "empty" };
|
|
842
|
+
resolve(promiseResults);
|
|
807
843
|
}
|
|
808
844
|
} catch (e) {
|
|
809
|
-
|
|
845
|
+
promiseResults.Results = e;
|
|
846
|
+
reject(promiseResults);
|
|
810
847
|
}
|
|
811
848
|
})
|
|
812
849
|
.catch((error) => {
|
|
813
|
-
|
|
850
|
+
promiseResults.Results = error;
|
|
851
|
+
reject(promiseResults);
|
|
814
852
|
}); // catches the error and logs it
|
|
815
853
|
});
|
|
816
854
|
}
|
|
@@ -887,11 +925,7 @@ const clean = (object) => {
|
|
|
887
925
|
if (v && typeof v === "object") {
|
|
888
926
|
clean(v);
|
|
889
927
|
}
|
|
890
|
-
if (
|
|
891
|
-
(v && typeof v === "object" && !Object.keys(v).length) ||
|
|
892
|
-
v === null ||
|
|
893
|
-
v === undefined
|
|
894
|
-
) {
|
|
928
|
+
if ((v && typeof v === "object" && !Object.keys(v).length) || v === null || v === undefined) {
|
|
895
929
|
if (Array.isArray(object)) {
|
|
896
930
|
object.splice(k, 1);
|
|
897
931
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cisco-perfmon",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "A library to pull Perfmon data from Cisco VOS applications via SOAP",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"dotenv": "*",
|
|
33
|
-
"envalid": "^8.0.0"
|
|
33
|
+
"envalid": "^8.0.0",
|
|
34
|
+
"jsdoc-to-markdown": "^9.0.4"
|
|
34
35
|
}
|
|
35
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);
|