backend/satellite_tools/rhn-db-stats | 36 +++++++++--------
backend/satellite_tools/rhn-db-stats.sgml | 7 ---
backend/satellite_tools/rhn-schema-stats | 54 ++++++++++++++++++++------
backend/satellite_tools/rhn-schema-stats.sgml | 7 ---
4 files changed, 63 insertions(+), 41 deletions(-)
New commits:
commit 406a9e35f36ca3bb5a08e5980d5b96fd88855df9
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Fri Apr 6 13:23:38 2012 +0200
rhn-schema-stats: update manual page
connect string is no longer a valid option
diff --git a/backend/satellite_tools/rhn-schema-stats.sgml
b/backend/satellite_tools/rhn-schema-stats.sgml
index e3f7ba2..668b15b 100644
--- a/backend/satellite_tools/rhn-schema-stats.sgml
+++ b/backend/satellite_tools/rhn-schema-stats.sgml
@@ -23,7 +23,6 @@ utility for querying important Spacewalk / Satellite database schema
statistics.
<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>
@@ -53,12 +52,6 @@ schema. Ordinarily, is used by spacewalk-debug (satellite-debug), but
it can be
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>
commit 89a9eae876d01e95c5cfd87c54183a922fca5374
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Fri Apr 6 13:22:41 2012 +0200
rhn-schema-stats: support for PostgreSQL
diff --git a/backend/satellite_tools/rhn-schema-stats
b/backend/satellite_tools/rhn-schema-stats
index 613002d..dfc7873 100755
--- a/backend/satellite_tools/rhn-schema-stats
+++ b/backend/satellite_tools/rhn-schema-stats
@@ -1,14 +1,12 @@
#!/bin/bash
-if [[ $@ =~ "--help|-h" ]] || [ $# -lt 1 -o $# -gt 2 ]; then
- echo "Usage: `basename $0` -h | --help | output-file [connect-string]"
+if [[ $@ =~ "--help" ]] || [[ $@ =~ "-h" ]] || [ $# -ne 1 ]; then
+ echo "Usage: `basename $0` -h | --help | output-file"
exit
fi
-connect=$(spacewalk-cfg-get default_db)
-[ -n "$2" ] && connect=$2
-
-sql="
+if [ $(spacewalk-cfg-get db_backend) = "oracle" ]; then
+ sql="
set pagesize 4000 linesize 200
set serverout on
@@ -58,11 +56,45 @@ where
quit;
"
+elif [ $(spacewalk-cfg-get db_backend) = "postgresql" ]; then
+ sql="
+select schemaname as schema,
+ relname as table,
+ n_live_tup as rows
+ from pg_stat_user_tables
+ order by n_live_tup desc;
+
+select con.conname as name,
+ con.contype as type,
+ cl.relname as table,
+ con.consrc as src
+ from pg_constraint con,
+ pg_class cl
+ where cl.oid = con.conrelid
+ order by name;
+
+select
+ rvi.label, to_char(rvi.created, 'YYYY-MM-DD') as created,
+ to_char(rvi.modified, 'YYYY-MM-DD') as 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;
+"
+
+fi
+
+output=$(echo "$sql" | spacewalk-sql --select-mode -)
-if [ "$1" == "-" ]; then
- echo "$sql" | sqlplus -S $connect
+if [ "$1" = "-" ]; then
+ echo "$output"
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
+ echo "$output" > $1
fi
commit b4af73bf66e2b58f9f73d1700cec87f367606643
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Fri Apr 6 12:49:48 2012 +0200
rhn-db-stats: update manual page
connect string is no longer a valid command line option
diff --git a/backend/satellite_tools/rhn-db-stats.sgml
b/backend/satellite_tools/rhn-db-stats.sgml
index 3ff342c..e26f8a0 100644
--- a/backend/satellite_tools/rhn-db-stats.sgml
+++ b/backend/satellite_tools/rhn-db-stats.sgml
@@ -24,7 +24,6 @@ utility for querying important database parameters used by
<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>
@@ -55,12 +54,6 @@ used by your Satellite / Spacewalk installation. It is used by
spacewalk-debug
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>
commit 4c775d87c7e0ae268bcb1a8963e3d494351765f2
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Fri Apr 6 12:49:00 2012 +0200
rhn-db-stats: support for PostgreSQL
diff --git a/backend/satellite_tools/rhn-db-stats b/backend/satellite_tools/rhn-db-stats
index 0895cdd..d6160ad 100755
--- a/backend/satellite_tools/rhn-db-stats
+++ b/backend/satellite_tools/rhn-db-stats
@@ -1,27 +1,31 @@
#!/bin/sh
-if [[ $@ =~ "--help|-h" ]] || [ $# -lt 1 -o $# -gt 2 ]; then
- echo "Usage: `basename $0` -h | --help | output-file [connect-string]"
- exit
+if [[ $@ =~ "-h" ]] || [[ $@ =~ "--help" ]] || [ $# -ne 1 -o $# -gt 1
]; then
+ echo "Usage: `basename $0` -h | --help | output-file"
+ exit
fi
-connect=$(spacewalk-cfg-get default_db)
-[ -n "$2" ] && connect=$2
-
-sql="
-set serverout on
-set pagesize 2000 linesize 145
-column name_col_plus_show_param format a40 word wrap heading PARAMETER
-column value_col_plus_show_param format a90 word wrap heading VALUE
+if [ "$(spacewalk-cfg-get db_backend)" = "oracle" ]; then
+ sql="
+set serverout on;
+set pagesize 2000 linesize 145;
+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;
"
-if [ "$1" == "-" ]; then
- echo "$sql" | sqlplus -S $connect
+elif [ "$(spacewalk-cfg-get db_backend)" = "postgresql" ]; then
+ sql="
+SHOW ALL;
+"
+fi
+
+output=$(echo "$sql" | spacewalk-sql --select-mode -)
+
+if [ "$1" = "-" ]; then
+ echo "$output"
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
+ echo "$output" > $1
fi