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
- Jared Still <jkstill_at_bcbso.com> wrote:
> On Sat, 11 Nov 2000, yong huang wrote:
>
> > I know the command "fuser somefile" reports what processes are accessing
> > somefile. Is there a way to continue monitoring this so it won't exit at
> the
> > initial detection? I'd like to see the output like "tail -f somelogfile". I
> > don't think wrapping this in a shell infinite loop is an option because (1)
> if
> > you don't use sleep in the loop, it hogs CPU; (2) if you do, there's too
> much
> > gap between two fuser calls.
> >
> > Yong Huang
> > yong321_at_yahoo.com
> >
>
> 1 second between calls to fuser via 'sleep 1' seems reasonable.
>
> If you need more granularity, and your system supports high
> resolution timers, here's an example of one that will time
> in nano-seconds.
>
>
> #include <sys/time.h>
> #include <stdio.h>
>
> void main ( int argc, char *argv[] ) {
> hrtime_t start, end;
> int i;
>
> i = argv[1] == NULL ? 200000000 : atoi(argv[1]);
>
> printf("Nanoseconds: %i nsec\n", i);
>
> start = gethrtime();
>
> printf("Start: %lld nsec\n", start);
>
> for (;;) {
> end = gethrtime();
> if ( ( end - start ) >= i ) { break; }
> }
>
> printf("End: %lld nsec\n", end);
>
>
> }
>
>
>
> Jared Still
> Certified Oracle DBA and Part Time Perl Evangelist ;-)
> Regence BlueCross BlueShield of Oregon
> jkstill_at_bcbso.com - Work - preferred address
> jkstill_at_teleport.com - private
>
>
Do You Yahoo!?
Yahoo! Calendar - Get organized for the holidays!
Received on Tue Nov 14 2000 - 17:04:00 CST