2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
28 def check_icmp_arguments(params
):
32 for key
, value
in params
.items():
34 args
.append("-t %d" % value
)
35 elif key
== "packets":
36 args
.append("-n %d" % value
)
41 args
.append("-w %.2f,%d%%" % (rta
[0], loss
[0]))
42 args
.append("-c %.2f,%d%%" % (rta
[1], loss
[1]))
44 target
= params
.get("address", "address")
45 if target
== "address":
46 args
.append("'$HOSTADDRESS$'")
48 elif target
== "alias":
49 args
.append("'$HOSTALIAS$'")
51 elif target
== "all_ipv4addresses":
52 args
+= ["$HOST_ADDRESSES_4$", "$HOST_ADDRESS_4$"]
54 elif target
== "all_ipv6addresses":
55 args
+= ["-6", "$HOST_ADDRESSES_6$", "$HOST_ADDRESS_6$"]
57 elif target
== "additional_ipv4addresses":
58 args
.append("$HOST_ADDRESSES_4$")
60 elif target
== "additional_ipv6addresses":
61 args
+= ["-6", "$HOST_ADDRESSES_6$"]
63 elif target
[0] == "indexed_ipv4address":
64 args
.append("$HOST_ADDRESS_4_%s$" % target
[1])
66 elif target
[0] == "indexed_ipv6address":
67 args
.append("$HOST_ADDRESS_6_%s$" % target
[1])
70 args
.append(quote_shell_string(target
[1]))
74 def check_icmp_description(params
):
76 target
= params
.get("address", "address")
77 if target
[0] == "indexed_ipv4address":
78 description
+= " IPv4/%s" % target
[1]
79 elif target
[0] == "indexed_ipv6address":
80 description
+= " IPv6/%s" % target
[1]
84 active_check_info
['icmp'] = {
85 "command_line": '$USER1$/check_icmp $ARG1$',
86 "argument_function": check_icmp_arguments
,
87 "service_description": check_icmp_description
,