From b7b5d8e4bcad8c5ec81ca1105cd85a26df398cca Mon Sep 17 00:00:00 2001 From: amreo Date: Mon, 18 Nov 2019 10:41:20 +0100 Subject: [PATCH] Various fix --- fetch/feature | 6 +++--- fetch/host | 5 +++++ fetch/license | 2 +- fetch/patch | 4 ++-- fetch/psu | 2 +- main.go | 9 +-------- sql/dbmounted.sql | 21 ++++++++++---------- sql/license-10.sql | 8 ++++---- sql/psu-1.sql | 49 +++++++++++++++++++++++++--------------------- sql/psu-2.sql | 11 ++++++----- 10 files changed, 61 insertions(+), 56 deletions(-) diff --git a/fetch/feature b/fetch/feature index ad696e0..4ef3925 100755 --- a/fetch/feature +++ b/fetch/feature @@ -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 diff --git a/fetch/host b/fetch/host index 061a026..4a97d5a 100755 --- a/fetch/host +++ b/fetch/host @@ -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 @@ -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 diff --git a/fetch/license b/fetch/license index 3fccc78..0b27aa4 100755 --- a/fetch/license +++ b/fetch/license @@ -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 diff --git a/fetch/patch b/fetch/patch index b46c939..91eed8e 100755 --- a/fetch/patch +++ b/fetch/patch @@ -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 \ No newline at end of file diff --git a/fetch/psu b/fetch/psu index 048dbac..2701ed8 100755 --- a/fetch/psu +++ b/fetch/psu @@ -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 diff --git a/main.go b/main.go index 2c7edb0..79cd8a5 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/sql/dbmounted.sql b/sql/dbmounted.sql index dec8bdf..8263027 100644 --- a/sql/dbmounted.sql +++ b/sql/dbmounted.sql @@ -13,8 +13,8 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -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 @@ -22,6 +22,7 @@ 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, @@ -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; diff --git a/sql/license-10.sql b/sql/license-10.sql index 39fb619..c547999 100644 --- a/sql/license-10.sql +++ b/sql/license-10.sql @@ -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; diff --git a/sql/psu-1.sql b/sql/psu-1.sql index 437d852..d4de705 100644 --- a/sql/psu-1.sql +++ b/sql/psu-1.sql @@ -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 @@ -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 @@ -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 ( @@ -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 diff --git a/sql/psu-2.sql b/sql/psu-2.sql index 787c5e1..828456e 100644 --- a/sql/psu-2.sql +++ b/sql/psu-2.sql @@ -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