un-cli 0.0.63 → 0.0.67
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/README.md +37 -19
- package/cmd.txt +3 -1
- package/index.mjs +264 -32
- package/out.txt +0 -0
- package/package.json +1 -1
- package/utilitynetwork.node.mjs +33 -1
package/README.md
CHANGED
|
@@ -18,26 +18,44 @@ npm install -g un-cli
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
+
|
|
21
22
|
uncli> help
|
|
22
|
-
|
|
23
|
-
│
|
|
24
|
-
|
|
25
|
-
│
|
|
26
|
-
│
|
|
27
|
-
│
|
|
28
|
-
│
|
|
29
|
-
│
|
|
30
|
-
│
|
|
31
|
-
│
|
|
32
|
-
│
|
|
33
|
-
│
|
|
34
|
-
│
|
|
35
|
-
│
|
|
36
|
-
│
|
|
37
|
-
│
|
|
38
|
-
│
|
|
39
|
-
│
|
|
40
|
-
|
|
23
|
+
┌───────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
24
|
+
│ (index) │ Values │
|
|
25
|
+
├───────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
26
|
+
│ help │ 'Displays this help' │
|
|
27
|
+
│ version │ 'Displays the version of uncli' │
|
|
28
|
+
│ ls │ 'List all services' │
|
|
29
|
+
│ def │ 'Show the feature service definition' │
|
|
30
|
+
│ def --layers │ 'List all layers in this service' │
|
|
31
|
+
│ subnetworks │ 'Lists all subnetworks' │
|
|
32
|
+
│ subnetworks --dirty │ 'Lists only dirty subnetworks' │
|
|
33
|
+
│ subnetworks --deleted │ 'Lists dirty and deleted subnetworks' │
|
|
34
|
+
│ evaluate │ 'Evaluate in parallel' │
|
|
35
|
+
│ trace --subnetwork <subnetwork> │ 'Traces input subnetwork and returns the time and number of elements returned .' │
|
|
36
|
+
│ topology │ 'Displays the topology status' │
|
|
37
|
+
│ topology --disable │ 'Disable topology' │
|
|
38
|
+
│ topology --enable │ 'Enable topology' │
|
|
39
|
+
│ topology --validate │ 'Validate topology (full extent)' │
|
|
40
|
+
│ update subnetworks --all │ 'Update all dirty subnetworks synchronously' │
|
|
41
|
+
│ update subnetworks --deleted │ 'Update all deleted dirty subnetworks synchronously' │
|
|
42
|
+
│ update subnetworks --all --async │ 'Update all dirty subnetworks asynchronously' │
|
|
43
|
+
│ export subnetworks --all │ 'Export all subnetworks with ACK ' │
|
|
44
|
+
│ export subnetworks --new │ "Export all subnetworks with ACK that haven't been exported " │
|
|
45
|
+
│ export subnetworks --deleted │ 'Export all subnetworks with ACK that are deleted ' │
|
|
46
|
+
│ count │ 'Lists the number of rows in all feature layers.' │
|
|
47
|
+
│ count --system │ 'Lists the number of rows in system layers.' │
|
|
48
|
+
│ connect --service │ 'Connects to the another service' │
|
|
49
|
+
│ tracelogs --age <minutes> │ 'Lists utility network trace summary logs for the last x minutes (requires admin)' │
|
|
50
|
+
│ validatelogs --age <minutes> │ 'Lists utility network validate summary logs for the last x minutes (requires admin)' │
|
|
51
|
+
│ updatesubnetworkslog --age <minutes> │ 'Lists utility network update subnetworks summary logs for the last x minutes (requires admin)' │
|
|
52
|
+
│ arlogs --age <minutes> │ 'Lists attribute rules execution logs for the last x minutes (requires admin)' │
|
|
53
|
+
│ arlogs --byrule [--minguid --maxguid] │ 'Lists attribute rules execution summary by rule (requires admin), --maxguid and --minguid show the GUID of the feature' │
|
|
54
|
+
│ topsql --age <minutes> │ 'Lists all queries executed in the last x minutes (requires admin)' │
|
|
55
|
+
│ whoami │ 'Lists the current login info' │
|
|
56
|
+
│ clear │ 'Clears this screen' │
|
|
57
|
+
│ quit │ 'Exit this program' │
|
|
58
|
+
└───────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
41
59
|
```
|
|
42
60
|
|
|
43
61
|
|
package/cmd.txt
CHANGED
package/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { AdminLog } from "./adminlog.mjs"
|
|
|
7
7
|
import { logger } from "./logger.mjs"
|
|
8
8
|
import fetch from "node-fetch"
|
|
9
9
|
//update version
|
|
10
|
-
let version = "0.0.
|
|
10
|
+
let version = "0.0.67";
|
|
11
11
|
const GENERATE_TOKEN_TIME_MIN = 30;
|
|
12
12
|
|
|
13
13
|
let rl = null;
|
|
@@ -172,15 +172,19 @@ const inputs = {
|
|
|
172
172
|
"update subnetworks --all": "Update all dirty subnetworks synchronously",
|
|
173
173
|
"update subnetworks --deleted": "Update all deleted dirty subnetworks synchronously",
|
|
174
174
|
"update subnetworks --all --async": "Update all dirty subnetworks asynchronously",
|
|
175
|
-
"export subnetworks --all": "Export all subnetworks with ACK ",
|
|
176
|
-
"export subnetworks --new": "Export all subnetworks with ACK that haven't been exported ",
|
|
175
|
+
"export subnetworks --all [--folder]": "Export all subnetworks with ACK --folder where exported files are saved",
|
|
176
|
+
"export subnetworks --new [--folder]": "Export all subnetworks with ACK that haven't been exported --folder where exported files are saved",
|
|
177
177
|
"export subnetworks --deleted": "Export all subnetworks with ACK that are deleted ",
|
|
178
178
|
"count": "Lists the number of rows in all feature layers.",
|
|
179
179
|
"count --system": "Lists the number of rows in system layers.",
|
|
180
180
|
"connect --service": "Connects to the another service",
|
|
181
|
-
"tracelogs --
|
|
182
|
-
"
|
|
181
|
+
"tracelogs --age <minutes>": "Lists utility network trace summary logs for the last x minutes (requires admin)",
|
|
182
|
+
"validatelogs --age <minutes>": "Lists utility network validate summary logs for the last x minutes (requires admin)",
|
|
183
|
+
"updatesubnetworkslog --age <minutes>": "Lists utility network update subnetworks summary logs for the last x minutes (requires admin)",
|
|
184
|
+
"arlogs --age <minutes>": "Lists attribute rules execution logs for the last x minutes (requires admin)",
|
|
183
185
|
"arlogs --byrule [--minguid --maxguid]": "Lists attribute rules execution summary by rule (requires admin), --maxguid and --minguid show the GUID of the feature",
|
|
186
|
+
"topsql --age <minutes>": "Lists all queries executed in the last x minutes (requires admin)",
|
|
187
|
+
|
|
184
188
|
"whoami": "Lists the current login info",
|
|
185
189
|
"clear": "Clears this screen",
|
|
186
190
|
"quit": "Exit this program"
|
|
@@ -243,7 +247,7 @@ const inputs = {
|
|
|
243
247
|
// console.log('\x1b[36m%s\x1b[0m', 'I am cyan'); //cyan
|
|
244
248
|
const topoMoments = networkMoments.networkMoments.map(m => {
|
|
245
249
|
const t = m.time === 0 ? "N/A": new Date(m.time*1000)
|
|
246
|
-
const d = m.duration === 0 ? "N/A" : numberWithCommas(Math.round(m.duration
|
|
250
|
+
const d = m.duration === 0 ? "N/A" : numberWithCommas(Math.round(m.duration)) + " ms"
|
|
247
251
|
m.time = t.toString()
|
|
248
252
|
m.duration = d;
|
|
249
253
|
return m;
|
|
@@ -261,7 +265,7 @@ const inputs = {
|
|
|
261
265
|
const result = await un.enableTopology()
|
|
262
266
|
const toDate = new Date();
|
|
263
267
|
const timeEnable = toDate.getTime() - fromDate.getTime();
|
|
264
|
-
result.duration = numberWithCommas(Math.round(timeEnable
|
|
268
|
+
result.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
|
|
265
269
|
console.table(result)
|
|
266
270
|
},
|
|
267
271
|
"^topology --disable$": async () => {
|
|
@@ -270,7 +274,7 @@ const inputs = {
|
|
|
270
274
|
const result = await un.disableTopology()
|
|
271
275
|
const toDate = new Date();
|
|
272
276
|
const timeEnable = toDate.getTime() - fromDate.getTime();
|
|
273
|
-
result.duration = numberWithCommas(Math.round(timeEnable
|
|
277
|
+
result.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
|
|
274
278
|
console.table(result)
|
|
275
279
|
},
|
|
276
280
|
"^evaluate$": async () => {
|
|
@@ -292,7 +296,7 @@ const inputs = {
|
|
|
292
296
|
const result = {}
|
|
293
297
|
const toDate = new Date();
|
|
294
298
|
const timeEnable = toDate.getTime() - fromDate.getTime();
|
|
295
|
-
result.duration = numberWithCommas(Math.round(timeEnable
|
|
299
|
+
result.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
|
|
296
300
|
console.log(result)
|
|
297
301
|
},
|
|
298
302
|
|
|
@@ -337,7 +341,7 @@ const inputs = {
|
|
|
337
341
|
const result = await un.validateNetworkTopology("sde.DEFAULT", e)
|
|
338
342
|
const toDate = new Date();
|
|
339
343
|
const timeEnable = toDate.getTime() - fromDate.getTime();
|
|
340
|
-
const duration = numberWithCommas(Math.round(timeEnable
|
|
344
|
+
const duration = numberWithCommas(Math.round(timeEnable)) + " ms"
|
|
341
345
|
console.clear()
|
|
342
346
|
console.log("Validating extent " + e.xmin)
|
|
343
347
|
console.table({duration})
|
|
@@ -353,7 +357,7 @@ const inputs = {
|
|
|
353
357
|
const result = await un.validateNetworkTopology()
|
|
354
358
|
const toDate = new Date();
|
|
355
359
|
const timeEnable = toDate.getTime() - fromDate.getTime();
|
|
356
|
-
result.duration = numberWithCommas(Math.round(timeEnable
|
|
360
|
+
result.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
|
|
357
361
|
console.table(result)
|
|
358
362
|
},
|
|
359
363
|
"^subnetworks --dirty$": async () => {
|
|
@@ -398,7 +402,7 @@ const inputs = {
|
|
|
398
402
|
|
|
399
403
|
const toDate = new Date();
|
|
400
404
|
const timeEnable = toDate.getTime() - fromDate.getTime();
|
|
401
|
-
subnetworkResult.duration = numberWithCommas(Math.round(timeEnable
|
|
405
|
+
subnetworkResult.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
|
|
402
406
|
|
|
403
407
|
|
|
404
408
|
console.log(`Result ${JSON.stringify(subnetworkResult)}`)
|
|
@@ -422,7 +426,7 @@ const inputs = {
|
|
|
422
426
|
|
|
423
427
|
const toDate = new Date();
|
|
424
428
|
const timeEnable = toDate.getTime() - fromDate.getTime();
|
|
425
|
-
subnetworkResult.duration = numberWithCommas(Math.round(timeEnable
|
|
429
|
+
subnetworkResult.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
|
|
426
430
|
|
|
427
431
|
console.log(`Result ${JSON.stringify(subnetworkResult)}`)
|
|
428
432
|
}
|
|
@@ -438,14 +442,14 @@ const inputs = {
|
|
|
438
442
|
console.log(`Result from submitting job ${JSON.stringify(subnetworkResult)}`)
|
|
439
443
|
}
|
|
440
444
|
},
|
|
441
|
-
|
|
445
|
+
"^export subnetworks --all --folder .*$|^export subnetworks --all$" : async input => {
|
|
442
446
|
|
|
443
447
|
|
|
444
448
|
//create folder
|
|
445
|
-
const file = input.match(
|
|
449
|
+
const file = input.match(/--folder .*/gm)
|
|
446
450
|
let inputDir = "Exported"
|
|
447
451
|
if (file != null && file.length > 0)
|
|
448
|
-
inputDir = file[0].replace("
|
|
452
|
+
inputDir = file[0].replace("--folder ", "")
|
|
449
453
|
//create directory if doesn't exists
|
|
450
454
|
if (!fs.existsSync(inputDir)) fs.mkdirSync(inputDir)
|
|
451
455
|
|
|
@@ -467,7 +471,7 @@ const inputs = {
|
|
|
467
471
|
|
|
468
472
|
const toDate = new Date();
|
|
469
473
|
const timeEnable = toDate.getTime() - fromDate.getTime();
|
|
470
|
-
subnetworkResult.duration = numberWithCommas(
|
|
474
|
+
subnetworkResult.duration = numberWithCommas(timeEnable) + " ms"
|
|
471
475
|
|
|
472
476
|
|
|
473
477
|
//fetch the json and write it to disk
|
|
@@ -551,7 +555,7 @@ const inputs = {
|
|
|
551
555
|
const toDate = new Date();
|
|
552
556
|
const timeRun = toDate.getTime() - fromDate.getTime();
|
|
553
557
|
const newResult = {}
|
|
554
|
-
newResult.duration = numberWithCommas(Math.round(timeRun
|
|
558
|
+
newResult.duration = numberWithCommas(Math.round(timeRun)) + " ms"
|
|
555
559
|
newResult.elementsCount = result.traceResults.elements.length;
|
|
556
560
|
console.table(newResult)
|
|
557
561
|
|
|
@@ -674,17 +678,27 @@ const inputs = {
|
|
|
674
678
|
|
|
675
679
|
},
|
|
676
680
|
|
|
677
|
-
"^arlogs
|
|
681
|
+
"^arlogs --age": async input => {
|
|
678
682
|
const topLogCount = 200;
|
|
679
683
|
const pageSize = 10000
|
|
680
|
-
console.log(`Querying attribute rules logs for ${parameters.service} ...`)
|
|
681
|
-
console.log(`Displaying top ${topLogCount} entries only..`)
|
|
682
684
|
|
|
683
|
-
|
|
685
|
+
|
|
686
|
+
const inputParam = input.match(/--age .*/gm)
|
|
687
|
+
let mins = 30; //query logs for the last 30 minutes
|
|
688
|
+
if (inputParam != null && inputParam.length > 0)
|
|
689
|
+
mins = inputParam[0].replace("--age ", "")
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
console.log(`Querying attribute rules logs for ${parameters.service} for the last ${mins} minutes ...`)
|
|
693
|
+
|
|
694
|
+
const startTime = Date.now() - mins*60*1000
|
|
695
|
+
const endTime = Date.now();
|
|
696
|
+
|
|
697
|
+
let result= await adminLog.query([102003], [parameters.service+ ".MapServer"], topLogCount, startTime, endTime , "DEBUG")
|
|
684
698
|
let jsonRes = await result.json()
|
|
685
699
|
let allMessages = [].concat(jsonRes.logMessages)
|
|
686
700
|
|
|
687
|
-
while (jsonRes.hasMore
|
|
701
|
+
while (jsonRes.hasMore )
|
|
688
702
|
{
|
|
689
703
|
//start paging
|
|
690
704
|
logger.info(`Aggregating messages... total so far ${allMessages.length} debug entries but more left, pulling logs before ${new Date(jsonRes.endTime)}`)
|
|
@@ -714,17 +728,16 @@ const inputs = {
|
|
|
714
728
|
|
|
715
729
|
},
|
|
716
730
|
|
|
717
|
-
|
|
718
|
-
|
|
731
|
+
|
|
719
732
|
|
|
720
|
-
"^tracelogs --
|
|
733
|
+
"^tracelogs --age": async input => {
|
|
721
734
|
const topLogCount = 1000;
|
|
722
735
|
const pageSize = 10000
|
|
723
736
|
|
|
724
|
-
const inputParam = input.match(/--
|
|
737
|
+
const inputParam = input.match(/--age .*/gm)
|
|
725
738
|
let mins = 30; //query logs for the last 30 minutes
|
|
726
739
|
if (inputParam != null && inputParam.length > 0)
|
|
727
|
-
mins = inputParam[0].replace("--
|
|
740
|
+
mins = inputParam[0].replace("--age ", "")
|
|
728
741
|
|
|
729
742
|
console.log(`Querying trace logs for ${parameters.service} for the last ${mins} minutes ...`)
|
|
730
743
|
const startTime = Date.now() - mins*60*1000
|
|
@@ -732,20 +745,239 @@ const inputs = {
|
|
|
732
745
|
let result= await adminLog.query([102002], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "VERBOSE")
|
|
733
746
|
let jsonRes = await result.json()
|
|
734
747
|
let allMessages = [].concat(jsonRes.logMessages)
|
|
735
|
-
allMessages = allMessages.filter(m => m.message.indexOf("
|
|
748
|
+
allMessages = allMessages.filter(m => m.message.indexOf("------ Trace Parameters ----") > -1)
|
|
736
749
|
while (jsonRes.hasMore)
|
|
737
750
|
{
|
|
738
751
|
//start paging
|
|
739
752
|
logger.info(`Aggregating messages... total so far ${allMessages.length} entries but more left, pulling logs before ${new Date(jsonRes.endTime)}`)
|
|
740
|
-
result= await adminLog.query([102002], [parameters.service + ".MapServer"], pageSize, jsonRes.endTime)
|
|
753
|
+
result= await adminLog.query([102002], [parameters.service + ".MapServer"], pageSize, jsonRes.endTime, null, "VERBOSE")
|
|
741
754
|
jsonRes = await result.json()
|
|
742
755
|
|
|
743
|
-
allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("
|
|
756
|
+
allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("------ Trace Parameters ----") > -1))
|
|
744
757
|
}
|
|
758
|
+
allMessages.forEach(m => {
|
|
759
|
+
const newMessage = Object.assign({}, m);
|
|
760
|
+
delete newMessage.message
|
|
761
|
+
delete newMessage.source;
|
|
762
|
+
delete newMessage.machine;
|
|
763
|
+
delete newMessage.type;
|
|
764
|
+
delete newMessage.requestID;
|
|
765
|
+
delete newMessage.thread;
|
|
766
|
+
delete newMessage.time;
|
|
767
|
+
|
|
768
|
+
console.table([newMessage])
|
|
769
|
+
console.log(m.message)
|
|
770
|
+
})
|
|
771
|
+
|
|
772
|
+
},
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
"^validatelogs --age": async input => {
|
|
777
|
+
|
|
778
|
+
const topLogCount = 1000;
|
|
779
|
+
const pageSize = 10000
|
|
745
780
|
|
|
746
|
-
|
|
781
|
+
const inputParam = input.match(/--age .*/gm)
|
|
782
|
+
let mins = 30; //query logs for the last 30 minutes
|
|
783
|
+
if (inputParam != null && inputParam.length > 0)
|
|
784
|
+
mins = inputParam[0].replace("--age ", "")
|
|
785
|
+
|
|
786
|
+
console.log(`Querying validate logs for ${parameters.service} for the last ${mins} minutes ...`)
|
|
787
|
+
const startTime = Date.now() - mins*60*1000
|
|
788
|
+
const endTime = Date.now();
|
|
789
|
+
let result= await adminLog.query([102003], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "VERBOSE")
|
|
790
|
+
let jsonRes = await result.json()
|
|
791
|
+
let allMessages = [].concat(jsonRes.logMessages)
|
|
792
|
+
allMessages = allMessages.filter(m => m.message.indexOf("-------- Environment ---") > -1 && m.message.indexOf("------ Trace Parameters ----") < 0)
|
|
793
|
+
while (jsonRes.hasMore)
|
|
794
|
+
{
|
|
795
|
+
//start paging
|
|
796
|
+
logger.info(`Aggregating messages... total so far ${allMessages.length} entries but more left, pulling logs before ${new Date(jsonRes.endTime)}`)
|
|
797
|
+
result= await adminLog.query([102003], [parameters.service + ".MapServer"], pageSize, jsonRes.endTime, null, "VERBOSE")
|
|
798
|
+
jsonRes = await result.json()
|
|
799
|
+
|
|
800
|
+
allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("-------- Environment ---") > -1 && m.message.indexOf("------ Trace Parameters ----") == -1))
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
allMessages.forEach(m => {
|
|
805
|
+
const newMessage = Object.assign({}, m);
|
|
806
|
+
delete newMessage.message
|
|
807
|
+
delete newMessage.source;
|
|
808
|
+
delete newMessage.machine;
|
|
809
|
+
delete newMessage.type;
|
|
810
|
+
delete newMessage.requestID;
|
|
811
|
+
delete newMessage.thread;
|
|
812
|
+
delete newMessage.time;
|
|
813
|
+
|
|
814
|
+
console.table([newMessage])
|
|
815
|
+
console.log(m.message)
|
|
816
|
+
})
|
|
817
|
+
|
|
818
|
+
},
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
"^updatesubnetworkslogs --age": async input => {
|
|
824
|
+
const topLogCount = 1000;
|
|
825
|
+
const pageSize = 10000
|
|
826
|
+
|
|
827
|
+
const inputParam = input.match(/--age .*/gm)
|
|
828
|
+
let mins = 30; //query logs for the last 30 minutes
|
|
829
|
+
if (inputParam != null && inputParam.length > 0)
|
|
830
|
+
mins = inputParam[0].replace("--age ", "")
|
|
831
|
+
|
|
832
|
+
console.log(`Querying subnetwork logs for ${parameters.service} for the last ${mins} minutes ...`)
|
|
833
|
+
const startTime = Date.now() - mins*60*1000
|
|
834
|
+
const endTime = Date.now();
|
|
835
|
+
let result= await adminLog.query([102003], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "VERBOSE")
|
|
836
|
+
let jsonRes = await result.json()
|
|
837
|
+
let allMessages = [].concat(jsonRes.logMessages)
|
|
838
|
+
allMessages = allMessages.filter(m => m.message.indexOf("---- Subnetwork Parameters ----") > -1)
|
|
839
|
+
while (jsonRes.hasMore)
|
|
840
|
+
{
|
|
841
|
+
//start paging
|
|
842
|
+
logger.info(`Aggregating messages... total so far ${allMessages.length} entries but more left, pulling logs before ${new Date(jsonRes.endTime)}`)
|
|
843
|
+
result= await adminLog.query([102003], [parameters.service + ".MapServer"], pageSize, jsonRes.endTime, null, "VERBOSE")
|
|
844
|
+
jsonRes = await result.json()
|
|
845
|
+
|
|
846
|
+
allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("---- Subnetwork Parameters ----") > -1))
|
|
847
|
+
}
|
|
848
|
+
allMessages.forEach(m => {
|
|
849
|
+
const newMessage = Object.assign({}, m);
|
|
850
|
+
delete newMessage.message
|
|
851
|
+
delete newMessage.source;
|
|
852
|
+
delete newMessage.machine;
|
|
853
|
+
delete newMessage.type;
|
|
854
|
+
delete newMessage.requestID;
|
|
855
|
+
delete newMessage.thread;
|
|
856
|
+
delete newMessage.time;
|
|
857
|
+
|
|
858
|
+
console.table([newMessage])
|
|
859
|
+
console.log(m.message)
|
|
860
|
+
})
|
|
747
861
|
|
|
748
862
|
},
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
"^topsql --age": async input => {
|
|
867
|
+
const topLogCount = 1000;
|
|
868
|
+
const pageSize = 10000
|
|
869
|
+
|
|
870
|
+
const inputParam = input.match(/--age .*/gm)
|
|
871
|
+
let mins = 30; //query logs for the last 30 minutes
|
|
872
|
+
if (inputParam != null && inputParam.length > 0)
|
|
873
|
+
mins = inputParam[0].replace("--age ", "")
|
|
874
|
+
|
|
875
|
+
console.log(`Querying cursor sql logs for ${parameters.service} for the last ${mins} minutes ...`)
|
|
876
|
+
const startTime = Date.now() - mins*60*1000
|
|
877
|
+
const endTime = Date.now();
|
|
878
|
+
let result= await adminLog.query([102023], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "DEBUG")
|
|
879
|
+
let jsonRes = await result.json()
|
|
880
|
+
let allMessages = [].concat(jsonRes.logMessages)
|
|
881
|
+
allMessages = allMessages.filter(m => m.message.indexOf("EndCursor;") > -1)
|
|
882
|
+
while (jsonRes.hasMore)
|
|
883
|
+
{
|
|
884
|
+
//start paging
|
|
885
|
+
logger.info(`Aggregating messages... total so far ${allMessages.length} entries but more left, pulling logs before ${new Date(jsonRes.endTime)}`)
|
|
886
|
+
result= await adminLog.query([102023], [parameters.service + ".MapServer"], pageSize, jsonRes.endTime, null, "DEBUG")
|
|
887
|
+
jsonRes = await result.json()
|
|
888
|
+
|
|
889
|
+
allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("EndCursor;") > -1))
|
|
890
|
+
}
|
|
891
|
+
console.log ("Filtering messages...")
|
|
892
|
+
|
|
893
|
+
allMessages = allMessages
|
|
894
|
+
.map( m=> {
|
|
895
|
+
m.dataAccessElapsed = parseFloat(m.message.split(";")[1].split(" ")[1])
|
|
896
|
+
m.ExecuteQueryElapsed = parseFloat(m.message.split(";")[2].split(" ")[1])
|
|
897
|
+
m.totalTimeElapsed = m.dataAccessElapsed + m.ExecuteQueryElapsed
|
|
898
|
+
m.elapsed = parseFloat(m.elapsed); return m;
|
|
899
|
+
|
|
900
|
+
})
|
|
901
|
+
.sort( (m1,m2) => m2.totalTimeElapsed - m1.totalTimeElapsed)
|
|
902
|
+
.slice(0, 10) ;//first 10
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
console.log("-----Top 10 SQL----")
|
|
906
|
+
let i =0;
|
|
907
|
+
allMessages= allMessages.forEach(m =>
|
|
908
|
+
{
|
|
909
|
+
|
|
910
|
+
const x = m.message.split(";")
|
|
911
|
+
console.log(`id: ${i++}`)
|
|
912
|
+
console.log(`\tAt: ${new Date(m.time)} (${m.time})`)
|
|
913
|
+
console.log(`\tUser: ${m.user}`)
|
|
914
|
+
console.log(`\tElapsed: ${m.elapsed*1000} ms`)
|
|
915
|
+
console.log(`\ttotalTimeElapsed: ${m.totalTimeElapsed} ms`)
|
|
916
|
+
console.log(`\tQuery:`)
|
|
917
|
+
x.forEach(a => console.log(`\t${a}`))
|
|
918
|
+
console.log(`\n`)
|
|
919
|
+
|
|
920
|
+
})
|
|
921
|
+
|
|
922
|
+
},
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
"^cursorlogs --age": async input => {
|
|
927
|
+
const topLogCount = 1000;
|
|
928
|
+
const pageSize = 10000
|
|
929
|
+
|
|
930
|
+
const inputParam = input.match(/--age .*/gm)
|
|
931
|
+
let mins = 30; //query logs for the last 30 minutes
|
|
932
|
+
if (inputParam != null && inputParam.length > 0)
|
|
933
|
+
mins = inputParam[0].replace("--age ", "")
|
|
934
|
+
|
|
935
|
+
console.log(`Querying cursor sql logs for ${parameters.service} for the last ${mins} minutes ...`)
|
|
936
|
+
const startTime = Date.now() - mins*60*1000
|
|
937
|
+
const endTime = Date.now();
|
|
938
|
+
let result= await adminLog.query([102023], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "DEBUG")
|
|
939
|
+
let jsonRes = await result.json()
|
|
940
|
+
let allMessages = [].concat(jsonRes.logMessages)
|
|
941
|
+
allMessages = allMessages.filter(m => m.message.indexOf("EndCursor;") > -1)
|
|
942
|
+
while (jsonRes.hasMore)
|
|
943
|
+
{
|
|
944
|
+
//start paging
|
|
945
|
+
logger.info(`Aggregating messages... total so far ${allMessages.length} entries but more left, pulling logs before ${new Date(jsonRes.endTime)}`)
|
|
946
|
+
result= await adminLog.query([102023], [parameters.service + ".MapServer"], pageSize, jsonRes.endTime, null, "DEBUG")
|
|
947
|
+
jsonRes = await result.json()
|
|
948
|
+
|
|
949
|
+
allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("EndCursor;") > -1))
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
//
|
|
954
|
+
allMessages= allMessages.map(m => {
|
|
955
|
+
|
|
956
|
+
const r= m.message.split (";")
|
|
957
|
+
delete r[0];
|
|
958
|
+
delete r[1];
|
|
959
|
+
delete r[3];
|
|
960
|
+
return r;
|
|
961
|
+
|
|
962
|
+
const newMessage = Object.assign({}, m);
|
|
963
|
+
|
|
964
|
+
delete newMessage.source;
|
|
965
|
+
delete newMessage.machine;
|
|
966
|
+
delete newMessage.type;
|
|
967
|
+
delete newMessage.requestID;
|
|
968
|
+
delete newMessage.methodName;
|
|
969
|
+
delete newMessage.process;
|
|
970
|
+
delete newMessage.thread;
|
|
971
|
+
delete newMessage.time;
|
|
972
|
+
delete newMessage.code;
|
|
973
|
+
|
|
974
|
+
return newMessage
|
|
975
|
+
|
|
976
|
+
})
|
|
977
|
+
console.table(allMessages)
|
|
978
|
+
},
|
|
979
|
+
|
|
980
|
+
|
|
749
981
|
"^arlogs --byrule": async input => {
|
|
750
982
|
//--minguid to show min guid
|
|
751
983
|
//--maxguid to show max guid
|
package/out.txt
ADDED
|
File without changes
|
package/package.json
CHANGED
package/utilitynetwork.node.mjs
CHANGED
|
@@ -997,6 +997,37 @@ export class UtilityNetwork {
|
|
|
997
997
|
let ar = thisObj.featureServiceUrl.split("/");
|
|
998
998
|
ar[ar.length-1]="UtilityNetworkServer";
|
|
999
999
|
let exportsubnetworkUrl = ar.join("/") + "/exportSubnetwork"
|
|
1000
|
+
const resultTypes = [
|
|
1001
|
+
{
|
|
1002
|
+
"type": "features",
|
|
1003
|
+
"includeGeometry": true,
|
|
1004
|
+
"includePropagatedValues": false,
|
|
1005
|
+
"includeDomainDescriptions": true,
|
|
1006
|
+
"networkAttributeNames": [
|
|
1007
|
+
"Is subnetwork controller"
|
|
1008
|
+
],
|
|
1009
|
+
"diagramTemplateName": "",
|
|
1010
|
+
"resultTypeFields": []
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
"type": "connectivity",
|
|
1014
|
+
"includeGeometry": true,
|
|
1015
|
+
"includePropagatedValues": false,
|
|
1016
|
+
"includeDomainDescriptions": true,
|
|
1017
|
+
"networkAttributeNames": [],
|
|
1018
|
+
"diagramTemplateName": "",
|
|
1019
|
+
"resultTypeFields": []
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
"type": "associations",
|
|
1023
|
+
"includeGeometry": false,
|
|
1024
|
+
"includePropagatedValues": false,
|
|
1025
|
+
"includeDomainDescriptions": true,
|
|
1026
|
+
"networkAttributeNames": [],
|
|
1027
|
+
"diagramTemplateName": "",
|
|
1028
|
+
"resultTypeFields": []
|
|
1029
|
+
}
|
|
1030
|
+
]
|
|
1000
1031
|
//traceConfiguration: JSON.stringify(subnetworkDef),
|
|
1001
1032
|
let exportsubnetworkJson = {
|
|
1002
1033
|
f: "json",
|
|
@@ -1007,9 +1038,10 @@ export class UtilityNetwork {
|
|
|
1007
1038
|
exportAcknowledgement: true,
|
|
1008
1039
|
allSubnetworksInTier: false,
|
|
1009
1040
|
continueOnFailure: false,
|
|
1010
|
-
traceConfiguration: subnetworkDef,
|
|
1041
|
+
traceConfiguration: subnetworkDef,
|
|
1011
1042
|
async: async,
|
|
1012
1043
|
gdbVersion:this.gdbVersion,
|
|
1044
|
+
resultTypes: JSON.stringify(resultTypes)
|
|
1013
1045
|
}
|
|
1014
1046
|
let un = this;
|
|
1015
1047
|
|