Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Manually merge PR #63, contribution by Daniël van Eeden for a new vie…
Browse files Browse the repository at this point in the history
…w for session SSL status.

Made a few changes from the original, such as a rename of the sessions view to session, and the contributed view to session_ssl_status.
  • Loading branch information
MarkLeith committed Aug 13, 2015
1 parent 077418d commit 72794f1
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 12 deletions.
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ A detailed non-blocking processlist view to replace [INFORMATION_SCHEMA. | SHOW

Performs less locking than the legacy sources, whilst giving extra information.

The output includes both background threads and user connections by default. See also sessions / x$sessions
The output includes both background threads and user connections by default. See also `session` / `x$session`
for a view that contains only user session information.

##### Structures (5.7)
Expand Down Expand Up @@ -2053,7 +2053,7 @@ mysql> select * from schema_unused_indexes limit 5;
+--------------------+---------------------+--------------------+
```

#### sessions / x$sessions
#### session / x$session

##### Description

Expand All @@ -2066,7 +2066,7 @@ The output of this view is restricted to threads from user sessions. See also p
##### Structures (5.7)

```SQL
mysql> desc sessions;
mysql> desc session;
+------------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+---------------------+------+-----+---------+-------+
Expand Down Expand Up @@ -2098,7 +2098,7 @@ mysql> desc sessions;
+------------------------+---------------------+------+-----+---------+-------+
25 rows in set (0.18 sec)

mysql> desc x$sessions;
mysql> desc x$session;
+------------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+---------------------+------+-----+---------+-------+
Expand Down Expand Up @@ -2134,7 +2134,7 @@ mysql> desc x$sessions;
##### Example

```SQL
mysql> select * from sys.sessions\G
mysql> select * from sys.session\G
*************************** 1. row ***************************
thd_id: 27
conn_id: 1
Expand Down Expand Up @@ -2169,7 +2169,7 @@ last_statement_latency: NULL
command: Query
state: Sending data
time: 0
current_statement: SELECT * FROM sessions
current_statement: SELECT * FROM session
statement_latency: 12.05 ms
progress: NULL
lock_latency: 938.00 us
Expand All @@ -2190,6 +2190,40 @@ last_statement_latency: NULL
2 rows in set (0.05 sec)
```

#### session_ssl_status

##### Description

Shows SSL version, cipher and the count of re-used SSL sessions per connection

##### Structures

```SQL
mysql> desc sys.session_ssl_status;
+---------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------------+---------------------+------+-----+---------+-------+
| thread_id | bigint(20) unsigned | NO | | NULL | |
| ssl_version | varchar(1024) | YES | | NULL | |
| ssl_cipher | varchar(1024) | YES | | NULL | |
| ssl_sessions_reused | varchar(1024) | YES | | NULL | |
+---------------------+---------------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
```

##### Example

```SQL
mysql> select * from session_ssl_status;
+-----------+-------------+--------------------+---------------------+
| thread_id | ssl_version | ssl_cipher | ssl_sessions_reused |
+-----------+-------------+--------------------+---------------------+
| 26 | TLSv1 | DHE-RSA-AES256-SHA | 0 |
| 27 | TLSv1 | DHE-RSA-AES256-SHA | 0 |
| 28 | TLSv1 | DHE-RSA-AES256-SHA | 0 |
+-----------+-------------+--------------------+---------------------+
3 rows in set (0.00 sec)
```

#### statement_analysis / x$statement_analysis

Expand Down
6 changes: 6 additions & 0 deletions mysql-test/suite/sysschema/r/all_sys_objects_exist.result
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ metrics
metrics_56
processlist
ps_check_lost_instrumentation
schema_auto_increment_columns
schema_index_statistics
schema_object_overview
schema_redundant_indexes
schema_tables_with_full_table_scans
schema_table_statistics
schema_table_statistics_with_buffer
schema_unused_indexes
session
session_ssl_status
statements_with_errors_or_warnings
statements_with_full_table_scans
statements_with_runtimes_in_95th_percentile
Expand Down Expand Up @@ -74,10 +78,12 @@ x$processlist
x$ps_digest_95th_percentile_by_avg_us
x$ps_digest_avg_latency_distribution
x$ps_schema_table_statistics_io
x$schema_flattened_keys
x$schema_index_statistics
x$schema_tables_with_full_table_scans
x$schema_table_statistics
x$schema_table_statistics_with_buffer
x$session
x$statements_with_errors_or_warnings
x$statements_with_full_table_scans
x$statements_with_runtimes_in_95th_percentile
Expand Down
56 changes: 56 additions & 0 deletions mysql-test/suite/sysschema/r/v_session.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
DESC sys.session;
Field Type Null Key Default Extra
thd_id bigint(20) unsigned NO NULL
conn_id bigint(20) unsigned YES NULL
user varchar(128) YES NULL
db varchar(64) YES NULL
command varchar(16) YES NULL
state varchar(64) YES NULL
time bigint(20) YES NULL
current_statement longtext YES NULL
statement_latency text YES NULL
progress decimal(26,2) YES NULL
lock_latency text YES NULL
rows_examined bigint(20) unsigned YES NULL
rows_sent bigint(20) unsigned YES NULL
rows_affected bigint(20) unsigned YES NULL
tmp_tables bigint(20) unsigned YES NULL
tmp_disk_tables bigint(20) unsigned YES NULL
full_scan varchar(3) NO
last_statement longtext YES NULL
last_statement_latency text YES NULL
current_memory text YES NULL
last_wait varchar(128) YES NULL
last_wait_latency text YES NULL
source varchar(64) YES NULL
pid varchar(1024) YES NULL
program_name varchar(1024) YES NULL
SELECT * FROM sys.session;
DESC sys.x$session;
Field Type Null Key Default Extra
thd_id bigint(20) unsigned NO NULL
conn_id bigint(20) unsigned YES NULL
user varchar(128) YES NULL
db varchar(64) YES NULL
command varchar(16) YES NULL
state varchar(64) YES NULL
time bigint(20) YES NULL
current_statement longtext YES NULL
statement_latency bigint(20) unsigned YES NULL
progress decimal(26,2) YES NULL
lock_latency bigint(20) unsigned YES NULL
rows_examined bigint(20) unsigned YES NULL
rows_sent bigint(20) unsigned YES NULL
rows_affected bigint(20) unsigned YES NULL
tmp_tables bigint(20) unsigned YES NULL
tmp_disk_tables bigint(20) unsigned YES NULL
full_scan varchar(3) NO
last_statement longtext YES NULL
last_statement_latency bigint(20) unsigned YES NULL
current_memory decimal(41,0) YES NULL
last_wait varchar(128) YES NULL
last_wait_latency varchar(20) YES NULL
source varchar(64) YES NULL
pid varchar(1024) YES NULL
program_name varchar(1024) YES NULL
SELECT * FROM sys.x$session;
7 changes: 7 additions & 0 deletions mysql-test/suite/sysschema/r/v_session_ssl_status.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DESC sys.session_ssl_status;
Field Type Null Key Default Extra
thread_id bigint(20) unsigned NO NULL
ssl_version varchar(1024) YES NULL
ssl_cipher varchar(1024) YES NULL
ssl_sessions_reused varchar(1024) YES NULL
SELECT * FROM sys.session_ssl_status;
21 changes: 21 additions & 0 deletions mysql-test/suite/sysschema/t/v_session.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- source include/not_embedded.inc
# Tests for sys schema
# Verify the sys.session view

# Ensure structure changes don't slip in
DESC sys.session;

# Make sure view select does not error, but ignore results
--disable_result_log
SELECT * FROM sys.session;
--enable_result_log


# Ensure structure changes don't slip in
DESC sys.x$session;

# Make sure view select does not error, but ignore results
--disable_result_log
SELECT * FROM sys.x$session;
--enable_result_log

11 changes: 11 additions & 0 deletions mysql-test/suite/sysschema/t/v_session_ssl_status.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- source include/not_embedded.inc
# Tests for sys schema
# Verify the sys.session_ssl_status view

# Ensure structure changes don't slip in
DESC sys.session_ssl_status;

# Make sure view select does not error, but ignore results
--disable_result_log
SELECT * FROM sys.session_ssl_status;
--enable_result_log
1 change: 1 addition & 0 deletions sys_57.sql
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ SOURCE ./views/p_s/x_processlist_57.sql

SOURCE ./views/p_s/sessions.sql
SOURCE ./views/p_s/x_sessions.sql
SOURCE ./views/p_s/session_ssl_status.sql

SOURCE ./procedures/create_synonym_db.sql
SOURCE ./procedures/execute_prepared_stmt.sql
Expand Down
36 changes: 36 additions & 0 deletions views/p_s/session_ssl_status.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--
-- View: session_ssl_status
--
-- Shows SSL version, cipher and the count of re-used SSL sessions per connection
--
-- mysql> select * from session_ssl_status;
-- +-----------+-------------+--------------------+---------------------+
-- | thread_id | ssl_version | ssl_cipher | ssl_sessions_reused |
-- +-----------+-------------+--------------------+---------------------+
-- | 26 | TLSv1 | DHE-RSA-AES256-SHA | 0 |
-- | 27 | TLSv1 | DHE-RSA-AES256-SHA | 0 |
-- | 28 | TLSv1 | DHE-RSA-AES256-SHA | 0 |
-- +-----------+-------------+--------------------+---------------------+
-- 3 rows in set (0.00 sec)
--

CREATE
ALGORITHM = MERGE
DEFINER = 'root'@'localhost'
SQL SECURITY INVOKER
VIEW session_ssl_status (
thread_id,
ssl_version,
ssl_cipher,
ssl_sessions_reused
) AS
SELECT sslver.thread_id,
sslver.variable_value ssl_version,
sslcip.variable_value ssl_cipher,
sslreuse.variable_value ssl_sessions_reused
FROM performance_schema.status_by_thread sslver
LEFT JOIN performance_schema.status_by_thread sslcip
ON (sslcip.thread_id=sslver.thread_id and sslcip.variable_name='Ssl_cipher')
LEFT JOIN performance_schema.status_by_thread sslreuse
ON (sslreuse.thread_id=sslver.thread_id and sslreuse.variable_name='Ssl_sessions_reused')
WHERE sslver.variable_name='Ssl_version';
6 changes: 3 additions & 3 deletions views/p_s/sessions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

--
-- View: sessions
-- View: session
--
-- Filter sys.processlist to only show user sessions and not background threads.
-- This is a non-blocking closer replacement to
-- [INFORMATION_SCHEMA. | SHOW FULL] PROCESSLIST
--
-- Performs less locking than the legacy sources, whilst giving extra information.
--
-- mysql> select * from sys.sessions\G
-- mysql> select * from sys.session\G
-- *************************** 1. row ***************************
-- thd_id: 44524
-- conn_id: 44502
Expand Down Expand Up @@ -54,7 +54,7 @@
CREATE OR REPLACE
DEFINER = 'root'@'localhost'
SQL SECURITY INVOKER
VIEW sessions
VIEW session
AS
SELECT * FROM sys.processlist
WHERE conn_id IS NOT NULL AND command != 'Daemon';
Expand Down
6 changes: 3 additions & 3 deletions views/p_s/x_sessions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

--
-- View: x$sessions
-- View: x$session
--
-- Filter sys.processlist to only show user sessions and not background threads.
-- This is a non-blocking closer replacement to
-- [INFORMATION_SCHEMA. | SHOW FULL] PROCESSLIST
--
-- Performs less locking than the legacy sources, whilst giving extra information.
--
-- mysql> select * from sys.x$sessions\G
-- mysql> select * from sys.x$session\G
-- *************************** 1. row ***************************
-- thd_id: 720
-- conn_id: 698
Expand Down Expand Up @@ -54,7 +54,7 @@
CREATE OR REPLACE
DEFINER = 'root'@'localhost'
SQL SECURITY INVOKER
VIEW x$sessions
VIEW x$session
AS
SELECT * FROM sys.x$processlist
WHERE conn_id IS NOT NULL AND command != 'Daemon';

0 comments on commit 72794f1

Please sign in to comment.