@@ -53,7 +53,7 @@ impl Command for ShowServers {
5353 Field :: text ( "connect_time" ) ,
5454 Field :: text ( "request_time" ) ,
5555 Field :: numeric ( "remote_pid" ) ,
56- // Field::bigint("client_id"),
56+ Field :: bigint ( "client_id" ) ,
5757 Field :: numeric ( "transactions" ) ,
5858 Field :: numeric ( "queries" ) ,
5959 Field :: numeric ( "rollbacks" ) ,
@@ -62,6 +62,8 @@ impl Command for ShowServers {
6262 Field :: numeric ( "errors" ) ,
6363 Field :: numeric ( "bytes_received" ) ,
6464 Field :: numeric ( "bytes_sent" ) ,
65+ Field :: text ( "last_sent" ) ,
66+ Field :: text ( "last_received" ) ,
6567 Field :: numeric ( "age" ) ,
6668 Field :: text ( "application_name" ) ,
6769 ] ,
@@ -78,32 +80,45 @@ impl Command for ShowServers {
7880 let now_time = SystemTime :: now ( ) ;
7981
8082 for ( _, server) in stats {
81- let stats = server. stats ;
82- let age = now. duration_since ( stats. created_at ) ;
83- let request_age = now. duration_since ( stats. last_used ) ;
83+ let age = now. duration_since ( server. stats . created_at ) ;
84+ let request_age = now. duration_since ( server. stats . last_used ) ;
8485 let request_time = now_time - request_age;
8586
8687 let dr = self
8788 . row
8889 . clone ( )
89- . add ( "pool_id" , stats. pool_id )
90+ . add ( "pool_id" , server . stats . pool_id )
9091 . add ( "database" , server. addr . database_name )
9192 . add ( "user" , server. addr . user )
9293 . add ( "addr" , server. addr . host . as_str ( ) )
9394 . add ( "port" , server. addr . port . to_string ( ) )
94- . add ( "state" , stats. state . to_string ( ) )
95- . add ( "connect_time" , format_time ( stats. created_at_time . into ( ) ) )
95+ . add ( "state" , server. stats . state . to_string ( ) )
96+ . add (
97+ "connect_time" ,
98+ format_time ( server. stats . created_at_time . into ( ) ) ,
99+ )
96100 . add ( "request_time" , format_time ( request_time. into ( ) ) )
97- . add ( "remote_pid" , stats. id . pid as i64 )
98- // .add("client_id", stats.client_id.map(|client| client.pid as i64))
99- . add ( "transactions" , stats. total . transactions )
100- . add ( "queries" , stats. total . queries )
101- . add ( "rollbacks" , stats. total . rollbacks )
102- . add ( "prepared_statements" , stats. total . prepared_statements )
103- . add ( "healthchecks" , stats. total . healthchecks )
104- . add ( "errors" , stats. total . errors )
105- . add ( "bytes_received" , stats. total . bytes_received )
106- . add ( "bytes_sent" , stats. total . bytes_sent )
101+ . add ( "remote_pid" , server. stats . id . pid as i64 )
102+ . add (
103+ "client_id" ,
104+ server. stats . client_id . map ( |client| client. pid as i64 ) ,
105+ )
106+ . add ( "transactions" , server. stats . total . transactions )
107+ . add ( "queries" , server. stats . total . queries )
108+ . add ( "rollbacks" , server. stats . total . rollbacks )
109+ . add (
110+ "prepared_statements" ,
111+ server. stats . total . prepared_statements ,
112+ )
113+ . add ( "healthchecks" , server. stats . total . healthchecks )
114+ . add ( "errors" , server. stats . total . errors )
115+ . add ( "bytes_received" , server. stats . total . bytes_received )
116+ . add ( "bytes_sent" , server. stats . total . bytes_sent )
117+ . add ( "last_sent" , ( server. stats . last_sent as char ) . to_string ( ) )
118+ . add (
119+ "last_received" ,
120+ ( server. stats . last_received as char ) . to_string ( ) ,
121+ )
107122 . add ( "age" , age. as_secs ( ) as i64 )
108123 . add ( "application_name" , server. application_name . as_str ( ) )
109124 . data_row ( ) ;
0 commit comments