# Example config file for Alarm Pinger

########################################
## General options

## Should debug messages be generated? (default: off)
#debug on 

## User and group the pinger should run as
user "nobody"
group "nogroup"

## Mailer to use (default: "/usr/lib/sendmail -t")
#mailer "/var/qmail/bin/qmail-inject" 

## Location of the pid-file (default: "/var/run/apinger.pid")
#pid_file "/tmp/apinger.pid"

## Format of timestamp (%s macro) (default: "%b %d %H:%M:%S")
#timestamp_format "%Y%m%d%H%M%S"

########################################
## Status output parameters

#status {
#	## File where the status information whould be written to
#	file "/tmp/apinger.status"
#
#	## Interval between file updates
#	## when 0 or not set, file is written only when SIGUSR1 is received
#	interval 5m
#}

########################################
# RRDTool status gathering configuration

# Interval between RRD updates
#rrd interval 30s;


########################################
## Alarm definitions

## Alarm defaults
## These parameters can be overriden in a specific alarm configuration
alarm default { 

	## Following "macros" may be used in options below:
	##	%t - target name (address)
	##	%T - target description
	##	%a - alarm name
	##	%A - alarm type ("down"/"loss"/"delay")
	##	%r - reason of message ("ALARM"/"alarm canceled"/"alarm canceled (config reload)")
	##	%p - probes send
	##	%P - probes received
	##	%l - recent average packet loss
	##	%d - recent average delay
	##	%s - current timestamp
	##	%% - '%' character

	## Mailbox where alarm report should be sent
	mailto "root@localhost"
	
	## What to put in the "From: " header
	mailfrom "root@localhost"
	
	## What should be the envelope sender
	#mailenvfrom "root@localhost"

	## Subject of the mail message (default: "%r: %T(%t) *** %a ***")
	#mailsubject "%s %r: %a: %T"

	## Command to execute when alarm is fired
	#command on "/usr/local/bin/do_something_about %t"
	#command off "/usr/local/bin/thanks_for_fixing %t"

	## Command the report should be piped to
	#pipe "sms 0-800-my-modem-is-dead"

	## Combine all alarms that are fired in the 5s interval
	## so one report is send for all of them
	#combine 5s

	## Repeat alarm actions each 5 minutes, but max 10 times (0 whould mean no limit)
	#repeat 5m 10
}

## Specific alarm definitions follow.
## Each defined with:
## alarm <type> <name> { <parameter>... }
## and contains alarm parameters, generic, which may also be used in the 
## "alarm default" section and type-specific ones
## More than one alarm of a given type may be defined.

## "Down" alarm definition. 
## This alarm will be fired when target doesn't respond for 30 seconds.
alarm down "down" {
	time 30s
}

## "Delay" alarm definition. 
## This alarm will be fired when responses are delayed more than 200ms
## it will be canceled, when the delay drops below 100ms
alarm delay "delay" {
	delay_low 100ms
	delay_high 200ms
}

## "Loss" alarm definition. 
## This alarm will be fired when packet loss goes over 20%
## it will be canceled, when the loss drops below 10%
alarm loss "loss" {
	percent_low 10
	percent_high 20
}

########################################
## Target definitions

## Target defaults
## These parameters can be overriden in a specific target configuration
target default {
	## How often the probe should be sent	
	interval 1s
	
	## How many replies should be used to compute average delay 
	## for controlling "delay" alarms
	avg_delay_samples 10
	
	## How many probes should be used to compute average loss
	avg_loss_samples 50

	## The delay (in samples) after which loss is computed
	## without this delays larger than interval would be treated as loss
	avg_loss_delay_samples 20

	## Names of the alarms that may be generated for the target
	alarms "down","delay","loss"

	## Location of the RRD
	#rrd file "/tmp/apinger-%t.rrd"
}

## Targets to probe
## Each one defined with:
## target <address> { <parameter>... }
## The parameters are those described above in the "target default" section
## plus the "description" parameter.
## the <address> should be IPv4 or IPv6 address (not hostname!)
target "127.0.0.1" { description "localhost IPv4"; }
target "::1" { 
	description "localhost IPv6";
	
	# generate _only_ "down" alarms
	# "alarms" directive without "override" keyword adds alarms to the default list
	alarms override "down"; 
}
