iptrigger (Sat Oct 25 2014 01:31:01)

iptrigger

This program walks a queue (and all its subqueues up to 25 levels) and checks
for new files, changes and deletions.

It can then be used to start another program or script accordingly.

The whole process is repeated every 5 minutes - changeable by the -w input
switch.

It uses a parameter file, tables/setup/TRIGGER by default, to determine which
script to run. The syntax of the parameter file is :

	; comment line is any with a leading semi-colon
	new: (program/script with all its switches)
		Script to run for a NEW file found		default: none
	chg: (program/script with all its switches)
		Script to run for a file that has been ALTERED.	default: none
		This can sometimes also be a new file if the file is opened and written
		to only after a delay.
	del: (program/script with all its switches)
		Script to run for a file is deleted		default: none
	read: (program/script with all its switches)
		Script to run for a file has been READ		default: none
		(unix only ..)
	include-file-mask: (FipSeq string)
		Allow only files containing this string		default: all files
	exclude-file-mask: (FipSeq string)
		Ignore files containing this string		default: exclude none
		eg:	exclude-file-mask:.lock
	include-dir-mask: (FipSeq string)
		Search only queues containing this string	default: all queues
	exclude-dir-mask: (FipSeq string)
		Ignore queues containing this string		default: exclude none
		eg:	exclude-dir-mask:.lock
	case-sensitive-mask:yes/no				default: no
		is the Mask case-sensitive
	locale: (name)						default: locale of the server
		change the default locale.  The locale MUST be valid !
		eg	locale:dk
	chkexists: (Full Path/file or queuename)		default: none
	chkexists-timeout: (time between trying/logging if path is not there) defauly:
60 secs
		Use these for NAS/non-local drives which may disappear from time to time.
		This is a complete pathname of either a standing file or a queue. This is
used to check that NFS drives are actually mounted BEFORE writing new files.
		eg : chkexists:/data1/nfs/helios/.Desktop
		For Win, use fwd slashes '/' rather than '' make the string much easier to
read !!
		chkexists://195.13.83.99/d$/.DSstore


	max-level: (number)					default: all
		Normally iptriggers walks the subqueues. This allows a limit (up to 25).
		Level 1 is the top folder, level 2 one level down etc

	log-line: (FipSeq String)
		log message to add to default

--------- Running redundant iptrigger on two Fip systems looking at the same
NAS drive
	check-primary-server: pseudo-host name that is specified in
tables/sys/DEST_REDUN
		that is used whether the current host should be getting the files or not.
		ie	check-primary-server:remotewire
		and in the DEST_REDUN is
			; psuedohost	primary secondary
			remotewire	fip1	fip2
		Then if fip1 is up, the 'nntpwire' on fip1 will always get while on fip2 it
will just check/loop.
			if fip1 is down, the 'nntpwire' on fip2 will start getting.
	balance-group: name of a balance group (in tables/sys/BALANCE) to distribute
the current state file (in /fip/fix) when changed (see doc on 'ipbalan')
		This is often used where a second system could be used as a redundant server
if the main system fails.
	balance-folder: name of the folder (in spool) where ipbalan is running	default
2balance

	example of a balance group
		balance-group:baltrigger
	and the sys/BALANCE file might have :
		group:baltrigger	host:fip1  ignore-localhost:	nofiphdr:
		group:baltrigger	host:fip2  ignore-localhost:	nofiphdr:

Note that
	Only one include-file OR exclude-file is allowed
	Only one include-dir  OR exclude-dir  is allowed

Note that
	Only one of the NEW/CHG/READ scripts will be run at any one time.

Example:
;
new:/fip/local/oinky -1 EQ/EN -ADD
chg:/fip/local/oinky -1 EQ/EN -CHG

Note that FipSeq can be added for runtime information. For each file the
follwoing FipHdr fields are filled in :
	EP : The top queue
	EQ : subqueue under the top where the file resides
	EN : Actual filename

Input parameters (all optional) are :
	-b : waiting period in seconds between files	default: 1 sec
	-C : coldstart - ALL files to be processed as NEW on the 1st scan. def: no
	-d : Winnt - drive for the top queue		default: fip drive
	-e : If the queue name is in the form dd-mmm-yyyy,	default: ignore
		only trigger on day, day+1 .. day+e
		-e 5 = for 5 days.
	-f : stable time for file			default: none - file is processed immediately
			Use this for large files being copied into a folder which may not complete
within a second.
	-H : hotstart - NO files to be processed at all on the 1st scan. def: all are.
	-l : log every new file pls			default: do NOT log
	-L : log every new file AND display on screen	default: do NOT log
	-q : top queue to monitor			default: spool/trigger
	-Q : quiet mode					default: no, verbose
		this does not message every time the check-primary-system runs
	-w : waiting period in seconds between scans	default: 300 (ie 5 mins)
	-X : scan once and then stop			default: keep scanning
	-z : name of parameter file in tables/setup	default: TRIGGER
	-Z : WINNT - convert ALL '/' to '' in the scripts	def: only program
	-v : print version no and exit
Version Control
;001t11	 4feb98 added better name (ie more unique) for the trigger name in fix
	;a  8feb98 WINNT mods
	;b 21dec99 added winnt drive
	;c/d 23may00 bug stopped tree walking and added READ
	;e-g 30jul03 max-level added; better handling of WINNT new
	;h 22apr05 for multiple levels WINNT
	;i-r 24may05 redid testing and added DELs
	;s 12feb07 added FipSeq - replace, partial etc
	;t9 04aug08 poss truncation with v long folder names ;4 added -H to ignore
changes 1st time around
		;6-9 30jun10 added check-primary-server and balance-group and balance-folder
		;9-11 13jul10 added locale, case-sensitive-mask, chkexists and
chkexists-timeout

(copyright) 2014 and previous years FingerPost Ltd.