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

object CheckCommand "webinject" {
	command = [ PluginContribDir + "/check_webinject" ]

	arguments = {
		"-c" = {
			value = "$webinject_config_file$"
			description = "There is a configuration file named 'config.xml' that is used to store configuration settings for your project. You can use this to specify which test case files to run and to set some constants and settings to be used by WebInject."
		}

		"-o" = {
			value = "$webinject_output$"
			description = "This option is followed by a directory name or a prefix to prepended to the output files. This is used to specify the location for writing output files (http.log, results.html, and results.xml). If a directory name is supplied (use either an absolute or relative path and make sure to add the trailing slash), all output files are written to this directory. If the trailing slash is ommitted, it is assumed to a prefix and this will be prepended to the output files. You may also use a combination of a directory and prefix."
		}

		"-n" = {
			set_if = "$webinject_no_output$"
			description = "Suppresses all output to STDOUT except the results summary."
		}

		"-t" = {
			value = "$webinject_timeout$"
			description = "The value [given in seconds] will be compared to the global time elapsed to run all the tests. If the tests have all been successful, but have taken more time than the 'globaltimeout' value, a warning message is sent back to Icinga."
		}

		"-r" = {
			value = "$webinject_report_type$"
			description = "This setting is used to enable output formatting that is compatible for use with specific external programs. The available values you can set this to are: nagios, mrtg, external and standard"
		}

		"-s" = {
			value = "$webinject_key_value$"
			description = "key=value"
		}

		"testcase_file" = {
			value = "$webinject_testcase_file$"
			description = "When you launch WebInject in console mode, you can optionally supply an argument for a testcase file to run. It will look for this file in the directory that webinject.pl resides in. If no filename is passed from the command line, it will look in config.xml for testcasefile declarations. If no files are specified, it will look for a default file named 'testcases.xml' in the current [webinject] directory. If none of these are found, the engine will stop and give you an error."
			skip_key = true
			order = 1
		}
	}
}

object CheckCommand "jmx4perl" {
	command = [ PluginContribDir + "/check_jmx4perl" ]

