* Add a force directive in log_badlogins. If uncommented it will force inserts even if there are
sql errors. That can help in case there is one sql query which stops the whole failed logins
logging system from working
+* Sort the servers list in failed_logins,user_stats,stats
+* Add the /bin postgresql compatibility patch from Guy Fraser
Ver 1.65:
* Add a captions.conf file with a few configurable captions for now
* Move the nas list to a separate file called naslist.conf
--- /dev/null
+Fri Dec 19 2003
+---------------
+Fixed a couple bugs.
+Tested against current CVS, and all programs appear to work.
+
+Wed Dec 17 2003
+---------------
+Added configurable entries to admin.conf.
+TODO: Write a proper config file parser to get recursive entries from config
+file.
+
+Tue Dec 16 2003
+---------------
+
+File Compatiblity Change
+----------------------- --------------- ---------------------------------------
+clean_radacct MySQL/PG Added PG compatability
+log_badlogins MySQL/PG Added PG compatability
+ " Added routine to determine ip from the
+ " FreeRadius clients.conf file.
+monthly_tot_stats MySQL/PG Added PG compatability
+showmodem UCD/NET Made compatabile with Net/UCD SNMP
+ " Cleaned up output formatting.
+snmpfinger UCD/NET Made compatabile with Net/UCD SNMP
+tot_stats MySQL/PG Added PG compatability
+ " Added a delete request.
+truncate_radacct MySQL/PG Added PG compatability
+
+These utilities have been updated to work with NET-SNMP, and have been modified
+to work with PostgreSQL.
+
+The argument order and options for NET-SNMP have changed from UCD-SNMP's
+requirements. Since most current Unix type systems are using the newer
+NET-SNMP, I have included the changes for everyones benefit.
+
+I have also modified some scripts :
+
+log_badlogins - I changed it to use the data from the FreeRadius clients.conf
+ file to determine the IP address of each NAS. I did this because in my
+ case, and likely that of many others, the shortname from the radius log
+ file is not shortname.domain.com, where domain.com is defined in
+ admin.conf.
+
+showmodem - I cleaned up the output presentation.
+
+Path to admin.conf, set to /usr/local/dialup_admin/conf/ for all scripts.
+
+Guy Fraser
+Network Administrator
+The Internet Centre
+Edmonton, Alberta, Canada.
#
# Clean stale open sessions from the radacct table.
# we only clean up sessions which are older than $back_days
+# Works with mysql and postgresql
#
use POSIX;
while(<CONF>){
chomp;
($key,$val)=(split /:\s*/,$_);
+ $sql_type = $val if ($key eq 'sql_type');
$sql_server = $val if ($key eq 'sql_server');
$sql_username = $val if ($key eq 'sql_username');
$sql_password = $val if ($key eq 'sql_password');
$sql_database = $val if ($key eq 'sql_database');
$sql_accounting_table = $val if ($key eq 'sql_accounting_table');
- $mysql = $val if ($key eq 'sql_command');
+ $sqlcmd = $val if ($key eq 'sql_command');
}
close CONF;
-die "sql_command directive is not set in admin.conf\n" if ($mysql eq '');
-die "Could not find mysql binary. Please make sure that the \$mysql variable points to the right location\n" if (! -x $mysql);
+die "sql_command directive is not set in admin.conf\n" if ($sqlcmd eq '');
+die "Could not find sql binary. Please make sure that the \$sqlcmd variable points to the right location\n" if (! -x $sqlcmd);
$sql_password = ($sql_password eq '') ? '' : "-p$sql_password";
$date = POSIX::strftime("%Y-%m-%d %T",$sec,$min,$hour,($mday - $back_days),$mon,$year,$wday,$yday,$isdst);
print "$date\n";
-$query = "DELETE FROM $sql_accounting_table WHERE AcctStopTime = '0' AND AcctStartTime < '$date';";
+$query = "DELETE FROM $sql_accounting_table WHERE AcctStopTime IS NULL AND AcctStartTime < '$date';";
print "$query\n";
open TMP, ">/tmp/clean_radacct.query"
or die "Could not open tmp file\n";
print TMP $query;
close TMP;
-`$mysql -h$sql_server -u$sql_username $sql_password $sql_database </tmp/clean_radacct.query`;
+$command = "$sqlcmd -h$sql_server -u$sql_username $sql_password $sql_database </tmp/clean_radacct.query" if ($sql_type eq 'mysql');
+$command = "$sqlcmd -U $sql_username -f /tmp/clean_radacct.query $sql_database" if ($sql_type eq 'pg');
+`$command`;
--- /dev/null
+1 0 * * * /usr/local/dialup_admin/bin/tot_stats >/dev/null 2>&1
+5 0 * * * /usr/local/dialup_admin/bin/monthly_tot_stats >/dev/null 2>&1
+10 0 1 * * /usr/local/dialup_admin/bin/truncate_radacct >/dev/null 2>&1
+15 0 1 * * /usr/local/dialup_admin/bin/clean_radacct >/dev/null 2>&1
#!/usr/bin/perl
#
# Log failed logins in the sql database
-# Works only with mysql
+# Works with mysql and postgresql
# It will read the sql parameters from the admin.conf file
#
# Usage:
# CHANGE THESE TO MATCH YOUR SETUP
#
#$regexp = 'from client localhost port 135|from client blabla ';
-$tmpfile='/var/tmp/mysql.input';
+$tmpfile='/var/tmp/sql.input';
#
#
while(<CONF>){
chomp;
($key,$val)=(split /:\s*/,$_);
+ # Fixme : recursivly solve %{.*} replacement for $val
+ # Fixme: Conf should be put in an associative array
+ $sql_type = $val if ($key eq 'sql_type');
$sql_server = $val if ($key eq 'sql_server');
$sql_username = $val if ($key eq 'sql_username');
$sql_password = $val if ($key eq 'sql_password');
$domain = $val if ($key eq 'general_domain');
$sql_timeout = $val if ($key eq 'sql_connect_timeout');
$sql_extra = $val if ($key eq 'sql_extra_servers');
- $mysql = $val if ($key eq 'sql_command');
+ $sqlcmd = $val if ($key eq 'sql_command');
+ $clients= $val if ($key eq 'general_clients_conf');
}
close CONF;
+
+open CLIENTS, "<$clients"
+ or die "Could not open $clients file\n";
+while(<CLIENTS>){
+ chomp;
+ s/^\s*//g;
+ s/\s*#.*//g;
+ if (!/^\s*$/ && /=/) {
+ ($key,$val)=(split /\s*=\s*/,$_);
+ $client_short = $val if ($key eq 'shortname');
+ } else {
+ if (/\{/) {
+ s/.*client\s+([^\s]*)\s+\{.*$/\1/;
+ if (/^\d+\.\d+\.\d+\.\d+/) {
+ $client = $_;
+ } else {
+ if (/\./ || /localhost/) {
+ $name = $_ ;
+ } else {
+ $name = $_.".".$domain;
+ }
+ $addr = gethostbyname $name;
+ ($a,$b,$c,$d)=unpack('C4',$addr);
+ $client = "$a.$b.$c.$d";
+#DEBUG# print $name." = ".$client."\n";
+ }
+ } else {
+ if (/\}/) {
+ $client_array{$client_short} .= $client;
+ }
+ }
+ }
+}
+close CLIENTS;
+
$realm_del = '@' if ($realm_del eq '');
$realm_for = 'suffix' if ($realm_for eq '');
$pass = ($sql_password ne '') ? "-p$sql_password" : '';
die "SQL server not defined\n" if ($sql_server eq '');
-die "sql_command directive is not set in admin.conf\n" if ($mysql eq '');
-die "Could not find mysql binary. Please make sure that the \$mysql variable points to the right location\n" if (! -x $mysql);
+die "sql_command directive is not set in admin.conf\n" if ($sqlcmd eq '');
+die "Could not find sql binary. Please make sure that the \$sqlcmd variable points to the right location\n" if (! -x $sqlcmd);
$opt = "";
$opt = "-O connect_timeout=$sql_timeout" if ($sql_timeout);
$caller='' if (!defined($caller));
$user =~s/[^\w\-\.\d\!\@\s]//g;
$nas =~s/[^\w\.]//g;
- if ($nas ne 'localhost' && $nas !~ /\.$domain$/){
- $nas .= ".$domain";
- }
$port =~s/[^\d]//g;
- $addr = gethostbyname $nas;
- ($a,$b,$c,$d)=unpack('C4',$addr);
- $addr = "$a.$b.$c.$d";
+ $addr = $client_array{$nas};
if ($user ne '' && $realm_strip eq 'yes'){
($one,$two) = (split /$realm_del/, $user)[0,1];
if ($two ne ''){
$ctx->add($time);
$ctx->add('badlogin');
$uniqueid = $ctx->hexdigest;
+#DEBUG# print "INSERT INTO $sql_accounting_table (UserName,AcctUniqueId,NASIPAddress,NASPortId,AcctStartTime,AcctStopTime,AcctSessionTime,AcctInputOctets,AcctOutputOctets,CallingStationId,AcctTerminateCause) VALUES ('$user','$uniqueid','$addr','$port','$time','$time','0','0','0','$caller','$cause');\n";
print TMP "INSERT INTO $sql_accounting_table (UserName,AcctUniqueId,NASIPAddress,NASPortId,AcctStartTime,AcctStopTime,AcctSessionTime,AcctInputOctets,AcctOutputOctets,CallingStationId,AcctTerminateCause) VALUES ('$user','$uniqueid','$addr','$port','$time','$time','0','0','0','$caller','$cause');\n";
close TMP;
- `$mysql -h$server $opt -u$sql_username $pass $sql_database <$tmpfile.$server`;
+ $command = "$sqlcmd -h$server $opt -u$sql_username $pass $sql_database <$tmpfile.$server" if ($sql_type eq 'mysql');
+ $command = "$sqlcmd -U $sql_username -f $tmpfile.$server $sql_database" if ($sql_type eq 'pg');
+ `$command`;
+
$exit = $? >> 8;
$delete{$server} = ($exit == 0) ? 1 : 0;
print "ERROR: SQL query failed for host $server\n" if ($exit != 0);
}
}
}
- sleep 2;
- seek LOG,0,1;
+ if ($all_file ne 'once') {
+ sleep 2;
+ seek LOG,0,1;
+ } else {
+ exit(0);
+ }
}
# each user spaning in one month period.
# If the current month has not ended it will log information up to
# the current month day
+# Works only with mysql and postgresql
+#
-$conf=shift||'/usr/local/dialupadmin/conf/admin.conf';
+$conf=shift||'/usr/local/dialup_admin/conf/admin.conf';
open CONF, "<$conf"
while(<CONF>){
chomp;
($key,$val)=(split /:\s*/,$_);
+ $sql_type = $val if ($key eq 'sql_type');
$sql_server = $val if ($key eq 'sql_server');
$sql_username = $val if ($key eq 'sql_username');
$sql_password = $val if ($key eq 'sql_password');
$sql_database = $val if ($key eq 'sql_database');
$sql_accounting_table = $val if ($key eq 'sql_accounting_table');
- $mysql = $val if ($key eq 'sql_command');
+ $sqlcmd = $val if ($key eq 'sql_command');
}
close CONF;
-die "sql_command directive is not set in admin.conf\n" if ($mysql eq '');
-die "Could not find mysql binary. Please make sure that the \$mysql variable points to the right location\n" if (! -x $mysql);
+die "sql_command directive is not set in admin.conf\n" if ($sqlcmd eq '');
+die "Could not find sql binary. Please make sure that the \$sqlcmd variable points to the right location\n" if (! -x $sqlcmd);
$sql_password = ($sql_password == '') ? '' : "-p$sql_password";
MAX(ConnMaxDuration),MIN(ConnMinDuration),SUM(InputOctets),
SUM(OutputOctets),NASIPAddress FROM totacct
WHERE AcctDate >= '$date_start' AND
- AcctDate <= '$date_end' GROUP BY UserName;";
+ AcctDate <= '$date_end' GROUP BY UserName,NASIPAddress;";
print "$query1\n";
print "$query2\n";
open TMP, ">/tmp/tot_stats.query"
print TMP $query1;
print TMP $query2;
close TMP;
-`$mysql -h $sql_server -u $sql_username $sql_password $sql_database </tmp/tot_stats.query`;
+$command = "$sqlcmd -h $sql_server -u $sql_username $sql_password $sql_database </tmp/tot_stats.query" if ($sql_type eq 'mysql');
+$command = "$sqlcmd -U $sql_username -f /tmp/tot_stats.query $sql_database" if ($sql_type eq 'pg');
+`$command`;
#!/usr/bin/perl
+#
+# This works with Net-SNMP and UCD-SNMP
-$snmpget="/usr/local/bin/snmpget";
-$snmpwalk="/usr/local/bin/snmpwalk";
-$nas=shift;
+$host=shift;
$user=shift;
-$com=shift || "public";
+$comm=shift || "public";
$type=shift|| "xml";
+$conf='/usr/local/dialup_admin/conf/admin.conf';
+open CONF, "<$conf"
+ or die "Could not open configuration file\n";
+while(<CONF>){
+ chomp;
+ ($key,$val)=(split /:\s*/,$_);
+ $snmp_type = $val if ($key eq 'general_snmp_type');
+ $snmpget = $val if ($key eq 'general_snmpget_command');
+ $snmpwalk = $val if ($key eq 'general_snmpwalk_command');
+}
+close CONF;
+
+die "general_snmp_type directive is not set in admin.conf\n" if ($snmp_type eq '');
+die "Could not find snmpwalk binary. Please make sure that the \$snmpwalk variable points to the right location\n" if (! -x $snmpwalk);
+
+if ($snmp_type = 'ucd') {
+ $snmpgetcmd="$snmpget $host $comm";
+ $snmpwalkcmd="$snmpwalk $host $comm";
+}
+if ($snmp_type = 'net') {
+ $snmpgetcmd="$snmpget -v 1 -c $comm $host";
+ $snmpwalkcmd="$snmpwalk -v 1 -c $comm $host";
+}
+#DEBUG#print "$snmpwalkcmd\n"; print "$snmpgetcmd\n";
@ModulationScheme = (
"error",
"unknown",
"ara20",
"unknown",
);
-
-$modem=`$snmpwalk $nas $com enterprises.9.2.9.2.1.18 | grep $user`;
+#DEBUG#print "$snmpwalkcmd enterprises.9.2.9.2.1.18 | grep $user\n";
+$modem=`$snmpwalkcmd enterprises.9.2.9.2.1.18 | grep $user`;
if($modem=~/enterprises\.9\.2\.9\.2\.1\.18\.(\d+) =/){
$modem=$1;
$slot=(1+int($modem/120));
$port=$modem%120-1;
$modem="$slot.$port";
-
- $duration=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.9.$modem` or die "No MIB\n";
+#DEBUG#print "$snmpgetcmd enterprises.9.9.47.1.3.1.1.9.$modem\n";
+ $duration=`$snmpgetcmd enterprises.9.9.47.1.3.1.1.9.$modem` or die "No MIB\n";
$duration=~/\) (.*)\./;
$duration=$1;
- $modulation=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.12.$modem` or die "No MIB\n";
+#DEBUG#print "$snmpgetcmd enterprises.9.9.47.1.3.1.1.12.$modem\n";
+ $modulation=`$snmpgetcmd enterprises.9.9.47.1.3.1.1.12.$modem` or die "No MIB\n";
$modulation=~/ \= (\d+)/;
$modulation=$ModulationScheme[$1];
- $protocol=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.13.$modem` or die "No MIB\n";
+#DEBUG#print "$snmpgetcmd enterprises.9.9.47.1.3.1.1.13.$modem\n";
+ $protocol=`$snmpgetcmd enterprises.9.9.47.1.3.1.1.13.$modem` or die "No MIB\n";
$protocol=~/ \= (\d+)/;
$protocol=$Protocol[$1];
- $txrate=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.14.$modem` or die "No MIB\n";
+#DEBUG#print "$snmpgetcmd enterprises.9.9.47.1.3.1.1.14.$modem\n";
+ $txrate=`$snmpgetcmd enterprises.9.9.47.1.3.1.1.14.$modem` or die "No MIB\n";
$txrate=~/Gauge32\: (\d+)/;
$txrate=$1;
- $rxrate=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.15.$modem` or die "No MIB\n";
+#DEBUG#print "$snmpgetcmd enterprises.9.9.47.1.3.1.1.15.$modem\n";
+ $rxrate=`$snmpgetcmd enterprises.9.9.47.1.3.1.1.15.$modem` or die "No MIB\n";
$rxrate=~/Gauge32\: (\d+)/;
$rxrate=$1;
- $rxsignal=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.17.$modem` or die "No MIB\n";
+#DEBUG#print "$snmpgetcmd enterprises.9.9.47.1.3.1.1.17.$modem\n";
+ $rxsignal=`$snmpgetcmd enterprises.9.9.47.1.3.1.1.17.$modem` or die "No MIB\n";
+# $rxsignal=~ s/INTEGER\://;
$rxsignal=~/ \= (.*)\n/;
$rxsignal=$1;
if($type eq "xml"){
- print"<Modulation>$modulation</Modulation><Protocol>$protocol</Protocol><TxRate>$txrate</TxRate><RxRate>$rxrate</RxRate><RxSignal>$rxsignal</RxSignal>\n";
-
+ print "<User>$user</User>\n";
+ print "\t<Duration>$duration</Duration>\n";
+ print "\t<Modulation>$modulation</Modulation>\n";
+ print "\t<Protocol>$protocol</Protocol>\n";
+ print "\t<TxRate>$txrate</TxRate>\n";
+ print "\t<RxRate>$rxrate</RxRate>\n";
+ print "\t<RxSignal>$rxsignal dBm</RxSignal>\n\n";
}else{
- print "Duration>\t$duration\n";
- print "Modulation>\t$modulation\n";
- print "Protocol>\t$protocol\n";
- print "TxRate>\t\t$txrate\n";
- print "RxRate>\t\t$rxrate\n";
- print "RxSignal>\t$rxsignal dbm\n";
+ printf("%14s\t%s\n","User",$user);
+ printf("%14s\t%s\n","Duration",$duration);
+ printf("%14s\t%s\n","Modulation",$modulation);
+ printf("%14s\t%s\n","Protocol",$protocol);
+ printf("%14s\t%s\n","TxRate",$txrate);
+ printf("%14s\t%s\n","RxRate",$rxrate);
+ printf("%14s\t%s dBm\n\n","RxSignal",$rxsignal);
}
}
#!/usr/bin/perl
+#
+# This works with Net-SNMP and UCD-SNMP
-$SNMPWALK="/usr/bin/snmpwalk";
$host=shift;
$comm=shift || 'public';
$type=shift || 'cisco';
-die "Could not find snmpwalk binary. Please make sure that the \$SNMPWALK variable points to the right location\n" if (! -x $SNMPWALK);
+$conf='/usr/local/dialup_admin/conf/admin.conf';
+open CONF, "<$conf"
+ or die "Could not open configuration file\n";
+while(<CONF>){
+ chomp;
+ ($key,$val)=(split /:\s*/,$_);
+ $snmp_type = $val if ($key eq 'general_snmp_type');
+ $snmpwalk = $val if ($key eq 'general_snmpwalk_command');
+}
+close CONF;
+
+die "general_snmp_type directive is not set in admin.conf\n" if ($snmp_type eq '');
+die "Could not find snmpwalk binary. Please make sure that the \$snmpwalk variable points to the right location\n" if (! -x $snmpwalk);
+
+$snmpwalkcmd="$snmpwalk $host $comm" if ($snmp_type = 'ucd');
+$snmpwalkcmd="$snmpwalk -v 1 -c $comm $host" if ($snmp_type = 'net');
if ($type eq 'cisco'){
- $walk =`$SNMPWALK -v2c -c $comm $host .iso.org.dod.internet.private.enterprises.9.9.150.1.1.3.1.2`;
+ $walk =`$snmpwalkcmd .iso.org.dod.internet.private.enterprises.9.9.150.1.1.3.1.2`;
if ($walk =~ /^$/){
- $walk =`$SNMPWALK -v2c -c $comm $host .iso.org.dod.internet.private.enterprises.9.2.9.2.1.18`;
- $walk.=`$SNMPWALK -v2c -c $comm $host .iso.org.dod.internet.private.enterprises.9.10.19.1.3.1.1.3`;
+ $walk =`$snmpwalkcmd .iso.org.dod.internet.private.enterprises.9.2.9.2.1.18`;
+ $walk.=`$snmpwalkcmd .iso.org.dod.internet.private.enterprises.9.10.19.1.3.1.1.3`;
}
}
elsif ($type eq 'lucent'){
- $walk =`$SNMPWALK -v2c -c $comm $host .iso.org.dod.internet.private.enterprises.529.10.4.1.12`;
+ $walk =`$snmpwalkcmd .iso.org.dod.internet.private.enterprises.529.10.4.1.12`;
}
while($walk=~/\"([\w\-]+?)\"/g){
# Log in the totacct table aggregated daily accounting information for
# each user.
# We keep a row per user for each day.
+# Works with mysql and postgresql
+#
-
-$conf=shift||'/usr/local/dialupadmin/conf/admin.conf';
+$conf=shift||'/usr/local/dialup_admin/conf/admin.conf';
open CONF, "<$conf"
while(<CONF>){
chomp;
($key,$val)=(split /:\s*/,$_);
+ $sql_type = $val if ($key eq 'sql_type');
$sql_server = $val if ($key eq 'sql_server');
$sql_username = $val if ($key eq 'sql_username');
$sql_password = $val if ($key eq 'sql_password');
$sql_database = $val if ($key eq 'sql_database');
$sql_accounting_table = $val if ($key eq 'sql_accounting_table');
- $mysql = $val if ($key eq 'sql_command');
+ $sqlcmd = $val if ($key eq 'sql_command');
}
close CONF;
-die "sql_command directive is not set in admin.conf\n" if ($mysql eq '');
-die "Could not find mysql binary. Please make sure that the \$mysql variable points to the right location\n" if (! -x $mysql);
+die "sql_command directive is not set in admin.conf\n" if ($sqlcmd eq '');
+die "Could not find sql binary. Please make sure that the \$sqlcmd variable points to the right location\n" if (! -x $sqlcmd);
$sql_password = ($sql_password == '') ? '' : "-p$sql_password";
$date_small_start = POSIX::strftime("%Y-%m-%d",0,0,0,($mday - 1),$mon,$year,$wday,$yday,$isdst);
$date_end = POSIX::strftime("%Y-%m-%d %T",0,0,0,$mday,$mon,$year,$wday,$yday,$isdst);
-$query = "INSERT INTO totacct (UserName,AcctDate,ConnNum,ConnTotDuration,
+$query1 = "DELETE FROM totacct WHERE AcctDate = '$date_start';";
+$query2 = "INSERT INTO totacct (UserName,AcctDate,ConnNum,ConnTotDuration,
ConnMaxDuration,ConnMinDuration,InputOctets,OutputOctets,NASIPAddress)
SELECT UserName,'$date_small_start',COUNT(*),SUM(AcctSessionTime),
MAX(AcctSessionTime),MIN(AcctSessionTime),SUM(AcctInputOctets),
SUM(AcctOutputOctets),NASIPAddress FROM radacct
WHERE AcctStopTime >= '$date_start' AND
- AcctStopTime < '$date_end' GROUP BY UserName;";
-print "$query\n";
+ AcctStopTime < '$date_end' GROUP BY UserName,NASIPAddress;";
+print "$query1\n";
+print "$query2\n";
open TMP, ">/tmp/tot_stats.query"
or die "Could not open tmp file\n";
-print TMP $query;
+print TMP $query1;
+print TMP $query2;
close TMP;
-`$mysql -h $sql_server -u $sql_username $sql_password $sql_database </tmp/tot_stats.query`;
+$command = "$sqlcmd -h $sql_server -u $sql_username $sql_password $sql_database </tmp/tot_stats.query" if ($sql_type eq 'mysql');
+$command = "$sqlcmd -U $sql_username -f /tmp/tot_stats.query $sql_database" if ($sql_type eq 'pg');
+`$command`;
#
# Delete sessions from the radacct table which are older than
# $back_days
+# Works with mysql and postgresql
#
use POSIX;
while(<CONF>){
chomp;
($key,$val)=(split /:\s*/,$_);
+ $sql_type = $val if ($key eq 'sql_type');
$sql_server = $val if ($key eq 'sql_server');
$sql_username = $val if ($key eq 'sql_username');
$sql_password = $val if ($key eq 'sql_password');
$sql_database = $val if ($key eq 'sql_database');
$sql_accounting_table = $val if ($key eq 'sql_accounting_table');
- $mysql = $val if ($key eq 'sql_command');
+ $sqlcmd = $val if ($key eq 'sql_command');
}
close CONF;
-die "sql_command directive is not set in admin.conf\n" if ($mysql eq '');
-die "Could not find mysql binary. Please make sure that the \$mysql variable points to the right location\n" if (! -x $mysql);
+die "sql_command directive is not set in admin.conf\n" if ($sqlcmd eq '');
+die "Could not find sql binary. Please make sure that the \$sqlcmd variable points to the right location\n" if (! -x $sqlcmd);
$sql_password = ($sql_password eq '') ? '' : "-p$sql_password";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$date = POSIX::strftime("%Y-%m-%d %T",$sec,$min,$hour,($mday - $back_days),$mon,$year,$wday,$yday,$isdst);
print "$date\n";
-
-$query = "LOCK TABLES $sql_accounting_table WRITE;";
-$query .= "DELETE FROM $sql_accounting_table WHERE AcctStopTime < '$date' AND AcctStopTime != 0;";
-$query .= "UNLOCK TABLES;";
+$query = "";
+$query = "LOCK TABLES $sql_accounting_table WRITE;" if ($sql_type eq 'mysql');
+$query .= "DELETE FROM $sql_accounting_table WHERE AcctStopTime < '$date' AND AcctStopTime IS NOT NULL ;";
+$query .= "UNLOCK TABLES;" if ($sql_type eq 'mysql');
print "$query\n";
open TMP, ">/tmp/truncate_radacct.query"
or die "Could not open tmp file\n";
print TMP $query;
close TMP;
-`$mysql -h$sql_server -u$sql_username $sql_password $sql_database </tmp/truncate_radacct.query`;
+$command = "$sqlcmd -h$sql_server -u$sql_username $sql_password $sql_database </tmp/truncate_radacct.query" if ($sql_type eq 'mysql');
+$command = "$sqlcmd -U $sql_username -f /tmp/truncate_radacct.query $sql_database" if ($sql_type eq 'pg');
+`$command`;
# the user edit page
general_show_user_password: yes
-
-general_ldap_attrmap: %{general_radiusd_base_dir}/etc/raddb/ldap.attrmap
+general_raddb_dir: %{general_radiusd_base_dir}/etc/raddb
+general_ldap_attrmap: %{general_raddb_dir}/ldap.attrmap
+# Need to fix admin.conf file parser
+#general_clients_conf: %{general_raddb_dir}/clients.conf
+general_clients_conf: /usr/local/etc/raddb/clients.conf
general_sql_attrmap: %{general_base_dir}/conf/sql.attrmap
general_accounting_attrs_file: %{general_base_dir}/conf/accounting.attrs
general_extra_ldap_attrmap: %{general_base_dir}/conf/extra.ldap-attrmap
#
# This variable is used by the scripts in the bin folder
# It should contain the path to the sql binary used to run
-# sql commands (mysql is only supported for now)
+# sql commands (mysql and psql are only supported for now)
sql_command: /usr/local/bin/mysql
#
+# This variable is used by the scripts in the bin folder
+# It should contain the snmp type and path to the binary
+# used to run snmp commands.
+# (ucd = UCD-Snmp and net = Net-Snmp are only supported for now)
+general_snmp_type: net
+general_snmpwalk_command: /usr/local/bin/snmpwalk
+general_snmpget_command: /usr/local/bin/snmpget
+#
# Uncomment to enable sql debug
#
#sql_debug: true
break;
}
$name_ip = 'nas' . $i . '_ip';
- if ($server == $config[$name_ip])
- echo "<option selected value=\"$config[$name_ip]\">$config[$name]\n";
+ $ip = $config[$name_ip];
+ $name = $config[$name];
+ $servers[$name] = $ip;
+}
+ksort($servers);
+foreach ($servers as $name => $ip){
+ if ($server == $ip)
+ echo "<option selected value=\"$ip\">$name\n";
else
- echo "<option value=\"$config[$name_ip]\">$config[$name]\n";
+ echo "<option value=\"$ip\">$name\n";
}
if ($server == '' || $server == 'all')
echo "<option selected value=\"all\">all\n";
+else
+ echo "<option value=\"all\">all\n";
?>
</select>
</td></tr>
$servers[$name] = $config[$ip];
$i++;
}
+ksort($servers);
if ($server != 'all' && $server != '')
$s = "AND nasipaddress = '$server'";
break;
}
$name_ip = 'nas' . $i . '_ip';
- if ($server == $config[$name_ip])
- echo "<option selected value=\"$config[$name_ip]\">$config[$name]\n";
+ $ip = $config[$name_ip];
+ $name = $config[$name];
+ $servers[$name] = $ip;
+}
+ksort($servers);
+foreach ($servers as $name => $ip){
+ if ($server == $ip])
+ echo "<option selected value=\"$ip\">$name\n";
else
- echo "<option value=\"$config[$name_ip]\">$config[$name]\n";
+ echo "<option value=\"$ip\">$name\n";
}
if ($server == '' || $server == 'all')
echo "<option selected value=\"all\">all\n";
+else
+ echo "<option value=\"all\">all\n";
?>
</select>
</td>