I Love Tips

Nice Tips & Tricks made easy

Archive for January, 2008

Configuration of Broadcom wireless cards for Ubuntu

Posted by Rajkiran Ghanta on January 24, 2008

Have you ever had trouble setting up your Broadcom wirless cards to work with Ubuntu? The following procedure worked perfect ( I have tried several times) for
me to configure Broadcom wireless card on my old and heavy Dell Inspiron 9100 to work with Ubuntu Edgy.

1) Before you start,  get a copy of bcmwl5.inf and bcmwl5.sys files and copy them to your desktop

2) Open a terminal session and enter the following commands

a) remove the broadcom module
$sudo gedit /etc/modprobe.d/blacklist
add: “blacklist bcm43xx” (no quotes) and save the file
$sudo modprobe -r bcm43xx
$sudo modprobe ndiswrapper

b) Install windows wireless drivers(ndiswrapper)

$sudo apt-get install ndiswrapper-utils
$sudo ndiswrapper -i ~/Desktop/bcmwl5.inf
$sudo ndiswrapper -m
$sudo modprobe ndiswrapper

3) Reboot your PC and the wireless card should start working fine.

Posted in Uncategorized | Leave a Comment »

Monitoring Temp Space Usage

Posted by Rajkiran Ghanta on January 15, 2008

The following is a very useful script to monitor temp space usage inside the database.

#!/usr/bin/ksh
#set up the Oracle environment.
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=/oracle/app/oracle/product/9.2.0; export ORACLE_HOME
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH; export
LD_LIBRARY_PATH
tmp_output=/tmp/temp_usage.log

script_name=${0##*/}
echo “”
echo “Script: $script_name”
echo ” started on: `date`”
echo ” by user: `id`”
echo ” on machine: `uname -n`”
echo “”
echo “This script is designed to capture temp space usage information “
echo “”

${ORACLE_HOME}/bin/sqlplus -s <$ORACLE_PASSWD
whenever sqlerror exit 3 rollback
whenever oserror exit 4 rollback
SET SERVEROUTPUT ON
SET FEEDBACK OFF
insert into temp_usage
select (select instance_name from v\$instance) instance_name ,
s.sid ,
s.username,
u.tablespace,
substr(a.sql_text, 1, 1000) sql_text,
round(((u.blocks*p.value)/1024/1024),2) size_mb ,sysdate
from v\$sort_usage u,
v\$session s,
v\$sqlarea a,
v\$parameter p
where s.saddr = u.session_addr
and a.address (+) = s.sql_address
and a.hash_value (+) = s.sql_hash_value
and p.name = ‘db_block_size’
/
exit;
EOF_TEMP
if [[ $? -ne 0 ]]; then
echo “*** ERROR: The ${script_name} did not complete successfully.”
exit 1
else
echo “The ${script_name} script appears to have completed successfully on `date`.”
exit 0
fi

Posted in DBA, Scripts | Leave a Comment »

RESUMABLE

Posted by Rajkiran Ghanta on January 11, 2008

From 9i, you can run long running operations/processes that run out of space, using RESUME feature. Basically, the transaction runs in resumable mode and if there are any space issues, the transaction will not fail. It will be suspended until the problem is fixed and will resume automatically after the space is available.

You will need to grant resumable to user, before the user can start a session in resumable mode

Examples:

Altering the session to resumable mode
Grant RESUMABLE to user1;
Alter session enable resumable timeout 3600 name ‘SPACE-ISSUE’;

Disabling resumable
Alter session disable resumable;

Monitoring the suspended sessions :
You can query dba_resumable view to monitor any suspended transactions.

SELECT * FROM dba_resumable;

Posted in DBA | Leave a Comment »

Purging STATSPACK snapshots

Posted by Rajkiran Ghanta on January 8, 2008

STATSPACK provides a purge utility to remove the older snapshots. sppurge.sql script can be invoked to remove specific snapshots.
You will need to specify begin and end snapid for the script or you can modify it to select all the snapids for a snap_time date range.
You can setup a small batch job to run daily to purge the snapshots older than certain time period, to free up perfstat tablespace.

$ORACLE_HOME/bin/sqlplus -s “perfstat/perfstat” << EOF
TTITLE OFF
SET HEADING OFF
SET FEEDBACK OFF
SET PAGES 0
SET SERVEROUTPUT ON SIZE 1000000
SET VERIFY OFF
WHENEVER SQLERROR EXIT 8
WHENEVER OSERROR EXIT 9
spool $HOME/logs/sp_purge_db1.log
@$HOME/scripts/statspack/sp_purge.sql
commit;
spool off
exit;
EOF
if [ `wc -l ${HOME}/logs/sp_purge_db1.log awk '{print $1}'` -gt 0 ]
then
/bin/mail -s “Error” email_dba < ${HOME}/logs/sp_purge_db1.log
fi

sp_purge.sql can modified to specify the required date range for the snapshots to be purged
———————-
———-
——————
column min_snap_id new_val LoSnapId
column max_snap_id new_val HiSnapId
select min(s.snap_id) min_snap_id, max(s.snap_id) max_snap_id
from stats$snapshot s
, stats$database_instance di
where s.dbid = :dbid
and di.dbid = :dbid
and s.instance_number = :inst_num
and di.instance_number = :inst_num
and di.startup_time = s.startup_time
and s.snap_time < sysdate – 60;


– Post warning

prompt
prompt
prompt Warning
prompt ~~~~~~~
prompt sppurge.sql deletes all snapshots ranging between the lower and
prompt upper bound Snapshot Id’s specified, for the database instance
prompt you are connected to.
prompt
prompt You may wish to export this data before continuing.
prompt


– Obtain snapshot ranges

prompt
prompt Specify the Lo Snap Id and Hi Snap Id range to purge
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt Using &&LoSnapId for lower bound.
prompt
prompt Using &&HiSnapId for upper bound.

variable lo_snap number;
variable hi_snap number;
begin
:lo_snap := &losnapid;
:hi_snap := &hisnapid;
end;
/

set termout off

– Get begin and end snapshot times – these are used to delete undostat
column btime new_value btime
column etime new_value etime
select to_char(snap_time, ‘YYYYMMDD HH24:MI:SS’) btime
from stats$snapshot b
where b.snap_id = :lo_snap
and b.dbid = :dbid
and b.instance_number = :inst_num;
select to_char(snap_time, ‘YYYYMMDD HH24:MI:SS’) etime
from stats$snapshot e
where e.snap_id = :hi_snap
and e.dbid = :dbid
and e.instance_number = :inst_num;

variable btime varchar2(25);
variable etime varchar2(25);
begin
:btime := ‘&btime’;
:etime := ‘&etime’;
end;
/
set termout on

set heading off

select ‘WARNING: LoSnapId or HiSnapId specified does not exist in STATS$SNAPSHOT’
from dual
where not exists
(select null
from stats$snapshot
where instance_number = :inst_num
and dbid = :dbid
and snap_id = :lo_snap)
or not exists
(select null
from stats$snapshot
where instance_number = :inst_num
and dbid = :dbid
and snap_id = :hi_snap);

set heading on
———————–
——————
———

Posted in DBA, Scripts | Leave a Comment »