/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */

/**
 * main snmp-manubulon template
 */

template CheckCommand "snmp-manubulon-command" {
	import "ipv4-or-ipv6"

	arguments = {
		"-H" = {
			value = "$snmp_address$"
			description = "Name or IP address of host to check"
		}
		"-C" = {
			set_if = "$snmp_nocrypt$"
			value = "$snmp_community$"
			description = "Community name for the host's SNMP agent (implies v1 protocol)"
		}
		"-p" = {
			value = "$snmp_port$"
			description = "SNMP port (Default 161)"
		}
		"-2" = {
			set_if = "$snmp_v2$"
			description = "Use snmp v2c"
		}
		"-l" = {
			set_if = "$snmp_v3$"
			value = "$snmp_login$"
			description = "Login and auth password for snmpv3 authentication"
		}
		"-x" = {
			set_if = "$snmp_v3$"
			value = "$snmp_password$"
			description = "Priv password"
		}
		"-L" = {
			set_if = "$snmp_v3_use_authprotocol$"
			value = "$snmp_authprotocol$"
			description = "<authproto>,<privproto> - <Authentication protocol (md5|sha : default md5)>,<Priv protocole (des|aes : default des)>"
		}
		"-X" = {
			set_if = "$snmp_v3_use_privpass$"
			value = "$snmp_privpass$"
			description = "Priv password for snmpv3 (AuthPriv protocol)"
		}
		"-w" = {
			value = "$snmp_warn$"
		}
		"-c" = {
			value = "$snmp_crit$"
		}
		"-t" = {
			value = "$snmp_timeout$"
			description = "Timeout for SNMP in seconds (Default: 5)"
		}
	}

	vars.snmp_address = "$check_address$"
	vars.snmp_nocrypt = true
	vars.snmp_community = "public"
	vars.snmp_v2 = false
	vars.snmp_v3 = false
	vars.snmp_login = "snmpuser"
	vars.snmp_v3_use_privpass = false
	vars.snmp_v3_use_authprotocol = false
	vars.snmp_authprotocol = "md5,des"
	vars.snmp_timeout = "5"
}


/**
 * snmp env
 *   Url reference: http://nagios.manubulon.com/snmp_env.html
 */

object CheckCommand "snmp-env" {
	import "snmp-manubulon-command"

	command = [ ManubulonPluginDir + "/check_snmp_env.pl" ]

	arguments += {
		"-T" = {
			value = "$snmp_env_type$"
			description = "Environment Type [cisco|nokia|bc|iron|foundry|linux]"
		}
		"-F" = {
			value = "$snmp_env_fan$"
			description = "Minimum fan rpm value (only needed for 'iron' & 'linux')"
		}
		"-c" = {
			value = "$snmp_env_celsius$"
			description = "Maximum temp in degrees celsius (only needed for 'iron' & 'linux')"
		}
		"-f" = {
			set_if = "$snmp_perf$"
			description = "Perfparse compatible output"
		}
	}

	vars.snmp_env_type = "cisco"
	vars.snmp_perf = true
}


/**
 * snmp load
 *   Url reference: http://nagios.manubulon.com/snmp_load.html
 */

object CheckCommand "snmp-load" {
	import "snmp-manubulon-command"

	command = [ ManubulonPluginDir + "/check_snmp_load.pl" ]

	arguments += {
		"-T" = {
			value = "$snmp_load_type$"
			description = "CPU check"
		}
		"-f" = {
			set_if = "$snmp_perf$"
			description = "Perfparse compatible output"
		}
	}

	vars.snmp_load_type = "stand"
	vars.snmp_warn = 85
	vars.snmp_crit = 95
	vars.snmp_perf = true
}


/**
 * Memory and swap usage on Linux given by Net-snmp
 *   Memory usage on cisco routers or Pix
 *   For other systems use check_snmp_storage.pl
 *   Url reference: http://nagios.manubulon.com/snmp_mem.html
 */

object CheckCommand "snmp-memory" {
	import "snmp-manubulon-command"

	command = [ ManubulonPluginDir + "/check_snmp_mem.pl" ]

