Weblogic Server Health checking Script

# Modify classpath to as per the weblocic server location in your environment
# The script takes 3 parameters
# The first parameter is the admin url
# The second parameter is the Username of admin server
# The third parameter is the password of admin server

CLASSPATH="/usr/java/lib/tools.jar:/apps/weblogic/server/lib/weblogic_sp.jar:/apps/weblogic/server/lib/weblogic.jar:/apps/weblogic/server/lib/ojdbc14.jar:"
export CLASSPATH
PATH="/apps/weblogic/server/bin:/usr/java/jre/bin:/usr/java/bin:/osmf/mgmt/condir/cft/BT/BTOPUT/bin/SSOL2:/usr/bin:/usr/ucb:/etc::/osmf/mgmt/condir/cft/cft/filexe:/osmf/mgmt/condir/cft/cft/filusr:/osmf/mgmt/condir/cft/cft/filexit:/osmf/mgmt/condir/cft/cft/filapi:/u01/app/oracle/product/8.1.7/bin:/apps/abinitio/bin"
export PATH
java weblogic.Admin -adminurl $1 -username $2 -password $3 GET -pretty -type ServerRuntime
java weblogic.Admin -adminurl $1 -username $2 -password $3 GET -pretty -type JVMRuntime
java weblogic.Admin -adminurl $1 -username $2 -password $3 GET -pretty -type JDBCConnectionPoolRuntime
java weblogic.Admin -adminurl $1 -username $2 -password $3 GET -pretty -type ExecuteQueueRuntime

Script to restart the weblogic server using crontab in unix without any manual intervention

Problem Description

This script can be used to restart the weblogic server using crontab in unix without any manual intervention.


Solution Description

This script can be used to restart the weblogic server without any manual intervention. It also sends email to the list of people once the restart is done.We can add few more manipulations if you need before restarting the weblogic server. This can be enabled through crontab in the unix.


Code Snippet

#! /bin/ksh

#This script is used for restarting the Weblogic server using CRONTAB

#-------------------------------------------------------------------

# Mail list is used to email the list of users once the restart is done

Maillist=" "

# Mail file is the file which will get emailed to the mail list users

Mailfile= " "

#This is the temporary log file where stopWeblogic.sh result will be stored

> Stop_log

# Stopping the Server

echo "Stopping Weblogic server"

. ./stopWebLogic.sh > Stop_log 2>& 1

sleep 90

echo "Confirming that the Weblogic server stopped"

. ./stopWebLogic.sh >> Stop_log 2>& 1

# Searching for the exception when you shut down the weblogic server for the second time

egrep '[Destination unreachable | "OPUSServer" was shutdown successfully]' Stop_log > /dev/null

if [ $? -eq 0 ]

then

echo "Weblogic server stopped successfully"

# Starting the Server

echo "Trying to start Weblogic server"

#. ./startWebLogic.sh > Start_log 2>& 1 &

. ./startWebLogic.sh > /dev/null

#Getting the process id for startWebLogic.sh process

id=$!

i=0

until [ $i -gt 1 ]

do

sleep 90

grep "Server started in RUNNING mode" /prod/opus/OPUS_CONS1/logs/wl-domain.log > /dev/null

if [ $? -eq 0 ]

then

echo "Weblogic server started successfully"

#Killing the process startWebLogic.sh using process id

#kill -9 $id

#echo "Killed startweb"

break

fi

i=`expr $i + 1`

done

if [ $i -ne 2 ]

then

echo "Weblogic server restarted successfully"

mailx -s "Weblogic_server name Restarted Succesfully" -r $Maillist < $Mailfile


else

echo "Weblogic server failed to start"

mailx -s "Weblogic_server name failed to start" -r $Maillist

fi

else

echo "Failed to stop Weblogic server"

mailx -s "Failed to stop Weblogic server" -r $Maillist

fi

echo "Completed the script"

exit

SCRIPT TO MONITOR MEMORY USAGE BY DATABASE SESSIONS

=============================================================================
SCRIPT TO MONITOR MEMORY USAGE BY DATABASE SESSIONS
=============================================================================
REM Created: 21/march/2003
REM Last update: 28/may/2003
REM
REM NAME
REM ====
REM MEMORY.sql
REM
REM
REM DISCLAIMER
REM ==========
REM This script is provided for educational purposes only. It is NOT supported by
REM Oracle World Wide Technical Support. The script has been tested and appears
REM to work as intended. However, you should always test any script before
REM relying on it.
REM
REM PURPOSE
REM =======
REM Retrieves PGA and UGA statistics for users and background processes sessions.
REM
REM EXECUTION ENVIRONMENT
REM =====================
REM SQL*Plus
REM
REM ACCESS PRIVILEGES
REM =================
REM Select on V$SESSTAT, V$SESSION, V$BGPROCESS, V$PROCESS and V$INSTANCE.
REM
REM USAGE
REM =====
REM $ sqlplus "/ as sysdba" @MEMORY
REM
REM INSTRUCTIONS
REM ============
REM Call MEMORY.sql from SQL*Plus, connected as any DBA user.
REM Press whenever you want to refresh information.
REM You can change the ordered column and the statistics shown by choosing from the menu.
REM Spool files named MEMORY_YYYYMMDD_HH24MISS.lst will be generated in the current directory.
REM Every time you refresh screen, a new spool file is created, with a snapshot of the statistics shown.
REM These snapshot files may be uploaded to Oracle Support Services for future reference, if needed.
REM
REM REFERENCES
REM ==========
REM "Oracle Reference" - Online Documentation
REM
REM SAMPLE OUTPUT
REM =============
REM :::::::::::::::::::::::::::::::::: PROGRAM GLOBAL AREA statistics :::::::::::::::::::::::::::::::::
REM
REM SESSION PID/THREAD CURRENT SIZE MAXIMUM SIZE
REM -------------------------------------------------- ---------- ------------------ ------------------
REM 9 - SYS: myworkstation 2258 10.59 MB 10.59 MB
REM 3 - LGWR: testserver 2246 5.71 MB 5.71 MB
REM 2 - DBW0: testserver 2244 2.67 MB 2.67 MB
REM ...
REM
REM :::::::::::::::::::::::::::::::::::: USER GLOBAL AREA statistics ::::::::::::::::::::::::::::::::::
REM
REM SESSION PID/THREAD CURRENT SIZE MAXIMUM SIZE
REM -------------------------------------------------- ---------- ------------------ ------------------
REM 9 - SYS: myworkstation 2258 0.29 MB 0.30 MB
REM 5 - SMON: testserver 2250 0.06 MB 0.06 MB
REM 4 - CKPT: testserver 2248 0.05 MB 0.05 MB
REM ...
REM
REM SCRIPT BODY
REM ===========


spool MEMORY_YYYYMMDD_HH24MISS.log

REM Starting script execution
CLE SCR
PROMPT .
PROMPT . ======== SCRIPT TO MONITOR MEMORY USAGE BY DATABASE SESSIONS ========
PROMPT .

REM Setting environment variables
SET LINESIZE 200
SET PAGESIZE 500
SET FEEDBACK OFF
SET VERIFY OFF
SET SERVEROUTPUT ON
SET TRIMSPOOL ON
COL "SESSION" FORMAT A50
COL "PID/THREAD" FORMAT A10
COL " CURRENT SIZE" FORMAT A18
COL " MAXIMUM SIZE" FORMAT A18

