Skip to content

Instantly share code, notes, and snippets.

@dotmaik1
dotmaik1 / rman: backups information.sql
Last active October 6, 2016 16:43
List all the backups information
set lines 200
select SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,
to_char(END_TIME,'mm/dd/yy hh24:mi') end_time,
round((end_time-start_time)*1440,2) "Minutes"
from V$RMAN_BACKUP_JOB_DETAILS
order by session_key desc;
@dotmaik1
dotmaik1 / scheduler: JOBS information.sql
Created October 6, 2016 16:39
Various queries that give us JOBS information
--Scheduler JOBS
set lines 200
set pages 500
column OWNER format a15
column SCHEDULE_NAME format a25
column START_DATE format a50
column REPEAT_INTERVAL format a20
SELECT OWNER, JOB_NAME, JOB_STYLE, SCHEDULE_NAME, START_DATE, REPEAT_INTERVAL, STATE FROM DBA_SCHEDULER_JOBS;
@dotmaik1
dotmaik1 / scripts: waits.sql
Created October 6, 2016 16:38
Checa por esperas y muestra el evento que esta esperando
set lines 200 pages 200
col state for a15
col seq# for 999999
col P1_P2_P3_TEXT for a30
col event for a20
select w.sid, to_char(p.spid,'99999') PID,
substr(w.event, 1, 28) event, substr(s.username,1,8) username,
substr(s.osuser, 1,8) osuser,
substr(w.state,1,20),
w.seq#,
@dotmaik1
dotmaik1 / scripts: filesystem check include Linux.sh
Last active October 6, 2016 16:43
Automated script that checks if the threshold has been exceded
# set -x
# Shell script to monitor or watch the disk space
# name: fs_check.sh
# umbrales: 85-89% WARNING; 90-99% SERIOUS; 100% CRITICAL
# ===================================================================================================#
# Set admin email so that you can get email.
email="HPSysAdmin@televisa.com.mx"
# Include list of FS to monitoring, if several partions then use "|" to separate the partitions.
INCLUDE_LIST="/u01|/u04|/u05|/oradata"
#
@dotmaik1
dotmaik1 / scripts: daily chek BAU.sh
Created October 6, 2016 16:36
Script para BAU diario
#!/bin/bash
export ORACLE_SID=mxapps1
export ORACLE_HOME=/u001/MXDB/oracle/product/11.2.0/db
export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/etc/opt/emcpower/bin:/u001/MXDB/oracle/product/11.2.0/db:/u001/MXDB/oracle/product/11.2.0/db/bin
export FECHA=`date '+%d%m%Y_%H%M%S'`
$ORACLE_HOME/bin/sqlplus -s "/as sysdba" <<EOF
SET PAGES 2000 LINES 200
SET SERVEROUTPUT ON
@dotmaik1
dotmaik1 / bloqueos: lw.sql
Created October 6, 2016 16:34
Bloque de PL/SQL para determinar si hay usuarios esperando por objetos bloqueados
set lines 200
set serveroutput on size 10000
declare
cursor c1 is
select * from v$lock where request != 0
order by id1, id2;
wid1 number := -999999;
wid2 number := -999999;
wholder_detail varchar2(120);
@dotmaik1
dotmaik1 / admin: hashsql.sql
Created October 6, 2016 16:32
It gets the query that was issue by Hash Value
set verify off
accept trgthash number default 0 prompt 'What is the SQL Hash Value : '
select t.sql_text
from v$sqltext_with_newlines t
where t.hash_value + 0 = &trgthash
and &trgthash != 0
order by t.piece;
@dotmaik1
dotmaik1 / scripts: statistics: Gather full DB statistics.sh
Created October 6, 2016 16:31
Script that gather full database statistics
##################################################################################
# Name : GSS_FULL_DB.sh
# Location : /home/oracle/scripts/mxoptix1/GSS
# Created By : [ Wipro DBA Team ]
# Purpose : GSS for FULL DB - MXAPPS[PROD]
#
###################################################################################
mail_list="miguel.ordonez@foit-foxconn.com,omar.santos@foit-foxconn.com"
echo -e "\nGSS for FULL DB Process Started at `date` \n \n \n" > /home/oracle/scripts/mxapps1/GSS/FULL_DB_GSS.log
@dotmaik1
dotmaik1 / scripts: DB_and_listener_check.sh
Created October 6, 2016 16:29
Automatic script that checks if the database is open an accesible
#!/bin/bash
ORACLE_SID=MXBRIDGE
export ORACLE_SID
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/MXBRIDGE
export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin
export PATH
mailto="foit-mx-server-alert@foit-foxconn.com"
TIMING=`date +"%d-%b-%Y %H:%M"`
$ORACLE_HOME/bin/sqlplus scott/tiger@'(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lfoitmatdb01.foit-foxconn.net)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MXBRIDGE) (FAILOVER_MODE = (TYPE = select) (METHOD = basic))))' <<END
@dotmaik1
dotmaik1 / admin: ckusess.sql
Created October 6, 2016 16:28
Get sessions status and what their are doing
-- Script para monitoreo de procesos de usuario
set verify off
col status format a8
col username format a13 heading 'DB User' trunc
col osuser format a12 heading 'OS User' trunc
col sid format 9999 heading SID
col serial# format 99999 heading SRL#
col spid format a6 heading DBPROC
col process format a10 heading APPPROC