/******************************************************************************
 * Icinga 2                                                                   *
 * Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)  *
 *                                                                            *
 * This program is free software; you can redistribute it and/or              *
 * modify it under the terms of the GNU General Public License                *
 * as published by the Free Software Foundation; either version 2             *
 * of the License, or (at your option) any later version.                     *
 *                                                                            *
 * This program is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU General Public License for more details.                               *
 *                                                                            *
 * You should have received a copy of the GNU General Public License          *
 * along with this program; if not, write to the Free Software Foundation     *
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ******************************************************************************/

object CheckCommand "interfacetable" {
	import "plugin-check-command"

	command = [ PluginContribDir + "/check_interface_table_v3t" ]

	arguments = {
		"-H" = {
			value = "$interfacetable_hostquery$"
			description = "Specifies the remote host to poll"
		}
		"-h" = {
			value = "$interfacetable_hostdisplay$"
			description = "Specifies the hostname to display in the HTML link"
		}
		"-r" = {
			set_if = "$interfacetable_regex$"
			description = "Interface names and property names for some other options will be interpreted as regular expressions"
		}
		"--outputshort" = {
			set_if = "$interfacetable_outputshort$"
			description = "Reduce the verbosity of the plugin output"
		}
		"-e" = {
			value = "$interfacetable_exclude$"
			description = "Comma separated list of interfaces globally excluded from the monitoring"
		}
		"-i" = {
			value = "$interfacetable_include$"
			description = "Comma separated list of interfaces globally included in the monitoring"
		}
		"--alias-matching" = {
			set_if = "$interfacetable_aliasmatching$"
			description = "Allow you to specify alias in addition to interface names"
		}
		"--et" = {
			value = "$interfacetable_excludetraffic$"
			description = "Comma separated list of interfaces excluded from traffic checks"
		}
		"--it" = {
			value = "$interfacetable_includetraffic$"
			description = "Comma separated list of interfaces included for traffic checks"
		}
		"--wt" = {
			value = "$interfacetable_warningtraffic$"
			description = "Interface traffic load percentage leading to a warning alert"
		}
		"--ct" = {
			value = "$interfacetable_criticaltraffic$"
			description = "Interface traffic load percentage leading to a critical alert"
		}
		"--pkt" = {
			set_if = "$interfacetable_pkt$"
			description = "Add unicast/non-unicast pkt stats for each interface"
		}
		"--tp" = {
			value = "$interfacetable_trackproperty$"
			description = "List of tracked properties"
		}
		"--ep" = {
			value = "$interfacetable_excludeproperty$"
			description = "Comma separated list of interfaces excluded from the property tracking"
		}
		"--ip" = {
			value = "$interfacetable_includeproperty$"
			description = "Comma separated list of interfaces included in the property tracking"
		}
		"--wp" = {
			value = "$interfacetable_warningproperty$"
			description = "Number of property changes before leading to a warning alert"
		}
		"--cp" = {
			value = "$interfacetable_criticalproperty$"
			description = "Number of property changes before leading to a critical alert"
		}
		"-C" = {
			value = "$interfacetable_community$"
			description = "Specifies the snmp v1/v2c community string"
		}
		"-2" = {
			set_if = "$interfacetable_snmpv2$"
			description = "Use snmp v2c"
		}
		"-l" = {
			value = "$interfacetable_login$"
			description = "Login for snmpv3 authentication"
		}
		"-x" = {
			value = "$interfacetable_passwd$"
			description = "Auth password for snmpv3 authentication"
		}
		"-X" = {
			value = "$interfacetable_privpass$"
			description = "Priv password for snmpv3"
		}
		"-L" = {
			value = "$interfacetable_protocols$"
			description = "Authentication protocol,Priv protocol"
		}
		"--domain" = {
			value = "$interfacetable_domain$"
			description = "SNMP transport domain"
		}
		"--contextname" = {
			value = "$interfacetable_contextname$"
			description = "Context name for the snmp requests"
		}
		"-P" = {
			value = "$interfacetable_port$"
			description = "SNMP port"
		}
		"--64bits" = {
			set_if = "$interfacetable_64bits$"
			description = "Use SNMP 64-bits counters"
		}
		"--max-repetitions" = {
			value = "$interfacetable_maxrepetitions$"
			description = "Increasing this value may enhance snmp query performances by gathering more results at one time"
		}
		"--snmp-timeout" = {
			value = "$interfacetable_snmptimeout$"
			description = "Define the Transport Layer timeout for the snmp queries"
		}
		"--snmp-retries" = {
			value = "$interfacetable_snmpretries$"
			description = "Define the number of times to retry sending a SNMP message"
		}
		"--unixsnmp" = {
			set_if = "$interfacetable_unixsnmp$"
			description = "Use unix snmp utilities for snmp requests"
		}
		"-f" = {
			set_if = "$interfacetable_enableperfdata$"
			description = "Enable port performance data"
		}
		"--perfdataformat" = {
			value = "$interfacetable_perfdataformat$"
			description = "Define which performance data will be generated"
		}
		"--perfdatathreshold" = {
			value = "$interfacetable_perfdatathreshold$"
			description = "Define which thresholds are printed in the generated performance data"
		}
		"--perfdatadir" = {
			value = "$interfacetable_perfdatadir$"
			description = "When specified, the performance data are also written directly to a file, in the specified location"
		}
		"--perfdataservicedesc" = {
			value = "$interfacetable_perfdataservicedesc$"
			description = "Specify additional parameters for output performance data to PNP"
		}
		"-g" = {
			value = "$interfacetable_grapher$"
			description = "Specify the used graphing solution"
		}
		"--grapherurl" = {
			value = "$interfacetable_grapherurl$"
			description = "Graphing system url"
		}
		"--portperfunit" = {
			value = "$interfacetable_portperfunit$"
			description = "Traffic could be reported in bits (counters) or in bps (calculated value)"
		}
		"--nodetype" = {
			value = "$interfacetable_nodetype$"
			description = "Specify the node type, for specific information to be printed / specific oids to be used"
		}
		"--duplex" = {
			set_if = "$interfacetable_duplex$"
			description = "Add the duplex mode property for each interface in the interface table"
		}
		"--stp" = {
			set_if = "$interfacetable_stp$"
			description = "Add the stp state property for each interface in the interface table"
		}
		"--vlan" = {
			set_if = "$interfacetable_vlan$"
			description = "Add the vlan attribution property for each interface in the interface table"
		}
		"--noipinfo" = {
			set_if = "$interfacetable_noipinfo$"
			description = "Remove the ip information for each interface from the interface table"
		}
		"--alias" = {
			set_if = "$interfacetable_alias$"
			description = "Add the alias information for each interface in the interface table"
		}
		"--accessmethod" = {
			value = "$interfacetable_accessmethod$"
			description = "Access method for a shortcut to the host in the HTML page"
		}
		"--htmltablelinktarget" = {
			value = "$interfacetable_htmltablelinktarget$"
			description = "Specifies the windows or the frame where the [details] link will load the generated html page"
		}
		"--delta" = {
			value = "$interfacetable_delta$"
			description = "Set the delta used for interface throuput calculation"
		}
		"--ifs" = {
			value = "$interfacetable_ifs$"
			description = "Input field separator"
		}
		"--cache" = {
			value = "$interfacetable_cache$"
			description = "Define the retention time of the cached data"
		}
		"--noifloadgradient" = {
			set_if = "$interfacetable_noifloadgradient$"
			description = "Disable color gradient from green over yellow to red for the load percentage"
		}
		"--nohuman" = {
			set_if = "$interfacetable_nohuman$"
			description = "Do not translate bandwidth usage in human readable format"
		}
		"--snapshot" = {
			set_if = "$interfacetable_snapshot$"
			description = "Force the plugin to run like if it was the first launch"
		}
		"--timeout" = {
			value = "$interfacetable_timeout$"
			description = "Define the global timeout limit of the plugin"
		}
		"--css" = {
			value = "$interfacetable_css$"
			description = "Define the css stylesheet used by the generated html files"
		}
		"--config" = {
			value = "$interfacetable_config$"
			description = "Specify a config file to load"
		}
		"--noconfigtable" = {
			set_if = "$interfacetable_noconfigtable$"
			description = "Disable configuration table on the generated HTML page"
		}
		"--notips" = {
			set_if = "$interfacetable_notips$"
			description = "Disable the tips in the generated html tables"
		}
		"--default-table-sorting" = {
			value = "$interfacetable_defaulttablesorting$"
			description = "Default table sorting"
		}
		"--table-split" = {
			set_if = "$interfacetable_tablesplit$"
			description = "Generate multiple interface tables, one per interface type"
		}
		"--notype" = {
			set_if = "$interfacetable_notype$"
			description = "Remove the interface type for each interface"
		}
	}

