Skip to content
This repository has been archived by the owner on Feb 15, 2021. It is now read-only.

Commit

Permalink
Various fix
Browse files Browse the repository at this point in the history
  • Loading branch information
amreo committed Nov 18, 2019
1 parent 79f8254 commit b7b5d8e
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 56 deletions.
6 changes: 3 additions & 3 deletions fetch/feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export ORACLE_SID=$SID
export ORACLE_HOME=$HOME
export PATH=$HOME/bin:$PATH

if [ $DBV == "11" ] || [ $DBV == "12" ]; then
sqlplus -S "/ AS SYSDBA" < ${ERCOLE_HOME}/sql/feature.sql
else
if [ $DBV == "9" ] || [ $DBV == "10" ]; then
sqlplus -S "/ AS SYSDBA" < ${ERCOLE_HOME}/sql/feature-10.sql
else
sqlplus -S "/ AS SYSDBA" < ${ERCOLE_HOME}/sql/feature.sql
fi
5 changes: 5 additions & 0 deletions fetch/host
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ CHECK_TYPE_SERVER_OVM_DMESG=$(dmesg | grep OVM | wc -l)
CHECK_TYPE_SERVER_OVM_LOG=$(grep -i ovm /var/log/dmesg | wc -l)
CHECK_TYPE_SERVER_VMWARE=$(dmesg | grep VMware | wc -l)
CHECK_TYPE_SERVER_VMWARE_LOG=$(grep VMware /var/log/dmesg* | wc -l)
CHECK_TYPE_SERVER_HYPERV=$(dmesg | grep HyperV|wc -l)
CHECK_TYPE_SERVER_HYPERV_LOG=$(grep HyperV /var/log/dmesg* | wc -l)
# CHECK_TYPE_SERVER_AIX=$(uname -L | awk '{print $1}')
# TODO: HPUX has a specific server type, see original script
CHECK_TYPE_SERVER_HPUX=0
Expand All @@ -75,6 +77,9 @@ if [ "$CHECK_TYPE_SERVER_OVM_DMESG" -gt 0 ] || [ "$CHECK_TYPE_SERVER_OVM_LOG" -g
elif [ $CHECK_TYPE_SERVER_VMWARE -gt 0 ] || [ "$CHECK_TYPE_SERVER_VMWARE_LOG" -gt 0 ]; then
TYPE=VMWARE
VIRTUAL=Y
elif [ $CHECK_TYPE_SERVER_HYPERV -gt 0 ] || [ "$CHECK_TYPE_SERVER_HYPERV_LOG" -gt 0 ]; then
TYPE=HYPERV
VIRTUAL=Y
elif [ $CHECK_TYPE_SERVER_HYPERVISOR -gt 0 ]; then
TYPE=VMOTHER
VIRTUAL=Y
Expand Down
2 changes: 1 addition & 1 deletion fetch/license
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ else
fi


if [ $DBV == "10" ]; then
if [ $DBV == "10" ] || [ $DBV == "9" ]; then
sqlplus -S "/ AS SYSDBA" @${ERCOLE_HOME}/sql/license-10.sql $LICENSING_CPU_CORES $FACTOR
else
sqlplus -S "/ AS SYSDBA" @${ERCOLE_HOME}/sql/license.sql $LICENSING_CPU_CORES $FACTOR $DB_ONE
Expand Down
4 changes: 2 additions & 2 deletions fetch/patch
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export ORACLE_SID=$SID
export ORACLE_HOME=$HOME
export PATH=$HOME/bin:$PATH

if [ $DBV == "12" ]; then
if [ $DBV -gt "11" ]; then
sqlplus -S "/ AS SYSDBA" < ${ERCOLE_HOME}/sql/patch-12.sql
else
sqlplus -S "/ AS SYSDBA" < ${ERCOLE_HOME}/sql/patch.sql
fi
fi
2 changes: 1 addition & 1 deletion fetch/psu
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export PATH=$HOME/bin:$PATH
ERCOLE_HOME=$(dirname "$0")
ERCOLE_HOME="$(dirname "$ERCOLE_HOME")"

if [ $DBV == "10" ] || [ $DBV == "11" ]; then
if [ $DBV -lt "12" ]; then
sqlplus -S "/ AS SYSDBA" < ${ERCOLE_HOME}/sql/psu-1.sql
else
sqlplus -S "/ AS SYSDBA" < ${ERCOLE_HOME}/sql/psu-2.sql
Expand Down
9 changes: 1 addition & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,7 @@ func buildData(configuration config.Configuration) {
out = fetcher(configuration, "dbversion", db.DBName, db.OracleHome)
outVersion := string(out)

dbVersion := "12"
if strings.HasPrefix(outVersion, "11") {
dbVersion = "11"
} else if strings.HasPrefix(outVersion, "10") {
dbVersion = "10"
} else if strings.HasPrefix(outVersion, "9") {
dbVersion = "9"
}
dbVersion := strings.Split(outVersion, ".")[0]

if configuration.Forcestats {
fetcher(configuration, "stats", db.DBName, db.OracleHome)
Expand Down
21 changes: 11 additions & 10 deletions sql/dbmounted.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.

set markup html on spool on
set lines 200 pages 0 feedback off verify off
set lines 32767 pages 0 feedback off verify off
set colsep "|||"
col owner for a30
col Nome_Acronimo for a8
col segment_name for a60

select
(select value from v$parameter where name='db_name') as Nome_DB,
(select db_unique_name from v$database) as DB_Unique_name,
(select instance_number from v$instance) as Instance_number,
(select status from v$instance) as DB_Status,
((SELECT version FROM V$INSTANCE)||(select (case when UPPER(banner) like '%EXTREME%' then ' Extreme Edition' when UPPER(banner) like '%ENTERPRISE%' then ' Enterprise Edition' else ' Standard Edition' end) from v$version where rownum=1)) as Versione,
(SELECT platform_name FROM V$database) as platform,
Expand All @@ -30,20 +31,20 @@ select
(select value from v$nls_parameters where parameter='NLS_NCHAR_CHARACTERSET') as NCharset,
(select value from v$parameter where name='db_block_size') as Blocksize,
(select value from v$parameter where name='cpu_count') as Cpu_count,
(select rtrim(to_char(value/1024/1024/1024, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS='',.'''),',') from v$parameter where name='sga_target') as Sga_Target,
(select rtrim(to_char(value/1024/1024/1024, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS='',.'''),',') from v$parameter where name='pga_aggregate_target') as Pga_Target,
(select rtrim(to_char(value/1024/1024/1024, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS='',.'''),',') from v$parameter where name='memory_target') as Pga_Target,
(select rtrim(to_char(value/1024/1024/1024, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS='',.'''),',') from v$parameter where name='sga_max_size') as sga_max_size,
(select rtrim(to_char(value/1024/1024/1024, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS=''.,'''),',') from v$parameter where name='sga_target') as Sga_Target,
(select rtrim(to_char(value/1024/1024/1024, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS=''.,'''),',') from v$parameter where name='pga_aggregate_target') as Pga_Target,
(select rtrim(to_char(value/1024/1024/1024, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS=''.,'''),',') from v$parameter where name='memory_target') as Pga_Target,
(select rtrim(to_char(value/1024/1024/1024, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS=''.,'''),',') from v$parameter where name='sga_max_size') as sga_max_size,
--(select round(sum(bytes/1024/1024/1024)) from dba_segments),
'N/A',
'0',
--((select round(sum(bytes/1024/1024/1024)) from v$datafile)+(select round(sum(bytes/1024/1024/1024)) from v$tempfile)+(select round(sum(bytes/1024/1024/1024)) from v$log)),
'N/A',
'0',
--((select round(sum(decode(autoextensible,'NO',bytes/1024/1024/1024,'YES',maxbytes/1024/1024/1024))) from v$datafile)+(select round(sum(bytes/1024/1024/1024)) from v$tempfile)+(select round(sum(bytes/1024/1024/1024)) from v$log)),
'N/A',
'0',
--(SELECT replace(replace(output,'Elapsed:',''),chr(32), '') FROM TABLE (DBMS_WORKLOAD_REPOSITORY.awr_report_text (:dbid, :inst_num, :bid, :eid, 0)) where rownum <20 and output like '%Elapsed: %'),
--(SELECT replace(replace(output,'DB Time:',''),chr(32), '') FROM TABLE (DBMS_WORKLOAD_REPOSITORY.awr_report_text (:dbid, :inst_num, :bid, :eid, 0)) where rownum <20 and output like '%DB Time: %'),
--:elapsed,:dbtime,(select :result from dual),
'N/A','N/A','N/A',
'0','0','0',
(select case when (select count(*) from v$datafile where name like '+%') > 0 then 'Y' else 'N' end as "ASM" from dual ),
case when ( select count(*) from V$DATAGUARD_CONFIG) > 1 then 'Y' else 'N' end as "Dataguard"
from dual;
Expand Down
8 changes: 4 additions & 4 deletions sql/license-10.sql
Original file line number Diff line number Diff line change
Expand Up @@ -248,25 +248,25 @@ end
from dual;
select
case when (select UPPER(banner) from v$version where rownum=1) like '%EXTREME%' or (select UPPER(banner) from v$version where rownum=1) like '%ENTERPRISE%' then
'Database Vault;'||:MASKING ||';'
'Database Vault;'||:VAULT ||';'
else 'Database Vault;;'
end
from dual;
select
case when (select UPPER(banner) from v$version where rownum=1) like '%EXTREME%' or (select UPPER(banner) from v$version where rownum=1) like '%ENTERPRISE%' then
'Database In-Memory;'||:VAULT ||';'
'Database In-Memory;'||:MEMORY ||';'
else 'Database In-Memory;;'
end
from dual;
select
case when (select UPPER(banner) from v$version where rownum=1) like '%EXTREME%' or (select UPPER(banner) from v$version where rownum=1) like '%ENTERPRISE%' then
'Database Gateway;'||:MEMORY ||';'
'Database Gateway;'||:GATEWAY ||';'
else 'Database Gateway;;'
end
from dual;
select
case when (select UPPER(banner) from v$version where rownum=1) like '%EXTREME%' or (select UPPER(banner) from v$version where rownum=1) like '%ENTERPRISE%' then
'Data Masking Pack;'||:GATEWAY ||';'
'Data Masking Pack;'||:MASKING ||';'
else 'Data Masking Pack;;'
end
from dual;
Expand Down
49 changes: 27 additions & 22 deletions sql/psu-1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ alter session set NLS_DATE_FORMAT='YYYY-MM-DD';
BEGIN
SELECT DBMS_DB_VERSION.VERSION || '.' || DBMS_DB_VERSION.RELEASE into :VERSION FROM v$instance;
SELECT version into :EXTENDVERSION from v$instance;
select count(*) into :EXIST from registry$history;
SELECT count(*) INTO :EXIST
FROM registry$history
WHERE COMMENTS LIKE 'PSU%'
OR COMMENTS LIKE 'BP%'
OR COMMENTS LIKE '%DATABASE PATCH SET UPDATE%'
OR COMMENTS LIKE 'BP%' ;
select * into :BP from (select COMMENTS from registry$history order by action_time DESC) where rownum=1;
-- 11.2
IF ( :EXTENDVERSION = '11.2.0.4.0' AND :EXIST > 0 AND :BP not like '%BP%') THEN
Expand Down Expand Up @@ -93,25 +98,25 @@ select * into :BP from (select COMMENTS from registry$history order by action_t
select
case
WHEN COMMENTS = 'BP20' THEN TO_DATE('151015','YYMMDD')
WHEN COMMENTS = 'BP19' THEN TO_DATE('150915','YYMMDD')
WHEN COMMENTS = 'BP18' THEN TO_DATE('150815','YYMMDD')
WHEN COMMENTS = 'BP17' THEN TO_DATE('150715','YYMMDD')
WHEN COMMENTS = 'BP16' THEN TO_DATE('150415','YYMMDD')
WHEN COMMENTS = 'BP15' THEN TO_DATE('150115','YYMMDD')
WHEN COMMENTS = 'BP14' THEN TO_DATE('151214','YYMMDD')
WHEN COMMENTS = 'BP13' THEN TO_DATE('151114','YYMMDD')
WHEN COMMENTS = 'BP12' THEN TO_DATE('151014','YYMMDD')
WHEN COMMENTS = 'BP11' THEN TO_DATE('150914','YYMMDD')
WHEN COMMENTS = 'BP10' THEN TO_DATE('150814','YYMMDD')
WHEN COMMENTS = 'BP9' THEN TO_DATE('150714','YYMMDD')
WHEN COMMENTS = 'BP8' THEN TO_DATE('150614','YYMMDD')
WHEN COMMENTS = 'BP7' THEN TO_DATE('150514','YYMMDD')
WHEN COMMENTS = 'BP6' THEN TO_DATE('150414','YYMMDD')
WHEN COMMENTS = 'BP5' THEN TO_DATE('150314','YYMMDD')
WHEN COMMENTS = 'BP4' THEN TO_DATE('150214','YYMMDD')
WHEN COMMENTS = 'BP3' THEN TO_DATE('150114','YYMMDD')
WHEN COMMENTS = 'BP2' THEN TO_DATE('151213','YYMMDD')
WHEN COMMENTS = 'BP1' THEN TO_DATE('151113','YYMMDD')
WHEN COMMENTS = 'BP19' THEN TO_DATE('150915','YYMMDD')
WHEN COMMENTS = 'BP18' THEN TO_DATE('150815','YYMMDD')
WHEN COMMENTS = 'BP17' THEN TO_DATE('150715','YYMMDD')
WHEN COMMENTS = 'BP16' THEN TO_DATE('150415','YYMMDD')
WHEN COMMENTS = 'BP15' THEN TO_DATE('150115','YYMMDD')
WHEN COMMENTS = 'BP14' THEN TO_DATE('151214','YYMMDD')
WHEN COMMENTS = 'BP13' THEN TO_DATE('151114','YYMMDD')
WHEN COMMENTS = 'BP12' THEN TO_DATE('151014','YYMMDD')
WHEN COMMENTS = 'BP11' THEN TO_DATE('150914','YYMMDD')
WHEN COMMENTS = 'BP10' THEN TO_DATE('150814','YYMMDD')
WHEN COMMENTS = 'BP9' THEN TO_DATE('150714','YYMMDD')
WHEN COMMENTS = 'BP8' THEN TO_DATE('150614','YYMMDD')
WHEN COMMENTS = 'BP7' THEN TO_DATE('150514','YYMMDD')
WHEN COMMENTS = 'BP6' THEN TO_DATE('150414','YYMMDD')
WHEN COMMENTS = 'BP5' THEN TO_DATE('150314','YYMMDD')
WHEN COMMENTS = 'BP4' THEN TO_DATE('150214','YYMMDD')
WHEN COMMENTS = 'BP3' THEN TO_DATE('150114','YYMMDD')
WHEN COMMENTS = 'BP2' THEN TO_DATE('151213','YYMMDD')
WHEN COMMENTS = 'BP1' THEN TO_DATE('151113','YYMMDD')
ELSE
TO_DATE(substr(COMMENTS,3,7), 'YYMMDD')
END as PSU_DATE
Expand Down Expand Up @@ -358,7 +363,7 @@ select * into :BP from (select COMMENTS from registry$history order by action_t
)
select distinct COMMENTS as DESCRIPTION,PSU_DATE,STATUS
into :DESCRIPTION,:PSU_DATE,:STATUS
from PSU,DATA,STATE;
from PSU,DATA,STATE;
ELSIF ( :EXTENDVERSION = '11.2.0.1.0' AND :EXIST > 0 AND :BP not like '%BP%') THEN
with PSU as
(
Expand Down Expand Up @@ -448,7 +453,7 @@ select * into :BP from (select COMMENTS from registry$history order by action_t
)
select distinct COMMENTS as DESCRIPTION,PSU_DATE,STATUS
into :DESCRIPTION,:PSU_DATE,:STATUS
from PSU,DATA,STATE;
from PSU,DATA,STATE;
ELSE
select 'N/A','N/A','N/A'
into :DESCRIPTION,:PSU_DATE,:STATUS
Expand Down
11 changes: 6 additions & 5 deletions sql/psu-2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ SELECT DBMS_DB_VERSION.VERSION || '.' || DBMS_DB_VERSION.RELEASE into :VERSION F
(
select
case
WHEN substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1) = '1' THEN TO_DATE('140114','YYMMDD')
WHEN substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1) = '2' THEN TO_DATE('150120','YYMMDD')
WHEN substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1) = '3' THEN TO_DATE('150414','YYMMDD')
WHEN substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1) = '4' THEN TO_DATE('150714','YYMMDD')
WHEN substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1) = '5' THEN TO_DATE('151020','YYMMDD')
WHEN length(substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1)) = 6 THEN TO_DATE(substr(substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1),1,7),'YYMMDD')
WHEN substr(substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1),1,1) = '1' THEN TO_DATE('140114','YYMMDD')
WHEN substr(substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1),1,1) = '2' THEN TO_DATE('150120','YYMMDD')
WHEN substr(substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1),1,1) = '3' THEN TO_DATE('150414','YYMMDD')
WHEN substr(substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1),1,1) = '4' THEN TO_DATE('150714','YYMMDD')
WHEN substr(substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1),1,1) = '5' THEN TO_DATE('151020','YYMMDD')
ELSE
TO_DATE(substr(substr(DESCRIPTION, - instr(reverse(DESCRIPTION), '.') + 1),1,7),'YYMMDD')
END as PSU_DATE
Expand Down

0 comments on commit b7b5d8e

Please sign in to comment.