Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to continue monitoring file access (sleep nanoseconds exa
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
Start: 4141823294742732 nsec
End : 4141824396675004 nsec
real 1.115 user 0.003 sys 0.007
open("/usr/lib/libkstat.so.1", O_RDONLY) = 4 fstat(4, 0xFFBEF05C) = 0
open("/usr/lib/libc.so.1", O_RDONLY) = 4 fstat(4, 0xFFBEF05C) = 0
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("/usr/lib/libdl.so.1", O_RDONLY) = 4 fstat(4, 0xFFBEF05C) = 0
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
-----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 itdoesn't
> (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 inReceived on Wed Nov 15 2000 - 13:20:57 CST