	vars.interfacetable_hostquery = "$address$"
	vars.interfacetable_hostdisplay = "$host.display_name$"
	vars.interfacetable_perfdataservicedesc = "$service.name$"
	vars.interfacetable_regex = false
	vars.interfacetable_outputshort = false
	vars.interfacetable_aliasmatching = false
	vars.interfacetable_pkt = false
	vars.interfacetable_snmpv2 = false
	vars.interfacetable_64bits = false
	vars.interfacetable_unixsnmp = false
	vars.interfacetable_enableperfdata = false
	vars.interfacetable_duplex = false
	vars.interfacetable_stp = false
	vars.interfacetable_vlan = false
	vars.interfacetable_noipinfo = false
	vars.interfacetable_noifloadgradient = false
	vars.interfacetable_nohuman = false
	vars.interfacetable_snapshot = false
	vars.interfacetable_noconfigtable = false
	vars.interfacetable_notips = false
	vars.interfacetable_notype = false
}

object CheckCommand "iftraffic" {
	import "plugin-check-command"
	import "ipv4-or-ipv6"

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

	arguments = {
		"-H" = {
			value = "$iftraffic_address$"
			description = "Check interface on the indicated host."
			required = true
		}
		"-C" = {
			value = "$iftraffic_community$"
			description = "SNMP community. Defaults to 'public' if omitted."
		}
		"-i" = {
			value = "$iftraffic_interface$"
			description = "Interface name."
			required = true
		}
		"-b" = {
			value = "$iftraffic_bandwidth$"
			description = "Interface maximum speed in kilo/mega/giga/bits per second."
			required = true
		}
		"-u" = {
			value = "$iftraffic_units$"
			description = "g=gigabits/s,m=megabits/s,k=kilobits/s,b=bits/s."
		}
		"-w" = {
			value = "$iftraffic_warn$"
			description = "% of bandwidth usage necessary to result in warning status (default: 85%)"
		}
		"-c" = {
			value = "$iftraffic_crit$"
			description = "% of bandwidth usage necessary to result in critical status (default: 98%)"
		}
		"-M" = {
			value = "$iftraffic_max_counter$"
			description = "Max counter value of net devices in kilo/mega/giga/bytes."
		}
	}