REM Setting user variables values
SET TERMOUT OFF
DEFINE sort_order = 3
DEFINE show_pga = 'ON'
DEFINE show_uga = 'ON'
COL sort_column NEW_VALUE sort_order
COL pga_column NEW_VALUE show_pga
COL uga_column NEW_VALUE show_uga
COL snap_column NEW_VALUE snap_time
SELECT nvl(:sort_choice, 3) "SORT_COLUMN"
FROM dual
/
SELECT nvl(:pga_choice, 'ON') "PGA_COLUMN"
FROM dual
/
SELECT nvl(:uga_choice, 'ON') "UGA_COLUMN"
FROM dual
/
SELECT to_char(sysdate, 'YYYYMMDD_HH24MISS') "SNAP_COLUMN"
FROM dual
/

REM Creating new snapshot spool file
SPOOL MEMORY_&snap_time

REM Showing PGA statistics for each session and background process
SET TERMOUT &show_pga
PROMPT
PROMPT :::::::::::::::::::::::::::::::::: PROGRAM GLOBAL AREA statistics :::::::::::::::::::::::::::::::::
SELECT to_char(ssn.sid, '9999') || ' - ' || nvl(ssn.username, nvl(bgp.name, 'background')) ||
nvl(lower(ssn.machine), ins.host_name) "SESSION",
to_char(prc.spid, '999999999') "PID/THREAD",
to_char((se1.value/1024)/1024, '999G999G990D00') || ' MB' " CURRENT SIZE",
to_char((se2.value/1024)/1024, '999G999G990D00') || ' MB' " MAXIMUM SIZE"
FROM v$sesstat se1, v$sesstat se2, v$session ssn, v$bgprocess bgp, v$process prc,
v$instance ins, v$statname stat1, v$statname stat2
WHERE se1.statistic# = stat1.statistic# and stat1.name = 'session pga memory'
AND se2.statistic# = stat2.statistic# and stat2.name = 'session pga memory max'
AND se1.sid = ssn.sid
AND se2.sid = ssn.sid
AND ssn.paddr = bgp.paddr (+)
AND ssn.paddr = prc.addr (+)
ORDER BY &sort_order DESC
/

REM Showing UGA statistics for each session and background process
SET TERMOUT &show_uga
PROMPT
PROMPT :::::::::::::::::::::::::::::::::::: USER GLOBAL AREA statistics ::::::::::::::::::::::::::::::::::
SELECT to_char(ssn.sid, '9999') || ' - ' || nvl(ssn.username, nvl(bgp.name, 'background')) ||
nvl(lower(ssn.machine), ins.host_name) "SESSION",
to_char(prc.spid, '999999999') "PID/THREAD",
to_char((se1.value/1024)/1024, '999G999G990D00') || ' MB' " CURRENT SIZE",
to_char((se2.value/1024)/1024, '999G999G990D00') || ' MB' " MAXIMUM SIZE"
FROM v$sesstat se1, v$sesstat se2, v$session ssn, v$bgprocess bgp, v$process prc,
v$instance ins, v$statname stat1, v$statname stat2
WHERE se1.statistic# = stat1.statistic# and stat1.name = 'session uga memory'
AND se2.statistic# = stat2.statistic# and stat2.name = 'session uga memory max'
AND se1.sid = ssn.sid
AND se2.sid = ssn.sid
AND ssn.paddr = bgp.paddr (+)
AND ssn.paddr = prc.addr (+)
ORDER BY &sort_order DESC
/

REM Showing sort information
SET TERMOUT ON
PROMPT
BEGIN
IF (&sort_order = 1) THEN
dbms_output.put_line('Ordered by SESSION');
ELSIF (&sort_order = 2) THEN
dbms_output.put_line('Ordered by PID/THREAD');
ELSIF (&sort_order = 3) THEN
dbms_output.put_line('Ordered by CURRENT SIZE');
ELSIF (&sort_order = 4) THEN
dbms_output.put_line('Ordered by MAXIMUM SIZE');
END IF;
END;
/

REM Closing current snapshot spool file
SPOOL OFF

REM Showing the menu and getting sort order and information viewing choice
PROMPT
PROMPT Choose the column you want to sort: == OR == You can choose which information to see:
PROMPT ... 1. Order by SESSION ... 5. PGA and UGA statistics (default)
PROMPT ... 2. Order by PID/THREAD ... 6. PGA statistics only
PROMPT ... 3. Order by CURRENT SIZE (default) ... 7. UGA statistics only
PROMPT ... 4. Order by MAXIMUM SIZE
PROMPT
ACCEPT choice NUMBER PROMPT 'Enter the number of your choice or press to refresh information: '
VAR sort_choice NUMBER
VAR pga_choice CHAR(3)
VAR uga_choice CHAR(3)
BEGIN
IF (&choice = 1 OR &choice = 2 OR &choice = 3 OR &choice = 4) THEN
:sort_choice := &choice;
:pga_choice := '&show_pga';
:uga_choice := '&show_uga';
ELSIF (&choice = 5) THEN
:sort_choice := &sort_order;
:pga_choice := 'ON';
:uga_choice := 'ON';
ELSIF (&choice = 6) THEN
:sort_choice := &sort_order;
:pga_choice := 'ON';
:uga_choice := 'OFF';
ELSIF (&choice = 7) THEN
:sort_choice := &sort_order;
:pga_choice := 'OFF';
:uga_choice := 'ON';
ELSE
:sort_choice := &sort_order;
:pga_choice := '&show_pga';
:uga_choice := '&show_uga';
END IF;
END;
/

REM Finishing script execution
PROMPT Type "@MEMORY" and press
SET FEEDBACK ON
SET VERIFY ON
SET SERVEROUTPUT OFF
SET TRIMSPOOL OFF

spool off

REM =============
REM END OF SCRIPT
REM =============

Database Health Monitoring Scripts in Oracle.

#################################################################################
---------------------- Database health Monitor ---------------------------------
#################################################################################

break on today
column today noprint new_value tdate
select substr(to_char(sysdate,'fmMonth DD, YYYY HH:MI:SS P.M.'),1,35) today from dual;
column name noprint new_value DB
select name from v$database;

set heading on
set feedback off

spool health.lst
--spool Windows Path or Unix Path\health.lst

prompt **********************************************************
prompt ***** Database Information *****
prompt **********************************************************
ttitle left "DATABASE: "DB" (AS OF: "tdate")"
select name, created, log_mode from v$database;
prompt
prompt **********************************************************
ttitle off

rem -------------------------------------------------------------
rem DB Block Buffer - Hit Ratio
rem -------------------------------------------------------------

clear breaks
clear computes

set heading off
set feedback off
set termout off

create table dbbb (
PR number,
CG number,
dbbg number);

insert into DBBB values (0,0,0);
UPDATE dbbb
set dbbg =
(SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'db block gets');
UPDATE dbbb
set cg =
(SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'consistent gets');
UPDATE dbbb
set pr =
(SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'physical reads');

set heading on
set termout on

column "Physical Reads" format 99,999,999,999
column "Consistent Gets" format 99,999,999,999
column "DB Block Gets" format 99,999,999,999
column "Percent (Above 70% ?)" format 999.99