	arguments = {
		"-u" = {
			value = "$jmx4perl_url$"
			description = "URL to agent web application (e.g. http://server:8080/jolokia/)"
		}
		"--product" = {
			value = "$jmx4perl_product$"
			description = "Name of app server product (e.g. jboss)"
		}
		"--alias" = {
			value = "$jmx4perl_alias$"
			description = "Alias name for attribute (e.g. MEMORY_HEAP_USED)"
		}
		"-m" = {
			value = "$jmx4perl_mbean$"
			description = "MBean name (e.g. java.lang:type=Memory)"
		}
		"-a" = {
			value = "$jmx4perl_attribute$"
			description = "Attribute name (e.g. HeapMemoryUsage)"
		}
		"-o" = {
			value = "$jmx4perl_operation$"
			description = "Operation to execute"
		}
		"--value" = {
			value = "$jmx4perl_value$"
			description = "Shortcut for specifying mbean/attribute/path. Slashes within names must be escaped with backslash"
		}
		"--delta" = {
			value = "$jmx4perl_delta$"
			description = "Switches on incremental mode. Optional argument are seconds used for normalizing."
		}
		"-p" = {
			value = "$jmx4perl_path$"
			description = "Inner path for extracting a single value from a complex attribute or return value (e.g. used)"
		}
		"--target" = {
			value = "$jmx4perl_target$"
			description = "JSR-160 Service URL specifing the target server"
		}
		"--target-user" = {
			value = "$jmx4perl_target_user$"
			description = "Username to use for JSR-160 connection"
		}
		"--target-password" = {
			value = "$jmx4perl_target_password$"
			description = "Password to use for JSR-160 connection"
		}
		"--proxy" = {
			value = "$jmx4perl_proxy$"
			description = "Proxy to use"
		}
		"--user" = {
			value = "$jmx4perl_user$"
			description = "User for HTTP authentication"
		}
		"--password" = {
			value = "$jmx4perl_password$"
			description = "Password for HTTP authentication"
		}
		"-n" = {
			value = "$jmx4perl_name$"
			description = "Name to use for output. Optional, by default a standard value based on the MBean and attribute will be used"
		}
		"--method" = {
			value = "$jmx4perl_method$"
			description = "HTTP method to use. Either get or post"
		}
		"-b" = {
			value = "$jmx4perl_base$"
			description = "Base name, which when given, interprets critical and warning values as relative in the range 0 .. 100%. Must be given in the form mbean/attribute/path"
		}
		"--base-mbean" = {
			value = "$jmx4perl_base_mbean$"
			description = "Base MBean name, interprets critical and warning values as relative in the range 0 .. 100%. Requires a base-attribute, too"
		}
		"--base-attribute" = {
			value = "$jmx4perl_base_attribute$"
			description = "Base attribute for a relative check. Used together with base-mbean"
		}
		"--base-path" = {
			value = "$jmx4perl_base_path$"
			description = "Base path for relative checks, where this path is used on the base attribute's value"
		}
		"--unit" = {
			value = "$jmx4perl_unit$"
			description = "Unit of measurement of the data retreived. Recognized values are [B|KB|MN|GB|TB] for memory values and [us|ms|s|m|h|d] for time values"
		}
		"--null" = {
			value = "$jmx4perl_null$"
			description = "Value which should be used in case of a null return value of an operation or attribute. Is null by default"
		}
		"--string" = {
			set_if = "$jmx4perl_string$"
			description = "Force string comparison for critical and warning checks"
		}
		"--numeric" = {
			set_if = "$jmx4perl_numeric$"
			description = "Force numeric comparison for critical and warning checks"
		}
		"-c" = {
			value = "$jmx4perl_critical$"
			description = "Critical threshold for value"
		}
		"-w" = {
			value = "$jmx4perl_warning$"
			description = "Warning threshold for value"
		}
		"-l" = {
			value = "$jmx4perl_label$"
			description = "Label to be used for printing out the result of the check. Placeholders can be used."
		}
		"--perfdata" = {
			value = "$jmx4perl_perfdata$"
			description = "Whether performance data should be omitted, which are included by default."
		}
		"--unknown-is-critical" = {
			set_if = "$jmx4perl_unknown_is_critical$"
			description = "Map UNKNOWN errors to errors with a CRITICAL status"
		}
		"-t" = {
			value = "$jmx4perl_timeout$"
			description = "Seconds before plugin times out (default: 15)"
		}
		"--config" = {
			value = "$jmx4perl_config$"
			description = "Path to configuration file."
		}
		"--server" = {
			value = "$jmx4perl_server$"
			description = "Symbolic name of server url to use, which needs to be configured in the configuration file."
		}
		"--check" = {
			value = "$jmx4perl_check$"
			description = "Name of a check configuration as defined in the configuration file, use array if you need arguments."
			order = 1
			repeat_key = false
		}
	}

	vars.jmx4perl_url = "http://$address$:8080/jolokia"
	vars.jmx4perl_string = false
	vars.jmx4perl_numeric = false
	vars.jmx4perl_unknown_is_critical = false
}

object CheckCommand "squid" {
	import "ipv4-or-ipv6"

	command = [ PluginContribDir + "/check_squid" ]

	arguments = {
		"--host" = {
			value = "$squid_hostname$"
			description = "Name of the proxy to check (default: localhost)"
		}
		"--data" = {
			value = "$squid_data$"
			description = "Optional data to fetch (default: Connections)    available data : Connections Cache Resources Memory FileDescriptors"
		}
		"--port" = {
			value = "$squid_port$"
			description = "Optional port number (default: 3128)"
		}
		"--user" = {
			value = "$squid_user$"
			description = "WWW user"
		}
		"--password" = {
			value = "$squid_password$"
			description = "WWW password"
		}
		"--warning" = {
			value = "$squid_warning$"
			description = "Warning threshold. See http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT for the threshold format."
		}
		"--critical" = {
			value = "$squid_critical$"
			description = "Critical threshold. See http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT for the threshold format."
		}
		"--squidclient" = {
			value = "$squid_client$"
			description = "Path of squidclient (default: /usr/bin/squidclient)"
		}
		"--timeout" = {
			value = "$squid_timeout$"
			description = "Seconds before plugin times out (default: 15)"
		}
	}

