-
Notifications
You must be signed in to change notification settings - Fork 1
/
exp_jobs.ksh
executable file
·51 lines (50 loc) · 1.8 KB
/
exp_jobs.ksh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# ------------------------------------------------------------------------------
# OraDBA - Oracle Database Infrastructur and Security, 5630 Muri, Switzerland
# ------------------------------------------------------------------------------
# Name.......: exp_jobs.ksh
# Author.....: Stefan Oehrli (oes) [email protected]
# Editor.....: Stefan Oehrli
# Date.......: 2023.05.04
# Version....: --
# Purpose....: Monitor the current runing DataPump jobs in v$session_longops
# Notes......: --
# Reference..: --
# License....: Apache License Version 2.0, January 2004 as shown
# at http://www.apache.org/licenses/
# ------------------------------------------------------------------------------
# Define initial values for sid_list
if [ $# -ne 0 ]; then
DB_SID=$*
else
DB_SID=$ORACLE_SID
fi
# loop over the sid list
for i in $DB_SID
do
echo "RMAN LongOps for $i"
# change the oracle environment
. oraenv.ksh $i
# run the sql query
sqlplus -S /nolog << EOI
set echo off
connect / as sysdba
set linesize 200
column "SID" format 999999
column "Serial" format 999999
column "Context" format 999999
column "Completed" format 99.99
column "Operation" format a50
column "Remain" format a12
SELECT SID "SID", serial# "Serial", CONTEXT "Context", sofar "so far", totalwork "total",
ROUND (sofar / totalwork * 100, 2) "Completed", opname "Operation",
to_char(trunc(time_remaining/60/60),'009')||to_char(trunc(mod(time_remaining,3600)/60),'09')||to_char(mod(mod(time_remaining,3600),60),'09') "Remain"
FROM
v\$session_longops
WHERE
opname LIKE '%EXP%'
AND totalwork != 0 AND sofar <> totalwork
ORDER BY 1;
EOI
done
# --- EOF ----------------------------------------------------------------------