[ale] SHELL: log files monitoring

Danny Cox danscox at mindspring.com
Thu Feb 14 15:37:00 EST 2002


Andy,

On Thu, 2002-02-14 at 14:43, Zyman, Andy wrote:
> I have Oracle Db and I'm monitoring alert<sid>.log ( it's the output of what
> happenning to instance (db) ).
>  I just want to see if db:
>  was shutting down - shoot email do dba,
>  up - email. 
>  "Alter database" statemnet - email. this kind of action.

	Well, if you could create named pipes (fifos) instead of files named
'alert<sid>.log', you could use 'tee' to log it into a regular file, and
then pass it on to various proggies to look for your patterns.  A Perl
or Python script hanging off the end seems quite appropriate for this.

	Failing that, then your idea of tail -f works just fine.  But feeding
it to a script program would give you maximum flexibility.

	For example:

		while (<>) {
			if (/Alter database/) {
				send_grump_email ("Joey's monkeying with the database again");
				UPS_send_msg ("SHUTDOWN NOW");
				system ("wall 'blame Joey'");
			}
		}

	You may also consider consolidating the streams.  While you need one
'tail -f' per file, you only need one scanner.  So something like:

	(
		for i in $*
		do
			tail -f $i
		done &
	) | scanner

could do the trick, I think.  Output *could* be intermingled, of course,
but if you don't care, it saves processes.

-- 
kernel, n.: A part of an operating system that preserves the
medieval traditions of sorcery and black art.

Danny


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list