	vars.squid_hostname = "$check_address$"
	vars.squid_client = "/usr/bin/squidclient"
}

object CheckCommand "nginx_status" {
		import "ipv4-or-ipv6"

		command = [ PluginContribDir + "/check_nginx_status.pl" ]

		arguments = {
			"--hostname" = {
				value = "$nginx_status_host_address$"
				description = "name or IP address of host to check"
			}
			"--port" = {
				value = "$nginx_status_port$"
				description = "the http port"
			}
			"--url" = {
				value = "$nginx_status_url$"
				description = "Specific URL to use, instead of the default 'http://<nginx_status_hostname>/nginx_status'"
			}
			"--servername" = {
				value = "$nginx_status_servername$"
				description = "ServerName, use it if you specified an IP in -H to match the good Virtualhost in your target"
			}
			"--ssl" = {
				set_if = "$nginx_status_ssl$"
				description = "Wether we should use HTTPS instead of HTTP"
			}
			"--disable-sslverifyhostname" = {
				set_if = "$nginx_status_disable_sslverify$"
				description = "Disable SSL hostname verification"
			}
			"--user" = {
				value = "$nginx_status_user$"
				description = "Username for basic auth"
			}
			"--pass" = {
				value = "$nginx_status_pass$"
				description = "Password for basic auth"
			}
			"--realm" = {
				value = "$nginx_status_realm$"
				description = "Realm for basic auth"
			}
			"--maxreach" = {
				value = "$nginx_status_maxreach$"
				description = "Number of max processes reached (since last check) that should trigger an alert"
			}
			"--timeout" = {
				value = "$nginx_status_timeout$"
				description = "timeout in seconds"
			}
			"--warn" = {
				value = "$nginx_status_warn$"
				description = "number of active connections, ReqPerSec or ConnPerSec that will cause a WARNING"
			}
			"--critical" = {
				value = "$nginx_status_critical$"
				description = "number of active connections, ReqPerSec or ConnPerSec that will cause a CRITICAL"
			}
		}

		vars.nginx_status_host_address = "$check_address$"
		vars.nginx_status_ssl = false
		vars.nginx_status_disable_sslverify = false
		vars.nginx_status_warn = "10000,100,200"
		vars.nginx_status_critical = "20000,200,300"
		vars.nginx_status_timeout = 15
}

object CheckCommand "apache-status" {
	import "ipv4-or-ipv6"

	command = [ PluginContribDir + "/check_apache_status.pl" ]

	arguments = {
		"-H" = {
			value = "$apache_status_address$"
			description = "name or IP address of host to check"
		}
		"-p" = {
			value = "$apache_status_port$"
			description = "the http port"
		}
		"-s" = {
			set_if = "$apache_status_ssl$"
			description = "Whether we should use HTTPS instead of HTTP"
		}
		"-u" = {
			value = "$apache_status_uri$"
			description = "Specific URL to use, instead of the default 'http://<apache_status_address>/server-status'"
		}
		"-U" = {
			value = "$apache_status_username$"
			description = "username for basic auth"
		}
		"-P" = {
			value = "$apache_status_password$"
			description = "password for basic auth"
		}
		"-w" = {
			value = "$apache_status_warning$"
			description = "number of open slots, busy workers and idle workers that will cause a WARNING"
		}
		"-c" = {
			value = "$apache_status_critical$"
			description = "number of open slots, busy workers and idle workers that will cause a CRITICAL"
		}
		"-t" = {
			value = "$apache_status_timeout$"
			description = "timeout in seconds"
		}
		"-N" = {
			set_if = "$apache_status_no_validate$"
			description = "do not validate the SSL certificate chain"
		}
		"-R" = {
			set_if = "$apache_status_unreachable$"
			description = "CRITICAL if socket timed out or http code >= 500"
		}
	}

	vars.apache_status_address = "$check_address$"
	vars.apache_status_ssl = false
}

object CheckCommand "ssl_cert" {
	import "ipv4-or-ipv6"

