Skip to main content

check_radius.pl

#!/usr/bin/perl
 
use Authen::Radius;
 
my $radiusserver = $ARGV[0];
my $radiussecret = $ARGV[1];
my $username = $ARGV[2];
my $password = $ARGV[3];
my $timeout = $ARGV[4];
my $debug = $ARGV[5] ? 1:0;
 
if (! $ARGV[4]) {
        print "Usage: check_radius.pl <server> <secret> <user> <password> <timeout> [<verbose>]\n";
        exit 0;
}
 
my $r = new Authen::Radius(Host => $radiusserver, Secret => $radiussecret, TimeOut => $timeout, Debug => $debug);
 
if (! $r) {
        print "CRITICAL - Radius dead\n";
        exit 2;
}
 
if ($r->check_pwd($username,$password)) {
        print "OK - Check ok\n";
        exit 0;
} else {
        print "Error: ", $r->strerror(), "\n" if $debug;
        print "Error: ", $r->get_error(), "\n" if $debug;
        print "OK - but Authen-Check failed\n";
        exit 1;
}