check_bandwidth: ignore interface option

This commit is contained in:
Cyberes 2023-04-26 13:20:10 -06:00
parent 2d2ba69c54
commit 488270282c
1 changed files with 3 additions and 0 deletions

View File

@ -14,6 +14,7 @@ parser.add_argument('--bandwidth', type=float, required=True, help='Bandwidth sp
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('--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('--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('--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.')
args = parser.parse_args() args = parser.parse_args()
@ -27,6 +28,8 @@ def main():
# Calculate bandwidth utilization for each interface # Calculate bandwidth utilization for each interface
for interface, stats in net_io_counters.items(): for interface, stats in net_io_counters.items():
if interface in args.ignore:
continue
# Get the number of bytes sent and received # Get the number of bytes sent and received
bytes_sent = stats.bytes_sent bytes_sent = stats.bytes_sent
bytes_recv = stats.bytes_recv bytes_recv = stats.bytes_recv