*** checkrad.old	Wed Feb 23 14:44:50 2005
--- checkrad	Wed Feb 23 14:45:23 2005
***************
*** 32,37 ****
--- 32,38 ----
  #		mikrotik_telnet  1.1    Author: Evren Yurtesen <yurtesen@ispro.net.tr>
  #		mikrotik_snmp    1.0    Author: Evren Yurtesen <yurtesen@ispro.net.tr>
  #		redback_telnet          Author: Eduardo Roldan
+ #		simple_www	        Author: Alex French <alex@bitbuzz.com>
  #
  #	Config: $debug is the file you want to put debug messages in
  #		$snmpget is the location of your ``snmpget'' program
***************
*** 88,93 ****
--- 89,97 ----
  		$::HAVE_SNMP_SESSION = ($@ eq "");
  		eval "use Socket;";
  	}
+ 
+ 	eval "use LWP::Simple;";
+ 	$::HAVE_LWP = ($@ eq "");
  };
  
  #
***************
*** 1344,1349 ****
--- 1348,1385 ----
      return 0;
  }
  
+ sub simple_www {
+     # Very simple sub to check a list of users retrieved from a www
+     # interface. 
+     # In this case I'm pulling data from a modified nocat server. I look
+     # for a line starting with the username and ending with the sessionid.
+     # This should be easily modified for other NAS-like devices that have
+     # www interfaces (e.g. WiFi access points)
+ 
+     # We need LWP (this is checked in the BEGIN block)
+     if( !$::HAVE_LWP) {
+       return(2);
+     }
+ 
+     # Localize variables
+     my(@lines,$line);
+     my ($nas) = $ARGV[1];
+     my ($user) = $ARGV[3];
+     my ($sid) = $ARGV[4];
+ 
+     # Retrive the list from the access point
+     my $text = get "http://$nas:5280/status-nxh";
+ 
+     @lines=split(/\n/,$text); 
+     splice(@lines,0,1); 
+     foreach $line (@lines) {
+       # Look for lines starting with username and ending with the sessionid
+       if($line =~ /^$user\s.+\s$sid$/) {
+         return 1;
+       } 
+     }
+     return 0;
+ }
  ###############################################################################
  
  # Poor man's getopt (for -d)
***************
*** 1418,1423 ****
--- 1454,1461 ----
          $ret = &mikrotik_snmp;
  } elsif ($ARGV[0] eq 'redback'){
          $ret = &redback_telnet;
+ } elsif ($ARGV[0] eq 'www'){
+         $ret = &simple_www;
  } elsif ($ARGV[0] eq 'other') {
  	$ret = 1;
  } else {
