Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request #39 from raffaelloferrari/master
Browse files Browse the repository at this point in the history
Various problem with licenses script #37 #38
  • Loading branch information
amreo authored Oct 25, 2019
2 parents ebeed40 + 04f0a9e commit a7fc73f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
56 changes: 40 additions & 16 deletions fetch/license
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/ksh

# Copyright (c) 2019 Sorint.lab S.p.A.
#
Expand Down Expand Up @@ -44,26 +44,28 @@ fi
ERCOLE_HOME=$(dirname "$0")
ERCOLE_HOME="$(dirname "$ERCOLE_HOME")"

export ORAENV_ASK=NO
export ORAENV_ASK=NO
export ORACLE_SID=$SID
export ORACLE_HOME=$HOME
export PATH=$HOME/bin:$PATH

#DB_VERSION=$(sqlplus -S / as sysdba << EOF
#set pages 0 feedback off
#select (case when UPPER(banner) like '%EXTREME%' then 'EXE' when UPPER(banner) like '%ENTERPRISE%' then 'ENT' else 'STD' end) as versione from v\$version where rownum=1;
#exit
#EOF
#)

export DB_VERSION="ENT"
S_VERSION="select (case when UPPER(banner) like '%EXTREME%' then 'EXE' when UPPER(banner) like '%ENTERPRISE%' then 'ENT' else 'STD' end) as versione from v\$version where rownum=1;"

DB_VERSION=$(sqlplus -S / as sysdba << EOF
set pages 0 feedback off
${S_VERSION}
exit
EOF
)

DB_NAME=$(sqlplus -S / as sysdba << EOF
set pages 0 feedback off
select name from v\$database;
exit
EOF
)

DB_ONE=x$(sqlplus -S / as sysdba << EOF
set pages 0 feedback off
HOST srvctl config database -d $DB_NAME |grep -i One
Expand All @@ -73,18 +75,38 @@ EOF



if [[ "$TYPE" = 'HPVRT' ]]
then
VIRTUAL=Y
CPU_THREAD=$(ioscan -fnk|grep proc|wc -l)
CPU_CORES=$(($CPU_THREAD/2))
SOCKET=1

if [[ $DB_VERSION = 'EXE' || $DB_VERSION = 'ENT' ]]; then
NUM_LICENSE=$(echo 0.5*$CPU_THREAD|bc)
FACTOR=0.5
elif [[ $DB_VERSION = 'STD' ]]; then
NUM_LICENSE=$SOCKET
FACTOR=$SOCKET
fi
elif [ $TYPE = 'PH' ]
then

VIRTUAL=N
DIVISO=$(/usr/contrib/bin/machinfo |grep -i processor| grep logical| awk '{print $4}'| awk -F "(" '{print $2}')
CPU_THREAD=$(/usr/contrib/bin/machinfo |grep -i processor| awk '{print $1}')
CPU_THREAD=$(/usr/contrib/bin/machinfo |grep -i processor| grep logical| awk '{print $1}')
CPU_CORES=$(($CPU_THREAD/2))
SOCKET=1
SOCKET=$(($CPU_THREAD / $DIVISO))


if [[ $DB_VERSION = 'EXE' || $DB_VERSION = 'ENT' ]]; then
NUM_LICENSE=$(echo 0.5*$CPU_THREAD|bc)
FACTOR='0.5'
NUM_LICENSE=$(echo 0.5*$CPU_THREAD|bc)
FACTOR=0.5
elif [[ $DB_VERSION = 'STD' ]]; then
NUM_LICENSE=$SOCKET
FACTOR=$SOCKET
NUM_LICENSE=$SOKET
FACTOR=$SOKET
fi
fi


if [[ $DB_VERSION = 'EXE' ]]; then
Expand All @@ -102,8 +124,10 @@ if [[ $DB_VERSION = 'STD' ]]; then
else
echo "Oracle STD;;"
fi


if [ $DBV = "10" ]; then
sqlplus -S "/ AS SYSDBA" @${ERCOLE_HOME}/sql/license-10.sql $CPU_THREAD $FACTOR
else
sqlplus -S "/ AS SYSDBA" @${ERCOLE_HOME}/sql/license.sql $CPU_THREAD $FACTOR $DB_ONE
fi
fi
5 changes: 3 additions & 2 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 Down

0 comments on commit a7fc73f

Please sign in to comment.