Performance Report Generated Based on WDR Snapshots
Statistics are summarized and collected based on WDR snapshot data tables to generate a performance report. By default, the initial user or monitor administrator can generate reports.
Prerequisites
A report can be generated after the WDR snapshot function is enabled (that is, enable_wdr_snapshot is set to on) and the number of snapshots is greater than or equal to 2.
Procedure
Run the following command to create a report file:
touch /home/om/wdrTestNode.html
Run the following command to connect to the postgres database.
gsql -d postgres -p [*Port number*] -r
Run the following command to query the generated snapshot and obtain snapshot_id:
select * from snapshot.snapshot;
(Optional) Run the following command on the CCN to manually create a snapshot. If only one snapshot exists in the database or you want to view the monitoring data of the database in the current period, manually create a snapshot. This command is only available to the sysadmin user.
select create_wdr_snapshot();
NOTE: Run the cm_ctl query -Cdvi command. In the command output, the information under Central Coordinator State is the CCN information.
Run the following commands to generate a WDR in HTML format on the local PC:
Run the following commands to set the report format. \a indicates that table row and column symbols are not displayed. \t indicates that column names are not displayed. \o specifies an output file.
gsql> \a gsql> \t gsql> \o /home/om/wdrTestNode.html
Run the following command to generate a WDR in HTML format:
gsql> select generate_wdr_report(begin_snap_id Oid, end_snap_id Oid, int report_type, int report_scope, int node_name );
Example 1: Generate a cluster-level report.
select generate_wdr_report(1, 2, 'all', 'cluster',null);
Example 2: Generate a report for a node.
select generate_wdr_report(1, 2, 'all', 'node', pgxc_node_str()::cstring);
NOTE: Currently, the name of the openGauss node is fixed to dn_6001_6002_6003. You can also replace it with the actual node name.
Table 1 Parameters of the generate_wdr_report function
Run the following command to disable the output options and format the output:
\o \a \t
View the WDR in /home/om/ as required.
Example
--Create a report file.
touch /home/om/wdrTestNode.html
--Connect to the database.
gsql -d postgres -p [*Port number*] -r
--Query the snapshots that have been generated.
openGauss=# select * from snapshot.snapshot;
snapshot_id | start_ts | end_ts
-------------+-------------------------------+-------------------------------
1 | 2020-09-07 10:20:36.763244+08 | 2020-09-07 10:20:42.166511+08
2 | 2020-09-07 10:21:13.416352+08 | 2020-09-07 10:21:19.470911+08
(2 rows)
--Generate the formatted performance report **wdrTestNode.html**.
openGauss=# \a \t \o /home/om/wdrTestNode.html
Output format is unaligned.
Showing only tuples.
--Write data into the performance report **wdrTestNode.html**.
openGauss=# select generate_wdr_report(1, 2, 'all', 'node', 'dn_6001_6002_6003');
--Close the performance report **wdrTestNode.html**.
openGauss=# \o
--Generate the formatted performance report **wdrTestCluster.html**.
openGauss=# \o /home/om/wdrTestCluster.html
--Write data into the performance report **wdrTestCluster.html**.
openGauss=# select generate_wdr_report(1, 2, 'all', 'cluster');
--Close the performance report **wdrTestCluster.html**.
openGauss=# \o \a \t
Output format is aligned.
Tuples only is off.