Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to continue monitoring file access (sleep nanoseconds exa

RE: How to continue monitoring file access (sleep nanoseconds exa

From: Brian MacLean <BMacLean_at_Homebid.com>
Date: Wed, 15 Nov 2000 12:20:57 -0700
Message-Id: <10681.122153@fatcity.com>


Maybe not perfect, but it seams to work (example 1). If you are looking at trying a roll-your-own fuser, might I suggest using truss on fuser as a starting point (example 2.

$
$ uname -a

SunOS dev1 5.7 Generic_106541-10 sun4u sparc SUNW,Ultra-250
$
$ cat ntime2.c

#include <sys/time.h>
#include <stdio.h>

main ( int argc, char *argv[] )
{

	hrtime_t start, end;
	long i;
      struct timespec rqtp;

	i = argv[1] == NULL ? 200000000 : atol(argv[1]);

	printf("Nanoseconds: %i nsec\n", i);

	start = gethrtime();
	printf("\nStart: %lld nsec\n", start);

      rqtp.tv_sec  = i / (unsigned long)  1000000;
      rqtp.tv_nsec = (i % (unsigned long) 1000000) * 1000 ;
      if (nanosleep(&rqtp,  (struct  timespec *) NULL) == -1)
        perror("nanosleep");

      end = gethrtime();
      printf("End  : %lld nsec\n", end);

      return (0);

}
/*
$
$
$ gcc -o ntime2 ntime2.c -lrt
$
$ ptime ntime2 100000

Nanoseconds: 100000 nsec

Start: 4141803413296166 nsec
End : 4141803516518404 nsec

real        0.116
user        0.003
sys         0.007

$ ptime ntime2 1100000

Nanoseconds: 1100000 nsec

Start: 4141823294742732 nsec
End : 4141824396675004 nsec

real        1.115
user        0.003
sys         0.007

$
$
$
$ fuser listener.log

listener.log: 12946o
$
$ ps -ef | grep 12946

  oracle 12946 1 0 15:29:54 ? 0:04 /export/home/oracle/app/product/8.1.5/bin/tnslsnr LISTENER -inherit
$
$ truss fuser listener.log

execve("/usr/sbin/fuser", 0xFFBEF4C4, 0xFFBEF4D0) argc = 2 open("/dev/zero", O_RDONLY) = 3
mmap(0x00000000, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xFF3A0000
open("/export/home/oracle/app/product/8.1.5/lib/libkstat.so.1", O_RDONLY) Err#2 ENOENT
open("/usr/lib/libkstat.so.1", O_RDONLY)	= 4
fstat(4, 0xFFBEF05C)				= 0

mmap(0x00000000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0xFF390000 mmap(0x00000000, 73728, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0xFF370000 munmap(0xFF372000, 57344) = 0
mmap(0xFF380000, 4528, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 4, 0) = 0xFF380000 close(4) = 0
open("/export/home/oracle/app/product/8.1.5/lib/libc.so.1", O_RDONLY) Err#2 ENOENT
open("/usr/lib/libc.so.1", O_RDONLY)		= 4
fstat(4, 0xFFBEF05C)				= 0

mmap(0xFF390000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 4, 0) = 0xFF390000
mmap(0x00000000, 770048, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0xFF280000
munmap(0xFF324000, 57344) = 0
mmap(0xFF332000, 31788, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED, 4, 663552) = 0xFF332000
mmap(0xFF33A000, 5520, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xFF33A000
close(4)					= 0

open("/export/home/oracle/app/product/8.1.5/lib/libdl.so.1", O_RDONLY) Err#2 ENOENT
open("/usr/lib/libdl.so.1", O_RDONLY)		= 4
fstat(4, 0xFFBEF05C)				= 0

mmap(0xFF390000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 4, 0) = 0xFF390000
close(4) = 0
open("/usr/platform/SUNW,Ultra-250/lib/libc_psr.so.1", O_RDONLY) = 4 fstat(4, 0xFFBEEE3C) = 0
mmap(0x00000000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0xFF360000 mmap(0x00000000, 16384, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0xFF350000
close(4)					= 0
close(3)					= 0
munmap(0xFF360000, 8192)			= 0
open("/dev/kstat", O_RDONLY)			= 3
brk(0x000218D0)					= 0
brk(0x000238D0)					= 0
ioctl(3, KSTAT_IOC_CHAIN_ID, 0x00000000)	= 997
ioctl(3, KSTAT_IOC_READ, "kstat_headers")	Err#12 ENOMEM
brk(0x000238D0)					= 0
brk(0x0002D8D0)					= 0
ioctl(3, KSTAT_IOC_READ, "kstat_headers")	= 997
brk(0x0002D8D0)					= 0
brk(0x0002F8D0)					= 0
brk(0x0002F8D0)					= 0
brk(0x000318D0)					= 0
brk(0x000318D0)					= 0
brk(0x000338D0)					= 0
brk(0x000338D0)					= 0
brk(0x000358D0)					= 0
brk(0x000358D0)					= 0
brk(0x000378D0)					= 0
ioctl(3, KSTAT_IOC_READ, "var")			= 997
close(3)					= 0
brk(0x000378D0)					= 0
brk(0x000398D0)					= 0
listener.logwrite(2, " l i s t e n e r . l o g", 12)	= 12
: write(2, " :  ", 2)				= 2
open("/etc/mnttab", O_RDONLY)			= 3
stat64("listener.log", 0xFFBEF2D0)		= 0
fstat64(3, 0xFFBEF0B0)				= 0
brk(0x000398D0)					= 0
brk(0x0003B8D0)					= 0
ioctl(3, TCGETA, 0xFFBEF03C)			Err#25 ENOTTY
read(3, " / p r o c\t / p r o c\t".., 8192)	= 2871
read(3, 0x000396AC, 8192)			= 0
llseek(3, 0, SEEK_CUR)				= 2871
close(3)					= 0
utssys("listener.log", 0x0000, FUSERS, 0x00021EE0) = 1
ioctl(1, TCGETA, 0xFFBEE4D4)			= 0
   12946write(1, "       1 2 9 4 6", 8)			= 8
owrite(2, " o", 1)				= 1

write(2, "\n", 1)				= 1
llseek(0, 0, SEEK_CUR)				= 481134

_exit(0)
$

-----Original Message-----
From: Jared Still [mailto:jkstill_at_bcbso.com] Sent: Wednesday, November 15, 2000 9:10 AM To: Multiple recipients of list ORACLE-L Subject: Re: How to continue monitoring file access (Was: Problem solved, but WHY??? (Long))

On Tue, 14 Nov 2000, yong huang wrote:

> Thanks, Jared.
> 
> gethrtime() is going to use a lot CPU, isn't it? What I really want is to
> capture fuser or lsof output absolutely without a single miss and it
doesn't
> use much CPU. I hope there's a way to tell fuser that whenever a file (such as
> sqlnet.ora) is read by a process, fuser writes the process info to a log file
> (or a pipe we create) so we can tail -f that_log_file.
> 
> Yong Huang
> yong321_at_yahoo.com
> 

There's also the 'nanosleep' call, but I couldn't get it to work right. ( I'm not a C programmer )

For what you are asking, you probably need to write your own code to read the process table.

Depending on platform, you may even be able to do it in Perl via the Proc::ProcessTable module.

Jared

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jared Still
  INET: jkstill_at_bcbso.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
Received on Wed Nov 15 2000 - 13:20:57 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US