cisco-perfmon 1.4.2 → 1.4.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.
- package/main.js +20 -9
- package/package.json +1 -1
- package/test/tests.js +3 -3
package/main.js
CHANGED
|
@@ -111,9 +111,20 @@ var errorResults = {
|
|
|
111
111
|
class perfMonService {
|
|
112
112
|
constructor(host, username, password, options) {
|
|
113
113
|
this._OPTIONS = {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
retryOn: function(attempt, error, response) {
|
|
115
|
+
// Only allow retries on JSESSIONIDSSO authenticaion attempts
|
|
116
|
+
if(!options){
|
|
117
|
+
return false
|
|
118
|
+
}else if (attempt > (process.env.PERFMON_RETRIES ? parseInt(process.env.PERFMON_RETRIES) : 3)) {
|
|
119
|
+
return false
|
|
120
|
+
};
|
|
121
|
+
// retry on any network error, or 4xx or 5xx status codes
|
|
122
|
+
if (error !== null || response.status >= 400) {
|
|
123
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
124
|
+
delay(process.env.PERFMON_RETRY_DELAY ? parseInt(process.env.PERFMON_RETRY_DELAY) : 1000);
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
},
|
|
117
128
|
method: "POST",
|
|
118
129
|
headers: {
|
|
119
130
|
Authorization: "Basic " + Buffer.from(username + ":" + password).toString("base64"),
|
|
@@ -702,11 +713,11 @@ class perfMonService {
|
|
|
702
713
|
var options = this._OPTIONS;
|
|
703
714
|
options.SOAPAction = `perfmonAddCounter`;
|
|
704
715
|
var server = this._HOST;
|
|
705
|
-
|
|
716
|
+
// var counterStr = "<soap:Counter>" + "\\\\" + counter.host + "\\" + (counter.instance ? `${counter.object}(${counter.instance})` : counter.object) + "\\" + counter.counter + "</soap:Counter>";
|
|
706
717
|
if (Array.isArray(counter)) {
|
|
707
|
-
counter.forEach((
|
|
718
|
+
counter.forEach((counter) => (counterStr += "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + (counter.instance ? `${counter.object}(${counter.instance})` : counter.object) + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>"));
|
|
708
719
|
} else {
|
|
709
|
-
counterStr = "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + counter.object + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>";
|
|
720
|
+
counterStr = "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + (counter.instance ? `${counter.object}(${counter.instance})` : counter.object) + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>";
|
|
710
721
|
}
|
|
711
722
|
|
|
712
723
|
XML = util.format(XML_ADD_COUNTER_ENVELOPE, sessionHandle, counterStr);
|
|
@@ -790,9 +801,9 @@ class perfMonService {
|
|
|
790
801
|
var server = this._HOST;
|
|
791
802
|
|
|
792
803
|
if (Array.isArray(counter)) {
|
|
793
|
-
counter.forEach((
|
|
804
|
+
counter.forEach((counter) => (counterStr += "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + (counter.instance ? `${counter.object}(${counter.instance})` : counter.object) + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>"));
|
|
794
805
|
} else {
|
|
795
|
-
counterStr = "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + counter.object + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>";
|
|
806
|
+
counterStr = "<soap:Counter>" + "<soap:Name>" + "\\\\" + counter.host + "\\" + (counter.instance ? `${counter.object}(${counter.instance})` : counter.object) + "\\" + counter.counter + "</soap:Name>" + "</soap:Counter>";
|
|
796
807
|
}
|
|
797
808
|
|
|
798
809
|
XML = util.format(XML_REMOVE_COUNTER_ENVELOPE, sessionHandle, counterStr);
|
|
@@ -873,7 +884,7 @@ class perfMonService {
|
|
|
873
884
|
options.SOAPAction = `perfmonQueryCounterDescription`;
|
|
874
885
|
var server = this._HOST;
|
|
875
886
|
|
|
876
|
-
var counterStr = "<soap:Counter>" + "\\\\" + counter.host + "\\" + counter.object + "\\" + counter.counter + "</soap:Counter>";
|
|
887
|
+
var counterStr = "<soap:Counter>" + "\\\\" + counter.host + "\\" + (counter.instance ? `${counter.object}(${counter.instance})` : counter.object) + "\\" + counter.counter + "</soap:Counter>";
|
|
877
888
|
|
|
878
889
|
XML = util.format(XML_QUERY_COUNTER_ENVELOPE, counterStr);
|
|
879
890
|
|
package/package.json
CHANGED
package/test/tests.js
CHANGED
|
@@ -30,11 +30,11 @@ var cucmServerName = env.CUCM_SERVER_NAME;
|
|
|
30
30
|
var SessionID;
|
|
31
31
|
var counterObj = {
|
|
32
32
|
host: cucmServerName,
|
|
33
|
-
object:
|
|
34
|
-
|
|
33
|
+
object: 'Partition',
|
|
34
|
+
instance: 'SharedMemory',
|
|
35
|
+
counter: 'Write Bytes Per Sec',
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
|
|
38
38
|
(async () => {
|
|
39
39
|
console.log("Let's get a description of our counter. We will also retrieve a cookie to use for the rest of the session.");
|
|
40
40
|
await service
|