backend/satellite_tools/Makefile | 2 backend/satellite_tools/rhn-db-stats | 59 ++++------------- backend/satellite_tools/rhn-db-stats.sgml | 18 ++++- backend/satellite_tools/rhn-schema-stats | 53 +++++++++++++++ backend/satellite_tools/rhn-schema-stats.sgml | 89 ++++++++++++++++++++++++++ backend/satellite_tools/spacewalk-debug | 3 backend/spacewalk-backend.spec | 2 7 files changed, 178 insertions(+), 48 deletions(-)
New commits: commit 9ae6aaaf641f0dcd2b8b6a5a6d42082d7d982742 Author: Milan Zazrivec mzazrivec@redhat.com Date: Thu Oct 1 13:28:28 2009 +0200
rhn-db-stats: split database & schema statistics
New divison: - rhn-db-stats: for database statistics - rhh-schema-stats: for schema statistics
diff --git a/backend/satellite_tools/Makefile b/backend/satellite_tools/Makefile index e14fdaa..fb22c4b 100644 --- a/backend/satellite_tools/Makefile +++ b/backend/satellite_tools/Makefile @@ -16,7 +16,7 @@ FILES = __init__ connection diskImportLib messages \
SCRIPTS = satellite-sync spacewalk-debug\ rhn-schema-version rhn-satellite-activate rhn-charsets \ - rhn-ssl-dbstore update-packages rhn-db-stats \ + rhn-ssl-dbstore update-packages rhn-db-stats rhn-schema-stats \ spacewalk-repo-sync spacewalk-report
SPACEWALK_SUBDIRS = reports reports/data diff --git a/backend/satellite_tools/rhn-db-stats b/backend/satellite_tools/rhn-db-stats index a90073b..0895cdd 100755 --- a/backend/satellite_tools/rhn-db-stats +++ b/backend/satellite_tools/rhn-db-stats @@ -1,54 +1,27 @@ #!/bin/sh
-if [ $# -lt 1 -o $# -gt 2 ]; then - echo "Usage: `basename $0` output-file [connect-string]" +if [[ $@ =~ "--help|-h" ]] || [ $# -lt 1 -o $# -gt 2 ]; then + echo "Usage: `basename $0` -h | --help | output-file [connect-string]" exit fi
-CONNECT=$(spacewalk-cfg-get default_db) -[ -n "$2" ] && CONNECT=$2 +connect=$(spacewalk-cfg-get default_db) +[ -n "$2" ] && connect=$2
-# sqlplus ... | cat > ... is here to fool selinux, since oracle_sqlplus_t -# cannot write just anywhere -sqlplus $CONNECT << EOS | cat > $1 -set echo on +sql=" set serverout on set pagesize 2000 linesize 145 -column name_col_plus_show_param format a40 word wrap -column value_col_plus_show_param format a90 word wrap +column name_col_plus_show_param format a40 word wrap heading PARAMETER +column value_col_plus_show_param format a90 word wrap heading VALUE
select dbms_stats.get_param('METHOD_OPT') from dual; - show parameter; - -declare - n number; -begin - for i in (select * from user_tables order by table_name) - loop - execute immediate 'select count(*) from ' || i.table_name into n; - dbms_output.put_line(i.table_name || ': ' || n); - end loop; -end; -/ - -column label format a30 -column name format a25 -column epoch format a10 -column version format a10 -column release format a10 - -select - rvi.label, to_char(rvi.created, 'YYYY-MM-DD') created, to_char(rvi.modified, 'YYYY-MM-DD') modified, - rpn.name, - rpe.epoch, rpe.version, rpe.release -from - rhnVersionInfo rvi, - rhnPackageName rpn, - rhnPackageEvr rpe -where - rvi.evr_id = rpe.id and - rvi.name_id = rpn.id; - -quit; -EOS +" + +if [ "$1" == "-" ]; then + echo "$sql" | sqlplus -S $connect +else + # sqlplus ... | cat ... is here to fool selinux, since oracle_sqlplus_t + # cannot write just anywhere (via spool ...) + echo "$sql" | sqlplus -S $connect | cat > $1 +fi diff --git a/backend/satellite_tools/rhn-db-stats.sgml b/backend/satellite_tools/rhn-db-stats.sgml index ac07a3d..3ff342c 100644 --- a/backend/satellite_tools/rhn-db-stats.sgml +++ b/backend/satellite_tools/rhn-db-stats.sgml @@ -22,8 +22,9 @@ utility for querying important database parameters used by <Synopsis> <cmdsynopsis> <command>&THECOMMAND;</command> - <arg choice="req">output-file</arg> - <arg>db-conect-string</arg> + <arg choice="opt">-h | --help</arg> + <arg choice="req">output-file</arg> + <arg choice="opt">db-conect-string</arg> </cmdsynopsis> </Synopsis> </RefSynopsisDiv> @@ -31,7 +32,7 @@ utility for querying important database parameters used by <RefSect1><Title>Description</Title>
<para> -rhn-db-stats retrieves important statistics and parameters from Oracle database +rhn-db-stats retrieves important parameters from Oracle database used by your Satellite / Spacewalk installation. It is used by spacewalk-debug (satellite-debug) or it can be used standalone. </para> @@ -41,9 +42,17 @@ used by your Satellite / Spacewalk installation. It is used by spacewalk-debug <RefSect1><Title>Options</Title> <variablelist> <varlistentry> + <term>-h | --help</term> + <listitem> + <para>Print usage information.</para> + </listitem> + </varlistentry> + + <varlistentry> <term>output-file</term> <listitem> - <para>File name to save the retrieved information to.</para> + <para>File name to save the retrieved information to. Use - if you wish to + print the output to stdout.</para> </listitem> </varlistentry> <varlistentry> @@ -70,6 +79,7 @@ used by your Satellite / Spacewalk installation. It is used by spacewalk-debug <RefSect1><Title>See Also</Title> <simplelist> <member>spacewalk-debug(8)</member> + <member>rhn-schema-stats(8)</member> </simplelist> </RefSect1>
diff --git a/backend/satellite_tools/rhn-schema-stats b/backend/satellite_tools/rhn-schema-stats new file mode 100755 index 0000000..03c5de9 --- /dev/null +++ b/backend/satellite_tools/rhn-schema-stats @@ -0,0 +1,53 @@ +#!/bin/bash + +if [[ $@ =~ "--help|-h" ]] || [ $# -lt 1 -o $# -gt 2 ]; then + echo "Usage: `basename $0` -h | --help | output-file [connect-string]" + exit +fi + +connect=$(spacewalk-cfg-get default_db) +[ -n "$2" ] && connect=$2 + +sql=" +set pagesize 2000 linesize 140 +set serverout on + +declare + n number; +begin + for i in (select * from user_tables order by table_name) + loop + execute immediate 'select count(*) from ' || i.table_name into n; + dbms_output.put_line(i.table_name || ': ' || n); + end loop; +end; +/ + +column label format a30 +column name format a25 +column epoch format a10 +column version format a10 +column release format a10 + +select + rvi.label, to_char(rvi.created, 'YYYY-MM-DD') created, to_char(rvi.modified, 'YYYY-MM-DD') modified, + rpn.name, + rpe.epoch, rpe.version, rpe.release +from + rhnVersionInfo rvi, + rhnPackageName rpn, + rhnPackageEvr rpe +where + rvi.evr_id = rpe.id and + rvi.name_id = rpn.id; + +quit; +" + +if [ "$1" == "-" ]; then + echo "$sql" | sqlplus -S $connect +else + # sqlplus ... | cat ... is here to fool selinux, since oracle_sqlplus_t + # cannot write just anywhere (via spool ...) + echo "$sql" | sqlplus -S $connect | cat > $1 +fi diff --git a/backend/satellite_tools/rhn-schema-stats.sgml b/backend/satellite_tools/rhn-schema-stats.sgml new file mode 100644 index 0000000..e3f7ba2 --- /dev/null +++ b/backend/satellite_tools/rhn-schema-stats.sgml @@ -0,0 +1,89 @@ +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [ +<!ENTITY RHNSAT "RHN Satellite Server" > +<!ENTITY THECOMMAND "rhn-schema-stats" > + +]> +<refentry> + +<RefMeta> +<RefEntryTitle>&THECOMMAND;</RefEntryTitle><manvolnum>8</manvolnum> +<RefMiscInfo>Version 1.0.0</RefMiscInfo> +</RefMeta> + +<RefNameDiv> +<RefName><command>&THECOMMAND;</command></RefName> +<RefPurpose> +utility for querying important Spacewalk / Satellite database schema statistics. +</RefPurpose> +</RefNameDiv> + +<RefSynopsisDiv> +<Synopsis> + <cmdsynopsis> + <command>&THECOMMAND;</command> + <arg choice="opt">-h | --help</arg> + <arg choice="req">output-file</arg> + <arg choice="opt">db-conect-string</arg> + </cmdsynopsis> +</Synopsis> +</RefSynopsisDiv> + +<RefSect1><Title>Description</Title> + +<para> +rhn-schema-stats retrieves important statistics from your Satellite / Spacewalk database +schema. Ordinarily, is used by spacewalk-debug (satellite-debug), but it can be used standalone. +</para> + +</RefSect1> + +<RefSect1><Title>Options</Title> +<variablelist> + <varlistentry> + <term>-h | --help</term> + <listitem> + <para>Print usage information.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term>output-file</term> + <listitem> + <para>File name to save the retrieved information to. Use - if you wish to + print the output to stdout.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>db-connect-string</term> + <listitem> + <para>Connection string to your Oracle database.</para> + </listitem> + </varlistentry> +</variablelist> +</RefSect1> + +<RefSect1><Title>Files</Title> +<simplelist> + <member>/usr/bin/&THECOMMAND;</member> +</simplelist> +</RefSect1> + +<RefSect1><Title>Example</Title> +<simplelist> + <member><command>&THECOMMAND; database.log</command></member> +</simplelist> +</RefSect1> + +<RefSect1><Title>See Also</Title> +<simplelist> + <member>spacewalk-debug(8)</member> + <member>rhn-db-stats(8)</member> +</simplelist> +</RefSect1> + +<RefSect1><Title>Authors</Title> +<simplelist> + <member>Milan Zazrivec <email>mzazrivec@redhat.com</email></member> +</simplelist> +</RefSect1> +</RefEntry> diff --git a/backend/satellite_tools/spacewalk-debug b/backend/satellite_tools/spacewalk-debug index 8372440..879ff7f 100755 --- a/backend/satellite_tools/spacewalk-debug +++ b/backend/satellite_tools/spacewalk-debug @@ -205,6 +205,9 @@ df -h > $DIR/diskinfo echo " * get database statistics" /usr/bin/rhn-db-stats $DIR/database/db-stats.log
+echo " * get schema statistics" +/usr/bin/rhn-schema-stats $DIR/database/schema-stats.log + # alert.log if [ -f /rhnsat/admin/rhnsat/bdump/alert_rhnsat.log ] ; then echo " * copying alert_rhnsat.log" diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec index 59f83a0..2495958 100644 --- a/backend/spacewalk-backend.spec +++ b/backend/spacewalk-backend.spec @@ -511,6 +511,7 @@ rm -f %{rhnconf}/rhnSecret.py* %attr(755,root,root) %{_bindir}/update-packages %attr(755,root,root) %{_bindir}/spacewalk-repo-sync %attr(755,root,root) %{_bindir}/rhn-db-stats +%attr(755,root,root) %{_bindir}/rhn-schema-stats %attr(750,root,root) %{_bindir}/satpasswd %attr(750,root,root) %{_bindir}/satwho %{rhnroot}/satellite_tools/SequenceServer.py* @@ -551,6 +552,7 @@ rm -f %{rhnconf}/rhnSecret.py* %{_mandir}/man8/rhn-schema-version.8* %{_mandir}/man8/rhn-ssl-dbstore.8* %{_mandir}/man8/rhn-db-stats.8* +%{_mandir}/man8/rhn-schema-stats.8* %{_mandir}/man8/satellite-sync.8* %{_mandir}/man8/spacewalk-debug.8* %{_mandir}/man8/spacewalk-report.8*
spacewalk-commits@lists.fedorahosted.org