	arguments += {
		"-f" = {
			set_if = "$snmp_perf$"
			description = "Performance data output"
		}
		"-I" = {
			set_if = "$snmp_is_cisco$"
			description = "check cisco memory (sum of all memory pools)"
		}
		"-E" = {
			set_if = "$snmp_is_hp$"
			description = "check HP / Procurve memory"
		}
		"-m" = {
			set_if = "$snmp_memcached$"
			description = "Include cached memory in used memory"
		}
		"-b" = {
			set_if = "$snmp_membuffer$"
			description = "Exclude buffered memory in used memory"
		}
	}

	vars.snmp_warn = "94,50"
	vars.snmp_crit = "98,80"
	vars.snmp_perf = true
	vars.snmp_is_cisco = false
	vars.snmp_memcached = false
	vars.snmp_membuffer = false
}


/**
 * snmp storage - Disk/Memory
 *   Url reference: http://nagios.manubulon.com/snmp_storage.html
 */
object CheckCommand "snmp-storage" {
	import "snmp-manubulon-command"

	command = [ ManubulonPluginDir + "/check_snmp_storage.pl" ]

	arguments += {
		"-m" = {
			value = "$snmp_storage_name$"
			description = "Name in description OID (can be mounpoints '/home' or 'Swap Space'...)"
		}
		"-f" = {
			set_if = "$snmp_perf$"
			description = "Perfparse compatible output"
		}
		"-e" = {
			set_if = "$snmp_exclude$"
			description = "Select all storages except the one(s) selected by -m. No action on storage type selection."
		}
		"-o" = {
			value = "$snmp_storage_olength$"
			description = "Max-size of the SNMP message, usefull in case of Too Long responses."
		}
		"-q" = {
			value = "$snmp_storage_type$"
			description = "Storage type: Other, Ram, VirtualMemory, FixedDisk, RemovableDisk, FloppyDisk, CompactDisk, RamDisk, FlashMemory, or NetworkDisk"
		}
	}

	vars.snmp_storage_name = "^/$$"
	vars.snmp_warn = 80
	vars.snmp_crit = 90
	vars.snmp_perf = true
	vars.snmp_exclude = false
}


/**
 * snmp network interfaces
 *   Url reference: http://nagios.manubulon.com/snmp_int.html
 */

object CheckCommand "snmp-interface" {
	import "snmp-manubulon-command"

	command = [ ManubulonPluginDir + "/check_snmp_int.pl" ]

	arguments += {
		"-n" = {
			value = "$snmp_interface$"
			description = "Name in description OID (eth0, ppp0 ...). This is treated as a regexp : -n eth will match eth0,eth1,..."
		}
		"-k" = {
			set_if = "$snmp_interface_perf$"
			description = "Check the input/ouput bandwidth of the interface"
		}
		"--label" = {
			value = "$snmp_interface_label$"
			description = "Add label before speed in output : in=, out=, errors-out=, etc..."
		}
		"-Y" = {
			set_if = "$snmp_interface_bits_bytes$"
			description = "Output performance data in bits/s or Bytes/s"
		}
		"-y" = {
			set_if = "$snmp_interface_percent$"
			description = "Output performance data in % of max speed"
		}
		"-B" = {
			set_if = "$snmp_interface_kbits$"
			description = "Make the warning and critical levels in K|M|G Bits/s instead of K|M|G Bytes/s"
		}
		"-M" = {
			set_if = "$snmp_interface_megabytes$"
			description = "Make the warning and critical levels in Mbps"
		}
		"--64bits" = {
			set_if = "$snmp_interface_64bit$"
			description = "Use 64 bits counters instead of the standard counters when checking bandwidth & performance data for interface >= 1Gbps"
		}
		"-e" = {
			set_if = "$snmp_interface_errors$"
			description = "Add error & discard to Perfparse output"
		}
		"-q" = {
			set_if = "$snmp_interface_extended_checks$"
			description = "Also check the error and discard input/output. When enabled format of snmp_warn and snmp_crit changes to <In bytes>,<Out bytes>,<In error>,<Out error>,<In disc>,<Out disc>"
		}
		"-i" = {
			set_if = "$snmp_interface_inverse$"
			description = "Make critical when up"
		}
		"-r" = {
			set_if = "$snmp_interface_noregexp$"
			description = "Do not use regexp to match NAME in description OID"
		}
		"-d" = {
			value = "$snmp_interface_delta$"
			description = "Make an average of <delta> seconds (default 300=5min)"
		}
		"-u" = {
			set_if = "$snmp_interface_warncrit_percent$"
			description = "Make the warning and critical levels in % of reported interface speed"
		}
		"-N" = {
			set_if = "$snmp_interface_ifname$"
		}
		"-A" = {
			set_if = "$snmp_interface_ifalias$"
		}
		"-f" = {
			set_if = "$snmp_perf$"
			description = "Perfparse compatible output (no output when interface is down)"
		}
		"-W" = {
			set_if = "$snmp_interface_weathermap$"
			description = "Include 'weathermap' data for NagVis in performance data"
		}
	}