TTitle left "***** Database: "db", DB Block Buffers ( As of: "tdate" ) *****" skip 1 - left "Percent = (100*(1-(Physical Reads/(Consistent Gets + DB Block Gets))))" skip 2
SELECT pr "Physical Reads",
cg "Consistent Gets",
dbbg "DB Block Gets",
(100*(1-(PR/(CG+dbbg)))) "Percent (Above 70% ?)"
from dbbb;

set heading off
set termout off
drop table dbbb;
ttitle off
clear breaks
clear computes
set heading on
set termout on

rem -------------------------------------------------------------
rem Shared Pool Size - Gets and Misses
rem -------------------------------------------------------------

set line 150

column "Executions" format 999,999,990
column "Cache Misses Executing" format 999,999,990
column "Data Dictionary Gets" format 999,999,999
column "Get Misses" format 999,999,999

ttitle left skip 1 - left "********** Shared Pool Size (Execution Misses) **********" skip 1

select sum(pins) "Executions",
sum(reloads) "Cache Misses Executing",
(sum(reloads)/sum(pins)*100) "% Ratio (STAY UNDER 1%)"
from v$librarycache;

ttitle left "********** Shared Pool Size (Dictionary Gets) **********" skip 1

select sum(gets) "Data Dictionary Gets",
sum(getmisses) "Get Misses",
100*(sum(getmisses)/sum(gets)) "% Ratio (STAY UNDER 12%)"
from v$rowcache;

ttitle off


rem -------------------------------------------------------------
rem Log Buffer
rem -------------------------------------------------------------

ttitle left "********** Log Buffers **********" skip 1

select substr(name,1,25) Name,
substr(value,1,15) "VALUE (Near 0?)"
from v$sysstat
where name = 'redo log space requests';

ttitle off


rem -------------------------------------------------------------
rem Latch Contention
rem -------------------------------------------------------------

ttitle left "********** Latch Information **********" skip 1

select substr(l.name,1,25) Name,
l.gets, l.misses,
l.immediate_gets, l.immediate_misses
from v$latch l, v$latchname ln
where ln.name in ('redo allocation', 'redo copy')
and ln.latch# = l.latch#;

ttitle off


rem -------------------------------------------------------------
rem Reinstates the xdbname parameter
rem -------------------------------------------------------------

column name noprint new_value xdbname
select name from v$database;


rem -------------------------------------------------------------
rem Tablespace Usage
rem -------------------------------------------------------------

set pagesize 66
set line 132

clear breaks
clear computes

column "Total Bytes" format 9,999,999,999
column "SQL Blocks" format 999,999,999
column "VMS Blocks" format 999,999,999
column "Bytes Free" format 9,999,999,999
column "Bytes Used" format 9,999,999,999
column "% Free" format 9999.999
column "% Used" format 9999.999
break on report
compute sum of "Total Bytes" on report
compute sum of "SQL Blocks" on report
compute sum of "VMS Blocks" on report
compute sum of "Bytes Free" on report
compute sum of "Bytes Used" on report
compute avg of "% Free" on report
compute avg of "% Used" on report

TTitle left "******* Database: "db", Current Tablespace Usage ( As of: "tdate" ) *******" skip 1

select substr(fs.FILE_ID,1,3) "ID#",
fs.tablespace_name,
df.bytes "Total Bytes",
df.blocks "SQL Blocks",
df.bytes/512 "VMS Blocks",
sum(fs.bytes) "Bytes Free",
(100*((sum(fs.bytes))/df.bytes)) "% Free",
df.bytes-sum(fs.bytes) "Bytes Used",
(100*((df.bytes-sum(fs.bytes))/df.bytes)) "% Used"
from sys.dba_data_files df, sys.dba_free_space fs
where df.file_id(+) = fs.file_id
group by fs.FILE_ID, fs.tablespace_name, df.bytes, df.blocks
order by fs.tablespace_name;

ttitle off

rem -------------------------------------------------------------
rem Disk Activity
rem -------------------------------------------------------------

column "File Total" format 99,999,990

set line 132
set pagesize 33

ttitle " ***** Database: "db", DataFile's Disk Activity (As of:" tdate " ) *****"

