#
# Network related checks (FFHO-built)
#


#
# ifupdown2
apply Service "ifupdown2" {
        import "generic-service"

	check_command = "ifupdown2"

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	vars.ok_string = "[ OK ]"

	assign where host.address && host.vars.os == "Linux"
	ignore where "ifupdown-ng" in host.vars.tags
}


#
# Metfilter connection tracking table size
apply Service "conntrack_size" {
	import "generic-service"

	check_command = "conntrack_size"

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	assign where host.address && host.vars.os == "Linux"
}


#
# bird process
apply Service "bird" {
	import "generic-service"

	check_command = "procs"

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	vars.procs_command = "bird"
	vars.procs_critical = "1:"
	vars.procs_warning = ":1"
	check_interval = 5m
	max_check_attempts = 3
	retry_interval = 3m

	assign where host.address && host.vars.os == "Linux" && "router" in host.vars.roles
}

apply Service "bird6" {
	import "generic-service"

	check_command = "procs"

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	vars.procs_command = "bird6"
	vars.procs_critical = "1:"
	vars.procs_warning = ":1"
	check_interval = 5m
	max_check_attempts = 3
	retry_interval = 3m

	assign where host.address && host.vars.os == "Linux" && "router" in host.vars.roles
}


#
# bird OSPF
apply Service "bird_ospf" {
	import "generic-service"

	check_command = "bird_ospf"
	vars.interfaces_down_ok_file = "/etc/icinga2/ffho-conf.d/bird_ospf_interfaces_down_ok.txt"
	vars.ignore_missing_file = true
	vars.no_ptp_ip = true

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	assign where host.address && host.vars.os == "Linux" && "router" in host.vars.roles
}

apply Service "bird_ospf6" {
	import "generic-service"

	check_command = "bird_ospf"
	vars.proto = "6"
	vars.interfaces_down_ok_file = "/etc/icinga2/ffho-conf.d/bird_ospf_interfaces_down_ok.txt"
	vars.ignore_missing_file = true
	vars.no_ptp_ip = true

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	assign where host.address && host.vars.os == "Linux" && "router" in host.vars.roles
}


#
# bird iBGP
apply Service "bird_ibgp4" {
	import "generic-service"

	check_command = "bird_bgp"

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	vars.ibgp = true
	vars.ibgp_w = "2:2"
	vars.ibgp_c = "3:"
	vars.asn = 65132
	vars.proto = "4"
	vars.sessions_down_ok_file = "/etc/icinga2/ffho-conf.d/bird_ibgp_sessions_down_ok.txt"
	vars.ignore_missing_file = true

	assign where host.address && host.vars.os == "Linux" && "router" in host.vars.roles
}

apply Service "bird_ibgp6" {
	import "generic-service"

	check_command = "bird_bgp"

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	vars.ibgp = true
	vars.ibgp_w = "2:2"
	vars.ibgp_c = "3:"
	vars.asn = 65132
	vars.proto = "6"
	vars.sessions_down_ok_file = "/etc/icinga2/ffho-conf.d/bird_ibgp_sessions_down_ok.txt"
	vars.ignore_missing_file = true

	assign where host.address && host.vars.os == "Linux" && "router" in host.vars.roles
}


#
# bird eBGP
apply Service "bird_ebgp4" {
	import "generic-service"

	check_command = "bird_bgp"

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	vars.ebgp = true
	vars.asn = 65132
	vars.proto = "4"

	assign where host.address && host.vars.os == "Linux" && "ffrl-exit" in host.vars.roles
}

apply Service "bird_ebgp6" {
	import "generic-service"

	check_command = "bird_bgp"

	if (host.name != NodeName) {
		command_endpoint = host.name
	}

	vars.ebgp = true
	vars.asn = 65132
	vars.proto = "6"

	assign where host.address && host.vars.os == "Linux" && "ffrl-exit" in host.vars.roles
}