Statspackのレポートを出力する
続いて、前のエントリで設定した自動取得が実際に動いているかどうか、
Statspackのレポートの取り出し方とあわせて確認していきます。
レポートってさらっといっちゃいましたけど、
Snapshotを取得することによって、格納されているOracleの統計情報を、
人間が見やすい形で様々な観点から分析してくれているものです。
取り方
perfstat(Statspack管理ユーザ)でログインして、
spreport.sql というsqlをたたくだけです。
この sql の実行結果の中に、Snapshotが取得された時間が
情報として出力されますので、前回の自動取得の設定が有効になっているか
どうかも確認できます。
さ、実行。
[oracle@test ~]$ sqlplus perfstat/perfstat SQL*Plus: Release 10.2.0.3.0 - Production on 水 5月 28 10:46:50 2008 Copyright (c) 1982, 2006, Oracle. All Rights Reserved. Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production With the Partitioning and Data Mining options に接続されました。 SQL> @?/rdbms/admin/spreport Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instance ----------- ------------ -------- ------------ 1026716219 ORCL1 1 orcl1 Instances in this Statspack schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host ----------- -------- ------------ ------------ ------------ 1026716219 1 ORCL1 orcl1 test Using 1026716219 for database Id Using 1 for instance number Specify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots. Listing all Completed Snapshots Snap Instance DB Name Snap Id Snap Started Level Comment ------------ ------------ --------- ----------------- ----- -------------------- orcl1 ORCL1 1 27 5月 2008 14:4 7 7 2 27 5月 2008 14:4 7 7 3 27 5月 2008 14:4 7 7 4 27 5月 2008 14:4 7 7 5 27 5月 2008 14:4 7 7 6 28 5月 2008 10:3 7 6 7 28 5月 2008 10:3 7 7 8 28 5月 2008 10:4 7 0 9 28 5月 2008 10:4 7 5 (以下略)
見にくい・・・。
英語で表示させると、みやすいんですけど、
日本語向けに作られてないんですよね・・・。
NLS_LANG を変更してもいいんですけどね。
[oracle@test ~]$ export NLS_LANG=American_America.UTF8 [oracle@test ~]$ sqlplus perfstat/perfstat @$ORACLE_HOME/rdbms/admin/spreport SQL*Plus: Release 10.2.0.3.0 - Production on Wed May 28 10:49:59 2008 Copyright (c) 1982, 2006, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production With the Partitioning and Data Mining options Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instance ----------- ------------ -------- ------------ 1026716219 ORCL1 1 orcl1 Instances in this Statspack schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host ----------- -------- ------------ ------------ ------------ 1026716219 1 ORCL1 orcl1 test Using 1026716219 for database Id Using 1 for instance number Specify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots. Listing all Completed Snapshots Snap Instance DB Name Snap Id Snap Started Level Comment ------------ ------------ --------- ----------------- ----- -------------------- orcl1 ORCL1 1 27 May 2008 14:47 7 2 27 May 2008 14:47 7 3 27 May 2008 14:47 7 4 27 May 2008 14:47 7 5 27 May 2008 14:47 7 6 28 May 2008 10:36 7 7 28 May 2008 10:37 7 8 28 May 2008 10:40 7 9 28 May 2008 10:45 7
なんか癪なので、sqlを書き換える。
spreport.sql の中を見てみると、sprepins.sql を呼んでいて、
そこで、「Snap Started」のカラムフォーマットが設定されてます。
193行目(10.2では)の a17 を 大き目に変更すればいけるでしょう。
# 自己責任でー。後ろの表示が崩れる可能性がありますので。
[oracle@test ~]$ sqlplus perfstat/perfstat SQL*Plus: Release 10.2.0.3.0 - Production on 水 5月 28 10:52:13 2008 Copyright (c) 1982, 2006, Oracle. All Rights Reserved. Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production With the Partitioning and Data Mining options に接続されました。 SQL> @?/rdbms/admin/spreport Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instance ----------- ------------ -------- ------------ 1026716219 ORCL1 1 orcl1 Instances in this Statspack schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host ----------- -------- ------------ ------------ ------------ 1026716219 1 ORCL1 orcl1 test Using 1026716219 for database Id Using 1 for instance number Specify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots. Listing all Completed Snapshots Snap Instance DB Name Snap Id Snap Started Level ------------ ------------ --------- -------------------- ----- Comment -------------------- orcl1 ORCL1 1 27 5月 2008 14:47 7 2 27 5月 2008 14:47 7 3 27 5月 2008 14:47 7 4 27 5月 2008 14:47 7 5 27 5月 2008 14:47 7 6 28 5月 2008 10:36 7 7 28 5月 2008 10:37 7 8 28 5月 2008 10:40 7 9 28 5月 2008 10:45 7 10 28 5月 2008 10:50 7
ぐは。
こんどは linesize か・・・。
ちょっと変えてみよう・・・。
# 自己責任でー。後ろの表示が崩れる可能性がありますので。
[oracle@test ~]$ sqlplus perfstat/perfstat SQL*Plus: Release 10.2.0.3.0 - Production on 水 5月 28 10:53:25 2008 Copyright (c) 1982, 2006, Oracle. All Rights Reserved. Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production With the Partitioning and Data Mining options に接続されました。 SQL> @?/rdbms/admin/spreport Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instance ----------- ------------ -------- ------------ 1026716219 ORCL1 1 orcl1 Instances in this Statspack schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host ----------- -------- ------------ ------------ ------------ 1026716219 1 ORCL1 orcl1 test Using 1026716219 for database Id Using 1 for instance number Specify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots. Listing all Completed Snapshots Snap Instance DB Name Snap Id Snap Started Level Comment ------------ ------------ --------- -------------------- ----- -------------------- orcl1 ORCL1 1 27 5月 2008 14:47 7 2 27 5月 2008 14:47 7 3 27 5月 2008 14:47 7 4 27 5月 2008 14:47 7 5 27 5月 2008 14:47 7 6 28 5月 2008 10:36 7 7 28 5月 2008 10:37 7 8 28 5月 2008 10:40 7 9 28 5月 2008 10:45 7 10 28 5月 2008 10:50 7 Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ begin_snapに値を入力してください:
おk。見やすくなった。
ちゃんと自動実行も有効になっているようですね。
ついでにレポートもとりますよ。
spreport.sql を実行すると上の状態で出力がとまりますので、
レポートに含めたい時間帯のうち、開始時間帯のほうの、
Snap Id を入力します。
たとえば、5/28 の 10:39 から 10:49 までの情報を取得したい場合は、
開始時間である 10:39 が含まれる Snap Id は 7 なので、
これを入力します。
begin_snapに値を入力してください: 7 Begin Snapshot Id specified: 7 end_snapに値を入力してください:
同じように終了時間帯の Snap Id を入力します。
今回の例だと、10 ですね。
end_snapに値を入力してください: 10 End Snapshot Id specified: 10 Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is sp_7_10. To use this name, press <return> to continue, otherwise enter an alternative. report_nameに値を入力してください:
デフォルト以外のレポート名をつけたい場合は、
ここで入力します。
デフォルトでよければ Enter で。
すると、ずごごごごごごご。っと出力がはじまります。
画面出力されますが、ちゃんとファイルにも落ちてるのでご安心を。
report_nameに値を入力してください: Using the report name sp_7_10 STATSPACK report for (以下略)
中身については、今回はみませんので、全部略しました。
長いし。
まぁ、こういう感じで出力すればいいんですよってことです。
見方がいち早くしりたい方はいつものとおり、
Google先生でお願いします・・・。
では。