@@ -163,7 +163,6 @@ function computeStatisticsRaw (result, start, clusterId) {
163
163
for ( let key in STAT_SERIES ) {
164
164
if ( STAT_SERIES . hasOwnProperty ( key ) ) {
165
165
path = STAT_SERIES [ key ] ;
166
-
167
166
result [ key ] . push ( stat [ path [ 0 ] ] [ path [ 1 ] ] ) ;
168
167
}
169
168
}
@@ -316,6 +315,7 @@ function computeStatisticsShort (start, clusterId) {
316
315
const result = { } ;
317
316
318
317
computeStatisticsRaw ( result , start , clusterId ) ;
318
+
319
319
computeStatisticsRaw15M ( result , start , clusterId ) ;
320
320
321
321
return result ;
@@ -405,13 +405,12 @@ router.use((req, res, next) => {
405
405
next ( ) ;
406
406
} ) ;
407
407
408
- router . get ( " /coordshort" , function ( req , res ) {
408
+ router . get ( ' /coordshort' , function ( req , res ) {
409
409
var merged = {
410
410
http : { }
411
411
} ;
412
412
413
- var mergeHistory = function ( data ) {
414
-
413
+ var mergeHistory = function ( data ) {
415
414
var onetime = [ 'times' ] ;
416
415
var values = [
417
416
'physicalMemory' ,
@@ -435,56 +434,58 @@ router.get("/coordshort", function(req, res) {
435
434
'avgRequestTime'
436
435
] ;
437
436
438
- var counter = 0 , counter2 ;
439
-
440
- _ . each ( data , function ( stat ) {
441
- //if (stat.enabled) {
442
- // self.statsEnabled = true;
443
- // }
444
- //else {
445
- // self.statsEnabled = false;
446
- //}
437
+ var counter = 0 ;
438
+ var counter2 ;
447
439
440
+ _ . each ( data , function ( stat ) {
448
441
if ( typeof stat === 'object' ) {
449
442
if ( counter === 0 ) {
450
- //one time value
451
- _ . each ( onetime , function ( value ) {
443
+ // one time value
444
+ _ . each ( onetime , function ( value ) {
452
445
merged [ value ] = stat [ value ] ;
453
446
} ) ;
454
447
455
- //values
456
- _ . each ( values , function ( value ) {
448
+ // values
449
+ _ . each ( values , function ( value ) {
457
450
merged [ value ] = stat [ value ] ;
458
451
} ) ;
459
452
460
- //http requests arrays
461
- _ . each ( http , function ( value ) {
453
+ // http requests arrays
454
+ _ . each ( http , function ( value ) {
462
455
merged . http [ value ] = stat [ value ] ;
463
456
} ) ;
464
457
465
- //arrays
466
- _ . each ( arrays , function ( value ) {
458
+ // arrays
459
+ _ . each ( arrays , function ( value ) {
467
460
merged [ value ] = stat [ value ] ;
468
461
} ) ;
469
-
470
- }
471
- else
A3DB
{
472
- //values
473
- _ . each ( values , function ( value ) {
462
+ } else {
463
+ // values
464
+ _ . each ( values , function ( value ) {
474
465
merged [ value ] = merged [ value ] + stat [ value ] ;
475
466
} ) ;
476
- //http requests arrays
477
- _ . each ( http , function ( value ) {
467
+ // http requests arrays
468
+ _ . each ( http , function ( value ) {
478
469
counter2 = 0 ;
479
- _ . each ( stat [ value ] , function ( x ) {
480
- merged . http [ value ] [ counter2 ] = merged . http [ value ] [ counter2 ] + x ;
470
+ _ . each ( stat [ value ] , function ( x ) {
471
+ if ( merged . http [ value ] [ counter2 ] === undefined ) {
472
+ // this will hit if a previous coordinater was not able to deliver
473
+ // proper current statistics, but the current one already has statistics.
474
+ merged . http [ value ] [ counter2 ] = x ;
475
+ } else {
476
+ merged . http [ value ] [ counter2 ] = merged . http [ value ] [ counter2 ] + x ;
477
+ }
481
478
counter2 ++ ;
482
479
} ) ;
483
480
} ) ;
484
- _ . each ( arrays , function ( value ) {
481
+ _ . each ( arrays , function ( value ) {
485
482
counter2 = 0 ;
486
- _ . each ( stat [ value ] , function ( x ) {
487
- merged [ value ] [ counter2 ] = merged [ value ] [ counter2 ] + x ;
483
+ _ . each ( stat [ value ] , function ( x ) {
484
+ if ( merged [ value ] [ counter2 ] === undefined ) {
485
+ merged [ value ] [ counter2 ] = 0 ;
486
+ } else {
487
+ merged [ value ] [ counter2 ] = merged [ value ] [ counter2 ] + x ;
488
+ }
488
489
counter2 ++ ;
489
490
} ) ;
490
491
} ) ;
@@ -495,17 +496,18 @@ router.get("/coordshort", function(req, res) {
495
496
} ;
496
497
497
498
var coordinators = global . ArangoClusterInfo . getCoordinators ( ) ;
499
+ var coordinatorStats ;
498
500
if ( Array . isArray ( coordinators ) ) {
499
- var coordinatorStats = coordinators . map ( coordinator => {
501
+ coordinatorStats = coordinators . map ( coordinator => {
500
502
var endpoint = global . ArangoClusterInfo . getServerEndpoint ( coordinator ) ;
501
503
if ( endpoint . substring ( 0 , 3 ) === 'ssl' ) {
502
504
// if protocol ssl is returned, change it to https
503
505
endpoint = 'https' + endpoint . substring ( 3 ) ;
504
506
}
505
- if ( endpoint !== "" ) {
506
- var response = download ( endpoint . replace ( / ^ t c p / , " http" ) + " /_db/_system/_admin/aardvark/statistics/short?count=" + coordinators . length , '' , { headers : { } } ) ;
507
+ if ( endpoint !== '' ) {
508
+ var response = download ( endpoint . replace ( / ^ t c p / , ' http' ) + ' /_db/_system/_admin/aardvark/statistics/short?count=' + coordinators . length , '' , { headers : { } } ) ;
507
509
if ( response . body === undefined ) {
508
- console . warn ( " cannot contact coordinator " + coordinator + " on endpoint " + endpoint ) ;
510
+ console . warn ( ' cannot contact coordinator ' + coordinator + ' on endpoint ' + endpoint ) ;
509
511
} else {
510
512
try {
511
513
return JSON . parse ( response . body ) ;
@@ -518,12 +520,21 @@ router.get("/coordshort", function(req, res) {
518
520
return false ;
519
521
} ) ;
520
522
521
- mergeHistory ( coordinatorStats ) ;
523
+ if ( coordinatorStats ) {
524
+ mergeHistory ( coordinatorStats ) ;
525
+ }
526
+ }
527
+ if ( coordinatorStats ) {
528
+ res . json ( { 'enabled' : coordinatorStats . some ( stat => stat . enabled ) , 'data' : merged } ) ;
529
+ } else {
530
+ res . json ( {
531
+ 'enabled' : false ,
532
+ 'data' : { }
533
+ } ) ;
522
534
}
523
- res . json ( { "enabled" : coordinatorStats . some ( stat => stat . enabled ) , "data" : merged } ) ;
524
535
} )
525
- . summary ( " Short term history for all coordinators" )
526
- . description ( " This function is used to get the statistics history." ) ;
536
+ . summary ( ' Short term history for all coordinators' )
537
+ . description ( ' This function is used to get the statistics history.' ) ;
527
538
528
539
router . get ( "/short" , function ( req , res ) {
529
540
const start = req . queryParams . start ;
0 commit comments