	vars.snmp_interface = "eth0"
	vars.snmp_interface_perf = true
	vars.snmp_interface_bits_bytes = true
	vars.snmp_interface_percent = false
	vars.snmp_interface_kbits = true
	vars.snmp_interface_megabytes = true
	vars.snmp_interface_64bit = false
	vars.snmp_interface_errors = true
	vars.snmp_interface_extended_checks = false
	vars.snmp_interface_noregexp = false
	vars.snmp_interface_delta = 300
	vars.snmp_interface_warncrit_percent = false
	vars.snmp_interface_ifname = false
	vars.snmp_interface_ifalias = false
	vars.snmp_warn = "300,400"
	vars.snmp_crit = "0,600"
	vars.snmp_perf = true
}


/**
 * snmp process
 *   Url reference: http://nagios.manubulon.com/snmp_process.html
 */

object CheckCommand "snmp-process" {
	import "snmp-manubulon-command"

	command = [ ManubulonPluginDir + "/check_snmp_process.pl" ]

	arguments += {
		"-n" = {
			value = "$snmp_process_name$"
			description = "Regex service name eg. ^apache2$"
		}
		"-F" = {
			set_if = "$snmp_perf$"
			description = "Add performance output (outputs : memory_usage, num_process, cpu_usage)"
		}
		"-A" = {
			set_if = "$snmp_process_use_params$"
			description = "Add parameters to select processes (ex : 'named.*-t /var/named/chroot' will only select named process with this parameter)"
		}
		"-m" = {
			set_if = "$snmp_process_mem_usage$"
			value = "$snmp_process_mem_threshold$"
			description = "Checks memory usage. Values warning and critical in Mb eg. 512,1024"
		}
		"-u" = {
			set_if = "$snmp_process_cpu_usage$"
			value = "$snmp_process_cpu_threshold$"
			description = "Checks CPU usage. Values warning and critical in % (value can be > 100% : 100%=1 CPU) eg. 15,50"
		}
	}

	vars.snmp_process_name = ".*"
	vars.snmp_warn = 0
	vars.snmp_crit = 0
	vars.snmp_perf = true
	vars.snmp_process_use_params = false
	vars.snmp_process_mem_usage = false
	vars.snmp_process_mem_threshold = "0,0"
	vars.snmp_process_cpu_usage = false
	vars.snmp_process_cpu_threshold = "0,0"
}

/**
 * snmp service
 *   Url reference: http://nagios.manubulon.com/snmp_windows.html
 */

object CheckCommand "snmp-service" {
	import "snmp-manubulon-command"

	command = [ ManubulonPluginDir + "/check_snmp_win.pl" ]

	arguments += {
		"-n" = {
			value = "$snmp_service_name$"
			description = "Comma separated names of services (perl regular expressions can be used for every one). By default, it is not case sensitive. eg. ^dns$"
		}
		"-N" = {
			value = "$snmp_service_count$"
			description = "Compare matching services with <n> instead of the number of names provided."
		}
		"-s" = {
			set_if = "$snmp_service_showall$"
			description = "Show all services in the output, instead of only the non-active ones."
		}
		"-r" = {
			set_if = "$snmp_service_noregexp$"
			description = "Do not use regexp to match NAME in service description."
		}
	}

	vars.snmp_service_name = ".*"
}