	command = [ PluginContribDir + "/check_ssl_cert" ]

	arguments = {
		"-H" = {
			value = "$ssl_cert_address$"
			description = "The host's address"
			required = true
		}
		"-p" = {
			value = "$ssl_cert_port$"
			description = "TCP port number (default: 443)"
		}
		"-f" = {
			value = "$ssl_cert_file$"
			description = "Local file path (works with -H localhost only)"
		}
		"-w" = {
			value = "$ssl_cert_warn$"
			description = "Minimum number of days a certificate has to be valid"
		}
		"-c" = {
			value = "$ssl_cert_critical$"
			description = "Minimum number of days a certificate has to be valid to issue a critical status"
		}
		"-n" = {
			value = "$ssl_cert_cn$"
			description = "Pattern to match the CN of the certificate"
		}
		"--altnames" = {
			set_if = "$ssl_cert_altnames$"
			description = "Matches the pattern specified in -n with alternate"
		}
		"-i" = {
			value = "$ssl_cert_issuer$"
			description = "Pattern to match the issuer of the certificate"
		}
		"-o" = {
			value = "$ssl_cert_org$"
			description = "Pattern to match the organization of the certificate"
		}
		"-e" = {
			value = "$ssl_cert_email$"
			description = "Pattern to match the email address contained in the certificate"
		}
		"-N" = {
			set_if = "$ssl_cert_match_host$"
			description = "Match CN with the host name"
		}
		"--serial" = {
			value = "$ssl_cert_serial$"
			description = "Pattern to match the serial number"
		}
		"-A" = {
			set_if = "$ssl_cert_noauth$"
			description = "Ignore authority warnings (expiration only)"
		}
		"-s" = {
			set_if = "$ssl_cert_selfsigned$"
			description = "Allow self-signed certificate"
		}
		"--sni" = {
			value = "$ssl_cert_sni$"
			description = "Sets the TLS SNI (Server Name Indication) extension"
		}
		"-t" = {
			value = "$ssl_cert_timeout$"
			description = "Seconds before connection times out (default: 15)"
		}
		"-P" = {
			value = "$ssl_cert_protocol$"
			description = "Use the specific protocol {http|smtp|pop3|imap|ftp|xmpp|irc|ldap} (default: http)"
		}
		"-C" = {
			value = "$ssl_cert_clientssl_cert$"
			description = "Use client certificate to authenticate"
		}
		"--clientpass" = {
			value = "$ssl_cert_clientpass$"
			description = "Set passphrase for client certificate"
		}
		"-L" = {
			value = "$ssl_cert_ssllabs$"
			description = "SSL Labs assestment"
		}
		"--ignore-ssl-labs-cache" = {
			set_if = "$ssl_cert_ssllabs_nocache$"
			description = "Forces a new check by SSL Labs"
		}
		"-r" = {
			value = "$ssl_cert_rootssl_cert$"
			description = "Root certificate or directory to be used for certificate validation"
		}
		"--ssl2" = {
			set_if = {{
				return macro("$ssl_cert_ssl_version$") == "ssl2"
			}}
		}
		"--ssl3" = {
			set_if = {{
				return macro("$ssl_cert_ssl_version$") == "ssl3"
			}}
		}
		"--tls1" = {
			set_if = {{
				return macro("$ssl_cert_ssl_version$") == "tls1"
			}}
		}
		"--tls1_1" = {
			set_if = {{
				return macro("$ssl_cert_ssl_version$") == "tls1_1"
			}}
		}
		"--tls1_2" = {
			set_if = {{
				return macro("$ssl_cert_ssl_version$") == "tls1_2"
			}}
		}
		"--no_ssl2" = {
			set_if = {{
				var disable_versions = macro("$ssl_cert_disable_ssl_versions$")
				if (typeof(disable_versions) == String) {
					disable_versions = [ disable_versions ]
				}
				return "ssl2" in disable_versions
			}}
		}
		"--no_ssl3" = {
			set_if = {{
				var disable_versions = macro("$ssl_cert_disable_ssl_versions$")
				if (typeof(disable_versions) == String) {
					disable_versions = [ disable_versions ]
				}
				return "ssl3" in disable_versions
			}}
		}
		"--no_tls1" = {
			set_if = {{
				var disable_versions = macro("$ssl_cert_disable_ssl_versions$")
				if (typeof(disable_versions) == String) {
					disable_versions = [ disable_versions ]
				}
				return "tls1" in disable_versions
			}}
		}
		"--no_tls1_1" = {
			set_if = {{
				var disable_versions = macro("$ssl_cert_disable_ssl_versions$")
				if (typeof(disable_versions) == String) {
					disable_versions = [ disable_versions ]
				}
				return "tls1_1" in disable_versions
			}}
		}
		"--no_tls1_2" = {
			set_if = {{
				var disable_versions = macro("$ssl_cert_disable_ssl_versions$")
				if (typeof(disable_versions) == String) {
					disable_versions = [ disable_versions ]
				}
				return "tls1_2" in disable_versions
			}}
		}
		"--ecdsa" = {
			set_if = {{
				return macro("$ssl_cert_cipher$") == "ecdsa"
			}}
			description = "Cipher selection: force ECDSA authentication"
		}
		"--rsa" = {
			set_if = {{
				return macro("$ssl_cert_cipher$") == "rsa"
			}}
			description = "Cipher selection: force RSA authentication"
		}
		"--ignore-sig-alg" = {
			set_if = "$ssl_cert_ignore_signature$"
			description = "Do not check if the certificate was signed with SHA1 od MD5"
		}
		"--ignore-exp" = {
			set_if = "$ssl_cert_ignore_expiration$"
			description = "Ignore expiration date"
		}
		"--ignore-ocsp" = {
			set_if = "$ssl_cert_ignore_ocsp$"
			description = "Do not check revocation with OCSP"
		}

	}