	vars.iftraffic_address = "$check_address$"
	vars.iftraffic_warn = "85%"
	vars.iftraffic_crit = "98%"
}

object CheckCommand "interfaces" {
	import "plugin-check-command"
	import "ipv4-or-ipv6"

	command = [ PluginContribDir + "/check_interfaces" ]

	arguments = {
		"--hostname" = "$interfaces_address$"
		"--community" = {
			value = "$interfaces_community$"
			description = "The community string (default public)."
		}
		"--regex" = {
			value = "$interfaces_regex$"
			description = "Interface list regexp."
		}
		"--exclude-regex" = {
			value = "$interfaces_exclude_regex$"
			description = "Interface list negative regexp."
		}
		"--errors" = {
			value = "$interfaces_errors$"
			description = "Number of in errors (CRC errors for cisco) to consider a warning (default 50)."
		}
		"--out-errors" = {
			value = "$interface_out_errors$"
			description = "Number of out errors (collisions for cisco) to consider a warning (default same as in errors)."
		}
		"--perfdata" = {
			value = "$interfaces_perfdata$"
		}
		"--prefix" = {
			value = "$interfaces_prefix$"
			description = "Prefix interface names with this label."
		}
		"--lastcheck" = {
			value = "$interfaces_lastcheck$"
			description = "Last checktime (unixtime)."
		}
		"--bandwidth" = {
			value = "$interfaces_bandwidth$"
			description = "Bandwidth warn level in percent."
		}
		"--speed" = {
			value = "$interfaces_speed$"
			description = "Override speed detection with this value (bits per sec)."
		}
		"--trim" = {
			value = "$interfaces_trim$"
			description = "Cut this number of characters from the start of interface descriptions."
		}
		"--mode" = {
			value = "$interfaces_mode$"
			description = "Special operating mode (default,cisco,nonbulk,bintec)."
		}
		"--auth-proto" = {
			value = "$interfaces_auth_proto$"
			description = "SNMPv3 Auth Protocol (SHA|MD5)"
		}
		"--auth-phrase" = {
			value = "$interfaces_auth_phrase$"
			description = "SNMPv3 Auth Phrase"
		}
		"--priv-proto" = {
			value = "$interfaces_priv_proto$"
			description = "SNMPv3 Privacy Protocol (AES|DES)"
		}
		"--priv-phrase" = {
			value = "$interfaces_priv_phrase$"
			description = "SNMPv3 Privacy Phrase"
		}
		"--user" = {
			value = "$interfaces_user$"
			description = "SNMPv3 User"
		}
		"--down-is-ok" = {
			set_if = "$interfaces_down_is_ok$"
			description = "Disables critical alerts for down interfaces."
		}
		"--aliases" = {
			set_if = "$interfaces_aliases$"
			description = "Retrieves the interface description."
		}
		"--match-aliases" = {
			set_if = "$interfaces_match_aliases$"
			description = "Also match against aliases (Option --aliases automatically enabled)."
		}
		"--timeout" = {
			value = "$interfaces_timeout$"
			description = "Sets the SNMP timeout (in ms)."
		}
		"--sleep" = {
			value = "$interfaces_sleep$"
			description = "Sleep between every SNMP query (in ms)."
		}
	}

