Date: Fri, 1 Jan 1999 21:06:53 +0000 (BST) From: Scot Elliott <scot@london.virgin.net> To: Jesper Skriver <jesper@skriver.dk> Cc: freebsd-isp@FreeBSD.ORG Subject: Re: How to check your RADIUS servers is running properly ? Message-ID: <Pine.SOL.4.05.9901012102330.27662-100000@athalassa> In-Reply-To: <19990101164642.C4446@skriver.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi.
Funny you should mention that... I wrote something recently that kindof
does that.
You'll need the ConfigFile, Authen::Radius and Time::Hires perl modules
installed for this to work:
#!/usr/local/bin/perl
#
# Authorization time test script
#
#
# Only change this; there aren't any other vars you need to touch.
#
my $configFile = "/usr/local/etc/authtest.conf";
################################################
use strict;
use Authen::Radius;
use Time::HiRes qw( gettimeofday tv_interval );
use ConfigFile;
################################################
# Get the configuration parameters
#
my %Params;
ReadConfigFile( \%Params );
# Try to authenticate ourselves
#
my $RequestTime = DoAuth();
# Log the result
#
my $OpenParams = ">>" . $Params{"log"};
open( LOGFILE, $OpenParams ) ||
open( LOGFILE, ">&STDOUT");
if( $RequestTime ) {
print LOGFILE "[" . gmtime() . "] - " . $Params{"server"} . " - SUCCESS - $RequestTime ms\n"
} else {
print LOGFILE "[" . gmtime() . "] - " . $Params{"server"} . " - FAILED -\n";
}
close( LOGFILE );
1;
# Makes an auth request and returns the amount of time it took to
# come back - or undefined if an error occured.
#
sub DoAuth {
# Make a new Radius client object
#
my $r = new Authen::Radius( Host => $Params{"server"},
Secret => $Params{"secret"},
Timeout => $Params{"timeout"} );
# Record the time now (hi-res)
#
my $startTime = [gettimeofday];
# Check the password with the radius server
#
my $result = $r->check_pwd( $Params{"username"}, $Params{"password"} );
# So how long did that take then?
#
my $elapsedTime = tv_interval( $startTime );
$elapsedTime = $elapsedTime * 1000;
$elapsedTime = $elapsedTime + 0.5;
$elapsedTime =~ s/(.*)\..*/$1/;
if( $result ) {
return $elapsedTime;
} else {
return undef;
}
}
sub ReadConfigFile {
my $paramsRef = shift;
my $config = new ConfigFile "$configFile";
my $hashref = $config->Section("authtest");
foreach my $key ( keys %{$hashref} ) {
$$paramsRef{$key} = $config->Parameter( "authtest", $key );
}
}
The config file should look like this:
[authtest]
server = auth1.yourdomain.com
secret = mysecret
username = testuser
password = testpass
timeout = 25
log = /var/log/authtest.log
Hope that's useful.
Scot.
On Fri, 1 Jan 1999, Jesper Skriver wrote:
> Hi,
>
> I'm going to find (or write) an application that can monitor our RADIUS
> servers, currently we're using a Winblows application, I don't know
> exactly what it checks for, it has cheated us a couple of times ...
>
> I was thinking of a program, that acted like a NAS, tried to
> authenticate a user logging on, and looks at the response from the
> RADIUS servers.
>
> Has anybody such a program, or knows of building blocks ?
>
> Without looking much at it so far, I was thinking of using the RADIUS
> module for perl5 ...
>
> /Jesper
>
> --
> Jesper Skriver (JS4261-RIPE), Network manager
> Tele Danmark DataNet, IP section (AS3292)
>
> One Unix to rule them all, One Resolver to find them,
> One IP to bring them all and in the zone to bind them.
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-isp" in the body of the message
>
-----------------------------------------------------------------------------
Scot Elliott Mobile: +44 (0)7050 126045
Work: scot@london.virgin.net, scot@nic.cx +44 (0)171 479 4482
Play: scot@poptart.org, scot@indiekid.co.uk, s@cx +44 (0)181 896 1019
-----------------------------------------------------------------------------
Public key available at: http://www.poptart.org/pgpkey.html
Fingerprint: FCAE9ED3A234FEB59F8C7F9DDD112D
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.4.05.9901012102330.27662-100000>