	vars.ssl_cert_address = "$check_address$"
	vars.ssl_cert_port = 443
}

object CheckCommand "varnish" {
	import "plugin-check-command"
	command = [ PluginContribDir + "/check_varnish" ]

	arguments = {
		"-n" = {
			value = "$varnish_name$"
			description = "Specify the Varnish instance name"
		}
		"-p" = {
			value = "$varnish_param$"
			description = "Specify the parameter to check (see below). The default is 'ratio'."
		}
		"-c" = {
			value = "$varnish_critical$"
			description = "Set critical threshold: [@][lo:]hi"
		}
		"-w" = {
			value = "$varnish_warning$"
			description = "Set warning threshold: [@][lo:]hi"
		}
	}
}

object CheckCommand "haproxy" {
	import "plugin-check-command"
	command = [ PluginContribDir + "/check_haproxy" ]

	arguments = {
		"--username" = {
			value = "$haproxy_username$"
			description = "Username for HTTP Auth"
		}
		"--password" = {
			value = "$haproxy_password$"
			description = "Password for HTTP Auth"
		}
		"--url" = {
			value = "$haproxy_url$"
			description = "URL of the HAProxy csv statistics page"
			required = true
		}
		"--timeout" = {
			value = "$haproxy_timeout$"
			description = "Seconds before plugin times out (default: 10)"
		}
		"-w" = {
			value = "$haproxy_warning$"
			description = "Warning request time threshold (in seconds)"
		}
		"-c" = {
			value = "$haproxy_critical$"
			description = "Critical request time threshold (in seconds)"
		}
	}
}

object CheckCommand "haproxy_status" {
	import "plugin-check-command"
	command = [ PluginContribDir + "/check_haproxy_status" ]