	vars.interfaces_address = "$check_address$"
	vars.interfaces_down_is_ok = false
	vars.interfaces_aliases = false
	vars.interfaces_match_aliases = false
}

object CheckCommand "nwc_health" {
	import "plugin-check-command"
	import "ipv4-or-ipv6"

	command = [ PluginContribDir + "/check_nwc_health" ]

	arguments = {
		"--timeout" = {
			value = "$nwc_health_timeout$"
			description = "Seconds before plugin times out (default: 15)"
		}
		"--blacklist" = {
			value = "$nwc_health_blacklist$"
			description = "Blacklist some (missing/failed) components"
		}
		"--hostname" = {
			value = "$nwc_health_hostname$"
			description = "Hostname or IP-address of the switch or router"
		}
		"--port" = {
			value = "$nwc_health_port$"
			description = "The SNMP port to use (default: 161)"
		}
		"--domain" = {
			value = "$nwc_health_domain$"
			description = "The transport domain to use (default: udp/ipv4, other possible values: udp6, udp/ipv6, tcp, tcp4, tcp/ipv4, tcp6, tcp/ipv6)"
		}
		"--protocol" = {
			value = "$nwc_health_protocol$"
			description = "The SNMP protocol to use (default: 2c, other possibilities: 1,3)"
		}
		"--community" = {
			value = "$nwc_health_community$"
			description = "SNMP community of the server (SNMP v1/2 only)"
		}
		"--username" = {
			value = "$nwc_health_username$"
			description = "The securityName for the USM security model (SNMPv3 only)"
		}
		"--authpassword" = {
			value = "$nwc_health_authpassword$"
			description = "The authentication password for SNMPv3"
		}
		"--authprotocol" = {
			value = "$nwc_health_authprotocol$"
			description = "The authentication protocol for SNMPv3 (md5|sha)"
		}
		"--privpassword" = {
			value = "$nwc_health_privpassword$"
			description = "The password for authPriv security level"
		}
		"--privprotocol" = {
			value = "$nwc_health_privprotocol$"
			description = "The private protocol for SNMPv3 (des|aes|aes128|3des|3desde)"
		}
		"--contextengineid" = {
			value = "$nwc_health_contextengineid$"
			description = "The context engine id for SNMPv3 (10 to 64 hex characters)"
		}
		"--contextname" = {
			value = "$nwc_health_contextname$"
			description = "The context name for SNMPv3 (empty represents the default context)"
		}
		"--mode" = {
			value = "$nwc_health_mode$"
			description = "Which mode should be executed. A list of all available modes can be found in the plugin documentation"
		}
		"--name" = {
			value = "$nwc_health_name$"
			description = "The name of an interface (ifDescr)"
		}
		"--drecksptkdb" = {
			value = "$nwc_health_drecksptkdb$"
			description = "This parameter must be used instead of --name, because Devel::ptkdb is stealing the latter from the command line"
		}
		"--alias" = {
			value = "$nwc_health_alias$"
			description = "The alias name of a 64bit-interface (ifAlias)"
		}
		"--regexp" = {
			set_if = "$nwc_health_regexp$"
			description = "A flag indicating that --name is a regular expression"
		}
		"--ifspeedin" = {
			value = "$nwc_health_ifspeedin$"
			description = "Override the ifspeed oid of an interface (only inbound)"
		}
		"--ifspeedout" = {
			value = "$nwc_health_ifspeedout$"
			description = "Override the ifspeed oid of an interface (only outbound)"
		}
		"--ifspeed" = {
			value = "$nwc_health_ifspeed$"
			description = "Override the ifspeed oid of an interface"
		}
		"--units" = {
			value = "$nwc_health_units$"
			description = "One of %, B, KB, MB, GB, Bit, KBi, MBi, GBi. (used for e.g. mode interface-usage)"
		}
		"--name2" = {
			value = "$nwc_health_name2$"
			description = "The secondary name of a component"
		}
		"--role" = {
			value = "$nwc_health_role$"
			description = "The role of this device in a hsrp group (active/standby/listen)"
		}
		"--report" = {
			set_if = "$nwc_health_report$"
			description = "Can be used to shorten the output"
		}
		"--lookback" = {
			value = "$nwc_health_lookback$"
			description = "The amount of time you want to look back when calculating average rates. Use it for mode interface-errors or interface-usage. Without --lookback the time between two runs of check_nwc_health is the base for calculations. If you want your checkresult to be based for example on the past hour, use --lookback 3600." 
		}
		"--critical" = {
			value = "$nwc_health_critical$"
			description = "The critical threshold"
		}
		"--warning" = {
			value = "$nwc_health_warning$"
			description = "The warning threshold"
		}
		"--warningx" = {
			value = "$nwc_health_warningx$"
			description = "The extended warning thresholds"
		}
		"--criticalx" = {
			value = "$nwc_health_criticalx$"
			description = "The extended critical thresholds"
		}
		"--mitigation" = {
			set_if = "$nwc_health_mitigation$"
			description = "The parameter allows you to change a critical error to a warning."
		}
		"--selectedperfdata" = {
			value = "$nwc_health_selectedperfdata$"
			description = "The parameter allows you to limit the list of performance data. It's a perl regexp. Only matching perfdata show up in the output."
		}
		"--morphperfdata" = {
			value = "$nwc_health_morphperfdata$"
			description = "The parameter allows you to change performance data labels. It's a perl regexp and a substitution. --morphperfdata '(.*)ISATAP(.*)'='$1patasi$2'"
		}
		"--negate" = {
			value = "$nwc_health_negate$"
			description = "The parameter allows you to map exit levels, such as warning=critical"
		}
		"--with-mymodules-dyn-dir" = {
			value = "$nwc_health_mymodules-dyn-dir$"
			description = "A directory where own extensions can be found"
		}
		"--servertype" = {
			value = "$nwc_health_servertype$"
			description = "The type of the network device: cisco (default). Use it if auto-detection is not possible"
		}
		"--statefilesdir" = {
			value = "$nwc_health_statefilesdir$"
			description = "An alternate directory where the plugin can save files"
		}
		"--oids" = {
			value = "$nwc_health_oids$"
			description = "A list of oids which are downloaded and written to a cache file. Use it together with --mode oidcache"
		}
		"--offline" = {
			value = "$nwc_health_offline$"
			description = "The maximum number of seconds since the last update of cache file before it is considered too old"
		}
		"--multiline" = {
			set_if = "$nwc_health_multiline$"
			description = "Multiline output"
		}
	}

	vars.nwc_health_hostname = "$check_address$"
	vars.nwc_health_mode = "hardware-health"
}