select substr(df.file#,1,2) "ID",
rpad(substr(name,1,52),52,'.') "File Name",
rpad(substr(phyrds,1,10),10,'.') "Phy Reads",
rpad(substr(phywrts,1,10),10,'.') "Phy Writes",
rpad(substr(phyblkrd,1,10),10,'.') "Blk Reads",
rpad(substr(phyblkwrt,1,10),10,'.') "Blk Writes",
rpad(substr(readtim,1,9),9,'.') "Read Time",
rpad(substr(writetim,1,10),10,'.') "Write Time",
(sum(phyrds+phywrts+phyblkrd+phyblkwrt+readtim)) "File Total"
from v$filestat fs, v$datafile df
where fs.file# = df.file#
group by df.file#, df.name, phyrds, phywrts, phyblkrd,
phyblkwrt, readtim, writetim
order by sum(phyrds+phywrts+phyblkrd+phyblkwrt+readtim) desc, df.name;

ttitle off


rem -------------------------------------------------------------
rem Fragmentation Need
rem -------------------------------------------------------------

set heading on
set termout on
set pagesize 66
set line 132

ttitle left " ***** Database: "db", DEFRAGMENTATION NEED, AS OF: " tdate " *****"

select substr(de.owner,1,8) "Owner",
substr(de.segment_type,1,8) "Seg Type",
substr(de.segment_name,1,35) "Table Name (Segment)",
substr(de.tablespace_name,1,20) "Tablespace Name",
count(*) "Frag NEED",
substr(df.name,1,40) "DataFile Name"
from sys.dba_extents de, v$datafile df
where de.owner <> 'SYS'
and de.file_id = df.file#
and de.segment_type = 'TABLE'
group by de.owner, de.segment_name, de.segment_type, de.tablespace_name,
df.name
having count(*) > 1
order by count(*) desc;

ttitle off


rem -------------------------------------------------------------
rem Rollback Information
rem -------------------------------------------------------------

set pagesize 66
set line 132

TTitle left "*** Database: "db", Rollback Information ( As of: " tdate " ) ***" skip 2

select substr(sys.dba_rollback_segs.SEGMENT_ID,1,5) "ID#",
substr(sys.dba_segments.OWNER,1,8) "Owner",
substr(sys.dba_segments.TABLESPACE_NAME,1,17) "Tablespace Name",
substr(sys.dba_segments.SEGMENT_NAME,1,17) "Rollback Name",
substr(sys.dba_rollback_segs.INITIAL_EXTENT,1,10) "INI_Extent",
substr(sys.dba_rollback_segs.NEXT_EXTENT,1,10) "Next Exts",
substr(sys.dba_segments.MIN_EXTENTS,1,5) "MinEx",
substr(sys.dba_segments.MAX_EXTENTS,1,5) "MaxEx",
substr(sys.dba_segments.PCT_INCREASE,1,5) "%Incr",
substr(sys.dba_segments.BYTES,1,15) "Size (Bytes)",
substr(sys.dba_segments.EXTENTS,1,6) "Extent#",
substr(sys.dba_rollback_segs.STATUS,1,10) "Status"
from sys.dba_segments, sys.dba_rollback_segs
where sys.dba_segments.segment_name = sys.dba_rollback_segs.segment_name and
sys.dba_segments.segment_type = 'ROLLBACK'
order by sys.dba_rollback_segs.segment_id;

ttitle off

TTitle left " " skip 2 - left "*** Database: "db", Rollback Status ( As of: " tdate " ) ***" skip 2

select substr(V$rollname.NAME,1,20) "Rollback_Name",
substr(V$rollstat.EXTENTS,1,6) "EXTENT",
v$rollstat.RSSIZE, v$rollstat.WRITES,
substr(v$rollstat.XACTS,1,6) "XACTS",
v$rollstat.GETS,
substr(v$rollstat.WAITS,1,6) "WAITS",
v$rollstat.HWMSIZE, v$rollstat.SHRINKS,
substr(v$rollstat.WRAPS,1,6) "WRAPS",
substr(v$rollstat.EXTENDS,1,6) "EXTEND",
v$rollstat.AVESHRINK,
v$rollstat.AVEACTIVE
from v$rollname, v$rollstat
where v$rollname.USN = v$rollstat.USN
order by v$rollname.USN;

ttitle off

TTitle left " " skip 2 - left "*** Database: "db", Rollback Segment Mapping ( As of: " tdate " ) ***" skip 2

select r.name Rollback_Name,
p.pid Oracle_PID,
p.spid VMS_PID,
nvl(p.username,'NO TRANSACTION') Transaction,
p.terminal Terminal
from v$lock l, v$process p, v$rollname r
where l.addr = p.addr(+)
and trunc(l.id1(+)/65536)=r.usn
and l.type(+) = 'TX'
and l.lmode(+) = 6
order by r.name;

ttitle off


rem -------------------------------------------------------------
rem Current Users
rem -------------------------------------------------------------

set line 132
set pagesize 66

TTitle left "*** Database: "db", Current User Info (As of: "tdate") ***" skip 1

select substr(s.username,1,15) "DB UserName",
s.osuser "OS UserName",
substr(a.object,1,25) Object,
a.type , s.command,
substr(s.machine,1,15) Machine,
substr(s.terminal,1,15) Terminal, s.process, s.status
from v$access a, v$session s
where a.sid = s.sid
order by username;

TTitle left "*** Database: "db", Current Sessions (As of: "tdate") ***" skip 1

select substr(username,1,15) "DB UserName",
substr(osuser,1,15) "OS UserName",
substr(command,1,3) CMD,
substr(machine,1,10) Machine,
terminal, process, status,
substr(program,1,50) "OS Program Name"
from v$session
where type = 'USER'
order by username;

TTitle left "*** Database: "db", Current Access (As of: "tdate") ***" skip 1

select sid,
substr(owner,1,15) Owner,
substr(object,1,25) Object,
type
from v$access
order by owner;


rem -------------------------------------------------------------
rem -------------------------------------------------------------

spool off
set feedback on

PL/SQL Procedure to write records to excel

-- This PL/SQL procedure will write records to an Excel File.
-- We will use UTL_FILE ( You need an init.ora parameter set for this to work correctly).
-- UTL_FILE allows us to write a file on the server.


create or replace
package spread_sheet as
--
type owaSylkArray is table of varchar2(2000);
--
procedure show(
sheet_file in utl_file.file_type,
sheet_query in varchar2,
sheet_parm_names in owaSylkArray default owaSylkArray(),
sheet_parm_values in owaSylkArray default owaSylkArray(),
sheet_sum_column in owaSylkArray default owaSylkArray(),
sheet_max_rows in number default 10000,
sheet_show_null_as in varchar2 default null,
sheet_show_grid in varchar2 default 'YES',
sheet_show_col_headers in varchar2 default 'YES',
sheet_font_name in varchar2 default 'Courier New',
sheet_widths in owaSylkArray default owaSylkArray(),
sheet_titles in owaSylkArray default owaSylkArray(),
sheet_strisheet_html in varchar2 default 'YES' );
--
procedure show(
sheet_filein utl_file.file_type,
sheet_cursor in integer,
sheet_sum_column in owaSylkArray default owaSylkArray(),
sheet_max_rows in number default 10000,
sheet_show_null_as in varchar2 default null,
sheet_show_grid in varchar2 default 'YES',
sheet_show_col_headers in varchar2 default 'YES',
sheet_font_name in varchar2 default 'Courier New',
sheet_widths in owaSylkArray default owaSylkArray(),
sheet_titles in owaSylkArray default owaSylkArray(),
sheet_strisheet_html in varchar2 default 'YES' );
--
end spread_sheet;
/
show error

create or replace
package body spread_sheet as
--
g_cvalue varchar2(32767);
g_desc_t dbms_sql.desc_tab;

type vc_arr is table of varchar2(2000) index by binary_integer;
g_lengths vc_arr;
g_sums vc_arr;
--
--

g_file utl_file.file_type;


procedure p( sheet_str in varchar2 )
is
begin
utl_file.put_line( g_file, sheet_str );
exception
when others then null;
end;

function build_cursor(
q in varchar2,
n in owaSylkArray,
v in owaSylkArray ) return integer is
c integer := dbms_sql.open_cursor;
i number := 1;
begin
dbms_sql.parse (c, q, dbms_sql.native);
loop
dbms_sql.bind_variable( c, n(i), v(i) );
i := i + 1;
end loop;
return c;
exception
when others then
return c;
end build_cursor;
--
--
function str_html ( line in varchar2 ) return varchar2 is
x varchar2(32767) := null;
in_html boolean := FALSE;
s varchar2(1);
begin
if line is null then
return line;
end if;
for i in 1 .. length( line ) loop
s := substr( line, i, 1 );
if in_html then
if s = '>' then
in_html := FALSE;
end if;
else
if s = '<' then
in_html := TRUE;
end if;
end if;
if not in_html and s != '>' then
x := x || s;
end if;
end loop;
return x;
end str_html;
--
function ite( b boolean,
t varchar2,
f varchar2 ) return varchar2 is
begin
if b then
return t;
else
return f;
end if;
end ite;
--
procedure print_comment( sheet_comment varchar2 ) is
begin
return;
p( ';' || chr(10) || '; ' || sheet_comment || chr(10) || ';' );
end print_comment;
--
procedure print_heading( font in varchar2,
grid in varchar2,
col_heading in varchar2,
titles in owaSylkArray )
is
l_title varchar2(2000);
begin
p( 'ID;ORACLE' );
print_comment( 'Fonts' );
p( 'P;F' || font || ';M200' );
p( 'P;F' || font || ';M200;SB' );
p( 'P;F' || font || ';M200;SUB' );
--
print_comment( 'Global Formatting' );
p( 'F;C1;FG0R;SM1' ||
ite( upper(grid)='YES', '', ';G' ) ||
ite( upper(col_heading)='YES', '', ';H' ) );
for i in 1 .. g_desc_t.count loop
p( 'F;C' || to_char(i+1) || ';FG0R;SM0' );
end loop;
--
print_comment( 'Title Row' );
p( 'F;R1;FG0C;SM2' );
for i in 1 .. g_desc_t.count loop
g_lengths(i) := g_desc_t(i).col_name_len;
g_sums(i) := 0;
begin
l_title := titles(i);
exception
when others then
l_title := g_desc_t(i).col_name;
end;
if i = 1 then
p( 'C;Y1;X2;K"' || l_title || '"' );
else
p( 'C;X' || to_char(i+1) || ';K"' || l_title || '"' );
end if;
end loop;
end print_heading;
--
function print_rows(
c in integer,
max_rows in number,
sum_columns in owaSylkArray,
show_null_as in varchar2,
strisheet_html in varchar2 ) return number is
row_cnt number := 0;
line varchar2(32767) := null;
n number;
begin
loop
exit when ( row_cnt >= max_rows or
dbms_sql.fetch_rows( c ) <= 0 );
row_cnt := row_cnt + 1;
print_comment( 'Row ' || row_cnt );
--
p( 'C;Y' || to_char(row_cnt+2) );

for i in 1 .. g_desc_t.count loop
dbms_sql.column_value( c, i, g_cvalue );
g_cvalue := translate( g_cvalue,
chr(10)||chr(9)||';', ' ' );
g_cvalue := ite( upper( strisheet_html ) = 'YES',
str_html( g_cvalue ),
g_cvalue );
g_lengths(i) := greatest( nvl(length(g_cvalue),
nvl(length(show_null_as),0)),
g_lengths(i) );
line := 'C;X' || to_char(i+1);
line := line || ';K';
begin
n := to_number( g_cvalue );
if upper( sum_columns(i)) = 'Y' then
g_sums(i) := g_sums(i) + nvl(n,0);
end if;
exception
when others then
n := null;
end;
line := line ||
ite( n is null,
ite( g_cvalue is null,
'"'||show_null_as||
'"', '"'||g_cvalue||'"' ),
n );
p( line );
end loop;
--
end loop;
return row_cnt;
end print_rows;
--
procedure print_sums(
sum_columns in owaSylkArray,
row_cnt in number ) is
begin
if sum_columns.count = 0 then
return;
end if;
--
print_comment( 'Totals Row' );
p( 'C;Y' || to_char(row_cnt + 4) );
p( 'C;X1;K"Totals:"' );
--
for i in 1 .. g_desc_t.count loop
begin
if upper(sum_columns(i)) = 'Y' then
p( 'C;X' || to_char(i+1) || ';ESUM(R3C:R' ||
to_char(row_cnt+2) || 'C)' );
end if;
exception
when others then
null;
end;
end loop;
end print_sums;
--
procedure print_widths( widths owaSylkArray ) is
begin
print_comment( 'Format Column Widths' );
p( 'F;W1 1 7' );
for i in 1 .. g_desc_t.count loop
begin
p( 'F;W' || to_char(i+1) || ' ' ||
to_char(i+1) || ' ' ||
to_char(to_number(widths(i))) );
exception
when others then
p( 'F;W' || to_char(i+1) || ' ' ||
to_char(i+1) || ' ' ||
greatest( g_lengths(i), length( g_sums(i) )));
end;
end loop;
p( 'E' );
end print_widths;
procedure show(
sheet_filein utl_file.file_type,
sheet_cursor in integer,
sheet_sum_column in owaSylkArray default owaSylkArray(),
sheet_max_rows in number default 10000,
sheet_show_null_as in varchar2 default null,
sheet_show_grid in varchar2 default 'YES',
sheet_show_col_headers in varchar2 default 'YES',
sheet_font_name in varchar2 default 'Courier New',
sheet_widths in owaSylkArray default owaSylkArray(),
sheet_titles in owaSylkArray default owaSylkArray(),
sheet_strisheet_html in varchar2 default 'YES' ) is
--
l_row_cnt number;
l_col_cnt number;
l_status number;
begin
g_file := sheet_file;
dbms_sql.describe_columns( sheet_cursor, l_col_cnt, g_desc_t );
--
for i in 1 .. g_desc_t.count loop
dbms_sql.define_column( sheet_cursor, i, g_cvalue, 32765);
end loop;
--
print_heading( sheet_font_name,
sheet_show_grid,
sheet_show_col_headers,
sheet_titles );
l_status := dbms_sql.execute( sheet_cursor );
l_row_cnt := print_rows(
sheet_cursor,
sheet_max_rows,
sheet_sum_column,
sheet_show_null_as,
sheet_strisheet_html );
print_sums( sheet_sum_column, l_row_cnt );
print_widths( sheet_widths );
end show;
--
procedure show(
sheet_filein utl_file.file_type,
sheet_query in varchar2,
sheet_parm_names in owaSylkArray default owaSylkArray(),
sheet_parm_values in owaSylkArray default owaSylkArray(),
sheet_sum_column in owaSylkArray default owaSylkArray(),
sheet_max_rows in number default 10000,
sheet_show_null_as in varchar2 default null,
sheet_show_grid in varchar2 default 'YES',
sheet_show_col_headers in varchar2 default 'YES',
sheet_font_name in varchar2 default 'Courier New',
sheet_widths in owaSylkArray default owaSylkArray(),
sheet_titles in owaSylkArray default owaSylkArray(),
sheet_strisheet_html in varchar2 default 'YES' ) is
begin
show( sheet_file => sheet_file,
sheet_cursor => build_cursor( sheet_query,
sheet_parm_names,
sheet_parm_values ),
sheet_sum_column => sheet_sum_column,
sheet_max_rows => sheet_max_rows,
sheet_show_null_as => sheet_show_null_as,
sheet_show_grid => sheet_show_grid,
sheet_show_col_headers => sheet_show_col_headers,
sheet_font_name => sheet_font_name,
sheet_widths => sheet_widths,
sheet_titles => sheet_titles,
sheet_strisheet_html => sheet_strisheet_html );
end show;
--
end spread_sheet;
/
show error
declare
l_cursor number := dbms_sql.open_cursor;
output utl_file.file_type;
begin
output := utl_file.fopen( 'c:\temp\', 'emp2.slk', 'w',32000 );

dbms_sql.parse( l_cursor,
'select empno id, ename employee,
sal Salary, comm commission ' ||
'from scott.emp ' ||
'where job = ''MANAGER'' ' ||
'and sal > 2000',
dbms_sql.native );

spread_sheet.show(
sheet_file => output ,
sheet_cursor => l_cursor,
sheet_sum_column =>
spread_sheet.owaSylkArray( 'N', 'N', 'Y', 'Y' ),
sheet_show_grid => 'NO' );
dbms_sql.close_cursor( l_cursor );
utl_file.fclose( output );
end;

Password Encrypt Query in Oracle

CREATE OR REPLACE PACKAGE ENCRY_PASS AS
FUNCTION encrypt( Str VARCHAR2 ) RETURN RAW;
FUNCTION decrypt( xCrypt VARCHAR2 ) RETURN VARCHAR2;
END ENCRY_PASS;
/

CREATE OR REPLACE PACKAGE BODY ENCRY_PASS AS
crypt_raw RAW(2000);
crypt_str VARCHAR(2000);

-- Encrypt the string --
FUNCTION encrypt( Str VARCHAR2 ) RETURN RAW AS

l INTEGER := LENGTH(str);
i INTEGER;
padblock RAW(2000);
Cle RAW(8) := UTL_RAW.CAST_TO_RAW('frankzap');

BEGIN
i := 8-MOD(l,8);
padblock := utl_raw.cast_to_raw(str||RPAD(CHR(i),i,CHR(i)));

dbms_obfuscation_toolkit.DESEncrypt(
input => padblock,
KEY => Cle,
encrypted_data => crypt_raw );
RETURN crypt_raw ;
END;

-- Decrypt the string --
FUNCTION decrypt( xCrypt VARCHAR2 ) RETURN VARCHAR2 AS
l NUMBER;
Cle RAW(8) := UTL_RAW.CAST_TO_RAW('frankzap');
crypt_raw RAW(2000) := utl_raw.cast_to_raw(utl_raw.cast_to_varchar2(xCrypt)) ;
BEGIN
dbms_obfuscation_toolkit.DESDecrypt(
input => xCrypt,
KEY => Cle,
decrypted_data => crypt_raw );
crypt_str := utl_raw.cast_to_varchar2(crypt_raw);
l := LENGTH(crypt_str);
crypt_str := RPAD(crypt_str,l-ASCII(SUBSTR(crypt_str,l)));
RETURN crypt_str;
END;
END ENCRY_PASS;
/

Locked Query Script in Oracle 10g

SELECT OBJECT_NAME, SQL_TEXT,SID, OSUSER, SCHEMANAME, RECURSIVE, LAST_CALL_ET/(60) MINUTES,
(case type when 'TM' then 'DML/TABLE LOCK'
when 'TX' then 'TRANSACTION LOCK'
when 'MR' then 'MEDIA RECOVERY'
when 'ST' then 'DISK SPACE TRANSACTION'
when 'UL' then 'USER SUPPLIED'
else 'LOCKED'
end) LOCK_TYPE,
decode(lmode,0,'NONE',1,'NULL',2,'ROW S',3,'ROW X',4,'TABLE S',5,'SHARED ROW X',6,'TABLE X',NULL) LOCK_MODE,
decode(REQUEST,0,'NONE',1,'NULL',2,'ROW S',3,'ROW X',4,'TABLE S',5,'SHARED ROW X',6,'TABLE X',NULL) REQUEST, CTIME/(60) LOCKED_SINCE_MIN
FROM V$TRANSACTION JOIN V$SESSION ON SADDR = SES_ADDR JOIN V$LOCK USING (SID)
JOIN V$SQLAREA ON ADDRESS = PREV_SQL_ADDR AND HASH_VALUE = PREV_HASH_VALUE
JOIN V$LOCKED_OBJECT ON SID=SESSION_ID
JOIN DBA_OBJECTS USING (OBJECT_ID)

Locked Query Script in Oracle 9i

SELECT OBJECT_NAME, SID, OSUSER, SCHEMANAME, RECURSIVE, LAST_CALL_ET/(60) MINUTES,
(case type when 'TM' then 'DML/TABLE LOCK'
when 'TX' then 'TRANSACTION LOCK'
when 'MR' then 'MEDIA RECOVERY'
when 'ST' then 'DISK SPACE TRANSACTION'
when 'UL' then 'USER SUPPLIED'
else 'LOCKED'
end) LOCK_TYPE,
decode(lmode,0,'NONE',1,'NULL',2,'ROW S',3,'ROW X',4,'TABLE S',5,'SHARED ROW X',6,'TABLE X',NULL) LOCK_MODE,
decode(REQUEST,0,'NONE',1,'NULL',2,'ROW S',3,'ROW X',4,'TABLE S',5,'SHARED ROW X',6,'TABLE X',NULL) REQUEST,
CTIME/(60) LOCKED_SINCE_MIN,SQL_TEXT
FROM V$TRANSACTION JOIN V$SESSION ON SADDR = SES_ADDR JOIN V$LOCK USING (SID)
JOIN V$SQLAREA ON HASH_VALUE = SQL_HASH_VALUE AND SQL_ADDRESS = ADDRESS
JOIN V$LOCKED_OBJECT ON SID=SESSION_ID
JOIN DBA_OBJECTS USING (OBJECT_ID)

Detailed Lock Scripts in Oracle

prompt "Identify the blocking session"
prompt "================================================="

select * from v$lock ;

prompt ""
prompt ""
prompt ""
prompt "Note the BLOCK column. If a session holds a lock that's blocking another session, BLOCK=1."
prompt "Further, you can tell which session is being blocked by comparing the values in ID1 and ID2."
prompt "The blocked session will have the same values in ID1 and ID2 as the blocking session,"
prompt "and, since it is requesting a lock it's unable to get, it will have REQUEST > 0."
prompt ""
prompt ""

prompt "================================================="
prompt "Detailed View"
prompt "================================================="

select l1.sid, ' IS BLOCKING ', l2.sid
from v$lock l1, v$lock l2
where l1.block =1 and l2.request > 0
and l1.id1=l2.id1
and l1.id2=l2.id2;

prompt ""
prompt ""
prompt "================================================="
prompt "Readable View"
prompt "================================================="


select s1.username || '@' || s1.machine|| ' ( SID=' || s1.sid || ' ) is blocking '|| s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
from v$lock l1, v$session s1, v$lock l2, v$session s2
where s1.sid=l1.sid and s2.sid=l2.sid
and l1.BLOCK=1 and l2.request > 0
and l1.id1 = l2.id1
and l2.id2 = l2.id2 ;

performance shared pool Script in Oracle

select 'Ratio Should be < 15%' from dual; select sum(getmisses), sum(gets) , (sum(getmisses) * 100)/sum(gets) "Misses To Gets Ratio" from v$rowcache select parameter, getmisses, gets from v$rowcache; select sum(pins), sum(reloads) , sum(reloads) / sum(pins) * 100 "Reload Ratio" from v$librarycache select 'GETHITRATIO should be high > 90%' from dual

select sum(pinhits)/sum(pins) "lib cache hit ratio" from v$librarycache

select namespace
, gethitratio
, pinhitratio
, reloads
, invalidations
from v$librarycache

select pool, name, bytes/(1024*1024) from v$sgastat where pool = 'shared pool' and name = 'free memory'
select * from v$sqlarea where parse_calls != executions
select * from v$sqlarea where sql_text like '%v$sqlarea%'
select * from v$sysstat where name like '%parse%'
select * from v$sysstat where name in ('parse count (total)','execute count')
select * from v$sysstat where name in ('parse time cpu','CPU used by this session')
select * from v$sysstat where name like '%sort%'

select * from v$statname

select * from v$sgastat

SELECT NAME, PHYSICAL_READS, DB_BLOCK_GETS, CONSISTENT_GETS,
1 - (PHYSICAL_READS / (DB_BLOCK_GETS + CONSISTENT_GETS)) "Hit Ratio"
FROM V$BUFFER_POOL_STATISTICS

select owner, object_name, count(*) from v$bh ,dba_objects where objd = object_id and
owner not in ('SYS','SYSTEM')
and owner = 'HCLT43_PERF'
group by cube(owner, object_name)
order by 1,3,2 desc

Differences between weblogic Versions 8 Vs 9/10

Weblogic 8
Weblogic 9/10
Console is an applet and uses JCX JCS JPF and Netui page flows Console is portal and uses JSTL (JSP 2.0)
No folder called config Folder called config is available
No Prepare state for application. Only active state Prepare state for application, This optimises memory utilization.
No app inf lib and classes App inf lib and app inf classes are added
Persistant store is defined Under JMS Persistant store is defined Under JDBC
We have connection pools and datasources We have datasources and connection pools are inside datasources.
We have exclude queues. We have work managers
No lock and edit Lock and edit is the new feature
We need to delete and redeploy from admin console We can update the application using admin console
All configuration information is in one config.xml Seperate xml files for domain config and jms modules are added
No concept of JMS modules and sub deployments Jms modules and subdeployments are included.
Queue/topic is configured under distributed destination Queue/topic/dd etc are all clubbed in a JMS modules
Side by site deployment is not possible Side by side deployment is possible
Server dosent come up if deployment fails Server boots in ADMIN mode if deployment failes

AIX Detailed Commands

As you know, AIX® has a vast array of commands that enable you to do a multitude of tasks. Depending on what you need to accomplish, you use only a certain subset of these commands. These subsets differ from user to user and from need to need. However, there are a few core commands that you commonly use. You need these commands either to answer your own questions or to provide answers to the queries of the support professionals.
In this article, I'll discuss some of these core commands. The intent is to provide a list that you can use as a ready reference. While the behavior of these commands should be identical in all releases of AIX, they have been only tested under AIX 5.3.
Note:
The
bootinfo command discussed in the following paragraphs is NOT a user-level command and is NOT supported in AIX 4.2 or later.


How would I know if I am running a 32-bit kernel or 64-bit kernel?
To display if the kernel is 32-bit enabled or 64-bit enabled, type:
bootinfo –K
How do I know if I am running a uniprocessor kernel or a multiprocessor kernel?
/unix is a symbolic link to the booted kernel. To find out what kernel mode is running, enter ls -l /unix and see what file /unix it links to. The following are the three possible outputs from the ls -l /unix command and their corresponding kernels:
/unix -> /usr/lib/boot/unix_up # 32 bit uniprocessor kernel
/unix -> /usr/lib/boot/unix_mp # 32 bit multiprocessor kernel
/unix -> /usr/lib/boot/unix_64 # 64 bit multiprocessor kernel
Note:
AIX 5L Version 5.3 does not support a uniprocessor kernel.
How can I change from one kernel mode to another?
During the installation process, one of the kernels, appropriate for the AIX version and the hardware in operation, is enabled by default. Let us use the method from the previous question and assume the 32-bit kernel is enabled. Let us also assume that you want to boot it up in the 64-bit kernel mode. This can be done by executing the following commands in sequence:
ln -sf /usr/lib/boot/unix_64 /unix
ln -sf /usr/lib/boot/unix_64 /usr/lib/boot/unix
bosboot -ad /dev/hdiskxx
shutdown -r
The /dev/hdiskxx directory is where the boot logical volume /dev/hd5 is located. To find out what xx is in hdiskxx, run the following command:
lslv -m hd5
Note:
In AIX 5.2, the 32-bit kernel is installed by default. In AIX 5.3, the 64-bit kernel is installed on 64-bit hardware and the 32-bit kernel is installed on 32-bit hardware by default.
How would I know if my machine is capable of running AIX 5L Version 5.3?
AIX 5L Version 5.3 runs on all currently supported CHRP (Common Hardware Reference Platform)-based POWER hardware.
How would I know if my machine is CHRP-based?
Run the prtconf command. If it's a CHRP machine, the string chrp appears on the Model Architecture line.
How would I know if my System p machine (hardware) is 32-bit or 64-bit?
To display if the hardware is 32-bit or 64-bit, type:
bootinfo -y
How much real memory does my machine have?
To display real memory in kilobytes (KB), type one of the following:
bootinfo -r

lsattr -El sys0 -a realmem
Can my machine run the 64-bit kernel?
64-bit hardware is required to run the 64-bit kernel.
What are the values of attributes for devices in my system?
To list the current values of the attributes for the tape device, rmt0, type:
lsattr -l rmt0 -E
To list the default values of the attributes for the tape device, rmt0, type:
lsattr -l rmt0 -D
To list the possible values of the login attribute for the TTY device, tty0, type:
lsattr -l tty0 -a login -R
To display system level attributes, type:
lsattr -E -l sys0
How many processors does my system have?
To display the number of processors on your system, type:
lscfg | grep proc
How many hard disks does my system have and which ones are in use?
To display the number of hard disks on your system, type:
lspv
How do I list information about a specific physical volume?
To find details about hdisk1, for example, run the following command:
lspv hdisk1
How do I get a detailed configuration of my system?
Type the following:
lscfg
The following options provide specific information:
-p
Displays platform-specific device information. The flag is applicable to AIX 4.2.1 or later.
-v
Displays the VPD (Vital Product Database) found in the customized VPD object class.
For example, to display details about the tape drive, rmt0, type:
lscfg -vl rmt0
You can obtain very similar information by running the prtconf command.
How do I find out the chip type, system name, node name, model number, and so forth?
The uname command provides details about your system.
uname -p
Displays the chip type of the system. For example, PowerPC.
uname -r
Displays the release number of the operating system.
uname -s
Displays the system name. For example, AIX.
uname -n
Displays the name of the node.
uname -a
Displays the system name, nodename, version, machine ID.
uname -M
Displays the system model name. For example, IBM, 9114-275.
uname -v
Displays the operating system version.
uname -m
Displays the machine ID number of the hardware running the system.
uname -u
Displays the system ID number.
What version, release, and maintenance level of AIX is running on my system?
Type one of the following:
oslevel -r
lslpp -h bos.rte
How can I determine which fileset updates are missing from a particular AIX level?
To determine which fileset updates are missing from 5300-04, for example, run the following command:
oslevel -rl 5300-04
What SP (Service Pack) is installed on my system?
To see which SP is currently installed on the system, run the oslevel -s command. Sample output for an AIX 5L Version 5.3 system, with TL4, and SP2 installed would be:
oslevel –s
5300-04-02
Is a CSP (Concluding Service Pack) installed on my system?
To see if a CSP is currently installed on the system, run the oslevel -s command. Sample output for an AIX 5L Version 5.3 system, with TL3, and CSP installed would be:
oslevel –s
5300-03-CSP
How do I create a file system?
The following command will create, within volume group testvg, a jfs file system of 10MB with mounting point /fs1:
crfs -v jfs -g testvg -a size=10M -m /fs1
The following command will create, within volume group testvg, a jfs2 file system of 10MB with mounting point /fs2 and having read only permissions:
crfs -v jfs2 -g testvg -a size=10M -p ro -m /fs2
How do I change the size of a file system?
To increase the /usr file system size by 1000000 512-byte blocks, type:
chfs -a size=+1000000 /usr
Note:
In AIX 5.3, the size of a JFS2 file system can be shrunk as well.
How do I mount a CD?
Type the following:
mount -V cdrfs -o ro /dev/cd0 /cdrom
How do I mount a file system?
The following command will mount file system /dev/fslv02 on the /test directory:
mount /dev/fslv02 /test
How do I mount all default file systems (all standard file systems in the /etc/filesystems file marked by the mount=true attribute)?
The following command will mount all such file systems:
mount {-a|all}
How do I unmount a file system?
Type the following command to unmount /test file system:
umount /test
How do I display mounted file systems?
Type the following command to display information about all currently mounted file systems:
mount
How do I remove a file system?
Type the following command to remove the /test file system:
rmfs /test
How can I defragment a file system?
The defragfs command can be used to improve or report the status of contiguous space within a file system. For example, to defragment the file system /home, use the following command:
defragfs /home
Which fileset contains a particular binary?
To show bos.acct contains /usr/bin/vmstat, type:
lslpp -w /usr/bin/vmstat
Or to show bos.perf.tools contains /usr/bin/svmon, type:
which_fileset svmon
How do I display information about installed filesets on my system?
Type the following:
lslpp -l
How do I determine if all filesets of maintenance levels are installed on my system?
Type the following:
instfix -i | grep ML
How do I determine if a fix is installed on my system?
To determine if IY24043 is installed, type:
instfix -ik IY24043
How do I install an individual fix by APAR?
To install APAR IY73748 from /dev/cd0, for example, enter the command:
instfix -k IY73748 -d /dev/cd0
How do I verify if filesets have required prerequisites and are completely installed?
To show which filesets need to be installed or corrected, type:
lppchk -v
How do I get a dump of the header of the loader section and the symbol entries in symbolic representation?
Type the following:
dump -Htv
How do I determine the amount of paging space allocated and in use?
Type the following:
lsps -a
How do I increase a paging space?
You can use the chps -s command to dynamically increase the size of a paging space. For example, if you want to increase the size of hd6 with 3 logical partitions, you issue the following command:
chps -s 3 hd6
How do I reduce a paging space?
You can use the chps -d command to dynamically reduce the size of a paging space. For example, if you want to decrease the size of hd6 with four logical partitions, you issue the following command:
chps -d 4 hd6
How would I know if my system is capable of using Simultaneous Multi-threading (SMT)?
Your system is capable of SMT if it's a POWER5-based system running AIX 5L Version 5.3.
How would I know if SMT is enabled for my system?
If you run the smtctl command without any options, it tells you if it's enabled or not.
Is SMT supported for the 32-bit kernel?
Yes, SMT is supported for both 32-bit and 64-bit kernel.
How do I enable or disable SMT?
You can enable or disable SMT by running the smtctl command. The following is the syntax:
smtctl [ -m off | on [ -w boot | now]]
The following options are available:
-m off
Sets SMT mode to disabled.
-m on
Sets SMT mode to enabled.
-w boot
Makes the SMT mode change effective on next and subsequent reboots if you run the bosboot command before the next system reboot.
-w now
Makes the SMT mode change immediately but will not persist across reboot.
If neither the -w boot or the -w now options are specified, then the mode change is made immediately. It persists across subsequent reboots if you run the bosboot command before the next system reboot.
How do I get partition-specific information and statistics?
The lparstat command provides a report of partition information and utilization statistics. This command also provides a display of Hypervisor information.
How do I know if my volume group is normal, big, or scalable?
Run the lsvg command on the volume group and look at the value for MAX PVs. The value is 32 for normal, 128 for big, and 1024 for scalable volume group.
How to create a volume group?
Use the following command, where spartition_size sets the number of megabytes (MB) in each physical partition where the partition_size is expressed in units of MB from 1 through 1024. (It's 1 through 131072 for AIX 5.3.) The partition_size variable must be equal to a power of 2 (for example: 1, 2, 4, 8). The default value for standard and big volume groups is the lowest value to remain within the limitation of 1016 physical partitions per physical volume. The default value for scalable volume groups is the lowest value to accommodate 2040 physical partitions per physical volume.
mkvg -y name_of_volume_group -s partition_size list_of_hard_disks
How can I change the characteristics of a volume group?
You use the following command to change the characteristics of a volume group:
chvg
How do I create a logical volume?
Type the following:
mklv -y name_of_logical_volume name_of_volume_group number_of_partition
How do I increase the size of a logical volume?
To increase the size of the logical volume represented by the lv05 directory by three logical partitions, for example, type:
extendlv lv05 3
How do I display all logical volumes that are part of a volume group (for example, rootvg)?
You can display all logical volumes that are part of rootvg by typing the following command:
lsvg -l rootvg
How do I list information about logical volumes?
Run the following command to display information about the logical volume lv1:
lslv lv1
How do I remove a logical volume?
You can remove the logical volume lv7 by running the following command:
rmlv lv7
The rmlv command removes only the logical volume, but does not remove other entities, such as file systems or paging spaces that were using the logical volume.
How do I mirror a logical volume?
  1. mklvcopy LogicalVolumeName Numberofcopies
  2. syncvg VolumeGroupName
How do I remove a copy of a logical volume?
You can use the rmlvcopy command to remove copies of logical partitions of a logical volume. To reduce the number of copies of each logical partition belonging to logical volume testlv, enter:
rmlvcopy testlv 2
Each logical partition in the logical volume now has at most two physical partitions.
Queries about volume groups
To show volume groups in the system, type:
lsvg
To show all the characteristics of rootvg, type:
lsvg rootvg
To show disks used by rootvg, type:
lsvg -p rootvg
How to add a disk to a volume group?
Type the following:
extendvg VolumeGroupName hdisk0 hdisk1 ... hdiskn
How do I find out what the maximum supported logical track group (LTG) size of my hard disk?
You can use the lquerypv command with the -M flag. The output gives the LTG size in KB. For instance, the LTG size for hdisk0 in the following example is 256 KB.
/usr/sbin/lquerypv -M hdisk0
256
You can also run the lspv command on the hard disk and look at the value for MAX REQUEST.
What does syncvg command do?
The syncvg command is used to synchronize stale physical partitions. It accepts names of logical volumes, physical volumes, or volume groups as parameters.
For example, to synchronize the physical partitions located on physical volumes hdisk6 and hdisk7, use:
syncvg -p hdisk4 hdisk5
To synchronize all physical partitions from volume group testvg, use:
syncvg -v testvg
How do I replace a disk?
  1. extendvg VolumeGroupName hdisk_new
  2. migratepv hdisk_bad hdisk_new
  3. reducevg -d VolumeGroupName hdisk_bad
How can I clone (make a copy of ) the rootvg?
You can run the alt_disk_copy command to copy the current rootvg to an alternate disk. The following example shows how to clone the rootvg to hdisk1.
alt_disk_copy -d hdisk1
How can I display or set values for network parameters?
The no command sets or displays current or next boot values for network tuning parameters.
How do I get the IP address of my machine?
Type one of the following:
ifconfig -a
host Fully_Qualified_Host_Name
For example, type host cyclop.austin.ibm.com.
How do I identify the network interfaces on my server?
Either of the following two commands will display the network interfaces:
lsdev -Cc if
ifconfig -a
To get information about one specific network interface, for example, tr0, run the command:
ifconfig tr0
How do I activate a network interface?
To activate the network interface tr0, run the command:
ifconfig tr0 up
How do I deactivate a network interface?
For example, to deactivate the network interface tr0, run the command:
ifconfig tr0 down


Admittedly, a list such as this can be helpful in quickly answering some of your own questions. However, it does not cover everything that you might need. You can extend the usefulness of such a list by adding other commands that answer additional questions not addressed here.
Powered by Blogger