@@ -14,7 +14,7 @@ if (process.argv.length >= 3) {
14
14
let withDiskUsage = false ;
15
15
if ( process . argv [ 3 ] ) {
16
16
test = process . argv [ 3 ] ;
17
- if ( test == 'diskusage:true' ) {
17
+ if ( test == 'diskusage:true' ) {
18
18
withDiskUsage = true ;
19
19
}
20
20
}
@@ -235,7 +235,7 @@ process.stdin.on('end', () => {
235
235
}
236
236
237
237
function getPoolStatsFromAPI ( ) {
238
- if ( ! withDiskUsage ) {
238
+ if ( ! withDiskUsage ) {
239
239
return false ;
240
240
}
241
241
return new Promise ( ( resolve , reject ) => {
@@ -260,7 +260,7 @@ process.stdin.on('end', () => {
260
260
}
261
261
262
262
function getDiskUsageFromAPI ( ) {
263
- if ( ! withDiskUsage ) {
263
+ if ( ! withDiskUsage ) {
264
264
return false ;
265
265
}
266
266
return new Promise ( ( resolve , reject ) => {
@@ -443,12 +443,19 @@ process.stdin.on('end', () => {
443
443
versionId : osInfo [ 'VERSION_ID' ] ,
444
444
prettyName : osInfo [ 'PRETTY_NAME' ] ,
445
445
codename : osInfo [ 'VERSION_CODENAME' ] ,
446
+ error : null
446
447
} ;
447
448
448
449
} catch ( error ) {
449
- throwError ( "Fehler beim Auslesen des Host OS:" + error , '' ) ;
450
- return null ;
451
- }
450
+
451
+ return {
452
+ id : null ,
453
+ versionId : null ,
454
+ prettyName : null ,
455
+ codename : null ,
456
+ error : error
457
+ } ;
458
+ }
452
459
}
453
460
454
461
function getPostgresVersion ( dsn ) {
@@ -491,7 +498,7 @@ process.stdin.on('end', () => {
491
498
let statusMessages = [ ] ;
492
499
493
500
let configinfo = infoData [ 6 ] ;
494
-
501
+
495
502
//////////////////////////////////////////////////////////////
496
503
// get postgres version, cannot be part of Promise.all(), because we need the DSN.
497
504
// DSN is in the response from getConfigFromInspectAPI()
@@ -754,10 +761,10 @@ process.stdin.on('end', () => {
754
761
// objecttypes stat
755
762
result . statistics = { } ;
756
763
result . statistics . objecttypes = { } ;
757
- if ( infoData [ 10 ] ) {
758
- if ( infoData [ 10 ] [ 'IndexedByTableNameRead' ] ) {
759
- Object . keys ( infoData [ 10 ] [ 'IndexedByTableNameRead' ] ) . forEach ( function ( key ) {
760
- if ( infoData [ 10 ] [ 'IndexedByTableNameRead' ] [ key ] . Count ) {
764
+ if ( infoData [ 10 ] ) {
765
+ if ( infoData [ 10 ] [ 'IndexedByTableNameRead' ] ) {
766
+ Object . keys ( infoData [ 10 ] [ 'IndexedByTableNameRead' ] ) . forEach ( function ( key ) {
767
+ if ( infoData [ 10 ] [ 'IndexedByTableNameRead' ] [ key ] . Count ) {
761
768
result . statistics . objecttypes [ key ] = infoData [ 10 ] [ 'IndexedByTableNameRead' ] [ key ] . Count ;
762
769
}
763
770
} ) ;
@@ -766,7 +773,7 @@ process.stdin.on('end', () => {
766
773
767
774
768
775
// filestats
769
- if ( withDiskUsage ) {
776
+ if ( withDiskUsage ) {
770
777
result . file_stats = { } ;
771
778
result . file_stats . count = 0 ;
772
779
result . file_stats . size = 0 ;
@@ -780,19 +787,19 @@ process.stdin.on('end', () => {
780
787
}
781
788
782
789
// from objecttype
783
- if ( infoData [ 9 ] . length > 0 ) {
790
+ if ( infoData [ 9 ] . length > 0 ) {
784
791
let otCount = 0 ;
785
792
let otSize = 0 ;
786
- for ( let i = 0 ; i < infoData [ 9 ] . length ; i ++ ) {
787
- if ( infoData [ 9 ] [ i ] . OtStats ) {
788
- if ( infoData [ 9 ] [ i ] . OtStats . files ) {
789
- if ( infoData [ 9 ] [ i ] . OtStats . files . size ) {
793
+ for ( let i = 0 ; i < infoData [ 9 ] . length ; i ++ ) {
794
+ if ( infoData [ 9 ] [ i ] . OtStats ) {
795
+ if ( infoData [ 9 ] [ i ] . OtStats . files ) {
796
+ if ( infoData [ 9 ] [ i ] . OtStats . files . size ) {
790
797
var size = infoData [ 9 ] [ i ] . OtStats . files . size ;
791
798
var count = infoData [ 9 ] [ i ] . OtStats . files . count ;
792
- if ( count ) {
799
+ if ( count ) {
793
800
otCount += count ;
794
801
}
795
- if ( size != 0 ) {
802
+ if ( size != 0 ) {
796
803
otSize = otSize + size ;
797
804
}
798
805
}
@@ -803,9 +810,9 @@ process.stdin.on('end', () => {
803
810
result . file_stats . size += otSize ;
804
811
}
805
812
806
- if ( result . file_stats . count > 0 ) {
813
+ if ( result . file_stats . count > 0 ) {
807
814
var sizeString = ( result . file_stats . size / ( 1024 ** 3 ) ) . toFixed ( 2 ) + ' GB' ;
808
- if ( sizeString == '0.00 GB' ) {
815
+ if ( sizeString == '0.00 GB' ) {
809
816
sizeString = ( result . file_stats . size / ( 1024 ** 2 ) ) . toFixed ( 2 ) + ' MB' ;
810
817
}
811
818
result . file_stats . size = sizeString ;
@@ -913,8 +920,14 @@ process.stdin.on('end', () => {
913
920
statusResults . loglevel = 'nothing' ;
914
921
statusResults . janitor = 'nothing' ;
915
922
923
+ // check of host-os-release file was read properly
924
+ if ( result . host_data . error !== null ) {
925
+ increaseStatus ( 'warning' ) ;
926
+ statusMessages . push ( 'Host os-release file: ' + result . host_data . error ) ;
927
+ }
928
+
916
929
// check backups
917
- if ( result . sqlbackups !== true ) {
930
+ if ( result . sqlbackups !== true ) {
918
931
increaseStatus ( 'warning' ) ;
919
932
statusMessages . push ( 'last Backup not found' ) ;
920
933
}
@@ -996,11 +1009,11 @@ process.stdin.on('end', () => {
996
1009
const highStatus = openSearchWatermarkConfig . high . replace ( '%' , '' ) * 1 ;
997
1010
const floodStatus = openSearchWatermarkConfig . flood_stage . replace ( '%' , '' ) * 1 ;
998
1011
999
- if ( usedDiskInPercent >= highStatus ) {
1012
+ if ( usedDiskInPercent >= highStatus ) {
1000
1013
openSearchWatermarkStatus = 'high' ;
1001
1014
statusMessages . push ( 'openSearchWatermarkStatus: high' ) ;
1002
1015
}
1003
- if ( usedDiskInPercent >= floodStatus ) {
1016
+ if ( usedDiskInPercent >= floodStatus ) {
1004
1017
openSearchWatermarkStatus = 'flood_stage' ;
1005
1018
statusMessages . push ( 'openSearchWatermarkStatus: flood_stage' ) ;
1006
1019
}
0 commit comments