@@ -13,17 +13,13 @@ import CompMetric04 from './Metric04';
13
13
import { configuration } from './../pages/Configs' ;
14
14
import Badge from "@awsui/components-react/badge" ;
15
15
import Link from "@awsui/components-react/link" ;
16
- import Box from "@awsui/components-react/box" ;
17
- import Table from "@awsui/components-react/table" ;
18
16
import Header from "@awsui/components-react/header" ;
19
17
20
18
const ComponentObject = memo ( ( { sessionId, clusterId, nodeStats } ) => {
21
19
22
20
const [ detailsVisible , setDetailsVisible ] = useState ( false ) ;
23
21
const detailsVisibleState = useRef ( false ) ;
24
- const activeSessions = useRef ( [ ] ) ;
25
-
26
-
22
+
27
23
const columnsTable = [
28
24
{ id : 'PID' , header : 'PID' , cell : item => item [ 'PID' ] , ariaLabel : createLabelFunction ( 'PID' ) , sortingField : 'ThreadID' , } ,
29
25
{ id : 'Username' , header : 'Username' , cell : item => item [ 'Username' ] , ariaLabel : createLabelFunction ( 'Username' ) , sortingField : 'Username' , } ,
@@ -38,45 +34,6 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
38
34
39
35
const visibleContent = [ 'PID' , 'Username' , 'State' , 'Host' , 'WaitEvent' , 'Database' , 'ElapsedTime' , 'AppName' , 'SQLText' ] ;
40
36
41
- //-- Function Gather Active Sessions
42
- async function fetchSessions ( ) {
43
- //--- API Call Gather Sessions
44
- if ( detailsVisibleState . current == true ) {
45
-
46
-
47
-
48
- //--- API Call Gather Sessions
49
- var api_params = {
50
- connectionId : sessionId ,
51
- clusterId : clusterId ,
52
- instanceId : nodeStats . name ,
53
- sql_statement : `
54
- select pid as "PID",usename as "Username",state as "State",wait_event as "WaitEvent",datname as "Database",CAST(CURRENT_TIMESTAMP-query_start AS VARCHAR) as "ElapsedTime",application_name as "AppName",client_addr as "Host",query as "SQLText" from pg_stat_activity where pid <> pg_backend_pid() and state = \'active\' order by query_start asc limit 250;
55
- `
56
- } ;
57
-
58
- Axios . get ( `${ configuration [ "apps-settings" ] [ "api_url" ] } /api/aurora/postgresql/cluster/sql/` , {
59
- params : api_params
60
- } ) . then ( ( data ) => {
61
-
62
- activeSessions . current = data . data . rows ;
63
-
64
- } )
65
- . catch ( ( err ) => {
66
- console . log ( 'Timeout API Call : /api/aurora/postgresql/cluster/sql/' ) ;
67
- console . log ( err )
68
- } ) ;
69
-
70
-
71
-
72
- }
73
- else {
74
- activeSessions . current = [ ] ;
75
- }
76
-
77
- }
78
-
79
-
80
37
function onClickNode ( ) {
81
38
82
39
detailsVisibleState . current = ( ! ( detailsVisibleState . current ) ) ;
@@ -85,13 +42,6 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
85
42
}
86
43
87
44
88
- useEffect ( ( ) => {
89
- const id = setInterval ( fetchSessions , configuration [ "apps-settings" ] [ "refresh-interval-aurora-pgs-sessions" ] ) ;
90
- return ( ) => clearInterval ( id ) ;
91
- // eslint-disable-next-line react-hooks/exhaustive-deps
92
- } , [ ] ) ;
93
-
94
-
95
45
return (
96
46
< >
97
47
< tr >
@@ -102,6 +52,9 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
102
52
{ nodeStats . role === "R" &&
103
53
< Badge color = "red" > R </ Badge >
104
54
}
55
+ { ( nodeStats . role != "P" && nodeStats . role != "R" ) &&
56
+ < Badge > - </ Badge >
57
+ }
105
58
106
59
< Link fontSize = "body-s" onFollow = { ( ) => onClickNode ( ) } > { nodeStats . name } </ Link >
107
60
</ td >
@@ -131,19 +84,23 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
131
84
chartColorLine = { "#D69855" }
132
85
/>
133
86
</ td >
134
- < td style = { { "width" :"9%" , "text-align" :"center" , "border-top" : "1pt solid " + configuration . colors . lines . separator100 } } >
135
- < CompMetric01
136
- value = { nodeStats . numbackends || 0 }
137
- title = { "" }
87
+ < td style = { { "width" :"9%" , "text-align" :"center" , "border-top" : "1pt solid " + configuration . colors . lines . separator100 } } >
88
+ < CompMetric04
89
+ value = { nodeStats . tuples || 0 }
138
90
precision = { 0 }
139
- format = { 3 }
91
+ format = { 1 }
92
+ height = { "30px" }
93
+ width = { "100px" }
94
+ history = { 20 }
95
+ type = { "line" }
140
96
fontSizeValue = { "14px" }
141
97
fontColorValue = { configuration . colors . fonts . metric100 }
98
+ chartColorLine = { "#D69855" }
142
99
/>
143
100
</ td >
144
101
< td style = { { "width" :"9%" , "text-align" :"center" , "border-top" : "1pt solid " + configuration . colors . lines . separator100 } } >
145
102
< CompMetric01
146
- value = { ( nodeStats . tupInserted + nodeStats . tupDeleted + nodeStats . tupUpdated + nodeStats . tupFetched ) || 0 }
103
+ value = { nodeStats . numbackends || 0 }
147
104
title = { "" }
148
105
precision = { 0 }
149
106
format = { 3 }
@@ -287,16 +244,6 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
287
244
fontSizeValue = { "16px" }
288
245
/>
289
246
</ td >
290
- < td style = { { "width" :"10%" , "border-left" : "2px solid " + configuration . colors . lines . separator100 , "padding-left" : "1em" } } >
291
- < CompMetric01
292
- value = { nodeStats . tupReturned || 0 }
293
- title = { "tupReturned/sec" }
294
- precision = { 0 }
295
- format = { 1 }
296
- fontColorValue = { configuration . colors . fonts . metric100 }
297
- fontSizeValue = { "16px" }
298
- />
299
- </ td >
300
247
< td style = { { "width" :"10%" , "border-left" : "2px solid " + configuration . colors . lines . separator100 , "padding-left" : "1em" } } >
301
248
< CompMetric01
302
249
value = { nodeStats . tupFetched || 0 }
@@ -337,6 +284,16 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
337
284
fontSizeValue = { "16px" }
338
285
/>
339
286
</ td >
287
+ < td style = { { "width" :"10%" , "border-left" : "2px solid " + configuration . colors . lines . separator100 , "padding-left" : "1em" } } >
288
+ < CompMetric01
289
+ value = { nodeStats . tupReturned || 0 }
290
+ title = { "tupReturned/sec" }
291
+ precision = { 0 }
292
+ format = { 1 }
293
+ fontColorValue = { configuration . colors . fonts . metric100 }
294
+ fontSizeValue = { "16px" }
295
+ />
296
+ </ td >
340
297
< td style = { { "width" :"10%" , "border-left" : "2px solid " + configuration . colors . lines . separator100 , "padding-left" : "1em" } } >
341
298
< CompMetric01
342
299
value = { nodeStats . ioreads || 0 }
@@ -405,7 +362,6 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
405
362
</ td >
406
363
< td style = { { "width" :"33%" , "padding-left" : "1em" } } >
407
364
< ChartLine02 series = { JSON . stringify ( [
408
- nodeStats . history . tupReturned ,
409
365
nodeStats . history . tupFetched ,
410
366
nodeStats . history . tupInserted ,
411
367
nodeStats . history . tupDeleted ,
@@ -431,8 +387,9 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
431
387
< CustomTable
432
388
columnsTable = { columnsTable }
433
389
visibleContent = { visibleContent }
434
- dataset = { activeSessions . current }
390
+ dataset = { nodeStats [ 'sessions' ] }
435
391
title = { "Active Sessions" }
392
+ description = { "Top 10 database active sessions" }
436
393
/>
437
394
</ div >
438
395
</ td >
0 commit comments