Compare commits

..

No commits in common. "2d67a016b0e8c93c652ba5724975791337ac0a6e" and "2c2f25092ef75b041796d7cc28595b40df4f88d6" have entirely different histories.

2 changed files with 23 additions and 80 deletions

View file

@ -166,10 +166,8 @@ def determine_result(options, json_data) -> Tuple[int, Optional[List[str]]]:
Args: Args:
options: An object with threshold attributes used for evaluation. options: An object with threshold attributes used for evaluation.
Expected attributes include: Expected attributes include:
- rate_up_warn (int): Warning threshold for upstream rate in bits per second. - rate_warn (int): Warning threshold for bits per second.
- rate_up_crit (int): Critical threshold for upstream rate in bits per second. - rate_crit (int): Critical threshold for bits per second.
- rate_down_warn (int): Warning threshold for downstream rate in bits per second.
- rate_down_crit (int): Critical threshold for downstream rate in bits per second.
- retrans_warn (int): Warning threshold for retransmissions (TCP only). - retrans_warn (int): Warning threshold for retransmissions (TCP only).
- retrans_crit (int): Critical threshold for retransmissions (TCP only). - retrans_crit (int): Critical threshold for retransmissions (TCP only).
- udp (bool): Whether the test was run over UDP (retransmissions are ignored if True). - udp (bool): Whether the test was run over UDP (retransmissions are ignored if True).
@ -190,34 +188,19 @@ def determine_result(options, json_data) -> Tuple[int, Optional[List[str]]]:
if "error" in json_data: if "error" in json_data:
nagexit(3, json_data["error"]) nagexit(3, json_data["error"])
json_end = json_data['end'] if options.rate_crit and options.rate_warn:
if json_data["end"]["sum_sent"]["bits_per_second"] <= options.rate_crit:
bps_avg_up = json_end['sum_sent']['bits_per_second'] if options.bidir or not options.downstream else None
bps_avg_down = json_end['sum_sent_bidir_reverse']['bits_per_second'] if options.bidir else \
json_data['end']['sum_sent']['bits_per_second'] if options.downstream else None
if bps_avg_up is not None:
if options.rate_up_crit and bps_avg_up <= options.rate_up_crit:
rc = max(rc, 2) rc = max(rc, 2)
statuslines.append("upstream rate below critical threshold") statuslines.append("transfer rate below critical threshold")
elif options.rate_up_warn and bps_avg_up <= options.rate_up_warn: elif json_data["end"]["sum_sent"]["bits_per_second"] <= options.rate_warn:
rc = max(rc, 1) rc = max(rc, 1)
statuslines.append("upstream rate below warning threshold") statuslines.append("transfer rate below warning threshold")
if bps_avg_down is not None:
if options.rate_down_crit and bps_avg_down <= options.rate_down_crit:
rc = max(rc, 2)
statuslines.append("downpstream rate below critical threshold")
elif options.rate_down_warn and bps_avg_down <= options.rate_down_warn:
rc = max(rc, 1)
statuslines.append("downstream rate below warning threshold")
if not options.udp and options.retrans_crit and options.retrans_warn: if not options.udp and options.retrans_crit and options.retrans_warn:
retransmits = json_data["end"]["sum_sent"]["retransmits"] if json_data["end"]["sum_sent"]["retransmits"] >= options.retrans_crit:
if retransmits >= options.retrans_crit:
rc = max(rc, 2) rc = max(rc, 2)
statuslines.append("retransmissions over critical threshold") statuslines.append("retransmissions over critical threshold")
elif retransmits >= options.retrans_warn: elif json_data["end"]["sum_sent"]["retransmits"] >= options.retrans_warn:
rc = max(rc, 1) rc = max(rc, 1)
statuslines.append("retransmissions over warning threshold") statuslines.append("retransmissions over warning threshold")
@ -304,10 +287,8 @@ def build_perfdata(options, json_data: dict) -> List[str]:
- bidir (bool): Whether the test was bidirectional. - bidir (bool): Whether the test was bidirectional.
- downstream (bool): Whether to use reverse (download) direction. - downstream (bool): Whether to use reverse (download) direction.
- udp (bool): Whether the test used UDP (retransmissions ignored). - udp (bool): Whether the test used UDP (retransmissions ignored).
- rate_up_warn (int): Warning threshold for upstream rate in bits per second. - rate_warn (int): Warning threshold for throughput (in bits/sec).
- rate_up_crit (int): Critical threshold for upstream rate in bits per second. - rate_crit (int): Critical threshold for throughput.
- rate_down_warn (int): Warning threshold for downstream rate in bits per second.
- rate_down_crit (int): Critical threshold for downstream rate in bits per second.
- retrans_warn (int): Warning threshold for retransmissions (TCP only). - retrans_warn (int): Warning threshold for retransmissions (TCP only).
- retrans_crit (int): Critical threshold for retransmissions. - retrans_crit (int): Critical threshold for retransmissions.
json_data (dict): Parsed iperf3 output containing measurement results. json_data (dict): Parsed iperf3 output containing measurement results.
@ -324,19 +305,19 @@ def build_perfdata(options, json_data: dict) -> List[str]:
json_end = json_data['end'] json_end = json_data['end']
bps_avg_up = json_end['sum_sent']['bits_per_second'] if options.bidir or not options.downstream else None bps_avg_up = json_end['sum_sent']['bits_per_second'] if options.bidir or not options.downstream else None
bps_avg_down = json_end['sum_sent_bidir_reverse']['bits_per_second'] if options.bidir else \ bps_avg_down = json_end['sum_sent_bidir_reverse']['bits_per_second'] if options.bidir else json_data[
json_data['end']['sum_sent']['bits_per_second'] if options.downstream else None 'end']['sum_sent']['bits_per_second'] if options.downstream else None
if not options.udp: if not options.udp:
retrans_sum_up = json_end['sum_sent']['retransmits'] if options.bidir or not options.downstream else None retrans_sum_up = json_end['sum_sent']['retransmits'] if options.bidir or not options.downstream else None
retrans_sum_down = json_end['sum_sent_bidir_reverse']['retransmits'] if options.bidir else \ retrans_sum_down = json_end['sum_sent_bidir_reverse']['retransmits'] if options.bidir else json_data[
json_data['end']['sum_sent']['retransmits'] if options.downstream else None 'end']['sum_sent']['retransmits'] if options.downstream else None
if bps_avg_up is not None: if bps_avg_up is not None:
perfdata.append(build_single_perfdata("bps_avg_up", bits_per_second( perfdata.append(build_single_perfdata("bps_avg_up", bits_per_second(
bps_avg_up), options.rate_up_warn, options.rate_up_crit)) bps_avg_up), options.rate_warn, options.rate_crit))
if bps_avg_down is not None: if bps_avg_down is not None:
perfdata.append(build_single_perfdata("bps_avg_down", bits_per_second( perfdata.append(build_single_perfdata("bps_avg_down", bits_per_second(
bps_avg_down), options.rate_down_warn, options.rate_down_crit)) bps_avg_down), options.rate_warn, options.rate_crit))
if not options.udp: if not options.udp:
if retrans_sum_up is not None: if retrans_sum_up is not None:
@ -346,10 +327,10 @@ def build_perfdata(options, json_data: dict) -> List[str]:
perfdata.append(build_single_perfdata("retrans_sum_down", packets( perfdata.append(build_single_perfdata("retrans_sum_down", packets(
retrans_sum_down), options.retrans_warn, options.retrans_crit)) retrans_sum_down), options.retrans_warn, options.retrans_crit))
perfdata.append(build_single_perfdata("local_cpu", perfdata.append(build_single_perfdata("local_cpu", percent(
percent(json_end['cpu_utilization_percent']['host_total']))) json_end['cpu_utilization_percent']['host_total'])))
perfdata.append(build_single_perfdata("remote_cpu", perfdata.append(build_single_perfdata("remote_cpu", percent(
percent(json_end['cpu_utilization_percent']['remote_total']))) json_end['cpu_utilization_percent']['remote_total'])))
return perfdata return perfdata
def check_iperf3(options): def check_iperf3(options):
@ -369,10 +350,8 @@ def check_iperf3(options):
- bidir (bool): Whether the test should be bidirectional. - bidir (bool): Whether the test should be bidirectional.
- downstream (bool): Whether the test should use reverse mode (server to client). - downstream (bool): Whether the test should use reverse mode (server to client).
- udp (bool): Whether the test should use UDP instead of TCP. - udp (bool): Whether the test should use UDP instead of TCP.
- rate_up_warn (int): Warning threshold for upstream rate in bits per second. - rate_warn (int): Warning threshold for throughput (in bits/sec).
- rate_up_crit (int): Critical threshold for upstream rate in bits per second. - rate_crit (int): Critical threshold for throughput.
- rate_down_warn (int): Warning threshold for downstream rate in bits per second.
- rate_down_crit (int): Critical threshold for downstream rate in bits per second.
- retrans_warn (int): Warning threshold for retransmissions (TCP only). - retrans_warn (int): Warning threshold for retransmissions (TCP only).
- retrans_crit (int): Critical threshold for retransmissions (TCP only). - retrans_crit (int): Critical threshold for retransmissions (TCP only).
- bytes (str): Optional. Data to transfer (e.g., '10M'). - bytes (str): Optional. Data to transfer (e.g., '10M').
@ -404,18 +383,6 @@ if __name__ == "__main__":
thres_opts.add_option("-c", "--rate-critical", dest="rate_crit", thres_opts.add_option("-c", "--rate-critical", dest="rate_crit",
type="int", metavar="BITS", action="store", type="int", metavar="BITS", action="store",
help="Defines the transfer rate's critical threshold") help="Defines the transfer rate's critical threshold")
thres_opts.add_option("--rate-up-warning", dest="rate_up_warn",
type="int", metavar="BITS", action="store",
help="Defines the upstream rate's warning threshold")
thres_opts.add_option("--rate-up-critical", dest="rate_up_crit",
type="int", metavar="BITS", action="store",
help="Defines the upstream rate's critical threshold")
thres_opts.add_option("--rate-down-warning", dest="rate_down_warn",
type="int", metavar="BITS", action="store",
help="Defines the downstream rate's warning threshold")
thres_opts.add_option("--rate-down-critical", dest="rate_down_crit",
type="int", metavar="BITS", action="store",
help="Defines the downstream rate's critical threshold")
# retransmits # retransmits
thres_opts.add_option("-W", "--retransmit-warning", dest="retrans_warn", thres_opts.add_option("-W", "--retransmit-warning", dest="retrans_warn",
@ -464,14 +431,6 @@ if __name__ == "__main__":
if not opts.remote or opts.time <= 0: if not opts.remote or opts.time <= 0:
parser.print_help() parser.print_help()
sys.exit(3) sys.exit(3)
if not opts.rate_up_warn:
opts.rate_up_warn = opts.rate_warn
if not opts.rate_down_warn:
opts.rate_down_warn = opts.rate_warn
if not opts.rate_up_crit:
opts.rate_up_crit = opts.rate_crit
if not opts.rate_down_crit:
opts.rate_down_crit = opts.rate_crit
check_iperf3(opts) check_iperf3(opts)

View file

@ -42,22 +42,6 @@ object CheckCommand "iperf3" {
description = "defines the transfer rate's critical threshold" description = "defines the transfer rate's critical threshold"
value = "$check_iperf3_rate_critical$" value = "$check_iperf3_rate_critical$"
} }
"--rate-up-warning" = {
description = "defines the upstream rate's warning threshold"
value = "$check_iperf3_rate_up_warning$"
}
"--rate-up-critical" = {
description = "defines the upstream rate's critical threshold"
value = "$check_iperf3_rate_up_critical$"
}
"--rate-down-warning" = {
description = "defines the downstream rate's warning threshold"
value = "$check_iperf3_rate_down_warning$"
}
"--rate-down-critical" = {
description = "defines the downstream rate's critical threshold"
value = "$check_iperf3_rate_down_critical$"
}
"--retransmission-warning" = { "--retransmission-warning" = {
description = "defines the transfer retransmission's warning threshold" description = "defines the transfer retransmission's warning threshold"
value = "$check_iperf3_retransmission_warning$" value = "$check_iperf3_retransmission_warning$"