cisco-perfmon 1.2.0 → 1.2.2
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 +2 -2
- package/package.json +6 -2
- package/test/tests.js +28 -7
package/main.js
CHANGED
|
@@ -260,7 +260,7 @@ class perfMonService {
|
|
|
260
260
|
(element) => element
|
|
261
261
|
);
|
|
262
262
|
|
|
263
|
-
let instanceArr =
|
|
263
|
+
let instanceArr = arr[1]
|
|
264
264
|
.split(/[()]+/)
|
|
265
265
|
.filter(function (e) {
|
|
266
266
|
return e;
|
|
@@ -280,7 +280,7 @@ class perfMonService {
|
|
|
280
280
|
(element) => element
|
|
281
281
|
);
|
|
282
282
|
|
|
283
|
-
let instanceArr =
|
|
283
|
+
let instanceArr = arr[1].split(/[()]+/).filter(function (e) {
|
|
284
284
|
return e;
|
|
285
285
|
});
|
|
286
286
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cisco-perfmon",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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 ./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
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -26,5 +26,9 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"util": "*",
|
|
28
28
|
"xml2js": "*"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"dotenv": "*",
|
|
32
|
+
"envalid": "^8.0.0"
|
|
29
33
|
}
|
|
30
34
|
}
|
package/test/tests.js
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
const perfMonService = require("../main");
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { cleanEnv, str, host } = require("envalid");
|
|
2
4
|
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
+
// If not production load the local env file
|
|
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
|
+
}
|
|
5
13
|
|
|
6
|
-
|
|
14
|
+
const env = cleanEnv(process.env, {
|
|
15
|
+
NODE_ENV: str({
|
|
16
|
+
choices: ["development", "test", "production", "staging"],
|
|
17
|
+
desc: "Node environment",
|
|
18
|
+
}),
|
|
19
|
+
CUCM_HOSTNAME: host({ desc: "Cisco CUCM Hostname or IP Address to send the perfmon request to. Typically the publisher." }),
|
|
20
|
+
CUCM_USERNAME: str({ desc: "Cisco CUCM AXL Username." }),
|
|
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." , example: "hq-cucm-pub or hq-cucm-sub" }),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
let service = new perfMonService(env.CUCM_HOSTNAME, env.CUCM_USERNAME, env.CUCM_PASSWORD);
|
|
26
|
+
|
|
27
|
+
var cucmServerName = env.CUCM_SERVER_NAME;
|
|
7
28
|
|
|
8
29
|
// Variables to hold our SessionID and our Session Counter
|
|
9
30
|
var SessionID;
|
|
10
31
|
var counterObj = {
|
|
11
|
-
host:
|
|
32
|
+
host: cucmServerName,
|
|
12
33
|
object: "Processor(_Total)",
|
|
13
34
|
counter: "% CPU Time",
|
|
14
35
|
};
|
|
@@ -75,7 +96,7 @@ var counterObj = {
|
|
|
75
96
|
|
|
76
97
|
console.log("Let's collect some non session counter data.");
|
|
77
98
|
await service
|
|
78
|
-
.collectCounterData(
|
|
99
|
+
.collectCounterData(cucmServerName, "Cisco CallManager")
|
|
79
100
|
.then((results) => {
|
|
80
101
|
console.log("collectCounterData", results);
|
|
81
102
|
})
|
|
@@ -87,7 +108,7 @@ var counterObj = {
|
|
|
87
108
|
"Let's returns the list of available PerfMon objects and counters on a particular host"
|
|
88
109
|
);
|
|
89
110
|
await service
|
|
90
|
-
.listCounter(
|
|
111
|
+
.listCounter(cucmServerName)
|
|
91
112
|
.then((results) => {
|
|
92
113
|
console.log("listCounter", results);
|
|
93
114
|
})
|
|
@@ -99,7 +120,7 @@ var counterObj = {
|
|
|
99
120
|
"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."
|
|
100
121
|
);
|
|
101
122
|
await service
|
|
102
|
-
.listInstance(
|
|
123
|
+
.listInstance(cucmServerName, "Processor")
|
|
103
124
|
.then((results) => {
|
|
104
125
|
console.log("listInstance", results);
|
|
105
126
|
})
|