	arguments = {
		"--defaults" = {
			value = "$haproxy_status_default$"
			description = "Set/Override the defaults which will be applied to all checks (unless specifically set by --overrides)."
		}
		"--frontends" = {
			set_if = "$haproxy_status_frontends$"
			description = "Enable checks for the frontends in HAProxy (that they're marked as OPEN and the session limits haven't been reached)."
		}
		"--nofrontends" = {
			set_if = "$haproxy_status_nofrontends$"
			description = "Disable checks for the frontends in HAProxy (that they're marked as OPEN and the session limits haven't been reached)."
		}
		"--backends" = {
			set_if = "$haproxy_status_backends$"
			description = "Enable checks for the backends in HAProxy (that they have the required quorum of servers, and that the session limits haven't been reached)."
		}
		"--nobackends" = {
			set_if = "$haproxy_status_nobackends$"
			description = "Disable checks for the backends in HAProxy (that they have the required quorum of servers, and that the session limits haven't been reached)."
		}
		"--servers" = {
			set_if = "$haproxy_status_servers$"
			description = "Enable checks for the servers in HAProxy (that they haven't reached the limits for the sessions or for queues)."
		}
		"--noservers" = {
			set_if = "$haproxy_status_noservers$"
			description = "Disable checks for the servers in HAProxy (that they haven't reached the limits for the sessions or for queues)."
		}
		"--overrides" = {
			value = "$haproxy_status_overrides$"
			description = "Override the defaults for a particular frontend or backend, in the form {name}:{override}, where {override} is the same format as --defaults above."
		}
		"--socket" = {
			value = "$haproxy_status_socket$"
			description = "Path to the socket check_haproxy should connect to"
			required = true
		}
	}
}

object CheckCommand "phpfpm_status" {
	import "plugin-check-command"
	command = [ PluginContribDir + "/check_phpfpm_status" ]

	arguments = {
		"-H" = {
			value = "$phpfpm_status_hostname$"
			description = "name or IP address of host to check"
			required = true
		}
		"-p" = {
			value = "$phpfpm_status_port$"
			description = "Http port, or Fastcgi port when using --fastcgi"
		}
		"-u" = {
			value = "$phpfpm_status_url$"
			description = "Specific URL (only the path part of it in fact) to use, instead of the default /fpm-status"
		}
		"-s" = {
			value = "$phpfpm_status_servername$"
			description = "ServerName, (host header of HTTP request) use it if you specified an IP in -H to match the good Virtualhost in your target"
		}
		"-f" = {
			set_if = "$phpfpm_status_fastcgi$"
			description = "Connect directly to php-fpm via network or local socket, using fastcgi protocol instead of HTTP."
		}
		"-U" = {
			value = "$phpfpm_status_user$"
			description = "Username for basic auth"
		}
		"-P" = {
			value = "$phpfpm_status_pass$"
			description = "Password for basic auth"
		}
		"-r" = {
			value = "$phpfpm_status_realm$"
			description = "Realm for basic auth"
		}
		"-d" = {
			set_if = "$phpfpm_status_debug$"
			description = "Debug mode (show http request response)"
		}
		"-t" = {
			value = "$phpfpm_status_timeout$"
			description = "timeout in seconds (Default: 15)"
		}
		"-S" = {
			set_if = "$phpfpm_status_ssl$"
			description = "Wether we should use HTTPS instead of HTTP. Note that you can give some extra parameters to this settings. Default value is 'TLSv1' but you could use things like 'TLSv1_1' or 'TLSV1_2' (or even 'SSLv23:!SSLv2:!SSLv3' for old stuff)."
		}
		"-x" = {
			set_if = "$phpfpm_status_verifyssl$"
			description = "verify certificate and hostname from ssl cert, default is 0 (no security), set it to 1 to really make SSL peer name and certificater checks."
		}
		"-X" = {
			value = "$phpfpm_status_cacert$"
			description = "Full path to the cacert.pem certificate authority used to verify ssl certificates (use with --verifyssl). if not given the cacert from Mozilla::CA cpan plugin will be used."
		}
		"-w" = {
			value = "$phpfpm_status_warn$"
			description = "MIN_AVAILABLE_PROCESSES,PROC_MAX_REACHED,QUEUE_MAX_REACHED number of available workers, or max states reached that will cause a warning. -1 for no warning"
		}
		"-c" = {
			value = "$phpfpm_status_critical$"
			description = "MIN_AVAILABLE_PROCESSES,PROC_MAX_REACHED,QUEUE_MAX_REACHED number of available workers, or max states reached that will cause an error, -1 for no CRITICAL"
		}
	}

	vars.phpfpm_status_hostname = "$address$"
}
