#!/usr/bin/perl # check_wireless_interface.pl - nagios plugin # USAGE: check_wireless_interface.pl [interface] [threshold/100] use strict; use Data::Dumper; my %ERRORS = ( 'UNKNOWN', '-1', 'OK', '0', 'WARNING', '1', 'CRITICAL', '2'); my ($state, $answer); my $IWCONFIG='/sbin/iwconfig'; my ($if, $thresh) = @ARGV; my $output=`$IWCONFIG $if`; $output =~ m#Link Quality=(\d+)/\d+#si; my $linkqual = $1; if ($linkqual < $thresh) { $state = 'WARNING'; $answer = "Warning Link Quality : $linkqual (Threshold = $thresh)\n"; } else { $state = 'OK'; $answer = "Link Quality OK - $linkqual\n"; } print $answer; exit $ERRORS{$state};