check_bandwidth: change ignore format

This commit is contained in:
Cyberes 2023-04-26 13:28:01 -06:00
parent 488270282c
commit 319851ea94
1 changed files with 3 additions and 3 deletions

View File

@ -8,15 +8,15 @@ import psutil
import checker.nagios as nagios
from checker.markdown import list_to_markdown_table
# Parse the bandwidth limit argument
parser = argparse.ArgumentParser(description='Check network interface bandwidth utilization.')
parser.add_argument('--bandwidth', type=float, required=True, help='Bandwidth speed in Mbps.')
parser.add_argument('--critical', type=int, default=75, help='Critical if percent of bandwidth usage is greater than or equal to this.')
parser.add_argument('--warn', type=int, default=50, help='Warning if percent of bandwidth usage is greater than or equal to this.')
parser.add_argument('--max', type=int, default=None, help='Set the max value the bandwidth can be. Useful for graphs and whatever.')
parser.add_argument('--ignore', nargs='*', default=[], help='Interface names to ignore.')
parser.add_argument('--ignore', default=None, help='Interface names to ignore.')
args = parser.parse_args()
ignore_interfaces = args.ignore.split(',') if args.ignore else []
def main():
data = []
@ -28,7 +28,7 @@ def main():
# Calculate bandwidth utilization for each interface
for interface, stats in net_io_counters.items():
if interface in args.ignore:
if interface in ignore_interfaces:
continue
# Get the number of bytes sent and received
bytes_sent = stats.bytes_sent