Wednesday, June 30, 2010

Joining Lines

This is a handy way to join text on seperate lines:-

$ srvctl config
DZHRAC10
DZHRAC20
DZHRAC30
DZHRON10
DZHRON20

$ srvctl config awk '{printf $0 " "}'
DZHRAC10 DZHRAC20 DZHRAC30 DZHRON10 DZHRON20

Tuesday, June 29, 2010

The number of virtual CPU's in a Solaris Server

A colleague asked me this question, after a read of the man page for psrinfo, came up with the following commands. The -p gives a count and -pv gives more information.

su78sr28# psrinfo -p
1

su78sr28# psrinfo -pv
The physical processor has 64 virtual processors (0-63)
UltraSPARC-T2 (chipid 0, clock 1415 MHz)

Tuesday, June 22, 2010

Finding process syscalls and times

$ ./procsystime -eT find /cs/oracle/product -name orapwDZHRAC10 -ls
124566 1 lrwxrwxrwx 1 oracle oinstall 38 Jun 7 09:39 /cs/oracle/product/11.2.0.1/dbs/orapwDZHRAC10 -> /dev/oracle/dbpw.500F3AB16FB.100.0.lun
Elapsed Times for command find /cs/oracle/product -name orapwDZHRAC10 -ls,
SYSCALL TIME (ns)
getrlimit 7778
getpid 9588
gtime 11216
chdir 15558
setcontext 15919
getuid 22160
readlink 27950
open64 39075
getcwd 40614
brk 60876
ioctl 62593
write 64493
read 69016
munmap 79961
acl 113518
pathconf 159830
stat64 175840
resolvepath 192936
memcntl 236985
open 261320
doorfs 306726
mmap 716657
fcntl 25747535
close 40922114
fsat 69467272
fchdir 75380605
fstat64 79424661
getdents64 200178852
lstat64 826298914
TOTAL: 1320110562

Friday, May 14, 2010

My 1st Dtrace script!

Dtracing the oracle user to see what whacky commands it lauches at crsctl stop/start:

argsnoop.d -->
#!/usr/bin/sh

/usr/sbin/dtrace -wn '

inline int OPT_timestr = '1';

#pragma D option quiet
#pragma D option switchrate=10

syscall::exec:return, syscall::exece:return
/uid == 900/
{
OPT_timestr ? printf("%-20Y ", walltimestamp) : 1;
stop();
system("pargs -l %d", pid);
system("prun %d", pid);
}
'

Wednesday, July 01, 2009

Calculating the size of an object

really easy:

select segment_name, segment_type, bytes/1024/1024 as "MEGABYTES"
from dba_segments
where owner = 'SIEBEL'
and segment_name = 'S_EVT_ACT'

Friday, June 19, 2009

Logon Trigger Trace

Generate 10046 level 12 traces when you can't do them in session with:

DROP TRIGGER SYS.ON_LOGON_TRACE;

CREATE OR REPLACE TRIGGER SYS.ON_LOGON_TRACE
AFTER LOGON ON DATABASE
WHEN (
USER = 'AGR55'
)
BEGIN
execute immediate 'alter session set events ''10046 trace name context forever, level 12''';
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
/

ALTER TRIGGER SYS.ON_LOGON_TRACE DISABLE;

Thursday, June 18, 2009

Generating CPU activity

sometimes you might want to generate some cpu activity, to maybe test a new CPU or check performance scripts etc.

On the command line:

while :
do
:
done

or:

while true
do
cat /dev/urandon >/dev/null
done

and then use mpsched to assign a cpu to the process:

mpsched -c /usr/bin/cat /dev/urandom > /dev/null &

or in c:

#include
#include
main()
{
int i=0;
float X[1024],Y[1024];

while (1)
{

for(i=0;i<1024;i++)
{
X[i]=1;
Y[i]=X[i] * M_PI; # M_PI is defined in /usr/include/math.h
}
}
}