cisco-perfmon 1.2.1 → 1.2.3

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.
Files changed (2) hide show
  1. package/package.json +7 -2
  2. package/test/tests.js +28 -7
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "cisco-perfmon",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
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
+ "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",
@@ -26,5 +27,9 @@
26
27
  "dependencies": {
27
28
  "util": "*",
28
29
  "xml2js": "*"
30
+ },
31
+ "devDependencies": {
32
+ "dotenv": "*",
33
+ "envalid": "^8.0.0"
29
34
  }
30
35
  }
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
- // Set up new PerfMon service
4
- let service = new perfMonService("10.10.20.1", "administrator", "ciscopsdt");
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
- var host = "hq-cucm-pub";
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: 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(host, "Cisco Hunt Pilots")
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(host)
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(host, "Processor")
123
+ .listInstance(cucmServerName, "Processor")
103
124
  .then((results) => {
104
125
  console.log("listInstance", results);
105
126
  })