@@ -13,17 +13,13 @@ import CompMetric04 from './Metric04';
1313import { configuration } from './../pages/Configs' ;
1414import Badge from "@awsui/components-react/badge" ;
1515import Link from "@awsui/components-react/link" ;
16- import Box from "@awsui/components-react/box" ;
17- import Table from "@awsui/components-react/table" ;
1816import Header from "@awsui/components-react/header" ;
1917
2018const ComponentObject = memo ( ( { sessionId, clusterId, nodeStats } ) => {
2119
2220 const [ detailsVisible , setDetailsVisible ] = useState ( false ) ;
2321 const detailsVisibleState = useRef ( false ) ;
24- const activeSessions = useRef ( [ ] ) ;
25-
26-
22+
2723 const columnsTable = [
2824 { id : 'PID' , header : 'PID' , cell : item => item [ 'PID' ] , ariaLabel : createLabelFunction ( 'PID' ) , sortingField : 'ThreadID' , } ,
2925 { id : 'Username' , header : 'Username' , cell : item => item [ 'Username' ] , ariaLabel : createLabelFunction ( 'Username' ) , sortingField : 'Username' , } ,
@@ -38,45 +34,6 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
3834
3935 const visibleContent = [ 'PID' , 'Username' , 'State' , 'Host' , 'WaitEvent' , 'Database' , 'ElapsedTime' , 'AppName' , 'SQLText' ] ;
4036
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-
8037 function onClickNode ( ) {
8138
8239 detailsVisibleState . current = ( ! ( detailsVisibleState . current ) ) ;
@@ -85,13 +42,6 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
8542 }
8643
8744
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-
9545 return (
9646 < >
9747 < tr >
@@ -102,6 +52,9 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
10252 { nodeStats . role === "R" &&
10353 < Badge color = "red" > R </ Badge >
10454 }
55+ { ( nodeStats . role != "P" && nodeStats . role != "R" ) &&
56+ < Badge > - </ Badge >
57+ }
10558
10659 < Link fontSize = "body-s" onFollow = { ( ) => onClickNode ( ) } > { nodeStats . name } </ Link >
10760 </ td >
@@ -131,19 +84,23 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
13184 chartColorLine = { "#D69855" }
13285 />
13386 </ 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 }
13890 precision = { 0 }
139- format = { 3 }
91+ format = { 1 }
92+ height = { "30px" }
93+ width = { "100px" }
94+ history = { 20 }
95+ type = { "line" }
14096 fontSizeValue = { "14px" }
14197 fontColorValue = { configuration . colors . fonts . metric100 }
98+ chartColorLine = { "#D69855" }
14299 />
143100 </ td >
144101 < td style = { { "width" :"9%" , "text-align" :"center" , "border-top" : "1pt solid " + configuration . colors . lines . separator100 } } >
145102 < CompMetric01
146- value = { ( nodeStats . tupInserted + nodeStats . tupDeleted + nodeStats . tupUpdated + nodeStats . tupFetched ) || 0 }
103+ value = { nodeStats . numbackends || 0 }
147104 title = { "" }
148105 precision = { 0 }
149106 format = { 3 }
@@ -287,16 +244,6 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
287244 fontSizeValue = { "16px" }
288245 />
289246 </ 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 >
300247 < td style = { { "width" :"10%" , "border-left" : "2px solid " + configuration . colors . lines . separator100 , "padding-left" : "1em" } } >
301248 < CompMetric01
302249 value = { nodeStats . tupFetched || 0 }
@@ -337,6 +284,16 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
337284 fontSizeValue = { "16px" }
338285 />
339286 </ 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 >
340297 < td style = { { "width" :"10%" , "border-left" : "2px solid " + configuration . colors . lines . separator100 , "padding-left" : "1em" } } >
341298 < CompMetric01
342299 value = { nodeStats . ioreads || 0 }
@@ -405,7 +362,6 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
405362 </ td >
406363 < td style = { { "width" :"33%" , "padding-left" : "1em" } } >
407364 < ChartLine02 series = { JSON . stringify ( [
408- nodeStats . history . tupReturned ,
409365 nodeStats . history . tupFetched ,
410366 nodeStats . history . tupInserted ,
411367 nodeStats . history . tupDeleted ,
@@ -431,8 +387,9 @@ const ComponentObject = memo(({ sessionId, clusterId, nodeStats }) => {
431387 < CustomTable
432388 columnsTable = { columnsTable }
433389 visibleContent = { visibleContent }
434- dataset = { activeSessions . current }
390+ dataset = { nodeStats [ 'sessions' ] }
435391 title = { "Active Sessions" }
392+ description = { "Top 10 database active sessions" }
436393 />
437394 </ div >
438395 </ td >
0 commit comments