NSLU2-Linux
view · edit · print · history

HowTo.GetDHCPStatus History

Hide minor edits - Show changes to markup

November 23, 2008, at 09:06 AM by janne5011 -- restored from spam
Changed lines 1-419 from:

mikey way my chemical romance [URL=http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1576.html]mikey way my chemical romance[/URL] [url=http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1576.html]mikey way my chemical romance[/url] [url]http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1576.html[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 23, 2008, at 03:19 AM by mikey way my chemical romance -- http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1576.html
Changed line 1 from:

<a href='http://novocraft.com/wiki/forumfiles/images/topic-505.htm'>ancient greek clothes</a> <a href="http://novocraft.com/wiki/forumfiles/images/topic-505.htm">ancient greek clothes</a> [link=http://novocraft.com/wiki/forumfiles/images/topic-505.htm]ancient greek clothes[/link]

to:

mikey way my chemical romance [URL=http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1576.html]mikey way my chemical romance[/URL] [url=http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1576.html]mikey way my chemical romance[/url] [url]http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1576.html[/url]

November 23, 2008, at 03:19 AM by ancient greek clothes -- http://novocraft.com/wiki/forumfiles/images/topic-505.htm
Changed line 1 from:

<a href='http://novocraft.com/wiki/forumfiles/images/topic-198.htm'>anara gupta video clips downloads</a> <a href="http://novocraft.com/wiki/forumfiles/images/topic-198.htm">anara gupta video clips downloads</a> [link=http://novocraft.com/wiki/forumfiles/images/topic-198.htm]anara gupta video clips downloads[/link]

to:

<a href='http://novocraft.com/wiki/forumfiles/images/topic-505.htm'>ancient greek clothes</a> <a href="http://novocraft.com/wiki/forumfiles/images/topic-505.htm">ancient greek clothes</a> [link=http://novocraft.com/wiki/forumfiles/images/topic-505.htm]ancient greek clothes[/link]

November 23, 2008, at 03:19 AM by anara gupta video clips downloads -- http://novocraft.com/wiki/forumfiles/images/topic-198.htm
Changed line 1 from:

zoolove [URL=http://softcastle.com/cache/temp/topic-156.htm]zoolove[/URL] [url=http://softcastle.com/cache/temp/topic-156.htm]zoolove[/url] [url]http://softcastle.com/cache/temp/topic-156.htm[/url]

to:

<a href='http://novocraft.com/wiki/forumfiles/images/topic-198.htm'>anara gupta video clips downloads</a> <a href="http://novocraft.com/wiki/forumfiles/images/topic-198.htm">anara gupta video clips downloads</a> [link=http://novocraft.com/wiki/forumfiles/images/topic-198.htm]anara gupta video clips downloads[/link]

November 23, 2008, at 03:18 AM by zoolove -- http://softcastle.com/cache/temp/topic-156.htm
Changed line 1 from:

<a href='http://pbnf.org/engine/inc/files/topic-1373.html'>webmap</a> <a href="http://pbnf.org/engine/inc/files/topic-1373.html">domain</a> [link=http://pbnf.org/engine/inc/files/topic-1373.html]top[/link]

to:

zoolove [URL=http://softcastle.com/cache/temp/topic-156.htm]zoolove[/URL] [url=http://softcastle.com/cache/temp/topic-156.htm]zoolove[/url] [url]http://softcastle.com/cache/temp/topic-156.htm[/url]

November 23, 2008, at 03:18 AM by http -- http://pbnf.org/engine/inc/files/topic-1373.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://pbnf.org/engine/inc/files/topic-1373.html'>webmap</a> <a href="http://pbnf.org/engine/inc/files/topic-1373.html">domain</a> [link=http://pbnf.org/engine/inc/files/topic-1373.html]top[/link]

November 22, 2008, at 01:20 PM by blubb -- restore
Changed lines 1-419 from:

lux video [URL=http://riokozpz.net/e107_themes/jay/eltrocf.htm]lux video[/URL] [url=http://riokozpz.net/e107_themes/jay/eltrocf.htm]lux video[/url] [url]http://riokozpz.net/e107_themes/jay/eltrocf.htm[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 22, 2008, at 01:10 PM by lux video -- http://riokozpz.net/e107_themes/jay/eltrocf.htm
Changed line 1 from:

love comes slowly movie [URL=http://n9ami.com/guestbook/templates/css/new137.htm]love comes slowly movie[/URL] [url=http://n9ami.com/guestbook/templates/css/new137.htm]love comes slowly movie[/url] [url]http://n9ami.com/guestbook/templates/css/new137.htm[/url]

to:

lux video [URL=http://riokozpz.net/e107_themes/jay/eltrocf.htm]lux video[/URL] [url=http://riokozpz.net/e107_themes/jay/eltrocf.htm]lux video[/url] [url]http://riokozpz.net/e107_themes/jay/eltrocf.htm[/url]

November 22, 2008, at 01:09 PM by love comes slowly movie -- http://n9ami.com/guestbook/templates/css/new137.htm
Changed line 1 from:

<a href='http://avdesigngroup.org/Images/gifts/thumbs/topic-261.html'>quebec financial planner</a> <a href="http://avdesigngroup.org/Images/gifts/thumbs/topic-261.html">quebec financial planner</a> [link=http://avdesigngroup.org/Images/gifts/thumbs/topic-261.html]quebec financial planner[/link]

to:

love comes slowly movie [URL=http://n9ami.com/guestbook/templates/css/new137.htm]love comes slowly movie[/URL] [url=http://n9ami.com/guestbook/templates/css/new137.htm]love comes slowly movie[/url] [url]http://n9ami.com/guestbook/templates/css/new137.htm[/url]

November 22, 2008, at 01:08 PM by quebec financial planner -- http://avdesigngroup.org/Images/gifts/thumbs/topic-261.html
Changed line 1 from:

<a href='http://superamazingcomics.com/comics/thumbs/text2609.htm'>juggalo music video</a> <a href="http://superamazingcomics.com/comics/thumbs/text2609.htm">juggalo music video</a> [link=http://superamazingcomics.com/comics/thumbs/text2609.htm]juggalo music video[/link]

to:

<a href='http://avdesigngroup.org/Images/gifts/thumbs/topic-261.html'>quebec financial planner</a> <a href="http://avdesigngroup.org/Images/gifts/thumbs/topic-261.html">quebec financial planner</a> [link=http://avdesigngroup.org/Images/gifts/thumbs/topic-261.html]quebec financial planner[/link]

November 22, 2008, at 01:07 PM by juggalo music video -- http://superamazingcomics.com/comics/thumbs/text2609.htm
Changed line 1 from:

<a href='http://evrikabg.com/templates/images/thumbs/news-1437-20081008.html'>license practice tests</a> <a href="http://evrikabg.com/templates/images/thumbs/news-1437-20081008.html">license practice tests</a> [link=http://evrikabg.com/templates/images/thumbs/news-1437-20081008.html]license practice tests[/link]

to:

<a href='http://superamazingcomics.com/comics/thumbs/text2609.htm'>juggalo music video</a> <a href="http://superamazingcomics.com/comics/thumbs/text2609.htm">juggalo music video</a> [link=http://superamazingcomics.com/comics/thumbs/text2609.htm]juggalo music video[/link]

November 22, 2008, at 01:06 PM by license practice tests -- http://evrikabg.com/templates/images/thumbs/news-1437-20081008.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://evrikabg.com/templates/images/thumbs/news-1437-20081008.html'>license practice tests</a> <a href="http://evrikabg.com/templates/images/thumbs/news-1437-20081008.html">license practice tests</a> [link=http://evrikabg.com/templates/images/thumbs/news-1437-20081008.html]license practice tests[/link]

November 22, 2008, at 12:38 PM by demon -- Restore with formatting
Changed line 13 from:

[=

to:
 [=
Changed lines 15-17 from:

if [ -e /opt/bin/leaseholders.cgi ]; then cp -p /opt/bin/leaseholders.cgi /home/httpd/html/leaseholders.cgi

to:

if [ -e /opt/bin/leaseholders.cgi ]; then

	cp -p /opt/bin/leaseholders.cgi 	/home/httpd/html/leaseholders.cgi
Changed line 24 from:

[=

to:
 [=
Changed lines 34-35 from:
  1. - output in HTML using -w option
  2. - eliminate double entries for same ip address
to:
  1. - output in HTML using -w option
  2. - eliminate double entries for same ip address
Changed lines 38-42 from:
  1. Rewrite parse to deal with ddns lines.
  2. Break out clients & addresses.
  3. Install in /opt/bin/leaseholders.txt
  4. Add a script to copy to /home/httpd/html/leaseholders.cgi
to:
  1. Rewrite parse to deal with ddns lines.
  2. Break out clients & addresses.
  3. Install in /opt/bin/leaseholders.txt
  4. Add a script to copy to /home/httpd/html/leaseholders.cgi
Changed line 50 from:
  1. Echo help message
to:
  1. Echo help message
Changed lines 52-54 from:

die "$0 [-w] List active and expired DHCP leases \n", "\tOptions:\n", "\t -w: output is not written in HTML format.\n\n";

to:
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
Changed lines 66-74 from:

next if ( $line =~ /^\s*#/o ); $mline = $line; chomp($mline); @wds = split( '=',$mline); next if ( $wds[0] ne "IPADDR" ); $ipAddr = $wds[1]; @numbers = split(/\./, $ipAddr); $ip_number = pack("C4", @numbers); ($ipName) = (gethostbyaddr($ip_number, 2))[0];

to:
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
Changed lines 81-82 from:
  1. Select the format of your choice. If you want the lease time to
  2. be printed in amarican style put a comment char ``#'' right in
to:
  1. Select the format of your choice. If you want the lease time to
  2. be printed in amarican style put a comment char ``#'' right in
Changed line 93 from:
  1. /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases
to:
  1. /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases
Changed lines 98-101 from:

if( -r "/etc/dhcpd.leases" ){ $LEASEFILE="/etc/dhcpd.leases"; }else{ die "Cannot find \"dhcpd.leases\" file \n";

to:
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
Changed lines 104-106 from:

}

  1. ### get universal date from system ###
to:
  1. ### get universal date from system ###
Changed lines 115-131 from:

next if( $line =~ /^\s*#/o ); $mline = $line; chomp($mline); $mline=~ s/ / /g;

@wds = split( ' ',$mline); if( !$inlease ) {

  1. Look for a lease record

next if( $wds[0] ne "lease" ); $ipAddr = $wds[1]; @numbers = split(/\./, $ipAddr); $ip_number = pack("C4", @numbers); ($ipName) = (gethostbyaddr($ip_number, 2))[0]; if ($ipName) { ; } else { $ipName = "<unknown>";

to:
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate?($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate?($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate?($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate?($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases = $lease;
	$ClientLeaseTime = $endDtUTC;
	$ClientLeaseState = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases = $lease;
	} else {
		$ExpiredLease = $lease;
	}
Changed lines 239-248 from:

$startDt = "<unknown>"; $endDt = "<unknown>"; $endNever = 0; $ddnsClient = "<unknown>"; $ethAddr = "<unknown>"; $hostName = "<unknown>"; $leaseState = "<unknown>"; $leaseAbandoned = 0; $inlease = 1; next;

to:

close(LEASES);

if( !$opt_w ){

	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
Changed lines 252-264 from:
  1. Parse each clause in lease

if( $wds[0] eq "starts" ) { $startDt = join( ' ', $wds[2], $wds[3] ); $startDt=~s/;\s*$//;

  1. Parse Date in Date::Manip internel format

$startDtUTC=ParseDate?($startDt);

  1. Convert it to local timezone

$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);

  1. Finally make a human readable date string out of it

$startDt=UnixDate?($startDtTZ, ($outputDateFormat) ) ; next;

to:
  1. Sort each hash & return the keys for in-order access

@ClientKeys? = sort(keys(%ClientLeases?)); # MAC address order @ActiveKeys? = sort(keys(%ActiveLeases?)); # IP address order @ExpiredKeys? = sort(keys(%ExpiredLeases?)); # IP address order @abandoned = sort(@abandoned); # MAC, IP address (?)

$xDate=UnixDate?($xTZ, ($outputDateFormat) ) ; print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0; print "\nActive Clients:"; foreach $i ( @ClientKeys? ) {

	next if( $ClientLeaseState ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases;
Changed lines 285-288 from:

if( $wds[0] eq "ends" ) { if( $wds[2] eq "never" ) { $endDt = "2999\/01\/01 12:00:00"; $endNever = 1;

to:

if( $actc == 0 ) {

	printf " None\n";
Changed lines 288-289 from:

$endDt = join( ' ', $wds[2], $wds[3] ); $endDt=~s/;\s*$//;

to:
	printf "Total active clients: %d\n", $actc;
Changed lines 290-298 from:
  1. Parse Date in Date::Manip internel format

$endDtUTC=ParseDate?($endDt);

  1. Convert it to local timezone

$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);

  1. Finally make a human readable date string out of it

$endDt=UnixDate?($endDtTZ, ($outputDateFormat) ) ; next;

to:

$iactc = 0; print "\nInactive Clients:"; foreach $i ( @ClientKeys? ) {

	next if( $ClientLeaseState eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases;
Changed lines 313-316 from:

if( $wds[0] eq "hardware" ) { $ethAddr = $wds[2]; $ethAddr=~s/;\s*$//; next;

to:

if( $iactc == 0 ) {

	printf " None\n";

} else {

	printf "Total inactive clients: %d\n", $iactc;
Changed lines 318-322 from:

if( $wds[0] eq "client-hostname" ) { $hostName = $wds[1]; $hostName=~s/;\s*$//; $hostName=~ s/"//g; next;

to:

$actn = 0; print "\nActive Addresses:"; foreach $i ( @ActiveKeys? ) {

	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases;
Changed lines 339-342 from:

if( $wds[0] eq "binding" ) { $leaseState = $wds[2]; $leaseState=~s/;\s*$//; next;

to:

if( $actn == 0 ) {

	printf " None\n";

} else {

	printf "Total Active: %d\n", $actn;
Changed lines 344-347 from:

if( $wds[0] eq "set" ) { if( $wds[1] eq "ddns-client-fqdn" ) { $ddnsClient = $wds[3]; $ddnsClient=~s/"//g;

to:

$expn = 0; print "\nExpired Leases:"; foreach $i ( @ExpiredKeys? ) {

	@wds = split( ' ', $ExpiredLeases);
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases;
	}
Added lines 368-371:

if( $expn == 0 ) {

	printf " None\n";

} else {

	printf "Total expired: %d\n", $expn;
Changed lines 373-375 from:

if( $wds[0] eq "abandoned;" ) { $leaseAbandoned = 1; next;

to:

$abdn = 0; print "\nAbandoned Addresses:"; foreach $i ( @abandoned ) {

	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
Changed lines 394-395 from:

if( $wds[0] ne "}" ) { next;

to:

if( $abdn == 0 ) {

	printf " None\n";

} else {

	printf "Total abandoned: %d\n", $abdn;
Changed lines 400-405 from:
  1. End of lease data, generate output

$inlease = 0;

if( $ipName eq "<unknown>" ) { $ipName = $ddnsClient;

to:

printf "\n";

if( !$opt_w ){

	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
Deleted lines 409-605:

$endDt = "dyn-bootp: never" if( $endNever ); $lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n", $ethAddr, $ipAddr, $startDt, $endDt, $hostName, $ipName;

$ClientLeases = $lease; $ClientLeaseTime = $endDtUTC; $ClientLeaseState = $leaseState;

if( $leaseAbandoned ) {

  1. Unexpectedly found someone with this address

$AbandonedAddresses[$abandonedc++] = $lease; next; }

if( $leaseState eq "active" ) { $ActiveLeases = $lease; } else { $ExpiredLease = $lease; } }

close(LEASES);

if( !$opt_w ){ $|=1; $q = new CGI; print $q->header('text/html'); print $q->start_html( -title=>"DHCP status on $localhost", -expires=>'+5s', -status=>'200 OK', -BGCOLOR=>'white' ); print "<PRE>\n"; }

  1. Sort each hash & return the keys for in-order access

@ClientKeys? = sort(keys(%ClientLeases?)); # MAC address order @ActiveKeys? = sort(keys(%ActiveLeases?)); # IP address order @ExpiredKeys? = sort(keys(%ExpiredLeases?)); # IP address order @abandoned = sort(@abandoned); # MAC, IP address (?)

$xDate=UnixDate?($xTZ, ($outputDateFormat) ) ; print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0; print "\nActive Clients:"; foreach $i ( @ClientKeys? ) { next if( $ClientLeaseState ne "active" );

if( $actc++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $ClientLeases; } if( $actc == 0 ) { printf " None\n"; } else { printf "Total active clients: %d\n", $actc; }

$iactc = 0; print "\nInactive Clients:"; foreach $i ( @ClientKeys? ) { next if( $ClientLeaseState eq "active" );

if( $iactc++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $ClientLeases; } if( $iactc == 0 ) { printf " None\n"; } else { printf "Total inactive clients: %d\n", $iactc; }

$actn = 0; print "\nActive Addresses:"; foreach $i ( @ActiveKeys? ) { if( $actn++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $ActiveLeases; } if( $actn == 0 ) { printf " None\n"; } else { printf "Total Active: %d\n", $actn; }

$expn = 0; print "\nExpired Leases:"; foreach $i ( @ExpiredKeys? ) { @wds = split( ' ', $ExpiredLeases); if( !defined($ActiveLeaseTime{$wds[1]}) ) { if( $expn++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $ExpiredLeases; } } if( $expn == 0 ) { printf " None\n"; } else { printf "Total expired: %d\n", $expn; }

$abdn = 0; print "\nAbandoned Addresses:"; foreach $i ( @abandoned ) { if( $abdn++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $i; } if( $abdn == 0 ) { printf " None\n"; } else { printf "Total abandoned: %d\n", $abdn; }

printf "\n";

if( !$opt_w ){ print "</PRE>\n"; $me = $q->url(); print $q->a({href=>$me},"Refresh"); print $q->br(); print $q->a({href=>"/"}, "Home Page"); print $q->end_html; }

Changed line 419 from:

--tlhackque

to:
 --tlhackque
November 22, 2008, at 11:16 AM by jeroen -- Put good version back
Changed lines 1-419 from:

<a href='http://evrikabg.com/templates/images/thumbs/news-1546-20081009.html'>american bald eagle</a> <a href="http://evrikabg.com/templates/images/thumbs/news-1546-20081009.html">american bald eagle</a> [link=http://evrikabg.com/templates/images/thumbs/news-1546-20081009.html]american bald eagle[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file) #!/bin/sh if [ -e /opt/bin/leaseholders.cgi ]; then cp -p /opt/bin/leaseholders.cgi \ /home/httpd/html/leaseholders.cgi fi # Last line of /opt/etc/init.d/S53dhcpweb Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file) #!/opt/bin/perl # # script to list active, expired and abandoned leases. # # Original script received by Ian Jones, ltjones@hawkeye.ualr.edu # # Current Version by Rainer Krienke, krienke@uni-koblenz.de # Version 1.0 # Added: - output in local timezone # - output in HTML using -w option # - eliminate double entries for same ip address # # TL: Rework for nslu2/thttpd cgi script. # Rewrite parse to deal with ddns lines. # Break out clients & addresses. # Install in /opt/bin/leaseholders.txt # Add a script to copy to /home/httpd/html/leaseholders.cgi use Getopt::Std; use Date::Manip; use CGI; # Look for Options $res=getopts('wh'); # Echo help message if( $opt_h || $res =="" ){ die "$0 [-w] List active and expired DHCP leases \n", "\tOptions:\n", "\t -w: output is not written in HTML format.\n\n"; } $abandonedc = 0; $leasesc = 0; $expiredc = 0; # Find local host name -- from IP address if possible. $ipName = `localhost`; open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0"); while ($line = <CFG>) { next if ( $line =~ /^\s*#/o ); $mline = $line; chomp($mline); @wds = split( '=',$mline); next if ( $wds[0] ne "IPADDR" ); $ipAddr = $wds[1]; @numbers = split(/\./, $ipAddr); $ip_number = pack("C4", @numbers); ($ipName) = (gethostbyaddr($ip_number, 2))[0]; } close(CFG); chomp($localhost = $ipName); # # Format (see man date) in that the expiration date is echoed. # Select the format of your choice. If you want the lease time to # be printed in amarican style put a comment char ``#'' right in # front of the first $outputDateFormat line and remove it from the # second one. # # European Style date #$outputDateFormat="%H:%M:%S %d.%m.%Y "; # American style date $outputDateFormat="%m/%d/%Y %H:%M:%S"; # ### point this to your dhcpd.leases ### # /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases # will be seachred by default. # $LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases"; if( ! -r $LEASEFILE ){ if( -r "/etc/dhcpd.leases" ){ $LEASEFILE="/etc/dhcpd.leases"; }else{ die "Cannot find \"dhcpd.leases\" file \n"; } } # ### get universal date from system ### # $xTZ = &ParseDate("now"); $tz=&Date_TimeZone; $x=Date_ConvTZ($xTZ, $tz, "UTC"); open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE"; $inlease = 0; while ($line = <LEASES>) { next if( $line =~ /^\s*#/o ); $mline = $line; chomp($mline); $mline=~ s/ / /g; @wds = split( ' ',$mline); if( !$inlease ) { # Look for a lease record next if( $wds[0] ne "lease" ); $ipAddr = $wds[1]; @numbers = split(/\./, $ipAddr); $ip_number = pack("C4", @numbers); ($ipName) = (gethostbyaddr($ip_number, 2))[0]; if ($ipName) { ; } else { $ipName = "<unknown>"; } $startDt = "<unknown>"; $endDt = "<unknown>"; $endNever = 0; $ddnsClient = "<unknown>"; $ethAddr = "<unknown>"; $hostName = "<unknown>"; $leaseState = "<unknown>"; $leaseAbandoned = 0; $inlease = 1; next; } # Parse each clause in lease if( $wds[0] eq "starts" ) { $startDt = join( ' ', $wds[2], $wds[3] ); $startDt=~s/;\s*$//; # Parse Date in Date::Manip internel format $startDtUTC=ParseDate($startDt); # # Convert it to local timezone $startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz); # # Finally make a human readable date string out of it $startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ; next; } if( $wds[0] eq "ends" ) { if( $wds[2] eq "never" ) { $endDt = "2999\/01\/01 12:00:00"; $endNever = 1; } else { $endDt = join( ' ', $wds[2], $wds[3] ); $endDt=~s/;\s*$//; } # Parse Date in Date::Manip internel format $endDtUTC=ParseDate($endDt); # # Convert it to local timezone $endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz); # # Finally make a human readable date string out of it $endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ; next; } if( $wds[0] eq "hardware" ) { $ethAddr = $wds[2]; $ethAddr=~s/;\s*$//; next; } if( $wds[0] eq "client-hostname" ) { $hostName = $wds[1]; $hostName=~s/;\s*$//; $hostName=~ s/"//g; next; } if( $wds[0] eq "binding" ) { $leaseState = $wds[2]; $leaseState=~s/;\s*$//; next; } if( $wds[0] eq "set" ) { if( $wds[1] eq "ddns-client-fqdn" ) { $ddnsClient = $wds[3]; $ddnsClient=~s/"//g; } } if( $wds[0] eq "abandoned;" ) { $leaseAbandoned = 1; next; } if( $wds[0] ne "}" ) { next; } ## End of lease data, generate output $inlease = 0; if( $ipName eq "<unknown>" ) { $ipName = $ddnsClient; } $endDt = "dyn-bootp: never" if( $endNever ); $lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n", $ethAddr, $ipAddr, $startDt, $endDt, $hostName, $ipName; $ClientLeases{$ethAddr} = $lease; $ClientLeaseTime{$ethAddr} = $endDtUTC; $ClientLeaseState{$ethAddr} = $leaseState; if( $leaseAbandoned ) { # Unexpectedly found someone with this address $AbandonedAddresses[$abandonedc++] = $lease; next; } if( $leaseState eq "active" ) { $ActiveLeases{$ipAddr} = $lease; } else { $ExpiredLease{$ipAddr} = $lease; } } close(LEASES); if( !$opt_w ){ $|=1; $q = new CGI; print $q->header('text/html'); print $q->start_html( -title=>"DHCP status on $localhost", -expires=>'+5s', -status=>'200 OK', -BGCOLOR=>'white' ); print "<PRE>\n"; } # Sort each hash & return the keys for in-order access @ClientKeys = sort(keys(%ClientLeases)); # MAC address order @ActiveKeys = sort(keys(%ActiveLeases)); # IP address order @ExpiredKeys = sort(keys(%ExpiredLeases)); # IP address order @abandoned = sort(@abandoned); # MAC, IP address (?) $xDate=UnixDate($xTZ, ($outputDateFormat) ) ; print "DHCP leases issued by $localhost as of $xDate\n"; $actc = 0; print "\nActive Clients:"; foreach $i ( @ClientKeys ) { next if( $ClientLeaseState{$i} ne "active" ); if( $actc++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $ClientLeases{$i}; } if( $actc == 0 ) { printf " None\n"; } else { printf "Total active clients: %d\n", $actc; } $iactc = 0; print "\nInactive Clients:"; foreach $i ( @ClientKeys ) { next if( $ClientLeaseState{$i} eq "active" ); if( $iactc++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $ClientLeases{$i}; } if( $iactc == 0 ) { printf " None\n"; } else { printf "Total inactive clients: %d\n", $iactc; } $actn = 0; print "\nActive Addresses:"; foreach $i ( @ActiveKeys ) { if( $actn++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $ActiveLeases{$i}; } if( $actn == 0 ) { printf " None\n"; } else { printf "Total Active: %d\n", $actn; } $expn = 0; print "\nExpired Leases:"; foreach $i ( @ExpiredKeys ) { @wds = split( ' ', $ExpiredLeases{$i}); if( !defined($ActiveLeaseTime{$wds[1]}) ) { if( $expn++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $ExpiredLeases{$i}; } } if( $expn == 0 ) { printf " None\n"; } else { printf "Total expired: %d\n", $expn; } $abdn = 0; print "\nAbandoned Addresses:"; foreach $i ( @abandoned ) { if( $abdn++ == 0 ) { print "\nEthernet Address"; print " IP Address"; print " Lease Issue Time"; print " Expiration Time"; print " Client Hostname"; print " DNS Hostname\n"; print "-----------------"; print " ---------------"; print " -------------------"; print " -------------------"; print " -------------------------"; print " --------------------"; print "---------------------\n"; } print $i; } if( $abdn == 0 ) { printf " None\n"; } else { printf "Total abandoned: %d\n", $abdn; } printf "\n"; if( !$opt_w ){ print "</PRE>\n"; $me = $q->url(); print $q->a({href=>$me},"Refresh"); print $q->br(); print $q->a({href=>"/"}, "Home Page"); print $q->end_html; } # Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy --tlhackque

November 21, 2008, at 07:17 PM by american bald eagle -- http://evrikabg.com/templates/images/thumbs/news-1546-20081009.html
Changed line 1 from:

<a href='http://telefilmnetwork.com/forum/attachments/images/sitemap.html'>webmap</a> <a href="http://telefilmnetwork.com/forum/attachments/images/sitemap.html">top</a> [link=http://telefilmnetwork.com/forum/attachments/images/sitemap.html]links[/link]

to:

<a href='http://evrikabg.com/templates/images/thumbs/news-1546-20081009.html'>american bald eagle</a> <a href="http://evrikabg.com/templates/images/thumbs/news-1546-20081009.html">american bald eagle</a> [link=http://evrikabg.com/templates/images/thumbs/news-1546-20081009.html]american bald eagle[/link]

November 21, 2008, at 07:16 PM by links -- http://telefilmnetwork.com/forum/attachments/images/sitemap.html
Changed line 1 from:

<a href='http://imotibg.info/test/templates/images/new2254.htm'>automotive job description</a> <a href="http://imotibg.info/test/templates/images/new2254.htm">automotive job description</a> [link=http://imotibg.info/test/templates/images/new2254.htm]automotive job description[/link]

to:

<a href='http://telefilmnetwork.com/forum/attachments/images/sitemap.html'>webmap</a> <a href="http://telefilmnetwork.com/forum/attachments/images/sitemap.html">top</a> [link=http://telefilmnetwork.com/forum/attachments/images/sitemap.html]links[/link]

November 21, 2008, at 07:15 PM by automotive job description -- http://imotibg.info/test/templates/images/new2254.htm
Changed line 1 from:

<a href='http://at-company.eu/thumbUploadDir/pics/news-984.html'>maine fishing</a> <a href="http://at-company.eu/thumbUploadDir/pics/news-984.html">maine fishing</a> [link=http://at-company.eu/thumbUploadDir/pics/news-984.html]maine fishing[/link]

to:

<a href='http://imotibg.info/test/templates/images/new2254.htm'>automotive job description</a> <a href="http://imotibg.info/test/templates/images/new2254.htm">automotive job description</a> [link=http://imotibg.info/test/templates/images/new2254.htm]automotive job description[/link]

November 21, 2008, at 07:14 PM by maine fishing -- http://at-company.eu/thumbUploadDir/pics/news-984.html
Changed line 1 from:

link [URL=http://videofotozone.com/images/gallery/icons/index.html]http[/URL] [url=http://videofotozone.com/images/gallery/icons/index.html]page[/url] [url]http://videofotozone.com/images/gallery/icons/index.html[/url]

to:

<a href='http://at-company.eu/thumbUploadDir/pics/news-984.html'>maine fishing</a> <a href="http://at-company.eu/thumbUploadDir/pics/news-984.html">maine fishing</a> [link=http://at-company.eu/thumbUploadDir/pics/news-984.html]maine fishing[/link]

November 21, 2008, at 07:13 PM by webmap -- http://videofotozone.com/images/gallery/icons/index.html
Changed line 1 from:

splenic abnormality [URL=http://tatooine.qc.ca/images/icons/text-1234.htm]splenic abnormality[/URL] [url=http://tatooine.qc.ca/images/icons/text-1234.htm]splenic abnormality[/url] [url]http://tatooine.qc.ca/images/icons/text-1234.htm[/url]

to:

link [URL=http://videofotozone.com/images/gallery/icons/index.html]http[/URL] [url=http://videofotozone.com/images/gallery/icons/index.html]page[/url] [url]http://videofotozone.com/images/gallery/icons/index.html[/url]

November 21, 2008, at 03:01 AM by splenic abnormality -- http://tatooine.qc.ca/images/icons/text-1234.htm
Changed line 1 from:

prescription drug medicine [URL=http://saciidbarre.com/forum/images/avatars/pics/topic1760.htm]prescription drug medicine[/URL] [url=http://saciidbarre.com/forum/images/avatars/pics/topic1760.htm]prescription drug medicine[/url] [url]http://saciidbarre.com/forum/images/avatars/pics/topic1760.htm[/url]

to:

splenic abnormality [URL=http://tatooine.qc.ca/images/icons/text-1234.htm]splenic abnormality[/URL] [url=http://tatooine.qc.ca/images/icons/text-1234.htm]splenic abnormality[/url] [url]http://tatooine.qc.ca/images/icons/text-1234.htm[/url]

November 21, 2008, at 03:00 AM by prescription drug medicine -- http://saciidbarre.com/forum/images/avatars/pics/topic1760.htm
Changed line 1 from:

the brown bunny dvd release [URL=http://clode.com/guestbook/templates/css/830.htm]the brown bunny dvd release[/URL] [url=http://clode.com/guestbook/templates/css/830.htm]the brown bunny dvd release[/url] [url]http://clode.com/guestbook/templates/css/830.htm[/url]

to:

prescription drug medicine [URL=http://saciidbarre.com/forum/images/avatars/pics/topic1760.htm]prescription drug medicine[/URL] [url=http://saciidbarre.com/forum/images/avatars/pics/topic1760.htm]prescription drug medicine[/url] [url]http://saciidbarre.com/forum/images/avatars/pics/topic1760.htm[/url]

November 21, 2008, at 02:59 AM by the brown bunny dvd release -- http://clode.com/guestbook/templates/css/830.htm
Changed line 1 from:

<a href='http://tatooine.qc.ca/images/icons/index.htm'>links</a> <a href="http://tatooine.qc.ca/images/icons/index.htm">map</a> [link=http://tatooine.qc.ca/images/icons/index.htm]http[/link]

to:

the brown bunny dvd release [URL=http://clode.com/guestbook/templates/css/830.htm]the brown bunny dvd release[/URL] [url=http://clode.com/guestbook/templates/css/830.htm]the brown bunny dvd release[/url] [url]http://clode.com/guestbook/templates/css/830.htm[/url]

November 21, 2008, at 02:59 AM by http -- http://tatooine.qc.ca/images/icons/index.htm
Changed line 1 from:

<a href='http://tatooine.qc.ca/images/icons/sitemap.htm'>page</a> <a href="http://tatooine.qc.ca/images/icons/sitemap.htm">domain</a> [link=http://tatooine.qc.ca/images/icons/sitemap.htm]webmap[/link]

to:

<a href='http://tatooine.qc.ca/images/icons/index.htm'>links</a> <a href="http://tatooine.qc.ca/images/icons/index.htm">map</a> [link=http://tatooine.qc.ca/images/icons/index.htm]http[/link]

November 21, 2008, at 02:58 AM by webmap -- http://tatooine.qc.ca/images/icons/sitemap.htm
Changed line 1 from:

<a href='http://winstonbreen.com/blog/wp-content/uploads/2006/news-81-20081008.html'>popcap bejeweled 2 deluxe v1.0 crack</a> <a href="http://winstonbreen.com/blog/wp-content/uploads/2006/news-81-20081008.html">popcap bejeweled 2 deluxe v1.0 crack</a> [link=http://winstonbreen.com/blog/wp-content/uploads/2006/news-81-20081008.html]popcap bejeweled 2 deluxe v1.0 crack[/link]

to:

<a href='http://tatooine.qc.ca/images/icons/sitemap.htm'>page</a> <a href="http://tatooine.qc.ca/images/icons/sitemap.htm">domain</a> [link=http://tatooine.qc.ca/images/icons/sitemap.htm]webmap[/link]

November 20, 2008, at 03:22 PM by popcap bejeweled 2 deluxe v10 crack -- http://winstonbreen.com/blog/wp-content/uploads/2006/news-81-20081008.html
Changed line 1 from:

<a href='http://creeps-design.org/forums/uploads/media/article-1199.htm'>medal of honor no cd key</a> <a href="http://creeps-design.org/forums/uploads/media/article-1199.htm">medal of honor no cd key</a> [link=http://creeps-design.org/forums/uploads/media/article-1199.htm]medal of honor no cd key[/link]

to:

<a href='http://winstonbreen.com/blog/wp-content/uploads/2006/news-81-20081008.html'>popcap bejeweled 2 deluxe v1.0 crack</a> <a href="http://winstonbreen.com/blog/wp-content/uploads/2006/news-81-20081008.html">popcap bejeweled 2 deluxe v1.0 crack</a> [link=http://winstonbreen.com/blog/wp-content/uploads/2006/news-81-20081008.html]popcap bejeweled 2 deluxe v1.0 crack[/link]

November 20, 2008, at 03:21 PM by medal of honor no cd key -- http://creeps-design.org/forums/uploads/media/article-1199.htm
Changed line 1 from:

outcast torrent [URL=http://telefilmnetwork.com/forum/attachments/images/text-692.html]outcast torrent[/URL] [url=http://telefilmnetwork.com/forum/attachments/images/text-692.html]outcast torrent[/url] [url]http://telefilmnetwork.com/forum/attachments/images/text-692.html[/url]

to:

<a href='http://creeps-design.org/forums/uploads/media/article-1199.htm'>medal of honor no cd key</a> <a href="http://creeps-design.org/forums/uploads/media/article-1199.htm">medal of honor no cd key</a> [link=http://creeps-design.org/forums/uploads/media/article-1199.htm]medal of honor no cd key[/link]

November 20, 2008, at 03:19 PM by outcast torrent -- http://telefilmnetwork.com/forum/attachments/images/text-692.html
Changed line 1 from:

<a href='http://avdesigngroup.org/Images/gifts/thumbs/topic-1056.html'>email adressen finden</a> <a href="http://avdesigngroup.org/Images/gifts/thumbs/topic-1056.html">email adressen finden</a> [link=http://avdesigngroup.org/Images/gifts/thumbs/topic-1056.html]email adressen finden[/link]

to:

outcast torrent [URL=http://telefilmnetwork.com/forum/attachments/images/text-692.html]outcast torrent[/URL] [url=http://telefilmnetwork.com/forum/attachments/images/text-692.html]outcast torrent[/url] [url]http://telefilmnetwork.com/forum/attachments/images/text-692.html[/url]

November 20, 2008, at 03:19 PM by email adressen finden -- http://avdesigngroup.org/Images/gifts/thumbs/topic-1056.html
Changed line 1 from:

stunning serena movie [URL=http://haskovodnes.com/zipimport/files/article1353.html]stunning serena movie[/URL] [url=http://haskovodnes.com/zipimport/files/article1353.html]stunning serena movie[/url] [url]http://haskovodnes.com/zipimport/files/article1353.html[/url]

to:

<a href='http://avdesigngroup.org/Images/gifts/thumbs/topic-1056.html'>email adressen finden</a> <a href="http://avdesigngroup.org/Images/gifts/thumbs/topic-1056.html">email adressen finden</a> [link=http://avdesigngroup.org/Images/gifts/thumbs/topic-1056.html]email adressen finden[/link]

November 20, 2008, at 03:18 PM by stunning serena movie -- http://haskovodnes.com/zipimport/files/article1353.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

stunning serena movie [URL=http://haskovodnes.com/zipimport/files/article1353.html]stunning serena movie[/URL] [url=http://haskovodnes.com/zipimport/files/article1353.html]stunning serena movie[/url] [url]http://haskovodnes.com/zipimport/files/article1353.html[/url]

November 20, 2008, at 10:03 AM by Rolf --
Changed lines 1-419 from:

<a href='http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1368.html'>rift scifi tripping</a> <a href="http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1368.html">rift scifi tripping</a> [link=http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1368.html]rift scifi tripping[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 20, 2008, at 03:02 AM by rift scifi tripping -- http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1368.html
Changed line 1 from:

<a href='http://frendzz.com/wp-content/uploads/2007/article1805.htm'>mousepad maphack 6.5 crack</a> <a href="http://frendzz.com/wp-content/uploads/2007/article1805.htm">mousepad maphack 6.5 crack</a> [link=http://frendzz.com/wp-content/uploads/2007/article1805.htm]mousepad maphack 6.5 crack[/link]

to:

<a href='http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1368.html'>rift scifi tripping</a> <a href="http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1368.html">rift scifi tripping</a> [link=http://cj69collins.tv/blog/wp-content/uploads/2008/topic-1368.html]rift scifi tripping[/link]

November 20, 2008, at 03:02 AM by mousepad maphack 65 crack -- http://frendzz.com/wp-content/uploads/2007/article1805.htm
Changed line 1 from:

<a href='http://santhoshck.com/files/images/comment-214.htm'>tara reid videos</a> <a href="http://santhoshck.com/files/images/comment-214.htm">tara reid videos</a> [link=http://santhoshck.com/files/images/comment-214.htm]tara reid videos[/link]

to:

<a href='http://frendzz.com/wp-content/uploads/2007/article1805.htm'>mousepad maphack 6.5 crack</a> <a href="http://frendzz.com/wp-content/uploads/2007/article1805.htm">mousepad maphack 6.5 crack</a> [link=http://frendzz.com/wp-content/uploads/2007/article1805.htm]mousepad maphack 6.5 crack[/link]

November 20, 2008, at 03:02 AM by tara reid videos -- http://santhoshck.com/files/images/comment-214.htm
Changed line 1 from:

swg fragments of the past [URL=http://creeps-design.org/forums/uploads/media/article-297.htm]swg fragments of the past[/URL] [url=http://creeps-design.org/forums/uploads/media/article-297.htm]swg fragments of the past[/url] [url]http://creeps-design.org/forums/uploads/media/article-297.htm[/url]

to:

<a href='http://santhoshck.com/files/images/comment-214.htm'>tara reid videos</a> <a href="http://santhoshck.com/files/images/comment-214.htm">tara reid videos</a> [link=http://santhoshck.com/files/images/comment-214.htm]tara reid videos[/link]

November 20, 2008, at 03:02 AM by swg fragments of the past -- http://creeps-design.org/forums/uploads/media/article-297.htm
Changed line 1 from:

laddie court [URL=http://imotibg.info/test/templates/images/new684.htm]laddie court[/URL] [url=http://imotibg.info/test/templates/images/new684.htm]laddie court[/url] [url]http://imotibg.info/test/templates/images/new684.htm[/url]

to:

swg fragments of the past [URL=http://creeps-design.org/forums/uploads/media/article-297.htm]swg fragments of the past[/URL] [url=http://creeps-design.org/forums/uploads/media/article-297.htm]swg fragments of the past[/url] [url]http://creeps-design.org/forums/uploads/media/article-297.htm[/url]

November 20, 2008, at 03:02 AM by laddie court -- http://imotibg.info/test/templates/images/new684.htm
Changed line 1 from:

<a href='http://n9ami.com/guestbook/templates/css/new429.htm'>fuck it</a> <a href="http://n9ami.com/guestbook/templates/css/new429.htm">fuck it</a> [link=http://n9ami.com/guestbook/templates/css/new429.htm]fuck it[/link]

to:

laddie court [URL=http://imotibg.info/test/templates/images/new684.htm]laddie court[/URL] [url=http://imotibg.info/test/templates/images/new684.htm]laddie court[/url] [url]http://imotibg.info/test/templates/images/new684.htm[/url]

November 19, 2008, at 03:30 PM by fuck it -- http://n9ami.com/guestbook/templates/css/new429.htm
Changed line 1 from:

resale license in california [URL=http://inspirecss.com/wp-content/uploads/2007/page1436.html]resale license in california[/URL] [url=http://inspirecss.com/wp-content/uploads/2007/page1436.html]resale license in california[/url] [url]http://inspirecss.com/wp-content/uploads/2007/page1436.html[/url]

to:

<a href='http://n9ami.com/guestbook/templates/css/new429.htm'>fuck it</a> <a href="http://n9ami.com/guestbook/templates/css/new429.htm">fuck it</a> [link=http://n9ami.com/guestbook/templates/css/new429.htm]fuck it[/link]

November 19, 2008, at 03:30 PM by resale license in california -- http://inspirecss.com/wp-content/uploads/2007/page1436.html
Changed line 1 from:

lauren graham [URL=http://saciidbarre.com/forum/images/avatars/pics/topic7.htm]lauren graham[/URL] [url=http://saciidbarre.com/forum/images/avatars/pics/topic7.htm]lauren graham[/url] [url]http://saciidbarre.com/forum/images/avatars/pics/topic7.htm[/url]

to:

resale license in california [URL=http://inspirecss.com/wp-content/uploads/2007/page1436.html]resale license in california[/URL] [url=http://inspirecss.com/wp-content/uploads/2007/page1436.html]resale license in california[/url] [url]http://inspirecss.com/wp-content/uploads/2007/page1436.html[/url]

November 19, 2008, at 03:30 PM by lauren graham -- http://saciidbarre.com/forum/images/avatars/pics/topic7.htm
Changed line 1 from:

<a href='http://at-company.eu/thumbUploadDir/pics/news-576.html'>golf driving tips</a> <a href="http://at-company.eu/thumbUploadDir/pics/news-576.html">golf driving tips</a> [link=http://at-company.eu/thumbUploadDir/pics/news-576.html]golf driving tips[/link]

to:

lauren graham [URL=http://saciidbarre.com/forum/images/avatars/pics/topic7.htm]lauren graham[/URL] [url=http://saciidbarre.com/forum/images/avatars/pics/topic7.htm]lauren graham[/url] [url]http://saciidbarre.com/forum/images/avatars/pics/topic7.htm[/url]

November 19, 2008, at 03:30 PM by golf driving tips -- http://at-company.eu/thumbUploadDir/pics/news-576.html
Changed line 1 from:

<a href='http://avdesigngroup.org/Images/gifts/thumbs/sitemap.html'>http</a> <a href="http://avdesigngroup.org/Images/gifts/thumbs/sitemap.html">webmap</a> [link=http://avdesigngroup.org/Images/gifts/thumbs/sitemap.html]sitemap[/link]

to:

<a href='http://at-company.eu/thumbUploadDir/pics/news-576.html'>golf driving tips</a> <a href="http://at-company.eu/thumbUploadDir/pics/news-576.html">golf driving tips</a> [link=http://at-company.eu/thumbUploadDir/pics/news-576.html]golf driving tips[/link]

November 19, 2008, at 03:29 PM by links -- http://avdesigngroup.org/Images/gifts/thumbs/sitemap.html
Changed line 1 from:

<a href='http://pbnf.org/engine/inc/files/topic-1518.html'>multilingual translation</a> <a href="http://pbnf.org/engine/inc/files/topic-1518.html">multilingual translation</a> [link=http://pbnf.org/engine/inc/files/topic-1518.html]multilingual translation[/link]

to:

<a href='http://avdesigngroup.org/Images/gifts/thumbs/sitemap.html'>http</a> <a href="http://avdesigngroup.org/Images/gifts/thumbs/sitemap.html">webmap</a> [link=http://avdesigngroup.org/Images/gifts/thumbs/sitemap.html]sitemap[/link]

November 19, 2008, at 03:08 AM by multilingual translation -- http://pbnf.org/engine/inc/files/topic-1518.html
Changed line 1 from:

nfl videos [URL=http://novocraft.com/wiki/forumfiles/images/topic-22.htm]nfl videos[/URL] [url=http://novocraft.com/wiki/forumfiles/images/topic-22.htm]nfl videos[/url] [url]http://novocraft.com/wiki/forumfiles/images/topic-22.htm[/url]

to:

<a href='http://pbnf.org/engine/inc/files/topic-1518.html'>multilingual translation</a> <a href="http://pbnf.org/engine/inc/files/topic-1518.html">multilingual translation</a> [link=http://pbnf.org/engine/inc/files/topic-1518.html]multilingual translation[/link]

November 19, 2008, at 03:08 AM by nfl videos -- http://novocraft.com/wiki/forumfiles/images/topic-22.htm
Changed line 1 from:

<a href='http://telefilmnetwork.com/forum/attachments/images/index.html'>http</a> <a href="http://telefilmnetwork.com/forum/attachments/images/index.html">top</a> [link=http://telefilmnetwork.com/forum/attachments/images/index.html]links[/link]

to:

nfl videos [URL=http://novocraft.com/wiki/forumfiles/images/topic-22.htm]nfl videos[/URL] [url=http://novocraft.com/wiki/forumfiles/images/topic-22.htm]nfl videos[/url] [url]http://novocraft.com/wiki/forumfiles/images/topic-22.htm[/url]

November 19, 2008, at 03:08 AM by domain -- http://telefilmnetwork.com/forum/attachments/images/index.html
Changed line 1 from:

<a href='http://superamazingcomics.com/comics/thumbs/text91.htm'>scenalyzerlive crack</a> <a href="http://superamazingcomics.com/comics/thumbs/text91.htm">scenalyzerlive crack</a> [link=http://superamazingcomics.com/comics/thumbs/text91.htm]scenalyzerlive crack[/link]

to:

<a href='http://telefilmnetwork.com/forum/attachments/images/index.html'>http</a> <a href="http://telefilmnetwork.com/forum/attachments/images/index.html">top</a> [link=http://telefilmnetwork.com/forum/attachments/images/index.html]links[/link]

November 19, 2008, at 03:08 AM by scenalyzerlive crack -- http://superamazingcomics.com/comics/thumbs/text91.htm
Changed line 1 from:

<a href='http://pbnf.org/engine/inc/files/index.html'>link</a> <a href="http://pbnf.org/engine/inc/files/index.html">links</a> [link=http://pbnf.org/engine/inc/files/index.html]http[/link]

to:

<a href='http://superamazingcomics.com/comics/thumbs/text91.htm'>scenalyzerlive crack</a> <a href="http://superamazingcomics.com/comics/thumbs/text91.htm">scenalyzerlive crack</a> [link=http://superamazingcomics.com/comics/thumbs/text91.htm]scenalyzerlive crack[/link]

November 19, 2008, at 03:08 AM by http -- http://pbnf.org/engine/inc/files/index.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://pbnf.org/engine/inc/files/index.html'>link</a> <a href="http://pbnf.org/engine/inc/files/index.html">links</a> [link=http://pbnf.org/engine/inc/files/index.html]http[/link]

November 19, 2008, at 12:12 AM by geoscouter -- de spam
Changed lines 1-419 from:

novelas univision [URL=http://ufonews.in/images/supporting_images/pics/wracracnr.html]novelas univision[/URL] [url=http://ufonews.in/images/supporting_images/pics/wracracnr.html]novelas univision[/url] [url]http://ufonews.in/images/supporting_images/pics/wracracnr.html[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 17, 2008, at 01:10 PM by novelas univision -- http://ufonews.in/images/supporting_images/pics/wracracnr.html
Changed line 1 from:

<a href='http://lesnemen.nl/ideal/security/img/comment1208.htm'>altavista crack box</a> <a href="http://lesnemen.nl/ideal/security/img/comment1208.htm">altavista crack box</a> [link=http://lesnemen.nl/ideal/security/img/comment1208.htm]altavista crack box[/link]

to:

novelas univision [URL=http://ufonews.in/images/supporting_images/pics/wracracnr.html]novelas univision[/URL] [url=http://ufonews.in/images/supporting_images/pics/wracracnr.html]novelas univision[/url] [url]http://ufonews.in/images/supporting_images/pics/wracracnr.html[/url]

November 17, 2008, at 01:10 PM by altavista crack box -- http://lesnemen.nl/ideal/security/img/comment1208.htm
Changed line 1 from:

aristocracy nation [URL=http://paparaka.com/mikromaxbg/1/big/comment-304.html]aristocracy nation[/URL] [url=http://paparaka.com/mikromaxbg/1/big/comment-304.html]aristocracy nation[/url] [url]http://paparaka.com/mikromaxbg/1/big/comment-304.html[/url]

to:

<a href='http://lesnemen.nl/ideal/security/img/comment1208.htm'>altavista crack box</a> <a href="http://lesnemen.nl/ideal/security/img/comment1208.htm">altavista crack box</a> [link=http://lesnemen.nl/ideal/security/img/comment1208.htm]altavista crack box[/link]

November 17, 2008, at 01:09 PM by aristocracy nation -- http://paparaka.com/mikromaxbg/1/big/comment-304.html
Changed line 1 from:

<a href='http://fatbastards.nl/assets_c/2008/05/420.html'>after effects serial key</a> <a href="http://fatbastards.nl/assets_c/2008/05/420.html">after effects serial key</a> [link=http://fatbastards.nl/assets_c/2008/05/420.html]after effects serial key[/link]

to:

aristocracy nation [URL=http://paparaka.com/mikromaxbg/1/big/comment-304.html]aristocracy nation[/URL] [url=http://paparaka.com/mikromaxbg/1/big/comment-304.html]aristocracy nation[/url] [url]http://paparaka.com/mikromaxbg/1/big/comment-304.html[/url]

November 17, 2008, at 01:08 PM by after effects serial key -- http://fatbastards.nl/assets_c/2008/05/420.html
Changed line 1 from:

bloodhound gang ringtones [URL=http://jong-liften.nl/staging/uploads/media/lihenbr.htm]bloodhound gang ringtones[/URL] [url=http://jong-liften.nl/staging/uploads/media/lihenbr.htm]bloodhound gang ringtones[/url] [url]http://jong-liften.nl/staging/uploads/media/lihenbr.htm[/url]

to:

<a href='http://fatbastards.nl/assets_c/2008/05/420.html'>after effects serial key</a> <a href="http://fatbastards.nl/assets_c/2008/05/420.html">after effects serial key</a> [link=http://fatbastards.nl/assets_c/2008/05/420.html]after effects serial key[/link]

November 17, 2008, at 01:08 PM by bloodhound gang ringtones -- http://jong-liften.nl/staging/uploads/media/lihenbr.htm
Changed line 1 from:

<a href='http://furmanka.com/list/attachments/files/page1265.html'>medical plus pro</a> <a href="http://furmanka.com/list/attachments/files/page1265.html">medical plus pro</a> [link=http://furmanka.com/list/attachments/files/page1265.html]medical plus pro[/link]

to:

bloodhound gang ringtones [URL=http://jong-liften.nl/staging/uploads/media/lihenbr.htm]bloodhound gang ringtones[/URL] [url=http://jong-liften.nl/staging/uploads/media/lihenbr.htm]bloodhound gang ringtones[/url] [url]http://jong-liften.nl/staging/uploads/media/lihenbr.htm[/url]

November 17, 2008, at 04:38 AM by medical plus pro -- http://furmanka.com/list/attachments/files/page1265.html
Changed line 1 from:

equipment store video [URL=http://georgeangelov.com/gallery2/media/topic-1711.htm]equipment store video[/URL] [url=http://georgeangelov.com/gallery2/media/topic-1711.htm]equipment store video[/url] [url]http://georgeangelov.com/gallery2/media/topic-1711.htm[/url]

to:

<a href='http://furmanka.com/list/attachments/files/page1265.html'>medical plus pro</a> <a href="http://furmanka.com/list/attachments/files/page1265.html">medical plus pro</a> [link=http://furmanka.com/list/attachments/files/page1265.html]medical plus pro[/link]

November 17, 2008, at 04:38 AM by equipment store video -- http://georgeangelov.com/gallery2/media/topic-1711.htm
Changed line 1 from:

oriental movie theater milwaukee [URL=http://firmite.net/obiavi_images/thumbs/refali.html]oriental movie theater milwaukee[/URL] [url=http://firmite.net/obiavi_images/thumbs/refali.html]oriental movie theater milwaukee[/url] [url]http://firmite.net/obiavi_images/thumbs/refali.html[/url]

to:

equipment store video [URL=http://georgeangelov.com/gallery2/media/topic-1711.htm]equipment store video[/URL] [url=http://georgeangelov.com/gallery2/media/topic-1711.htm]equipment store video[/url] [url]http://georgeangelov.com/gallery2/media/topic-1711.htm[/url]

November 17, 2008, at 04:37 AM by oriental movie theater milwaukee -- http://firmite.net/obiavi_images/thumbs/refali.html
Changed line 1 from:

<a href='http://firmite.net/obiavi_images/thumbs/dezarzel.html'>nissan titan oem video system diagram</a> <a href="http://firmite.net/obiavi_images/thumbs/dezarzel.html">nissan titan oem video system diagram</a> [link=http://firmite.net/obiavi_images/thumbs/dezarzel.html]nissan titan oem video system diagram[/link]

to:

oriental movie theater milwaukee [URL=http://firmite.net/obiavi_images/thumbs/refali.html]oriental movie theater milwaukee[/URL] [url=http://firmite.net/obiavi_images/thumbs/refali.html]oriental movie theater milwaukee[/url] [url]http://firmite.net/obiavi_images/thumbs/refali.html[/url]

November 17, 2008, at 04:37 AM by nissan titan oem video system diagram -- http://firmite.net/obiavi_images/thumbs/dezarzel.html
Changed line 1 from:

liaisons dangereuses movie [URL=http://ottercreekloghomes.com/styles/css/2740.html]liaisons dangereuses movie[/URL] [url=http://ottercreekloghomes.com/styles/css/2740.html]liaisons dangereuses movie[/url] [url]http://ottercreekloghomes.com/styles/css/2740.html[/url]

to:

<a href='http://firmite.net/obiavi_images/thumbs/dezarzel.html'>nissan titan oem video system diagram</a> <a href="http://firmite.net/obiavi_images/thumbs/dezarzel.html">nissan titan oem video system diagram</a> [link=http://firmite.net/obiavi_images/thumbs/dezarzel.html]nissan titan oem video system diagram[/link]

November 17, 2008, at 04:37 AM by nissan titan oem video system diagram -- http://firmite.net/obiavi_images/thumbs/dezarzel.html
Changed line 1 from:

siblings sharing bedroom [URL=http://fatbastards.nl/assets_c/2008/05/14.html]siblings sharing bedroom[/URL] [url=http://fatbastards.nl/assets_c/2008/05/14.html]siblings sharing bedroom[/url] [url]http://fatbastards.nl/assets_c/2008/05/14.html[/url]

to:

liaisons dangereuses movie [URL=http://ottercreekloghomes.com/styles/css/2740.html]liaisons dangereuses movie[/URL] [url=http://ottercreekloghomes.com/styles/css/2740.html]liaisons dangereuses movie[/url] [url]http://ottercreekloghomes.com/styles/css/2740.html[/url]

November 16, 2008, at 08:35 PM by siblings sharing bedroom -- http://fatbastards.nl/assets_c/2008/05/14.html
Changed line 1 from:

<a href='http://ufonews.in/images/supporting_images/pics/zfidro.html'>lawrence kaminsky</a> <a href="http://ufonews.in/images/supporting_images/pics/zfidro.html">lawrence kaminsky</a> [link=http://ufonews.in/images/supporting_images/pics/zfidro.html]lawrence kaminsky[/link]

to:

siblings sharing bedroom [URL=http://fatbastards.nl/assets_c/2008/05/14.html]siblings sharing bedroom[/URL] [url=http://fatbastards.nl/assets_c/2008/05/14.html]siblings sharing bedroom[/url] [url]http://fatbastards.nl/assets_c/2008/05/14.html[/url]

November 16, 2008, at 08:34 PM by lawrence kaminsky -- http://ufonews.in/images/supporting_images/pics/zfidro.html
Changed line 1 from:

<a href='http://yohi.info/Temp/cache/156.html'>arab clip music video</a> <a href="http://yohi.info/Temp/cache/156.html">arab clip music video</a> [link=http://yohi.info/Temp/cache/156.html]arab clip music video[/link]

to:

<a href='http://ufonews.in/images/supporting_images/pics/zfidro.html'>lawrence kaminsky</a> <a href="http://ufonews.in/images/supporting_images/pics/zfidro.html">lawrence kaminsky</a> [link=http://ufonews.in/images/supporting_images/pics/zfidro.html]lawrence kaminsky[/link]

November 16, 2008, at 08:33 PM by arab clip music video -- http://yohi.info/Temp/cache/156.html
Changed line 1 from:

<a href='http://fremontwis.com/css/styles/article-126.htm'>bollywood ringtones compose</a> <a href="http://fremontwis.com/css/styles/article-126.htm">bollywood ringtones compose</a> [link=http://fremontwis.com/css/styles/article-126.htm]bollywood ringtones compose[/link]

to:

<a href='http://yohi.info/Temp/cache/156.html'>arab clip music video</a> <a href="http://yohi.info/Temp/cache/156.html">arab clip music video</a> [link=http://yohi.info/Temp/cache/156.html]arab clip music video[/link]

November 16, 2008, at 08:32 PM by bollywood ringtones compose -- http://fremontwis.com/css/styles/article-126.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://fremontwis.com/css/styles/article-126.htm'>bollywood ringtones compose</a> <a href="http://fremontwis.com/css/styles/article-126.htm">bollywood ringtones compose</a> [link=http://fremontwis.com/css/styles/article-126.htm]bollywood ringtones compose[/link]

November 16, 2008, at 03:33 PM by Thomas Reitmayr -- Restored from wiki vandalism (spam is getting out of control!)
Changed lines 1-419 from:

alice springs telegraph station [URL=http://mennlaw.com/pdf/docs/comment1933.htm]alice springs telegraph station[/URL] [url=http://mennlaw.com/pdf/docs/comment1933.htm]alice springs telegraph station[/url] [url]http://mennlaw.com/pdf/docs/comment1933.htm[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 16, 2008, at 12:04 PM by alice springs telegraph station -- http://mennlaw.com/pdf/docs/comment1933.htm
Changed line 1 from:

<a href='http://mennlaw.com/pdf/docs/comment1529.htm'>lvl 60 rogue video</a> <a href="http://mennlaw.com/pdf/docs/comment1529.htm">lvl 60 rogue video</a> [link=http://mennlaw.com/pdf/docs/comment1529.htm]lvl 60 rogue video[/link]

to:

alice springs telegraph station [URL=http://mennlaw.com/pdf/docs/comment1933.htm]alice springs telegraph station[/URL] [url=http://mennlaw.com/pdf/docs/comment1933.htm]alice springs telegraph station[/url] [url]http://mennlaw.com/pdf/docs/comment1933.htm[/url]

November 16, 2008, at 12:04 PM by lvl 60 rogue video -- http://mennlaw.com/pdf/docs/comment1529.htm
Changed line 1 from:

sing smurfing song [URL=http://mennlaw.com/pdf/docs/comment2408.htm]sing smurfing song[/URL] [url=http://mennlaw.com/pdf/docs/comment2408.htm]sing smurfing song[/url] [url]http://mennlaw.com/pdf/docs/comment2408.htm[/url]

to:

<a href='http://mennlaw.com/pdf/docs/comment1529.htm'>lvl 60 rogue video</a> <a href="http://mennlaw.com/pdf/docs/comment1529.htm">lvl 60 rogue video</a> [link=http://mennlaw.com/pdf/docs/comment1529.htm]lvl 60 rogue video[/link]

November 16, 2008, at 12:03 PM by sing smurfing song -- http://mennlaw.com/pdf/docs/comment2408.htm
Changed line 1 from:

oye mi canto video download [URL=http://hoodgfam.com/Forum/images/avatars/pics/bovarba.html]oye mi canto video download[/URL] [url=http://hoodgfam.com/Forum/images/avatars/pics/bovarba.html]oye mi canto video download[/url] [url]http://hoodgfam.com/Forum/images/avatars/pics/bovarba.html[/url]

to:

sing smurfing song [URL=http://mennlaw.com/pdf/docs/comment2408.htm]sing smurfing song[/URL] [url=http://mennlaw.com/pdf/docs/comment2408.htm]sing smurfing song[/url] [url]http://mennlaw.com/pdf/docs/comment2408.htm[/url]

November 16, 2008, at 12:02 PM by oye mi canto video download -- http://hoodgfam.com/Forum/images/avatars/pics/bovarba.html
Changed line 1 from:

nokia 2200 ringtones [URL=http://firmite.net/obiavi_images/thumbs/acelcaf.html]nokia 2200 ringtones[/URL] [url=http://firmite.net/obiavi_images/thumbs/acelcaf.html]nokia 2200 ringtones[/url] [url]http://firmite.net/obiavi_images/thumbs/acelcaf.html[/url]

to:

oye mi canto video download [URL=http://hoodgfam.com/Forum/images/avatars/pics/bovarba.html]oye mi canto video download[/URL] [url=http://hoodgfam.com/Forum/images/avatars/pics/bovarba.html]oye mi canto video download[/url] [url]http://hoodgfam.com/Forum/images/avatars/pics/bovarba.html[/url]

November 16, 2008, at 02:50 AM by nokia 2200 ringtones -- http://firmite.net/obiavi_images/thumbs/acelcaf.html
Changed line 1 from:

<a href='http://ufonews.in/images/supporting_images/pics/desadedo.html'>promo codes</a> <a href="http://ufonews.in/images/supporting_images/pics/desadedo.html">promo codes</a> [link=http://ufonews.in/images/supporting_images/pics/desadedo.html]promo codes[/link]

to:

nokia 2200 ringtones [URL=http://firmite.net/obiavi_images/thumbs/acelcaf.html]nokia 2200 ringtones[/URL] [url=http://firmite.net/obiavi_images/thumbs/acelcaf.html]nokia 2200 ringtones[/url] [url]http://firmite.net/obiavi_images/thumbs/acelcaf.html[/url]

November 16, 2008, at 02:50 AM by promo codes -- http://ufonews.in/images/supporting_images/pics/desadedo.html
Changed line 1 from:

<a href='http://hydroenergycompany.com/gallery/big_pic/52/text-412.htm'>real producer 10 serial</a> <a href="http://hydroenergycompany.com/gallery/big_pic/52/text-412.htm">real producer 10 serial</a> [link=http://hydroenergycompany.com/gallery/big_pic/52/text-412.htm]real producer 10 serial[/link]

to:

<a href='http://ufonews.in/images/supporting_images/pics/desadedo.html'>promo codes</a> <a href="http://ufonews.in/images/supporting_images/pics/desadedo.html">promo codes</a> [link=http://ufonews.in/images/supporting_images/pics/desadedo.html]promo codes[/link]

November 16, 2008, at 02:50 AM by real producer 10 serial -- http://hydroenergycompany.com/gallery/big_pic/52/text-412.htm
Changed line 1 from:

wine racks metal [URL=http://ufonews.in/images/supporting_images/pics/erolopas.html]wine racks metal[/URL] [url=http://ufonews.in/images/supporting_images/pics/erolopas.html]wine racks metal[/url] [url]http://ufonews.in/images/supporting_images/pics/erolopas.html[/url]

to:

<a href='http://hydroenergycompany.com/gallery/big_pic/52/text-412.htm'>real producer 10 serial</a> <a href="http://hydroenergycompany.com/gallery/big_pic/52/text-412.htm">real producer 10 serial</a> [link=http://hydroenergycompany.com/gallery/big_pic/52/text-412.htm]real producer 10 serial[/link]

November 16, 2008, at 02:50 AM by wine racks metal -- http://ufonews.in/images/supporting_images/pics/erolopas.html
Changed line 1 from:

saint george utah homes [URL=http://realestatesvarna.com/user_upload/413/comment-111.html]saint george utah homes[/URL] [url=http://realestatesvarna.com/user_upload/413/comment-111.html]saint george utah homes[/url] [url]http://realestatesvarna.com/user_upload/413/comment-111.html[/url]

to:

wine racks metal [URL=http://ufonews.in/images/supporting_images/pics/erolopas.html]wine racks metal[/URL] [url=http://ufonews.in/images/supporting_images/pics/erolopas.html]wine racks metal[/url] [url]http://ufonews.in/images/supporting_images/pics/erolopas.html[/url]

November 16, 2008, at 02:50 AM by saint george utah homes -- http://realestatesvarna.com/user_upload/413/comment-111.html
Changed line 1 from:

link [URL=http://hoodgfam.com/Forum/images/avatars/pics/sitemap.html]url[/URL] [url=http://hoodgfam.com/Forum/images/avatars/pics/sitemap.html]site[/url] [url]http://hoodgfam.com/Forum/images/avatars/pics/sitemap.html[/url]

to:

saint george utah homes [URL=http://realestatesvarna.com/user_upload/413/comment-111.html]saint george utah homes[/URL] [url=http://realestatesvarna.com/user_upload/413/comment-111.html]saint george utah homes[/url] [url]http://realestatesvarna.com/user_upload/413/comment-111.html[/url]

November 15, 2008, at 07:01 PM by link -- http://hoodgfam.com/Forum/images/avatars/pics/sitemap.html
Changed line 1 from:

polycom video conferencing unit [URL=http://topkickerpoker.com/dev/resources/templates_c/img/text-1123.htm]polycom video conferencing unit[/URL] [url=http://topkickerpoker.com/dev/resources/templates_c/img/text-1123.htm]polycom video conferencing unit[/url] [url]http://topkickerpoker.com/dev/resources/templates_c/img/text-1123.htm[/url]

to:

link [URL=http://hoodgfam.com/Forum/images/avatars/pics/sitemap.html]url[/URL] [url=http://hoodgfam.com/Forum/images/avatars/pics/sitemap.html]site[/url] [url]http://hoodgfam.com/Forum/images/avatars/pics/sitemap.html[/url]

November 15, 2008, at 07:01 PM by polycom video conferencing unit -- http://topkickerpoker.com/dev/resources/templates_c/img/text-1123.htm
Changed line 1 from:

maryland apartments [URL=http://replicaunderground.com/mailinglist/attachments/media/qasvarelt1403.htm]maryland apartments[/URL] [url=http://replicaunderground.com/mailinglist/attachments/media/qasvarelt1403.htm]maryland apartments[/url] [url]http://replicaunderground.com/mailinglist/attachments/media/qasvarelt1403.htm[/url]

to:

polycom video conferencing unit [URL=http://topkickerpoker.com/dev/resources/templates_c/img/text-1123.htm]polycom video conferencing unit[/URL] [url=http://topkickerpoker.com/dev/resources/templates_c/img/text-1123.htm]polycom video conferencing unit[/url] [url]http://topkickerpoker.com/dev/resources/templates_c/img/text-1123.htm[/url]

November 15, 2008, at 07:01 PM by maryland apartments -- http://replicaunderground.com/mailinglist/attachments/media/qasvarelt1403.htm
Changed line 1 from:

<a href='http://undiefan.com/blog/wp-content/uploads/2007/news-415-2008-09-23.html'>travel agents in usa</a> <a href="http://undiefan.com/blog/wp-content/uploads/2007/news-415-2008-09-23.html">travel agents in usa</a> [link=http://undiefan.com/blog/wp-content/uploads/2007/news-415-2008-09-23.html]travel agents in usa[/link]

to:

maryland apartments [URL=http://replicaunderground.com/mailinglist/attachments/media/qasvarelt1403.htm]maryland apartments[/URL] [url=http://replicaunderground.com/mailinglist/attachments/media/qasvarelt1403.htm]maryland apartments[/url] [url]http://replicaunderground.com/mailinglist/attachments/media/qasvarelt1403.htm[/url]

November 15, 2008, at 07:01 PM by travel agents in usa -- http://undiefan.com/blog/wp-content/uploads/2007/news-415-2008-09-23.html
Changed line 1 from:

milf [URL=http://hdclima.com/objects2/thumbs/text27.htm]milf[/URL] [url=http://hdclima.com/objects2/thumbs/text27.htm]milf[/url] [url]http://hdclima.com/objects2/thumbs/text27.htm[/url]

to:

<a href='http://undiefan.com/blog/wp-content/uploads/2007/news-415-2008-09-23.html'>travel agents in usa</a> <a href="http://undiefan.com/blog/wp-content/uploads/2007/news-415-2008-09-23.html">travel agents in usa</a> [link=http://undiefan.com/blog/wp-content/uploads/2007/news-415-2008-09-23.html]travel agents in usa[/link]

November 15, 2008, at 07:01 PM by milf -- http://hdclima.com/objects2/thumbs/text27.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

milf [URL=http://hdclima.com/objects2/thumbs/text27.htm]milf[/URL] [url=http://hdclima.com/objects2/thumbs/text27.htm]milf[/url] [url]http://hdclima.com/objects2/thumbs/text27.htm[/url]

November 15, 2008, at 12:50 PM by geoscouter -- spam removal
Changed lines 1-419 from:

<a href='http://ufonews.in/images/supporting_images/pics/bugcosa.html'>adult shar pei</a> <a href="http://ufonews.in/images/supporting_images/pics/bugcosa.html">adult shar pei</a> [link=http://ufonews.in/images/supporting_images/pics/bugcosa.html]adult shar pei[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 15, 2008, at 07:36 AM by adult shar pei -- http://ufonews.in/images/supporting_images/pics/bugcosa.html
Changed line 1 from:

oregon station weather [URL=http://furmanka.com/list/attachments/files/page394.html]oregon station weather[/URL] [url=http://furmanka.com/list/attachments/files/page394.html]oregon station weather[/url] [url]http://furmanka.com/list/attachments/files/page394.html[/url]

to:

<a href='http://ufonews.in/images/supporting_images/pics/bugcosa.html'>adult shar pei</a> <a href="http://ufonews.in/images/supporting_images/pics/bugcosa.html">adult shar pei</a> [link=http://ufonews.in/images/supporting_images/pics/bugcosa.html]adult shar pei[/link]

November 15, 2008, at 07:36 AM by oregon station weather -- http://furmanka.com/list/attachments/files/page394.html
Changed line 1 from:

oklahoma betting [URL=http://furmanka.com/list/attachments/files/page292.html]oklahoma betting[/URL] [url=http://furmanka.com/list/attachments/files/page292.html]oklahoma betting[/url] [url]http://furmanka.com/list/attachments/files/page292.html[/url]

to:

oregon station weather [URL=http://furmanka.com/list/attachments/files/page394.html]oregon station weather[/URL] [url=http://furmanka.com/list/attachments/files/page394.html]oregon station weather[/url] [url]http://furmanka.com/list/attachments/files/page394.html[/url]

November 15, 2008, at 07:36 AM by oklahoma betting -- http://furmanka.com/list/attachments/files/page292.html
Changed line 1 from:

psp 2.0 firmware cracked [URL=http://fatbastards.nl/assets_c/2008/05/351.html]psp 2.0 firmware cracked[/URL] [url=http://fatbastards.nl/assets_c/2008/05/351.html]psp 2.0 firmware cracked[/url] [url]http://fatbastards.nl/assets_c/2008/05/351.html[/url]

to:

oklahoma betting [URL=http://furmanka.com/list/attachments/files/page292.html]oklahoma betting[/URL] [url=http://furmanka.com/list/attachments/files/page292.html]oklahoma betting[/url] [url]http://furmanka.com/list/attachments/files/page292.html[/url]

November 15, 2008, at 07:35 AM by psp 20 firmware cracked -- http://fatbastards.nl/assets_c/2008/05/351.html
Changed line 1 from:

movie godfather [URL=http://realestatesvarna.com/user_upload/413/comment-42.html]movie godfather[/URL] [url=http://realestatesvarna.com/user_upload/413/comment-42.html]movie godfather[/url] [url]http://realestatesvarna.com/user_upload/413/comment-42.html[/url]

to:

psp 2.0 firmware cracked [URL=http://fatbastards.nl/assets_c/2008/05/351.html]psp 2.0 firmware cracked[/URL] [url=http://fatbastards.nl/assets_c/2008/05/351.html]psp 2.0 firmware cracked[/url] [url]http://fatbastards.nl/assets_c/2008/05/351.html[/url]

November 15, 2008, at 07:35 AM by movie godfather -- http://realestatesvarna.com/user_upload/413/comment-42.html
Changed line 1 from:

pittsburg kansas movie theatre [URL=http://jong-liften.nl/staging/uploads/media/inpasd.htm]pittsburg kansas movie theatre[/URL] [url=http://jong-liften.nl/staging/uploads/media/inpasd.htm]pittsburg kansas movie theatre[/url] [url]http://jong-liften.nl/staging/uploads/media/inpasd.htm[/url]

to:

movie godfather [URL=http://realestatesvarna.com/user_upload/413/comment-42.html]movie godfather[/URL] [url=http://realestatesvarna.com/user_upload/413/comment-42.html]movie godfather[/url] [url]http://realestatesvarna.com/user_upload/413/comment-42.html[/url]

November 14, 2008, at 01:25 PM by pittsburg kansas movie theatre -- http://jong-liften.nl/staging/uploads/media/inpasd.htm
Changed line 1 from:

<a href='http://ufonews.in/images/supporting_images/pics/varzar.html'>candi evans</a> <a href="http://ufonews.in/images/supporting_images/pics/varzar.html">candi evans</a> [link=http://ufonews.in/images/supporting_images/pics/varzar.html]candi evans[/link]

to:

pittsburg kansas movie theatre [URL=http://jong-liften.nl/staging/uploads/media/inpasd.htm]pittsburg kansas movie theatre[/URL] [url=http://jong-liften.nl/staging/uploads/media/inpasd.htm]pittsburg kansas movie theatre[/url] [url]http://jong-liften.nl/staging/uploads/media/inpasd.htm[/url]

November 14, 2008, at 01:25 PM by candi evans -- http://ufonews.in/images/supporting_images/pics/varzar.html
Changed line 1 from:

<a href='http://fatbastards.nl/assets_c/2008/05/1670.html'>jake simpson oprah</a> <a href="http://fatbastards.nl/assets_c/2008/05/1670.html">jake simpson oprah</a> [link=http://fatbastards.nl/assets_c/2008/05/1670.html]jake simpson oprah[/link]

to:

<a href='http://ufonews.in/images/supporting_images/pics/varzar.html'>candi evans</a> <a href="http://ufonews.in/images/supporting_images/pics/varzar.html">candi evans</a> [link=http://ufonews.in/images/supporting_images/pics/varzar.html]candi evans[/link]

November 14, 2008, at 01:22 PM by jake simpson oprah -- http://fatbastards.nl/assets_c/2008/05/1670.html
Changed line 1 from:

<a href='http://firmite.net/obiavi_images/thumbs/eltrdomme.html'>quote on drug addict</a> <a href="http://firmite.net/obiavi_images/thumbs/eltrdomme.html">quote on drug addict</a> [link=http://firmite.net/obiavi_images/thumbs/eltrdomme.html]quote on drug addict[/link]

to:

<a href='http://fatbastards.nl/assets_c/2008/05/1670.html'>jake simpson oprah</a> <a href="http://fatbastards.nl/assets_c/2008/05/1670.html">jake simpson oprah</a> [link=http://fatbastards.nl/assets_c/2008/05/1670.html]jake simpson oprah[/link]

November 14, 2008, at 01:22 PM by quote on drug addict -- http://firmite.net/obiavi_images/thumbs/eltrdomme.html
Changed line 1 from:

<a href='http://ottercreekloghomes.com/styles/css/181.html'>roman costumes</a> <a href="http://ottercreekloghomes.com/styles/css/181.html">roman costumes</a> [link=http://ottercreekloghomes.com/styles/css/181.html]roman costumes[/link]

to:

<a href='http://firmite.net/obiavi_images/thumbs/eltrdomme.html'>quote on drug addict</a> <a href="http://firmite.net/obiavi_images/thumbs/eltrdomme.html">quote on drug addict</a> [link=http://firmite.net/obiavi_images/thumbs/eltrdomme.html]quote on drug addict[/link]

November 14, 2008, at 01:21 PM by roman costumes -- http://ottercreekloghomes.com/styles/css/181.html
Changed line 1 from:

<a href='http://ufonews.in/images/supporting_images/pics/nolasedf.html'>ebony free lesbian movie sex</a> <a href="http://ufonews.in/images/supporting_images/pics/nolasedf.html">ebony free lesbian movie sex</a> [link=http://ufonews.in/images/supporting_images/pics/nolasedf.html]ebony free lesbian movie sex[/link]

to:

<a href='http://ottercreekloghomes.com/styles/css/181.html'>roman costumes</a> <a href="http://ottercreekloghomes.com/styles/css/181.html">roman costumes</a> [link=http://ottercreekloghomes.com/styles/css/181.html]roman costumes[/link]

November 13, 2008, at 11:50 PM by ebony free lesbian movie sex -- http://ufonews.in/images/supporting_images/pics/nolasedf.html
Changed line 1 from:

real fight club video [URL=http://realestatesvarna.com/user_upload/413/comment-1018.html]real fight club video[/URL] [url=http://realestatesvarna.com/user_upload/413/comment-1018.html]real fight club video[/url] [url]http://realestatesvarna.com/user_upload/413/comment-1018.html[/url]

to:

<a href='http://ufonews.in/images/supporting_images/pics/nolasedf.html'>ebony free lesbian movie sex</a> <a href="http://ufonews.in/images/supporting_images/pics/nolasedf.html">ebony free lesbian movie sex</a> [link=http://ufonews.in/images/supporting_images/pics/nolasedf.html]ebony free lesbian movie sex[/link]

November 13, 2008, at 11:50 PM by real fight club video -- http://realestatesvarna.com/user_upload/413/comment-1018.html
Changed line 1 from:

<a href='http://talibov.info/osc/images/pixels/text-1256.htm'>love naruto sakura sasuke story video</a> <a href="http://talibov.info/osc/images/pixels/text-1256.htm">love naruto sakura sasuke story video</a> [link=http://talibov.info/osc/images/pixels/text-1256.htm]love naruto sakura sasuke story video[/link]

to:

real fight club video [URL=http://realestatesvarna.com/user_upload/413/comment-1018.html]real fight club video[/URL] [url=http://realestatesvarna.com/user_upload/413/comment-1018.html]real fight club video[/url] [url]http://realestatesvarna.com/user_upload/413/comment-1018.html[/url]

November 13, 2008, at 11:50 PM by love naruto sakura sasuke story video -- http://talibov.info/osc/images/pixels/text-1256.htm
Changed line 1 from:

cum swapers [URL=http://topkickerpoker.com/dev/resources/templates_c/img/text-1686.htm]cum swapers[/URL] [url=http://topkickerpoker.com/dev/resources/templates_c/img/text-1686.htm]cum swapers[/url] [url]http://topkickerpoker.com/dev/resources/templates_c/img/text-1686.htm[/url]

to:

<a href='http://talibov.info/osc/images/pixels/text-1256.htm'>love naruto sakura sasuke story video</a> <a href="http://talibov.info/osc/images/pixels/text-1256.htm">love naruto sakura sasuke story video</a> [link=http://talibov.info/osc/images/pixels/text-1256.htm]love naruto sakura sasuke story video[/link]

November 13, 2008, at 11:49 PM by cum swapers -- http://topkickerpoker.com/dev/resources/templates_c/img/text-1686.htm
Changed line 1 from:

<a href='http://wma-bg.com/files/gallery/thumbs/pic/sitemap.html'>http</a> <a href="http://wma-bg.com/files/gallery/thumbs/pic/sitemap.html">index</a> [link=http://wma-bg.com/files/gallery/thumbs/pic/sitemap.html]top[/link]

to:

cum swapers [URL=http://topkickerpoker.com/dev/resources/templates_c/img/text-1686.htm]cum swapers[/URL] [url=http://topkickerpoker.com/dev/resources/templates_c/img/text-1686.htm]cum swapers[/url] [url]http://topkickerpoker.com/dev/resources/templates_c/img/text-1686.htm[/url]

November 13, 2008, at 11:49 PM by index -- http://wma-bg.com/files/gallery/thumbs/pic/sitemap.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://wma-bg.com/files/gallery/thumbs/pic/sitemap.html'>http</a> <a href="http://wma-bg.com/files/gallery/thumbs/pic/sitemap.html">index</a> [link=http://wma-bg.com/files/gallery/thumbs/pic/sitemap.html]top[/link]

November 13, 2008, at 11:30 AM by Daniel -- Restoring after spamming
Changed lines 1-419 from:

<a href='http://stoneyardbar.com/tester/files/news-231.html'>link creativecommons.org license nc sa 1.0 fi</a> <a href="http://stoneyardbar.com/tester/files/news-231.html">link creativecommons.org license nc sa 1.0 fi</a> [link=http://stoneyardbar.com/tester/files/news-231.html]link creativecommons.org license nc sa 1.0 fi[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 13, 2008, at 08:09 AM by link creativecommonsorg license nc sa 10 fi -- http://stoneyardbar.com/tester/files/news-231.html
Changed line 1 from:

screen saver [URL=http://hdclima.com/objects2/thumbs/text903.htm]screen saver[/URL] [url=http://hdclima.com/objects2/thumbs/text903.htm]screen saver[/url] [url]http://hdclima.com/objects2/thumbs/text903.htm[/url]

to:

<a href='http://stoneyardbar.com/tester/files/news-231.html'>link creativecommons.org license nc sa 1.0 fi</a> <a href="http://stoneyardbar.com/tester/files/news-231.html">link creativecommons.org license nc sa 1.0 fi</a> [link=http://stoneyardbar.com/tester/files/news-231.html]link creativecommons.org license nc sa 1.0 fi[/link]

November 13, 2008, at 08:08 AM by screen saver -- http://hdclima.com/objects2/thumbs/text903.htm
Changed line 1 from:

adipex by paypal [URL=http://emreguler.com/defter/wp-content/uploads/2007/comment-1773.htm]adipex by paypal[/URL] [url=http://emreguler.com/defter/wp-content/uploads/2007/comment-1773.htm]adipex by paypal[/url] [url]http://emreguler.com/defter/wp-content/uploads/2007/comment-1773.htm[/url]

to:

screen saver [URL=http://hdclima.com/objects2/thumbs/text903.htm]screen saver[/URL] [url=http://hdclima.com/objects2/thumbs/text903.htm]screen saver[/url] [url]http://hdclima.com/objects2/thumbs/text903.htm[/url]

November 13, 2008, at 08:08 AM by adipex by paypal -- http://emreguler.com/defter/wp-content/uploads/2007/comment-1773.htm
Changed line 1 from:

alvin cartoon chipmunk home video [URL=http://emreguler.com/defter/wp-content/uploads/2007/comment-778.htm]alvin cartoon chipmunk home video[/URL] [url=http://emreguler.com/defter/wp-content/uploads/2007/comment-778.htm]alvin cartoon chipmunk home video[/url] [url]http://emreguler.com/defter/wp-content/uploads/2007/comment-778.htm[/url]

to:

adipex by paypal [URL=http://emreguler.com/defter/wp-content/uploads/2007/comment-1773.htm]adipex by paypal[/URL] [url=http://emreguler.com/defter/wp-content/uploads/2007/comment-1773.htm]adipex by paypal[/url] [url]http://emreguler.com/defter/wp-content/uploads/2007/comment-1773.htm[/url]

November 13, 2008, at 08:08 AM by alvin cartoon chipmunk home video -- http://emreguler.com/defter/wp-content/uploads/2007/comment-778.htm
Changed line 1 from:

new napster crack [URL=http://paparaka.com/mikromaxbg/1/big/comment-660.html]new napster crack[/URL] [url=http://paparaka.com/mikromaxbg/1/big/comment-660.html]new napster crack[/url] [url]http://paparaka.com/mikromaxbg/1/big/comment-660.html[/url]

to:

alvin cartoon chipmunk home video [URL=http://emreguler.com/defter/wp-content/uploads/2007/comment-778.htm]alvin cartoon chipmunk home video[/URL] [url=http://emreguler.com/defter/wp-content/uploads/2007/comment-778.htm]alvin cartoon chipmunk home video[/url] [url]http://emreguler.com/defter/wp-content/uploads/2007/comment-778.htm[/url]

November 13, 2008, at 08:07 AM by new napster crack -- http://paparaka.com/mikromaxbg/1/big/comment-660.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

new napster crack [URL=http://paparaka.com/mikromaxbg/1/big/comment-660.html]new napster crack[/URL] [url=http://paparaka.com/mikromaxbg/1/big/comment-660.html]new napster crack[/url] [url]http://paparaka.com/mikromaxbg/1/big/comment-660.html[/url]

November 12, 2008, at 09:48 PM by astx813 -- Undoing spam
Changed lines 1-419 from:

<a href='http://powermag.gr/mediagallery/backups/dump/resource-2403.html'>replenex drug</a> <a href="http://powermag.gr/mediagallery/backups/dump/resource-2403.html">replenex drug</a> [link=http://powermag.gr/mediagallery/backups/dump/resource-2403.html]replenex drug[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 12, 2008, at 11:41 AM by replenex drug -- http://powermag.gr/mediagallery/backups/dump/resource-2403.html
Changed line 1 from:

movie software download [URL=http://theiporeporter.com/archive_tmp/media/article1241.htm]movie software download[/URL] [url=http://theiporeporter.com/archive_tmp/media/article1241.htm]movie software download[/url] [url]http://theiporeporter.com/archive_tmp/media/article1241.htm[/url]

to:

<a href='http://powermag.gr/mediagallery/backups/dump/resource-2403.html'>replenex drug</a> <a href="http://powermag.gr/mediagallery/backups/dump/resource-2403.html">replenex drug</a> [link=http://powermag.gr/mediagallery/backups/dump/resource-2403.html]replenex drug[/link]

November 12, 2008, at 11:41 AM by movie software download -- http://theiporeporter.com/archive_tmp/media/article1241.htm
Changed line 1 from:

english to italian dictionary translation [URL=http://hotel-fjord.com/.components.nick/com_fish/topic2077.htm]english to italian dictionary translation[/URL] [url=http://hotel-fjord.com/.components.nick/com_fish/topic2077.htm]english to italian dictionary translation[/url] [url]http://hotel-fjord.com/.components.nick/com_fish/topic2077.htm[/url]

to:

movie software download [URL=http://theiporeporter.com/archive_tmp/media/article1241.htm]movie software download[/URL] [url=http://theiporeporter.com/archive_tmp/media/article1241.htm]movie software download[/url] [url]http://theiporeporter.com/archive_tmp/media/article1241.htm[/url]

November 12, 2008, at 11:41 AM by english to italian dictionary translation -- http://hotel-fjord.com/.components.nick/com_fish/topic2077.htm
Changed line 1 from:

excema treatment [URL=http://hotel-fjord.com/.components.nick/com_fish/topic950.htm]excema treatment[/URL] [url=http://hotel-fjord.com/.components.nick/com_fish/topic950.htm]excema treatment[/url] [url]http://hotel-fjord.com/.components.nick/com_fish/topic950.htm[/url]

to:

english to italian dictionary translation [URL=http://hotel-fjord.com/.components.nick/com_fish/topic2077.htm]english to italian dictionary translation[/URL] [url=http://hotel-fjord.com/.components.nick/com_fish/topic2077.htm]english to italian dictionary translation[/url] [url]http://hotel-fjord.com/.components.nick/com_fish/topic2077.htm[/url]

November 12, 2008, at 11:40 AM by excema treatment -- http://hotel-fjord.com/.components.nick/com_fish/topic950.htm
Changed line 1 from:

refurbished precor treadmills [URL=http://ontas.com.tr/img/thumbs/article1833.html]refurbished precor treadmills[/URL] [url=http://ontas.com.tr/img/thumbs/article1833.html]refurbished precor treadmills[/url] [url]http://ontas.com.tr/img/thumbs/article1833.html[/url]

to:

excema treatment [URL=http://hotel-fjord.com/.components.nick/com_fish/topic950.htm]excema treatment[/URL] [url=http://hotel-fjord.com/.components.nick/com_fish/topic950.htm]excema treatment[/url] [url]http://hotel-fjord.com/.components.nick/com_fish/topic950.htm[/url]

November 12, 2008, at 11:39 AM by refurbished precor treadmills -- http://ontas.com.tr/img/thumbs/article1833.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

refurbished precor treadmills [URL=http://ontas.com.tr/img/thumbs/article1833.html]refurbished precor treadmills[/URL] [url=http://ontas.com.tr/img/thumbs/article1833.html]refurbished precor treadmills[/url] [url]http://ontas.com.tr/img/thumbs/article1833.html[/url]

November 12, 2008, at 12:00 AM by slugmanbashi -- Spam is getting out of control. Admins, help, please?. Can something be done ?
Changed lines 1-419 from:

<a href='http://realestatebg.org/banners/img/news-960-2008-09-15.html'>parts for power tools</a> <a href="http://realestatebg.org/banners/img/news-960-2008-09-15.html">parts for power tools</a> [link=http://realestatebg.org/banners/img/news-960-2008-09-15.html]parts for power tools[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 11, 2008, at 06:06 PM by parts for power tools -- http://realestatebg.org/banners/img/news-960-2008-09-15.html
Changed line 1 from:

site [URL=http://athina2002.com/nexgennet/language/En/sitemap.htm]index[/URL] [url=http://athina2002.com/nexgennet/language/En/sitemap.htm]url[/url] [url]http://athina2002.com/nexgennet/language/En/sitemap.htm[/url]

to:

<a href='http://realestatebg.org/banners/img/news-960-2008-09-15.html'>parts for power tools</a> <a href="http://realestatebg.org/banners/img/news-960-2008-09-15.html">parts for power tools</a> [link=http://realestatebg.org/banners/img/news-960-2008-09-15.html]parts for power tools[/link]

November 11, 2008, at 06:05 PM by site -- http://athina2002.com/nexgennet/language/En/sitemap.htm
Changed line 1 from:

sexual stimulant for women [URL=http://psycomfort.com/forms/logfile/cache/news-461.html]sexual stimulant for women[/URL] [url=http://psycomfort.com/forms/logfile/cache/news-461.html]sexual stimulant for women[/url] [url]http://psycomfort.com/forms/logfile/cache/news-461.html[/url]

to:

site [URL=http://athina2002.com/nexgennet/language/En/sitemap.htm]index[/URL] [url=http://athina2002.com/nexgennet/language/En/sitemap.htm]url[/url] [url]http://athina2002.com/nexgennet/language/En/sitemap.htm[/url]

November 11, 2008, at 06:05 PM by sexual stimulant for women -- http://psycomfort.com/forms/logfile/cache/news-461.html
Changed line 1 from:

<a href='http://ozcelik.com.tr/images/_notes/pic/cabasv-1894.html'>joseph inga, crystal sky</a> <a href="http://ozcelik.com.tr/images/_notes/pic/cabasv-1894.html">joseph inga, crystal sky</a> [link=http://ozcelik.com.tr/images/_notes/pic/cabasv-1894.html]joseph inga, crystal sky[/link]

to:

sexual stimulant for women [URL=http://psycomfort.com/forms/logfile/cache/news-461.html]sexual stimulant for women[/URL] [url=http://psycomfort.com/forms/logfile/cache/news-461.html]sexual stimulant for women[/url] [url]http://psycomfort.com/forms/logfile/cache/news-461.html[/url]

November 11, 2008, at 06:04 PM by joseph inga crystal sky -- http://ozcelik.com.tr/images/_notes/pic/cabasv-1894.html
Changed line 1 from:

nj state licensed real estate course instructor [URL=http://scriptx.info/paste/old/storage/temp/article-1353.htm]nj state licensed real estate course instructor[/URL] [url=http://scriptx.info/paste/old/storage/temp/article-1353.htm]nj state licensed real estate course instructor[/url] [url]http://scriptx.info/paste/old/storage/temp/article-1353.htm[/url]

to:

<a href='http://ozcelik.com.tr/images/_notes/pic/cabasv-1894.html'>joseph inga, crystal sky</a> <a href="http://ozcelik.com.tr/images/_notes/pic/cabasv-1894.html">joseph inga, crystal sky</a> [link=http://ozcelik.com.tr/images/_notes/pic/cabasv-1894.html]joseph inga, crystal sky[/link]

November 11, 2008, at 06:04 PM by nj state licensed real estate course instructor -- http://scriptx.info/paste/old/storage/temp/article-1353.htm
Changed line 1 from:

designer [URL=http://xp2p.org/soban/thespot/new/icons/resource577.htm]designer[/URL] [url=http://xp2p.org/soban/thespot/new/icons/resource577.htm]designer[/url] [url]http://xp2p.org/soban/thespot/new/icons/resource577.htm[/url]

to:

nj state licensed real estate course instructor [URL=http://scriptx.info/paste/old/storage/temp/article-1353.htm]nj state licensed real estate course instructor[/URL] [url=http://scriptx.info/paste/old/storage/temp/article-1353.htm]nj state licensed real estate course instructor[/url] [url]http://scriptx.info/paste/old/storage/temp/article-1353.htm[/url]

November 10, 2008, at 09:14 AM by designer -- http://xp2p.org/soban/thespot/new/icons/resource577.htm
Changed line 1 from:

<a href='http://stucs.net/images/StucsPhotos/thumbs/news-199-20080924.html'>okinawa training video</a> <a href="http://stucs.net/images/StucsPhotos/thumbs/news-199-20080924.html">okinawa training video</a> [link=http://stucs.net/images/StucsPhotos/thumbs/news-199-20080924.html]okinawa training video[/link]

to:

designer [URL=http://xp2p.org/soban/thespot/new/icons/resource577.htm]designer[/URL] [url=http://xp2p.org/soban/thespot/new/icons/resource577.htm]designer[/url] [url]http://xp2p.org/soban/thespot/new/icons/resource577.htm[/url]

November 10, 2008, at 09:14 AM by okinawa training video -- http://stucs.net/images/StucsPhotos/thumbs/news-199-20080924.html
Changed line 1 from:

<a href='http://powerbikes.gr/main/videogallery/photos/9/195.html'>cheats for heli attack 3</a> <a href="http://powerbikes.gr/main/videogallery/photos/9/195.html">cheats for heli attack 3</a> [link=http://powerbikes.gr/main/videogallery/photos/9/195.html]cheats for heli attack 3[/link]

to:

<a href='http://stucs.net/images/StucsPhotos/thumbs/news-199-20080924.html'>okinawa training video</a> <a href="http://stucs.net/images/StucsPhotos/thumbs/news-199-20080924.html">okinawa training video</a> [link=http://stucs.net/images/StucsPhotos/thumbs/news-199-20080924.html]okinawa training video[/link]

November 09, 2008, at 10:22 AM by cheats for heli attack 3 -- http://powerbikes.gr/main/videogallery/photos/9/195.html
Changed line 1 from:

<a href='http://pcappleton.com/documents/docs/sitemap.html'>http</a> <a href="http://pcappleton.com/documents/docs/sitemap.html">top</a> [link=http://pcappleton.com/documents/docs/sitemap.html]url[/link]

to:

<a href='http://powerbikes.gr/main/videogallery/photos/9/195.html'>cheats for heli attack 3</a> <a href="http://powerbikes.gr/main/videogallery/photos/9/195.html">cheats for heli attack 3</a> [link=http://powerbikes.gr/main/videogallery/photos/9/195.html]cheats for heli attack 3[/link]

November 09, 2008, at 10:22 AM by webmap -- http://pcappleton.com/documents/docs/sitemap.html
Changed line 1 from:

adalt friend finder [URL=http://imogladiola.ro/flash/files/firoou.htm]adalt friend finder[/URL] [url=http://imogladiola.ro/flash/files/firoou.htm]adalt friend finder[/url] [url]http://imogladiola.ro/flash/files/firoou.htm[/url]

to:

<a href='http://pcappleton.com/documents/docs/sitemap.html'>http</a> <a href="http://pcappleton.com/documents/docs/sitemap.html">top</a> [link=http://pcappleton.com/documents/docs/sitemap.html]url[/link]

November 09, 2008, at 10:22 AM by adalt friend finder -- http://imogladiola.ro/flash/files/firoou.htm
Changed line 1 from:

showtunes ringtones [URL=http://imogladiola.ro/flash/files/lamonplnr.htm]showtunes ringtones[/URL] [url=http://imogladiola.ro/flash/files/lamonplnr.htm]showtunes ringtones[/url] [url]http://imogladiola.ro/flash/files/lamonplnr.htm[/url]

to:

adalt friend finder [URL=http://imogladiola.ro/flash/files/firoou.htm]adalt friend finder[/URL] [url=http://imogladiola.ro/flash/files/firoou.htm]adalt friend finder[/url] [url]http://imogladiola.ro/flash/files/firoou.htm[/url]

November 09, 2008, at 10:22 AM by showtunes ringtones -- http://imogladiola.ro/flash/files/lamonplnr.htm
Changed line 1 from:

hip roof [URL=http://hotel-fjord.com/.components.nick/com_fish/topic1382.htm]hip roof[/URL] [url=http://hotel-fjord.com/.components.nick/com_fish/topic1382.htm]hip roof[/url] [url]http://hotel-fjord.com/.components.nick/com_fish/topic1382.htm[/url]

to:

showtunes ringtones [URL=http://imogladiola.ro/flash/files/lamonplnr.htm]showtunes ringtones[/URL] [url=http://imogladiola.ro/flash/files/lamonplnr.htm]showtunes ringtones[/url] [url]http://imogladiola.ro/flash/files/lamonplnr.htm[/url]

November 09, 2008, at 10:21 AM by hip roof -- http://hotel-fjord.com/.components.nick/com_fish/topic1382.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

hip roof [URL=http://hotel-fjord.com/.components.nick/com_fish/topic1382.htm]hip roof[/URL] [url=http://hotel-fjord.com/.components.nick/com_fish/topic1382.htm]hip roof[/url] [url]http://hotel-fjord.com/.components.nick/com_fish/topic1382.htm[/url]

November 08, 2008, at 10:27 PM by geoscouter -- de spam
Changed lines 1-419 from:

archive thumb video [URL=http://ontas.com.tr/img/thumbs/article1004.html]archive thumb video[/URL] [url=http://ontas.com.tr/img/thumbs/article1004.html]archive thumb video[/url] [url]http://ontas.com.tr/img/thumbs/article1004.html[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 08, 2008, at 09:44 PM by archive thumb video -- http://ontas.com.tr/img/thumbs/article1004.html
Changed line 1 from:

<a href='http://knifebg.com/blog/uploaded_images/photos/2464.htm'>empire earth cracked</a> <a href="http://knifebg.com/blog/uploaded_images/photos/2464.htm">empire earth cracked</a> [link=http://knifebg.com/blog/uploaded_images/photos/2464.htm]empire earth cracked[/link]

to:

archive thumb video [URL=http://ontas.com.tr/img/thumbs/article1004.html]archive thumb video[/URL] [url=http://ontas.com.tr/img/thumbs/article1004.html]archive thumb video[/url] [url]http://ontas.com.tr/img/thumbs/article1004.html[/url]

November 08, 2008, at 09:44 PM by empire earth cracked -- http://knifebg.com/blog/uploaded_images/photos/2464.htm
Changed line 1 from:

<a href='http://realestatebg.org/banners/img/news-393-2008-09-23.html'>gunbroker</a> <a href="http://realestatebg.org/banners/img/news-393-2008-09-23.html">gunbroker</a> [link=http://realestatebg.org/banners/img/news-393-2008-09-23.html]gunbroker[/link]

to:

<a href='http://knifebg.com/blog/uploaded_images/photos/2464.htm'>empire earth cracked</a> <a href="http://knifebg.com/blog/uploaded_images/photos/2464.htm">empire earth cracked</a> [link=http://knifebg.com/blog/uploaded_images/photos/2464.htm]empire earth cracked[/link]

November 08, 2008, at 09:43 PM by gunbroker -- http://realestatebg.org/banners/img/news-393-2008-09-23.html
Changed line 1 from:

boxing equipment houston [URL=http://scriptx.info/paste/old/storage/temp/article-569.htm]boxing equipment houston[/URL] [url=http://scriptx.info/paste/old/storage/temp/article-569.htm]boxing equipment houston[/url] [url]http://scriptx.info/paste/old/storage/temp/article-569.htm[/url]

to:

<a href='http://realestatebg.org/banners/img/news-393-2008-09-23.html'>gunbroker</a> <a href="http://realestatebg.org/banners/img/news-393-2008-09-23.html">gunbroker</a> [link=http://realestatebg.org/banners/img/news-393-2008-09-23.html]gunbroker[/link]

November 08, 2008, at 09:42 PM by boxing equipment houston -- http://scriptx.info/paste/old/storage/temp/article-569.htm
Changed line 1 from:

<a href='http://xp2p.org/soban/thespot/new/icons/resource392.htm'>vanessa angel nude</a> <a href="http://xp2p.org/soban/thespot/new/icons/resource392.htm">vanessa angel nude</a> [link=http://xp2p.org/soban/thespot/new/icons/resource392.htm]vanessa angel nude[/link]

to:

boxing equipment houston [URL=http://scriptx.info/paste/old/storage/temp/article-569.htm]boxing equipment houston[/URL] [url=http://scriptx.info/paste/old/storage/temp/article-569.htm]boxing equipment houston[/url] [url]http://scriptx.info/paste/old/storage/temp/article-569.htm[/url]

November 08, 2008, at 09:42 PM by vanessa angel nude -- http://xp2p.org/soban/thespot/new/icons/resource392.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://xp2p.org/soban/thespot/new/icons/resource392.htm'>vanessa angel nude</a> <a href="http://xp2p.org/soban/thespot/new/icons/resource392.htm">vanessa angel nude</a> [link=http://xp2p.org/soban/thespot/new/icons/resource392.htm]vanessa angel nude[/link]

November 08, 2008, at 12:44 PM by geoscouter -- remove spam
Changed lines 1-419 from:

<a href='http://ontas.com.tr/img/thumbs/article1252.html'>average blood pressure by age</a> <a href="http://ontas.com.tr/img/thumbs/article1252.html">average blood pressure by age</a> [link=http://ontas.com.tr/img/thumbs/article1252.html]average blood pressure by age[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 08, 2008, at 06:33 AM by average blood pressure by age -- http://ontas.com.tr/img/thumbs/article1252.html
Changed line 1 from:

susquehanna mall movies [URL=http://applause-applause.com/RRR/pages/images/text751.htm]susquehanna mall movies[/URL] [url=http://applause-applause.com/RRR/pages/images/text751.htm]susquehanna mall movies[/url] [url]http://applause-applause.com/RRR/pages/images/text751.htm[/url]

to:

<a href='http://ontas.com.tr/img/thumbs/article1252.html'>average blood pressure by age</a> <a href="http://ontas.com.tr/img/thumbs/article1252.html">average blood pressure by age</a> [link=http://ontas.com.tr/img/thumbs/article1252.html]average blood pressure by age[/link]

November 08, 2008, at 06:33 AM by susquehanna mall movies -- http://applause-applause.com/RRR/pages/images/text751.htm
Changed line 1 from:

http [URL=http://decomat.org/games/tempswf/flash/sitemap.htm]link[/URL] [url=http://decomat.org/games/tempswf/flash/sitemap.htm]links[/url] [url]http://decomat.org/games/tempswf/flash/sitemap.htm[/url]

to:

susquehanna mall movies [URL=http://applause-applause.com/RRR/pages/images/text751.htm]susquehanna mall movies[/URL] [url=http://applause-applause.com/RRR/pages/images/text751.htm]susquehanna mall movies[/url] [url]http://applause-applause.com/RRR/pages/images/text751.htm[/url]

November 08, 2008, at 06:33 AM by links -- http://decomat.org/games/tempswf/flash/sitemap.htm
Changed line 1 from:

<a href='http://knifebg.com/blog/uploaded_images/photos/286.htm'>what is vestibular dysfunction</a> <a href="http://knifebg.com/blog/uploaded_images/photos/286.htm">what is vestibular dysfunction</a> [link=http://knifebg.com/blog/uploaded_images/photos/286.htm]what is vestibular dysfunction[/link]

to:

http [URL=http://decomat.org/games/tempswf/flash/sitemap.htm]link[/URL] [url=http://decomat.org/games/tempswf/flash/sitemap.htm]links[/url] [url]http://decomat.org/games/tempswf/flash/sitemap.htm[/url]

November 08, 2008, at 06:33 AM by what is vestibular dysfunction -- http://knifebg.com/blog/uploaded_images/photos/286.htm
Changed line 1 from:

<a href='http://fwwebdevelopment.com/wordpress/wp-content/themes/img/topic-408.html'>pc video player</a> <a href="http://fwwebdevelopment.com/wordpress/wp-content/themes/img/topic-408.html">pc video player</a> [link=http://fwwebdevelopment.com/wordpress/wp-content/themes/img/topic-408.html]pc video player[/link]

to:

<a href='http://knifebg.com/blog/uploaded_images/photos/286.htm'>what is vestibular dysfunction</a> <a href="http://knifebg.com/blog/uploaded_images/photos/286.htm">what is vestibular dysfunction</a> [link=http://knifebg.com/blog/uploaded_images/photos/286.htm]what is vestibular dysfunction[/link]

November 08, 2008, at 06:33 AM by pc video player -- http://fwwebdevelopment.com/wordpress/wp-content/themes/img/topic-408.html
Changed line 1 from:

know making music things video when [URL=http://scriptx.info/paste/old/storage/temp/article-489.htm]know making music things video when[/URL] [url=http://scriptx.info/paste/old/storage/temp/article-489.htm]know making music things video when[/url] [url]http://scriptx.info/paste/old/storage/temp/article-489.htm[/url]

to:

<a href='http://fwwebdevelopment.com/wordpress/wp-content/themes/img/topic-408.html'>pc video player</a> <a href="http://fwwebdevelopment.com/wordpress/wp-content/themes/img/topic-408.html">pc video player</a> [link=http://fwwebdevelopment.com/wordpress/wp-content/themes/img/topic-408.html]pc video player[/link]

November 07, 2008, at 06:53 PM by know making music things video when -- http://scriptx.info/paste/old/storage/temp/article-489.htm
Changed line 1 from:

<a href='http://homeopathyfor.us/images/pics/thumbs/text181.htm'>kid playground safety video</a> <a href="http://homeopathyfor.us/images/pics/thumbs/text181.htm">kid playground safety video</a> [link=http://homeopathyfor.us/images/pics/thumbs/text181.htm]kid playground safety video[/link]

to:

know making music things video when [URL=http://scriptx.info/paste/old/storage/temp/article-489.htm]know making music things video when[/URL] [url=http://scriptx.info/paste/old/storage/temp/article-489.htm]know making music things video when[/url] [url]http://scriptx.info/paste/old/storage/temp/article-489.htm[/url]

November 07, 2008, at 06:53 PM by kid playground safety video -- http://homeopathyfor.us/images/pics/thumbs/text181.htm
Changed line 1 from:

tow cars [URL=http://reckdesign.com/gallery/albums/7-2007/376.html]tow cars[/URL] [url=http://reckdesign.com/gallery/albums/7-2007/376.html]tow cars[/url] [url]http://reckdesign.com/gallery/albums/7-2007/376.html[/url]

to:

<a href='http://homeopathyfor.us/images/pics/thumbs/text181.htm'>kid playground safety video</a> <a href="http://homeopathyfor.us/images/pics/thumbs/text181.htm">kid playground safety video</a> [link=http://homeopathyfor.us/images/pics/thumbs/text181.htm]kid playground safety video[/link]

November 07, 2008, at 06:52 PM by tow cars -- http://reckdesign.com/gallery/albums/7-2007/376.html
Changed line 1 from:

<a href='http://ontas.com.tr/img/thumbs/sitemap.html'>top</a> <a href="http://ontas.com.tr/img/thumbs/sitemap.html">webmap</a> [link=http://ontas.com.tr/img/thumbs/sitemap.html]index[/link]

to:

tow cars [URL=http://reckdesign.com/gallery/albums/7-2007/376.html]tow cars[/URL] [url=http://reckdesign.com/gallery/albums/7-2007/376.html]tow cars[/url] [url]http://reckdesign.com/gallery/albums/7-2007/376.html[/url]

November 07, 2008, at 06:52 PM by index -- http://ontas.com.tr/img/thumbs/sitemap.html
Changed line 1 from:

index [URL=http://ontas.com.tr/img/thumbs/index.html]page[/URL] [url=http://ontas.com.tr/img/thumbs/index.html]site[/url] [url]http://ontas.com.tr/img/thumbs/index.html[/url]

to:

<a href='http://ontas.com.tr/img/thumbs/sitemap.html'>top</a> <a href="http://ontas.com.tr/img/thumbs/sitemap.html">webmap</a> [link=http://ontas.com.tr/img/thumbs/sitemap.html]index[/link]

November 07, 2008, at 06:51 PM by domain -- http://ontas.com.tr/img/thumbs/index.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

index [URL=http://ontas.com.tr/img/thumbs/index.html]page[/URL] [url=http://ontas.com.tr/img/thumbs/index.html]site[/url] [url]http://ontas.com.tr/img/thumbs/index.html[/url]

November 07, 2008, at 09:01 AM by pembo -- removed spam
Changed lines 1-419 from:

lanview crack [URL=http://cheapbgproperty.org/files/tn/thumbs/news-599-20080913.html]lanview crack[/URL] [url=http://cheapbgproperty.org/files/tn/thumbs/news-599-20080913.html]lanview crack[/url] [url]http://cheapbgproperty.org/files/tn/thumbs/news-599-20080913.html[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 07, 2008, at 05:10 AM by lanview crack -- http://cheapbgproperty.org/files/tn/thumbs/news-599-20080913.html
Changed line 1 from:

<a href='http://kiekaboe.nl/nabestellen/pics/small/comment-1322.html'>real estate exam license nc school</a> <a href="http://kiekaboe.nl/nabestellen/pics/small/comment-1322.html">real estate exam license nc school</a> [link=http://kiekaboe.nl/nabestellen/pics/small/comment-1322.html]real estate exam license nc school[/link]

to:

lanview crack [URL=http://cheapbgproperty.org/files/tn/thumbs/news-599-20080913.html]lanview crack[/URL] [url=http://cheapbgproperty.org/files/tn/thumbs/news-599-20080913.html]lanview crack[/url] [url]http://cheapbgproperty.org/files/tn/thumbs/news-599-20080913.html[/url]

November 07, 2008, at 05:10 AM by real estate exam license nc school -- http://kiekaboe.nl/nabestellen/pics/small/comment-1322.html
Changed line 1 from:

racketeering [URL=http://martenica.net/img/old_martenici/icons/comment476.htm]racketeering[/URL] [url=http://martenica.net/img/old_martenici/icons/comment476.htm]racketeering[/url] [url]http://martenica.net/img/old_martenici/icons/comment476.htm[/url]

to:

<a href='http://kiekaboe.nl/nabestellen/pics/small/comment-1322.html'>real estate exam license nc school</a> <a href="http://kiekaboe.nl/nabestellen/pics/small/comment-1322.html">real estate exam license nc school</a> [link=http://kiekaboe.nl/nabestellen/pics/small/comment-1322.html]real estate exam license nc school[/link]

November 07, 2008, at 05:10 AM by racketeering -- http://martenica.net/img/old_martenici/icons/comment476.htm
Changed line 1 from:

<a href='http://hauntingbreaks.co.uk/affiliate/images/pics/racsar-2352.html'>pima justice</a> <a href="http://hauntingbreaks.co.uk/affiliate/images/pics/racsar-2352.html">pima justice</a> [link=http://hauntingbreaks.co.uk/affiliate/images/pics/racsar-2352.html]pima justice[/link]

to:

racketeering [URL=http://martenica.net/img/old_martenici/icons/comment476.htm]racketeering[/URL] [url=http://martenica.net/img/old_martenici/icons/comment476.htm]racketeering[/url] [url]http://martenica.net/img/old_martenici/icons/comment476.htm[/url]

November 07, 2008, at 05:10 AM by pima justice -- http://hauntingbreaks.co.uk/affiliate/images/pics/racsar-2352.html
Changed line 1 from:

illinois malpractice attorneys [URL=http://nwebi.net/n/public_html/media/images/resource-2205.html]illinois malpractice attorneys[/URL] [url=http://nwebi.net/n/public_html/media/images/resource-2205.html]illinois malpractice attorneys[/url] [url]http://nwebi.net/n/public_html/media/images/resource-2205.html[/url]

to:

<a href='http://hauntingbreaks.co.uk/affiliate/images/pics/racsar-2352.html'>pima justice</a> <a href="http://hauntingbreaks.co.uk/affiliate/images/pics/racsar-2352.html">pima justice</a> [link=http://hauntingbreaks.co.uk/affiliate/images/pics/racsar-2352.html]pima justice[/link]

November 07, 2008, at 05:09 AM by illinois malpractice attorneys -- http://nwebi.net/n/public_html/media/images/resource-2205.html
Changed line 1 from:

<a href='http://nwebi.net/n/public_html/media/images/resource-2910.html'>efficiency fuel kid video</a> <a href="http://nwebi.net/n/public_html/media/images/resource-2910.html">efficiency fuel kid video</a> [link=http://nwebi.net/n/public_html/media/images/resource-2910.html]efficiency fuel kid video[/link]

to:

illinois malpractice attorneys [URL=http://nwebi.net/n/public_html/media/images/resource-2205.html]illinois malpractice attorneys[/URL] [url=http://nwebi.net/n/public_html/media/images/resource-2205.html]illinois malpractice attorneys[/url] [url]http://nwebi.net/n/public_html/media/images/resource-2205.html[/url]

November 06, 2008, at 06:38 PM by efficiency fuel kid video -- http://nwebi.net/n/public_html/media/images/resource-2910.html
Changed line 1 from:

<a href='http://unicert.com.tr/UserFiles/Image/icons/relouzca-1168.html'>cute chick ringtone</a> <a href="http://unicert.com.tr/UserFiles/Image/icons/relouzca-1168.html">cute chick ringtone</a> [link=http://unicert.com.tr/UserFiles/Image/icons/relouzca-1168.html]cute chick ringtone[/link]

to:

<a href='http://nwebi.net/n/public_html/media/images/resource-2910.html'>efficiency fuel kid video</a> <a href="http://nwebi.net/n/public_html/media/images/resource-2910.html">efficiency fuel kid video</a> [link=http://nwebi.net/n/public_html/media/images/resource-2910.html]efficiency fuel kid video[/link]

November 06, 2008, at 06:38 PM by cute chick ringtone -- http://unicert.com.tr/UserFiles/Image/icons/relouzca-1168.html
Changed line 1 from:

link [URL=http://libragroup.org/gb/templates/image/sitemap.html]webmap[/URL] [url=http://libragroup.org/gb/templates/image/sitemap.html]index[/url] [url]http://libragroup.org/gb/templates/image/sitemap.html[/url]

to:

<a href='http://unicert.com.tr/UserFiles/Image/icons/relouzca-1168.html'>cute chick ringtone</a> <a href="http://unicert.com.tr/UserFiles/Image/icons/relouzca-1168.html">cute chick ringtone</a> [link=http://unicert.com.tr/UserFiles/Image/icons/relouzca-1168.html]cute chick ringtone[/link]

November 06, 2008, at 06:38 PM by link -- http://libragroup.org/gb/templates/image/sitemap.html
Changed line 1 from:

link [URL=http://lombardo-mebelsbg.com/e107_themes/reline/icons/sitemap.htm]url[/URL] [url=http://lombardo-mebelsbg.com/e107_themes/reline/icons/sitemap.htm]map[/url] [url]http://lombardo-mebelsbg.com/e107_themes/reline/icons/sitemap.htm[/url]

to:

link [URL=http://libragroup.org/gb/templates/image/sitemap.html]webmap[/URL] [url=http://libragroup.org/gb/templates/image/sitemap.html]index[/url] [url]http://libragroup.org/gb/templates/image/sitemap.html[/url]

November 06, 2008, at 06:37 PM by domain -- http://lombardo-mebelsbg.com/e107_themes/reline/icons/sitemap.htm
Changed line 1 from:

<a href='http://hauntingbreaks.co.uk/affiliate/images/pics/elnogetde-634.html'>la audio video western</a> <a href="http://hauntingbreaks.co.uk/affiliate/images/pics/elnogetde-634.html">la audio video western</a> [link=http://hauntingbreaks.co.uk/affiliate/images/pics/elnogetde-634.html]la audio video western[/link]

to:

link [URL=http://lombardo-mebelsbg.com/e107_themes/reline/icons/sitemap.htm]url[/URL] [url=http://lombardo-mebelsbg.com/e107_themes/reline/icons/sitemap.htm]map[/url] [url]http://lombardo-mebelsbg.com/e107_themes/reline/icons/sitemap.htm[/url]

November 06, 2008, at 06:37 PM by la audio video western -- http://hauntingbreaks.co.uk/affiliate/images/pics/elnogetde-634.html
Changed line 1 from:

top [URL=http://africawebaustralia.com.au/img_upload/img/icons/sitemap.html]index[/URL] [url=http://africawebaustralia.com.au/img_upload/img/icons/sitemap.html]page[/url] [url]http://africawebaustralia.com.au/img_upload/img/icons/sitemap.html[/url]

to:

<a href='http://hauntingbreaks.co.uk/affiliate/images/pics/elnogetde-634.html'>la audio video western</a> <a href="http://hauntingbreaks.co.uk/affiliate/images/pics/elnogetde-634.html">la audio video western</a> [link=http://hauntingbreaks.co.uk/affiliate/images/pics/elnogetde-634.html]la audio video western[/link]

November 06, 2008, at 07:28 AM by index -- http://africawebaustralia.com.au/img_upload/img/icons/sitemap.html
Changed line 1 from:

real estate license exam online [URL=http://myesk.ws/phpBB3/store/ini/article215.html]real estate license exam online[/URL] [url=http://myesk.ws/phpBB3/store/ini/article215.html]real estate license exam online[/url] [url]http://myesk.ws/phpBB3/store/ini/article215.html[/url]

to:

top [URL=http://africawebaustralia.com.au/img_upload/img/icons/sitemap.html]index[/URL] [url=http://africawebaustralia.com.au/img_upload/img/icons/sitemap.html]page[/url] [url]http://africawebaustralia.com.au/img_upload/img/icons/sitemap.html[/url]

November 06, 2008, at 07:28 AM by real estate license exam online -- http://myesk.ws/phpBB3/store/ini/article215.html
Changed line 1 from:

<a href='http://balletcaraibes.org/buyclasses/data_files/images/text-1202.htm'>smooth criminal video michael jackson</a> <a href="http://balletcaraibes.org/buyclasses/data_files/images/text-1202.htm">smooth criminal video michael jackson</a> [link=http://balletcaraibes.org/buyclasses/data_files/images/text-1202.htm]smooth criminal video michael jackson[/link]

to:

real estate license exam online [URL=http://myesk.ws/phpBB3/store/ini/article215.html]real estate license exam online[/URL] [url=http://myesk.ws/phpBB3/store/ini/article215.html]real estate license exam online[/url] [url]http://myesk.ws/phpBB3/store/ini/article215.html[/url]

November 06, 2008, at 07:27 AM by smooth criminal video michael jackson -- http://balletcaraibes.org/buyclasses/data_files/images/text-1202.htm
Changed line 1 from:

<a href='http://theatrelinks.com/wp-content/backup-028b4/dump/article2405.html'>kalinka ringtone</a> <a href="http://theatrelinks.com/wp-content/backup-028b4/dump/article2405.html">kalinka ringtone</a> [link=http://theatrelinks.com/wp-content/backup-028b4/dump/article2405.html]kalinka ringtone[/link]

to:

<a href='http://balletcaraibes.org/buyclasses/data_files/images/text-1202.htm'>smooth criminal video michael jackson</a> <a href="http://balletcaraibes.org/buyclasses/data_files/images/text-1202.htm">smooth criminal video michael jackson</a> [link=http://balletcaraibes.org/buyclasses/data_files/images/text-1202.htm]smooth criminal video michael jackson[/link]

November 06, 2008, at 07:27 AM by kalinka ringtone -- http://theatrelinks.com/wp-content/backup-028b4/dump/article2405.html
Changed line 1 from:

turn on [URL=http://myesk.ws/phpBB3/store/ini/article1009.html]turn on[/URL] [url=http://myesk.ws/phpBB3/store/ini/article1009.html]turn on[/url] [url]http://myesk.ws/phpBB3/store/ini/article1009.html[/url]

to:

<a href='http://theatrelinks.com/wp-content/backup-028b4/dump/article2405.html'>kalinka ringtone</a> <a href="http://theatrelinks.com/wp-content/backup-028b4/dump/article2405.html">kalinka ringtone</a> [link=http://theatrelinks.com/wp-content/backup-028b4/dump/article2405.html]kalinka ringtone[/link]

November 06, 2008, at 07:27 AM by turn on -- http://myesk.ws/phpBB3/store/ini/article1009.html
Changed line 1 from:

kultur tourismus [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new935.htm]kultur tourismus[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new935.htm]kultur tourismus[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new935.htm[/url]

to:

turn on [URL=http://myesk.ws/phpBB3/store/ini/article1009.html]turn on[/URL] [url=http://myesk.ws/phpBB3/store/ini/article1009.html]turn on[/url] [url]http://myesk.ws/phpBB3/store/ini/article1009.html[/url]

November 05, 2008, at 09:58 PM by kultur tourismus -- http://valterperlini.com/0_MaNaGeR/backups/dump/new935.htm
Changed line 1 from:

<a href='http://labetullasport.it/file/viaggi/img/topic621.htm'>sears store locator</a> <a href="http://labetullasport.it/file/viaggi/img/topic621.htm">sears store locator</a> [link=http://labetullasport.it/file/viaggi/img/topic621.htm]sears store locator[/link]

to:

kultur tourismus [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new935.htm]kultur tourismus[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new935.htm]kultur tourismus[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new935.htm[/url]

November 05, 2008, at 09:58 PM by sears store locator -- http://labetullasport.it/file/viaggi/img/topic621.htm
Changed line 1 from:

<a href='http://liberty-health.net/new_page1.htm/public/files/sitemap.html'>domain</a> <a href="http://liberty-health.net/new_page1.htm/public/files/sitemap.html">link</a> [link=http://liberty-health.net/new_page1.htm/public/files/sitemap.html]url[/link]

to:

<a href='http://labetullasport.it/file/viaggi/img/topic621.htm'>sears store locator</a> <a href="http://labetullasport.it/file/viaggi/img/topic621.htm">sears store locator</a> [link=http://labetullasport.it/file/viaggi/img/topic621.htm]sears store locator[/link]

November 05, 2008, at 09:58 PM by map -- http://liberty-health.net/new_page1.htm/public/files/sitemap.html
Changed line 1 from:

<a href='http://liberty-health.net/new_page1.htm/public/files/news-565-20080910.html'>gay daddy</a> <a href="http://liberty-health.net/new_page1.htm/public/files/news-565-20080910.html">gay daddy</a> [link=http://liberty-health.net/new_page1.htm/public/files/news-565-20080910.html]gay daddy[/link]

to:

<a href='http://liberty-health.net/new_page1.htm/public/files/sitemap.html'>domain</a> <a href="http://liberty-health.net/new_page1.htm/public/files/sitemap.html">link</a> [link=http://liberty-health.net/new_page1.htm/public/files/sitemap.html]url[/link]

November 05, 2008, at 09:58 PM by gay daddy -- http://liberty-health.net/new_page1.htm/public/files/news-565-20080910.html
Changed line 1 from:

contact center analytics [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new1456.htm]contact center analytics[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new1456.htm]contact center analytics[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new1456.htm[/url]

to:

<a href='http://liberty-health.net/new_page1.htm/public/files/news-565-20080910.html'>gay daddy</a> <a href="http://liberty-health.net/new_page1.htm/public/files/news-565-20080910.html">gay daddy</a> [link=http://liberty-health.net/new_page1.htm/public/files/news-565-20080910.html]gay daddy[/link]

November 05, 2008, at 09:58 PM by contact center analytics -- http://valterperlini.com/0_MaNaGeR/backups/dump/new1456.htm
Changed line 1 from:

map [URL=http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html]page[/URL] [url=http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html]url[/url] [url]http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html[/url]

to:

contact center analytics [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new1456.htm]contact center analytics[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new1456.htm]contact center analytics[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new1456.htm[/url]

November 05, 2008, at 01:24 PM by http -- http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html
Changed line 1 from:

anneberg foundation [URL=http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1447.htm]anneberg foundation[/URL] [url=http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1447.htm]anneberg foundation[/url] [url]http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1447.htm[/url]

to:

map [URL=http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html]page[/URL] [url=http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html]url[/url] [url]http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html[/url]

November 05, 2008, at 01:24 PM by anneberg foundation -- http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1447.htm
Changed line 1 from:

american idle [URL=http://dreamers-online.com/cutecast/data/forum8/text559.htm]american idle[/URL] [url=http://dreamers-online.com/cutecast/data/forum8/text559.htm]american idle[/url] [url]http://dreamers-online.com/cutecast/data/forum8/text559.htm[/url]

to:

anneberg foundation [URL=http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1447.htm]anneberg foundation[/URL] [url=http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1447.htm]anneberg foundation[/url] [url]http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1447.htm[/url]

November 05, 2008, at 01:24 PM by american idle -- http://dreamers-online.com/cutecast/data/forum8/text559.htm
Changed line 1 from:

drunk porn [URL=http://sokeosb.org.tr/admin/images/icons/article2091.html]drunk porn[/URL] [url=http://sokeosb.org.tr/admin/images/icons/article2091.html]drunk porn[/url] [url]http://sokeosb.org.tr/admin/images/icons/article2091.html[/url]

to:

american idle [URL=http://dreamers-online.com/cutecast/data/forum8/text559.htm]american idle[/URL] [url=http://dreamers-online.com/cutecast/data/forum8/text559.htm]american idle[/url] [url]http://dreamers-online.com/cutecast/data/forum8/text559.htm[/url]

November 05, 2008, at 01:23 PM by drunk porn -- http://sokeosb.org.tr/admin/images/icons/article2091.html
Changed line 1 from:

very young asian lolitas [URL=http://copyproductions.com/aplugin/images/topic-2005.html]very young asian lolitas[/URL] [url=http://copyproductions.com/aplugin/images/topic-2005.html]very young asian lolitas[/url] [url]http://copyproductions.com/aplugin/images/topic-2005.html[/url]

to:

drunk porn [URL=http://sokeosb.org.tr/admin/images/icons/article2091.html]drunk porn[/URL] [url=http://sokeosb.org.tr/admin/images/icons/article2091.html]drunk porn[/url] [url]http://sokeosb.org.tr/admin/images/icons/article2091.html[/url]

November 05, 2008, at 01:23 PM by very young asian lolitas -- http://copyproductions.com/aplugin/images/topic-2005.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

very young asian lolitas [URL=http://copyproductions.com/aplugin/images/topic-2005.html]very young asian lolitas[/URL] [url=http://copyproductions.com/aplugin/images/topic-2005.html]very young asian lolitas[/url] [url]http://copyproductions.com/aplugin/images/topic-2005.html[/url]

November 05, 2008, at 01:02 PM by bjohv052 -- Undid spam
Changed lines 1-419 from:

snow plow equipment [URL=http://banooshop.ir/prodimg/pics/topic-400.htm]snow plow equipment[/URL] [url=http://banooshop.ir/prodimg/pics/topic-400.htm]snow plow equipment[/url] [url]http://banooshop.ir/prodimg/pics/topic-400.htm[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 05, 2008, at 04:02 AM by snow plow equipment -- http://banooshop.ir/prodimg/pics/topic-400.htm
Changed line 1 from:

anara gupta video clippings [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new1602.htm]anara gupta video clippings[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new1602.htm]anara gupta video clippings[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new1602.htm[/url]

to:

snow plow equipment [URL=http://banooshop.ir/prodimg/pics/topic-400.htm]snow plow equipment[/URL] [url=http://banooshop.ir/prodimg/pics/topic-400.htm]snow plow equipment[/url] [url]http://banooshop.ir/prodimg/pics/topic-400.htm[/url]

November 05, 2008, at 04:02 AM by anara gupta video clippings -- http://valterperlini.com/0_MaNaGeR/backups/dump/new1602.htm
Changed line 1 from:

simpsons intro video [URL=http://vbij.com/uploads/images/thumbs/article-2102.htm]simpsons intro video[/URL] [url=http://vbij.com/uploads/images/thumbs/article-2102.htm]simpsons intro video[/url] [url]http://vbij.com/uploads/images/thumbs/article-2102.htm[/url]

to:

anara gupta video clippings [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new1602.htm]anara gupta video clippings[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new1602.htm]anara gupta video clippings[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new1602.htm[/url]

November 05, 2008, at 04:02 AM by simpsons intro video -- http://vbij.com/uploads/images/thumbs/article-2102.htm
Changed line 1 from:

arizona golf peoria properties [URL=http://nwiptcruisers.com/gallery/albums/userpics/10002/page647.html]arizona golf peoria properties[/URL] [url=http://nwiptcruisers.com/gallery/albums/userpics/10002/page647.html]arizona golf peoria properties[/url] [url]http://nwiptcruisers.com/gallery/albums/userpics/10002/page647.html[/url]

to:

simpsons intro video [URL=http://vbij.com/uploads/images/thumbs/article-2102.htm]simpsons intro video[/URL] [url=http://vbij.com/uploads/images/thumbs/article-2102.htm]simpsons intro video[/url] [url]http://vbij.com/uploads/images/thumbs/article-2102.htm[/url]

November 05, 2008, at 04:02 AM by arizona golf peoria properties -- http://nwiptcruisers.com/gallery/albums/userpics/10002/page647.html
Changed line 1 from:

la bamba movie script [URL=http://africawebaustralia.com.au/img_upload/img/icons/news-587-2008-09-16.html]la bamba movie script[/URL] [url=http://africawebaustralia.com.au/img_upload/img/icons/news-587-2008-09-16.html]la bamba movie script[/url] [url]http://africawebaustralia.com.au/img_upload/img/icons/news-587-2008-09-16.html[/url]

to:

arizona golf peoria properties [URL=http://nwiptcruisers.com/gallery/albums/userpics/10002/page647.html]arizona golf peoria properties[/URL] [url=http://nwiptcruisers.com/gallery/albums/userpics/10002/page647.html]arizona golf peoria properties[/url] [url]http://nwiptcruisers.com/gallery/albums/userpics/10002/page647.html[/url]

November 05, 2008, at 04:02 AM by la bamba movie script -- http://africawebaustralia.com.au/img_upload/img/icons/news-587-2008-09-16.html
Changed line 1 from:

joanna lumley [URL=http://dreamers-online.com/cutecast/data/forum8/text804.htm]joanna lumley[/URL] [url=http://dreamers-online.com/cutecast/data/forum8/text804.htm]joanna lumley[/url] [url]http://dreamers-online.com/cutecast/data/forum8/text804.htm[/url]

to:

la bamba movie script [URL=http://africawebaustralia.com.au/img_upload/img/icons/news-587-2008-09-16.html]la bamba movie script[/URL] [url=http://africawebaustralia.com.au/img_upload/img/icons/news-587-2008-09-16.html]la bamba movie script[/url] [url]http://africawebaustralia.com.au/img_upload/img/icons/news-587-2008-09-16.html[/url]

November 04, 2008, at 07:23 PM by joanna lumley -- http://dreamers-online.com/cutecast/data/forum8/text804.htm
Changed line 1 from:

<a href='http://regnum.com.tr/images/original/thumbs/index.html'>map</a> <a href="http://regnum.com.tr/images/original/thumbs/index.html">domain</a> [link=http://regnum.com.tr/images/original/thumbs/index.html]site[/link]

to:

joanna lumley [URL=http://dreamers-online.com/cutecast/data/forum8/text804.htm]joanna lumley[/URL] [url=http://dreamers-online.com/cutecast/data/forum8/text804.htm]joanna lumley[/url] [url]http://dreamers-online.com/cutecast/data/forum8/text804.htm[/url]

November 04, 2008, at 07:23 PM by map -- http://regnum.com.tr/images/original/thumbs/index.html
Changed line 1 from:

<a href='http://balletcaraibes.org/buyclasses/data_files/images/text-266.htm'>nymphomaniac girls</a> <a href="http://balletcaraibes.org/buyclasses/data_files/images/text-266.htm">nymphomaniac girls</a> [link=http://balletcaraibes.org/buyclasses/data_files/images/text-266.htm]nymphomaniac girls[/link]

to:

<a href='http://regnum.com.tr/images/original/thumbs/index.html'>map</a> <a href="http://regnum.com.tr/images/original/thumbs/index.html">domain</a> [link=http://regnum.com.tr/images/original/thumbs/index.html]site[/link]

November 04, 2008, at 07:23 PM by nymphomaniac girls -- http://balletcaraibes.org/buyclasses/data_files/images/text-266.htm
Changed line 1 from:

ellipticals true [URL=http://banooshop.ir/prodimg/pics/topic-243.htm]ellipticals true[/URL] [url=http://banooshop.ir/prodimg/pics/topic-243.htm]ellipticals true[/url] [url]http://banooshop.ir/prodimg/pics/topic-243.htm[/url]

to:

<a href='http://balletcaraibes.org/buyclasses/data_files/images/text-266.htm'>nymphomaniac girls</a> <a href="http://balletcaraibes.org/buyclasses/data_files/images/text-266.htm">nymphomaniac girls</a> [link=http://balletcaraibes.org/buyclasses/data_files/images/text-266.htm]nymphomaniac girls[/link]

November 04, 2008, at 07:23 PM by ellipticals true -- http://banooshop.ir/prodimg/pics/topic-243.htm
Changed line 1 from:

link [URL=http://awakeningwest.com/forum/lang/En/index.htm]links[/URL] [url=http://awakeningwest.com/forum/lang/En/index.htm]top[/url] [url]http://awakeningwest.com/forum/lang/En/index.htm[/url]

to:

ellipticals true [URL=http://banooshop.ir/prodimg/pics/topic-243.htm]ellipticals true[/URL] [url=http://banooshop.ir/prodimg/pics/topic-243.htm]ellipticals true[/url] [url]http://banooshop.ir/prodimg/pics/topic-243.htm[/url]

November 04, 2008, at 07:23 PM by sitemap -- http://awakeningwest.com/forum/lang/En/index.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

link [URL=http://awakeningwest.com/forum/lang/En/index.htm]links[/URL] [url=http://awakeningwest.com/forum/lang/En/index.htm]top[/url] [url]http://awakeningwest.com/forum/lang/En/index.htm[/url]

November 04, 2008, at 10:43 AM by Sil53r Surf3r -- Restored original content; well, I think the wiki should be protected from open access.
Changed lines 1-419 from:

neuter [URL=http://giorgiafiorio.org/eng/galleries/rm/gcache/1967.html]neuter[/URL] [url=http://giorgiafiorio.org/eng/galleries/rm/gcache/1967.html]neuter[/url] [url]http://giorgiafiorio.org/eng/galleries/rm/gcache/1967.html[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 04, 2008, at 09:10 AM by neuter -- http://giorgiafiorio.org/eng/galleries/rm/gcache/1967.html
Changed line 1 from:

<a href='http://wesselmarquering.com/hedgefunds/media/images/article1704.html'>nursing care of infants with respiratory disease</a> <a href="http://wesselmarquering.com/hedgefunds/media/images/article1704.html">nursing care of infants with respiratory disease</a> [link=http://wesselmarquering.com/hedgefunds/media/images/article1704.html]nursing care of infants with respiratory disease[/link]

to:

neuter [URL=http://giorgiafiorio.org/eng/galleries/rm/gcache/1967.html]neuter[/URL] [url=http://giorgiafiorio.org/eng/galleries/rm/gcache/1967.html]neuter[/url] [url]http://giorgiafiorio.org/eng/galleries/rm/gcache/1967.html[/url]

November 04, 2008, at 09:10 AM by nursing care of infants with respiratory disease -- http://wesselmarquering.com/hedgefunds/media/images/article1704.html
Changed line 1 from:

<a href='http://catadoptionslasvegas.com/mlm/images/icons/text1501.htm'>newbury park real estate</a> <a href="http://catadoptionslasvegas.com/mlm/images/icons/text1501.htm">newbury park real estate</a> [link=http://catadoptionslasvegas.com/mlm/images/icons/text1501.htm]newbury park real estate[/link]

to:

<a href='http://wesselmarquering.com/hedgefunds/media/images/article1704.html'>nursing care of infants with respiratory disease</a> <a href="http://wesselmarquering.com/hedgefunds/media/images/article1704.html">nursing care of infants with respiratory disease</a> [link=http://wesselmarquering.com/hedgefunds/media/images/article1704.html]nursing care of infants with respiratory disease[/link]

November 04, 2008, at 09:10 AM by newbury park real estate -- http://catadoptionslasvegas.com/mlm/images/icons/text1501.htm
Changed line 1 from:

<a href='http://banooshop.ir/prodimg/pics/topic-1513.htm'>spring break movies free</a> <a href="http://banooshop.ir/prodimg/pics/topic-1513.htm">spring break movies free</a> [link=http://banooshop.ir/prodimg/pics/topic-1513.htm]spring break movies free[/link]

to:

<a href='http://catadoptionslasvegas.com/mlm/images/icons/text1501.htm'>newbury park real estate</a> <a href="http://catadoptionslasvegas.com/mlm/images/icons/text1501.htm">newbury park real estate</a> [link=http://catadoptionslasvegas.com/mlm/images/icons/text1501.htm]newbury park real estate[/link]

November 04, 2008, at 09:10 AM by spring break movies free -- http://banooshop.ir/prodimg/pics/topic-1513.htm
Changed line 1 from:

<a href='http://wesselmarquering.com/hedgefunds/media/images/article1963.html'>mr potato head</a> <a href="http://wesselmarquering.com/hedgefunds/media/images/article1963.html">mr potato head</a> [link=http://wesselmarquering.com/hedgefunds/media/images/article1963.html]mr potato head[/link]

to:

<a href='http://banooshop.ir/prodimg/pics/topic-1513.htm'>spring break movies free</a> <a href="http://banooshop.ir/prodimg/pics/topic-1513.htm">spring break movies free</a> [link=http://banooshop.ir/prodimg/pics/topic-1513.htm]spring break movies free[/link]

November 04, 2008, at 09:10 AM by mr potato head -- http://wesselmarquering.com/hedgefunds/media/images/article1963.html
Changed line 1 from:

miami lake movie theater [URL=http://banooshop.ir/prodimg/pics/topic-1402.htm]miami lake movie theater[/URL] [url=http://banooshop.ir/prodimg/pics/topic-1402.htm]miami lake movie theater[/url] [url]http://banooshop.ir/prodimg/pics/topic-1402.htm[/url]

to:

<a href='http://wesselmarquering.com/hedgefunds/media/images/article1963.html'>mr potato head</a> <a href="http://wesselmarquering.com/hedgefunds/media/images/article1963.html">mr potato head</a> [link=http://wesselmarquering.com/hedgefunds/media/images/article1963.html]mr potato head[/link]

November 03, 2008, at 11:08 PM by miami lake movie theater -- http://banooshop.ir/prodimg/pics/topic-1402.htm
Changed line 1 from:

sidhe [URL=http://giorgiafiorio.org/eng/galleries/rm/gcache/2107.html]sidhe[/URL] [url=http://giorgiafiorio.org/eng/galleries/rm/gcache/2107.html]sidhe[/url] [url]http://giorgiafiorio.org/eng/galleries/rm/gcache/2107.html[/url]

to:

miami lake movie theater [URL=http://banooshop.ir/prodimg/pics/topic-1402.htm]miami lake movie theater[/URL] [url=http://banooshop.ir/prodimg/pics/topic-1402.htm]miami lake movie theater[/url] [url]http://banooshop.ir/prodimg/pics/topic-1402.htm[/url]

November 03, 2008, at 11:08 PM by sidhe -- http://giorgiafiorio.org/eng/galleries/rm/gcache/2107.html
Changed line 1 from:

<a href='http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article221.htm'>mike russell photoshop</a> <a href="http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article221.htm">mike russell photoshop</a> [link=http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article221.htm]mike russell photoshop[/link]

to:

sidhe [URL=http://giorgiafiorio.org/eng/galleries/rm/gcache/2107.html]sidhe[/URL] [url=http://giorgiafiorio.org/eng/galleries/rm/gcache/2107.html]sidhe[/url] [url]http://giorgiafiorio.org/eng/galleries/rm/gcache/2107.html[/url]

November 03, 2008, at 11:08 PM by mike russell photoshop -- http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article221.htm
Changed line 1 from:

nokia 3330 ringtones [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new1689.htm]nokia 3330 ringtones[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new1689.htm]nokia 3330 ringtones[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new1689.htm[/url]

to:

<a href='http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article221.htm'>mike russell photoshop</a> <a href="http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article221.htm">mike russell photoshop</a> [link=http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article221.htm]mike russell photoshop[/link]

November 03, 2008, at 11:07 PM by nokia 3330 ringtones -- http://valterperlini.com/0_MaNaGeR/backups/dump/new1689.htm
Changed line 1 from:

nutcracker ballet story [URL=http://fair-credit-reporting.com/classifieds/pictures/cats/pic/news-59-2008-09-18.html]nutcracker ballet story[/URL] [url=http://fair-credit-reporting.com/classifieds/pictures/cats/pic/news-59-2008-09-18.html]nutcracker ballet story[/url] [url]http://fair-credit-reporting.com/classifieds/pictures/cats/pic/news-59-2008-09-18.html[/url]

to:

nokia 3330 ringtones [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new1689.htm]nokia 3330 ringtones[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new1689.htm]nokia 3330 ringtones[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new1689.htm[/url]

November 03, 2008, at 11:07 PM by nutcracker ballet story -- http://fair-credit-reporting.com/classifieds/pictures/cats/pic/news-59-2008-09-18.html
Changed line 1 from:

<a href='http://nwiptcruisers.com/gallery/albums/userpics/10002/page519.html'>visual sensations for women</a> <a href="http://nwiptcruisers.com/gallery/albums/userpics/10002/page519.html">visual sensations for women</a> [link=http://nwiptcruisers.com/gallery/albums/userpics/10002/page519.html]visual sensations for women[/link]

to:

nutcracker ballet story [URL=http://fair-credit-reporting.com/classifieds/pictures/cats/pic/news-59-2008-09-18.html]nutcracker ballet story[/URL] [url=http://fair-credit-reporting.com/classifieds/pictures/cats/pic/news-59-2008-09-18.html]nutcracker ballet story[/url] [url]http://fair-credit-reporting.com/classifieds/pictures/cats/pic/news-59-2008-09-18.html[/url]

November 03, 2008, at 02:06 PM by visual sensations for women -- http://nwiptcruisers.com/gallery/albums/userpics/10002/page519.html
Changed line 1 from:

<a href='http://myesk.ws/phpBB3/store/ini/article1313.html'>memorial florist houston</a> <a href="http://myesk.ws/phpBB3/store/ini/article1313.html">memorial florist houston</a> [link=http://myesk.ws/phpBB3/store/ini/article1313.html]memorial florist houston[/link]

to:

<a href='http://nwiptcruisers.com/gallery/albums/userpics/10002/page519.html'>visual sensations for women</a> <a href="http://nwiptcruisers.com/gallery/albums/userpics/10002/page519.html">visual sensations for women</a> [link=http://nwiptcruisers.com/gallery/albums/userpics/10002/page519.html]visual sensations for women[/link]

November 03, 2008, at 02:06 PM by memorial florist houston -- http://myesk.ws/phpBB3/store/ini/article1313.html
Changed line 1 from:

real estate license louisiana [URL=http://giorgiafiorio.org/eng/galleries/rm/gcache/1829.html]real estate license louisiana[/URL] [url=http://giorgiafiorio.org/eng/galleries/rm/gcache/1829.html]real estate license louisiana[/url] [url]http://giorgiafiorio.org/eng/galleries/rm/gcache/1829.html[/url]

to:

<a href='http://myesk.ws/phpBB3/store/ini/article1313.html'>memorial florist houston</a> <a href="http://myesk.ws/phpBB3/store/ini/article1313.html">memorial florist houston</a> [link=http://myesk.ws/phpBB3/store/ini/article1313.html]memorial florist houston[/link]

November 03, 2008, at 02:06 PM by real estate license louisiana -- http://giorgiafiorio.org/eng/galleries/rm/gcache/1829.html
Changed line 1 from:

xeriscape designs [URL=http://sokeosb.org.tr/admin/images/icons/article1355.html]xeriscape designs[/URL] [url=http://sokeosb.org.tr/admin/images/icons/article1355.html]xeriscape designs[/url] [url]http://sokeosb.org.tr/admin/images/icons/article1355.html[/url]

to:

real estate license louisiana [URL=http://giorgiafiorio.org/eng/galleries/rm/gcache/1829.html]real estate license louisiana[/URL] [url=http://giorgiafiorio.org/eng/galleries/rm/gcache/1829.html]real estate license louisiana[/url] [url]http://giorgiafiorio.org/eng/galleries/rm/gcache/1829.html[/url]

November 03, 2008, at 02:06 PM by xeriscape designs -- http://sokeosb.org.tr/admin/images/icons/article1355.html
Changed line 1 from:

piantball gear [URL=http://schuurman.org/tripsim/components/com_inc/news-509.html]piantball gear[/URL] [url=http://schuurman.org/tripsim/components/com_inc/news-509.html]piantball gear[/url] [url]http://schuurman.org/tripsim/components/com_inc/news-509.html[/url]

to:

xeriscape designs [URL=http://sokeosb.org.tr/admin/images/icons/article1355.html]xeriscape designs[/URL] [url=http://sokeosb.org.tr/admin/images/icons/article1355.html]xeriscape designs[/url] [url]http://sokeosb.org.tr/admin/images/icons/article1355.html[/url]

November 03, 2008, at 02:06 PM by piantball gear -- http://schuurman.org/tripsim/components/com_inc/news-509.html
Changed line 1 from:

<a href='http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-405.html'>airport car edinburgh hire uk</a> <a href="http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-405.html">airport car edinburgh hire uk</a> [link=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-405.html]airport car edinburgh hire uk[/link]

to:

piantball gear [URL=http://schuurman.org/tripsim/components/com_inc/news-509.html]piantball gear[/URL] [url=http://schuurman.org/tripsim/components/com_inc/news-509.html]piantball gear[/url] [url]http://schuurman.org/tripsim/components/com_inc/news-509.html[/url]

November 03, 2008, at 04:08 AM by airport car edinburgh hire uk -- http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-405.html
Changed line 1 from:

<a href='http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1291.htm'>rotate movie quicktime</a> <a href="http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1291.htm">rotate movie quicktime</a> [link=http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1291.htm]rotate movie quicktime[/link]

to:

<a href='http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-405.html'>airport car edinburgh hire uk</a> <a href="http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-405.html">airport car edinburgh hire uk</a> [link=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-405.html]airport car edinburgh hire uk[/link]

November 03, 2008, at 04:08 AM by rotate movie quicktime -- http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1291.htm
Changed line 1 from:

chantelle fontain [URL=http://nwiptcruisers.com/gallery/albums/userpics/10002/page849.html]chantelle fontain[/URL] [url=http://nwiptcruisers.com/gallery/albums/userpics/10002/page849.html]chantelle fontain[/url] [url]http://nwiptcruisers.com/gallery/albums/userpics/10002/page849.html[/url]

to:

<a href='http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1291.htm'>rotate movie quicktime</a> <a href="http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1291.htm">rotate movie quicktime</a> [link=http://algostudioinformatico.it/fantasiadifilieintrecci/cgi-bin/files/article1291.htm]rotate movie quicktime[/link]

November 03, 2008, at 04:08 AM by chantelle fontain -- http://nwiptcruisers.com/gallery/albums/userpics/10002/page849.html
Changed line 1 from:

<a href='http://sintjosephkerk.com/faq/kb_upload/media/topic-2011.htm'>safety dance music video</a> <a href="http://sintjosephkerk.com/faq/kb_upload/media/topic-2011.htm">safety dance music video</a> [link=http://sintjosephkerk.com/faq/kb_upload/media/topic-2011.htm]safety dance music video[/link]

to:

chantelle fontain [URL=http://nwiptcruisers.com/gallery/albums/userpics/10002/page849.html]chantelle fontain[/URL] [url=http://nwiptcruisers.com/gallery/albums/userpics/10002/page849.html]chantelle fontain[/url] [url]http://nwiptcruisers.com/gallery/albums/userpics/10002/page849.html[/url]

November 03, 2008, at 04:07 AM by safety dance music video -- http://sintjosephkerk.com/faq/kb_upload/media/topic-2011.htm
Changed line 1 from:

<a href='http://awakeningwest.com/forum/lang/En/c4tenboce1746.htm'>contract furniture parts</a> <a href="http://awakeningwest.com/forum/lang/En/c4tenboce1746.htm">contract furniture parts</a> [link=http://awakeningwest.com/forum/lang/En/c4tenboce1746.htm]contract furniture parts[/link]

to:

<a href='http://sintjosephkerk.com/faq/kb_upload/media/topic-2011.htm'>safety dance music video</a> <a href="http://sintjosephkerk.com/faq/kb_upload/media/topic-2011.htm">safety dance music video</a> [link=http://sintjosephkerk.com/faq/kb_upload/media/topic-2011.htm]safety dance music video[/link]

November 03, 2008, at 04:06 AM by contract furniture parts -- http://awakeningwest.com/forum/lang/En/c4tenboce1746.htm
Changed line 1 from:

extreme mountain biking video clips [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new889.htm]extreme mountain biking video clips[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new889.htm]extreme mountain biking video clips[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new889.htm[/url]

to:

<a href='http://awakeningwest.com/forum/lang/En/c4tenboce1746.htm'>contract furniture parts</a> <a href="http://awakeningwest.com/forum/lang/En/c4tenboce1746.htm">contract furniture parts</a> [link=http://awakeningwest.com/forum/lang/En/c4tenboce1746.htm]contract furniture parts[/link]

November 02, 2008, at 06:03 PM by extreme mountain biking video clips -- http://valterperlini.com/0_MaNaGeR/backups/dump/new889.htm
Changed line 1 from:

<a href='http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html'>links</a> <a href="http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html">domain</a> [link=http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html]http[/link]

to:

extreme mountain biking video clips [URL=http://valterperlini.com/0_MaNaGeR/backups/dump/new889.htm]extreme mountain biking video clips[/URL] [url=http://valterperlini.com/0_MaNaGeR/backups/dump/new889.htm]extreme mountain biking video clips[/url] [url]http://valterperlini.com/0_MaNaGeR/backups/dump/new889.htm[/url]

November 02, 2008, at 06:03 PM by domain -- http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html
Changed line 1 from:

i klaymation make movie myspace.com site [URL=http://sintjosephkerk.com/faq/kb_upload/media/topic-2590.htm]i klaymation make movie myspace.com site[/URL] [url=http://sintjosephkerk.com/faq/kb_upload/media/topic-2590.htm]i klaymation make movie myspace.com site[/url] [url]http://sintjosephkerk.com/faq/kb_upload/media/topic-2590.htm[/url]

to:

<a href='http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html'>links</a> <a href="http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html">domain</a> [link=http://mediawebsolutions.it/images/portfolio/TN/thumbs/index.html]http[/link]

November 02, 2008, at 06:03 PM by i klaymation make movie myspacecom site -- http://sintjosephkerk.com/faq/kb_upload/media/topic-2590.htm
Changed line 1 from:

ne.jp viagra yybbs yybbs.cgi [URL=http://sintjosephkerk.com/faq/kb_upload/media/topic-1452.htm]ne.jp viagra yybbs yybbs.cgi[/URL] [url=http://sintjosephkerk.com/faq/kb_upload/media/topic-1452.htm]ne.jp viagra yybbs yybbs.cgi[/url] [url]http://sintjosephkerk.com/faq/kb_upload/media/topic-1452.htm[/url]

to:

i klaymation make movie myspace.com site [URL=http://sintjosephkerk.com/faq/kb_upload/media/topic-2590.htm]i klaymation make movie myspace.com site[/URL] [url=http://sintjosephkerk.com/faq/kb_upload/media/topic-2590.htm]i klaymation make movie myspace.com site[/url] [url]http://sintjosephkerk.com/faq/kb_upload/media/topic-2590.htm[/url]

November 02, 2008, at 06:03 PM by nejp viagra yybbs yybbscgi -- http://sintjosephkerk.com/faq/kb_upload/media/topic-1452.htm
Changed line 1 from:

link [URL=http://sintjosephkerk.com/faq/kb_upload/media/sitemap.htm]site[/URL] [url=http://sintjosephkerk.com/faq/kb_upload/media/sitemap.htm]webmap[/url] [url]http://sintjosephkerk.com/faq/kb_upload/media/sitemap.htm[/url]

to:

ne.jp viagra yybbs yybbs.cgi [URL=http://sintjosephkerk.com/faq/kb_upload/media/topic-1452.htm]ne.jp viagra yybbs yybbs.cgi[/URL] [url=http://sintjosephkerk.com/faq/kb_upload/media/topic-1452.htm]ne.jp viagra yybbs yybbs.cgi[/url] [url]http://sintjosephkerk.com/faq/kb_upload/media/topic-1452.htm[/url]

November 02, 2008, at 06:03 PM by top -- http://sintjosephkerk.com/faq/kb_upload/media/sitemap.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

link [URL=http://sintjosephkerk.com/faq/kb_upload/media/sitemap.htm]site[/URL] [url=http://sintjosephkerk.com/faq/kb_upload/media/sitemap.htm]webmap[/url] [url]http://sintjosephkerk.com/faq/kb_upload/media/sitemap.htm[/url]

November 02, 2008, at 08:29 AM by t0ny -- Restored from spam
Changed lines 1-419 from:

<a href='http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-999.html'>navy blue shower curtain</a> <a href="http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-999.html">navy blue shower curtain</a> [link=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-999.html]navy blue shower curtain[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 01, 2008, at 07:46 PM by navy blue shower curtain -- http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-999.html
Changed line 1 from:

mystery novels [URL=http://sintjosephkerk.com/faq/kb_upload/media/topic-2041.htm]mystery novels[/URL] [url=http://sintjosephkerk.com/faq/kb_upload/media/topic-2041.htm]mystery novels[/url] [url]http://sintjosephkerk.com/faq/kb_upload/media/topic-2041.htm[/url]

to:

<a href='http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-999.html'>navy blue shower curtain</a> <a href="http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-999.html">navy blue shower curtain</a> [link=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-999.html]navy blue shower curtain[/link]

November 01, 2008, at 07:46 PM by mystery novels -- http://sintjosephkerk.com/faq/kb_upload/media/topic-2041.htm
Changed line 1 from:

yingyangtwins [URL=http://valleofantofestival.com/upload/tmp/old_files/article390.html]yingyangtwins[/URL] [url=http://valleofantofestival.com/upload/tmp/old_files/article390.html]yingyangtwins[/url] [url]http://valleofantofestival.com/upload/tmp/old_files/article390.html[/url]

to:

mystery novels [URL=http://sintjosephkerk.com/faq/kb_upload/media/topic-2041.htm]mystery novels[/URL] [url=http://sintjosephkerk.com/faq/kb_upload/media/topic-2041.htm]mystery novels[/url] [url]http://sintjosephkerk.com/faq/kb_upload/media/topic-2041.htm[/url]

November 01, 2008, at 07:46 PM by yingyangtwins -- http://valleofantofestival.com/upload/tmp/old_files/article390.html
Changed line 1 from:

monster truck crash videos [URL=http://catadoptionslasvegas.com/mlm/images/icons/text504.htm]monster truck crash videos[/URL] [url=http://catadoptionslasvegas.com/mlm/images/icons/text504.htm]monster truck crash videos[/url] [url]http://catadoptionslasvegas.com/mlm/images/icons/text504.htm[/url]

to:

yingyangtwins [URL=http://valleofantofestival.com/upload/tmp/old_files/article390.html]yingyangtwins[/URL] [url=http://valleofantofestival.com/upload/tmp/old_files/article390.html]yingyangtwins[/url] [url]http://valleofantofestival.com/upload/tmp/old_files/article390.html[/url]

November 01, 2008, at 07:46 PM by monster truck crash videos -- http://catadoptionslasvegas.com/mlm/images/icons/text504.htm
Changed line 1 from:

in the movie the gospel [URL=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1974.html]in the movie the gospel[/URL] [url=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1974.html]in the movie the gospel[/url] [url]http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1974.html[/url]

to:

monster truck crash videos [URL=http://catadoptionslasvegas.com/mlm/images/icons/text504.htm]monster truck crash videos[/URL] [url=http://catadoptionslasvegas.com/mlm/images/icons/text504.htm]monster truck crash videos[/url] [url]http://catadoptionslasvegas.com/mlm/images/icons/text504.htm[/url]

November 01, 2008, at 07:46 PM by in the movie the gospel -- http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1974.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

in the movie the gospel [URL=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1974.html]in the movie the gospel[/URL] [url=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1974.html]in the movie the gospel[/url] [url]http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1974.html[/url]

November 01, 2008, at 01:07 PM by slugmanbashi -- restored after spam attack. Can we install CAPTCHA on the wiki ?
Changed lines 1-419 from:

<a href='http://balletcaraibes.org/buyclasses/data_files/images/text-374.htm'>lock folder xp crack</a> <a href="http://balletcaraibes.org/buyclasses/data_files/images/text-374.htm">lock folder xp crack</a> [link=http://balletcaraibes.org/buyclasses/data_files/images/text-374.htm]lock folder xp crack[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
November 01, 2008, at 05:01 AM by lock folder xp crack -- http://balletcaraibes.org/buyclasses/data_files/images/text-374.htm
Changed line 1 from:

lil jon ice cube roll call video [URL=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1329.html]lil jon ice cube roll call video[/URL] [url=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1329.html]lil jon ice cube roll call video[/url] [url]http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1329.html[/url]

to:

<a href='http://balletcaraibes.org/buyclasses/data_files/images/text-374.htm'>lock folder xp crack</a> <a href="http://balletcaraibes.org/buyclasses/data_files/images/text-374.htm">lock folder xp crack</a> [link=http://balletcaraibes.org/buyclasses/data_files/images/text-374.htm]lock folder xp crack[/link]

November 01, 2008, at 05:01 AM by lil jon ice cube roll call video -- http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1329.html
Changed line 1 from:

<a href='http://liberty-health.net/new_page1.htm/public/files/news-1354-20080913.html'>broken ankle</a> <a href="http://liberty-health.net/new_page1.htm/public/files/news-1354-20080913.html">broken ankle</a> [link=http://liberty-health.net/new_page1.htm/public/files/news-1354-20080913.html]broken ankle[/link]

to:

lil jon ice cube roll call video [URL=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1329.html]lil jon ice cube roll call video[/URL] [url=http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1329.html]lil jon ice cube roll call video[/url] [url]http://nucleator.net/_OFFLINE/cms/wp-backup-db/dump/page-1329.html[/url]

November 01, 2008, at 05:01 AM by broken ankle -- http://liberty-health.net/new_page1.htm/public/files/news-1354-20080913.html
Changed line 1 from:

<a href='http://dreamers-online.com/cutecast/data/forum8/text857.htm'>energy speakers</a> <a href="http://dreamers-online.com/cutecast/data/forum8/text857.htm">energy speakers</a> [link=http://dreamers-online.com/cutecast/data/forum8/text857.htm]energy speakers[/link]

to:

<a href='http://liberty-health.net/new_page1.htm/public/files/news-1354-20080913.html'>broken ankle</a> <a href="http://liberty-health.net/new_page1.htm/public/files/news-1354-20080913.html">broken ankle</a> [link=http://liberty-health.net/new_page1.htm/public/files/news-1354-20080913.html]broken ankle[/link]

November 01, 2008, at 05:00 AM by energy speakers -- http://dreamers-online.com/cutecast/data/forum8/text857.htm
Changed line 1 from:

<a href='http://dreamers-online.com/cutecast/data/forum8/text2314.htm'>aileen wuornos video clips</a> <a href="http://dreamers-online.com/cutecast/data/forum8/text2314.htm">aileen wuornos video clips</a> [link=http://dreamers-online.com/cutecast/data/forum8/text2314.htm]aileen wuornos video clips[/link]

to:

<a href='http://dreamers-online.com/cutecast/data/forum8/text857.htm'>energy speakers</a> <a href="http://dreamers-online.com/cutecast/data/forum8/text857.htm">energy speakers</a> [link=http://dreamers-online.com/cutecast/data/forum8/text857.htm]energy speakers[/link]

November 01, 2008, at 04:59 AM by aileen wuornos video clips -- http://dreamers-online.com/cutecast/data/forum8/text2314.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://dreamers-online.com/cutecast/data/forum8/text2314.htm'>aileen wuornos video clips</a> <a href="http://dreamers-online.com/cutecast/data/forum8/text2314.htm">aileen wuornos video clips</a> [link=http://dreamers-online.com/cutecast/data/forum8/text2314.htm]aileen wuornos video clips[/link]

October 30, 2008, at 10:24 AM by Thomas Reitmayr -- Restored from wiki vandalism
Changed lines 1-419 from:

stamina-rx [URL=http://banooshop.ir/prodimg/pics/topic-921.htm]stamina-rx[/URL] [url=http://banooshop.ir/prodimg/pics/topic-921.htm]stamina-rx[/url] [url]http://banooshop.ir/prodimg/pics/topic-921.htm[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
October 28, 2008, at 08:52 PM by stamina-rx -- http://banooshop.ir/prodimg/pics/topic-921.htm
Changed line 1 from:

<a href='http://africawebaustralia.com.au/img_upload/img/icons/news-1896-2008-09-19.html'>the equinox resort spa</a> <a href="http://africawebaustralia.com.au/img_upload/img/icons/news-1896-2008-09-19.html">the equinox resort spa</a> [link=http://africawebaustralia.com.au/img_upload/img/icons/news-1896-2008-09-19.html]the equinox resort spa[/link]

to:

stamina-rx [URL=http://banooshop.ir/prodimg/pics/topic-921.htm]stamina-rx[/URL] [url=http://banooshop.ir/prodimg/pics/topic-921.htm]stamina-rx[/url] [url]http://banooshop.ir/prodimg/pics/topic-921.htm[/url]

October 28, 2008, at 08:52 PM by the equinox resort spa -- http://africawebaustralia.com.au/img_upload/img/icons/news-1896-2008-09-19.html
Changed line 1 from:

elite personnel [URL=http://mediawebsolutions.it/images/portfolio/TN/thumbs/page1407.html]elite personnel[/URL] [url=http://mediawebsolutions.it/images/portfolio/TN/thumbs/page1407.html]elite personnel[/url] [url]http://mediawebsolutions.it/images/portfolio/TN/thumbs/page1407.html[/url]

to:

<a href='http://africawebaustralia.com.au/img_upload/img/icons/news-1896-2008-09-19.html'>the equinox resort spa</a> <a href="http://africawebaustralia.com.au/img_upload/img/icons/news-1896-2008-09-19.html">the equinox resort spa</a> [link=http://africawebaustralia.com.au/img_upload/img/icons/news-1896-2008-09-19.html]the equinox resort spa[/link]

October 28, 2008, at 08:52 PM by elite personnel -- http://mediawebsolutions.it/images/portfolio/TN/thumbs/page1407.html
Changed line 1 from:

<a href='http://cislscuolaliguria.it/cutenews/emoticons/pics/hencacar.htm'>password videoz.com</a> <a href="http://cislscuolaliguria.it/cutenews/emoticons/pics/hencacar.htm">password videoz.com</a> [link=http://cislscuolaliguria.it/cutenews/emoticons/pics/hencacar.htm]password videoz.com[/link]

to:

elite personnel [URL=http://mediawebsolutions.it/images/portfolio/TN/thumbs/page1407.html]elite personnel[/URL] [url=http://mediawebsolutions.it/images/portfolio/TN/thumbs/page1407.html]elite personnel[/url] [url]http://mediawebsolutions.it/images/portfolio/TN/thumbs/page1407.html[/url]

October 28, 2008, at 08:52 PM by password videozcom -- http://cislscuolaliguria.it/cutenews/emoticons/pics/hencacar.htm
Changed line 1 from:

<a href='http://wesselmarquering.com/hedgefunds/media/images/article507.html'>serial port definition</a> <a href="http://wesselmarquering.com/hedgefunds/media/images/article507.html">serial port definition</a> [link=http://wesselmarquering.com/hedgefunds/media/images/article507.html]serial port definition[/link]

to:

<a href='http://cislscuolaliguria.it/cutenews/emoticons/pics/hencacar.htm'>password videoz.com</a> <a href="http://cislscuolaliguria.it/cutenews/emoticons/pics/hencacar.htm">password videoz.com</a> [link=http://cislscuolaliguria.it/cutenews/emoticons/pics/hencacar.htm]password videoz.com[/link]

October 28, 2008, at 08:52 PM by serial port definition -- http://wesselmarquering.com/hedgefunds/media/images/article507.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://wesselmarquering.com/hedgefunds/media/images/article507.html'>serial port definition</a> <a href="http://wesselmarquering.com/hedgefunds/media/images/article507.html">serial port definition</a> [link=http://wesselmarquering.com/hedgefunds/media/images/article507.html]serial port definition[/link]

October 28, 2008, at 01:23 PM by slugmanbashi -- restored after span attack. Can we install CAPTCHA on the wiki ?
Changed lines 1-419 from:

<a href='http://copyproductions.com/aplugin/images/topic-780.html'>lorazepam 1mg tablets</a> <a href="http://copyproductions.com/aplugin/images/topic-780.html">lorazepam 1mg tablets</a> [link=http://copyproductions.com/aplugin/images/topic-780.html]lorazepam 1mg tablets[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
October 27, 2008, at 07:29 PM by lorazepam 1mg tablets -- http://copyproductions.com/aplugin/images/topic-780.html
Changed line 1 from:

<a href='http://valterperlini.com/0_MaNaGeR/backups/dump/new1533.htm'>license plate fastener</a> <a href="http://valterperlini.com/0_MaNaGeR/backups/dump/new1533.htm">license plate fastener</a> [link=http://valterperlini.com/0_MaNaGeR/backups/dump/new1533.htm]license plate fastener[/link]

to:

<a href='http://copyproductions.com/aplugin/images/topic-780.html'>lorazepam 1mg tablets</a> <a href="http://copyproductions.com/aplugin/images/topic-780.html">lorazepam 1mg tablets</a> [link=http://copyproductions.com/aplugin/images/topic-780.html]lorazepam 1mg tablets[/link]

October 27, 2008, at 07:29 PM by license plate fastener -- http://valterperlini.com/0_MaNaGeR/backups/dump/new1533.htm
Changed line 1 from:

<a href='http://wesselmarquering.com/hedgefunds/media/images/article1305.html'>swap shop movies</a> <a href="http://wesselmarquering.com/hedgefunds/media/images/article1305.html">swap shop movies</a> [link=http://wesselmarquering.com/hedgefunds/media/images/article1305.html]swap shop movies[/link]

to:

<a href='http://valterperlini.com/0_MaNaGeR/backups/dump/new1533.htm'>license plate fastener</a> <a href="http://valterperlini.com/0_MaNaGeR/backups/dump/new1533.htm">license plate fastener</a> [link=http://valterperlini.com/0_MaNaGeR/backups/dump/new1533.htm]license plate fastener[/link]

October 27, 2008, at 07:28 PM by swap shop movies -- http://wesselmarquering.com/hedgefunds/media/images/article1305.html
Changed line 1 from:

<a href='http://copyproductions.com/aplugin/images/topic-737.html'>canadiantire.ca</a> <a href="http://copyproductions.com/aplugin/images/topic-737.html">canadiantire.ca</a> [link=http://copyproductions.com/aplugin/images/topic-737.html]canadiantire.ca[/link]

to:

<a href='http://wesselmarquering.com/hedgefunds/media/images/article1305.html'>swap shop movies</a> <a href="http://wesselmarquering.com/hedgefunds/media/images/article1305.html">swap shop movies</a> [link=http://wesselmarquering.com/hedgefunds/media/images/article1305.html]swap shop movies[/link]

October 27, 2008, at 07:28 PM by canadiantireca -- http://copyproductions.com/aplugin/images/topic-737.html
Changed line 1 from:

<a href='http://valleofantofestival.com/upload/tmp/old_files/index.html'>index</a> <a href="http://valleofantofestival.com/upload/tmp/old_files/index.html">links</a> [link=http://valleofantofestival.com/upload/tmp/old_files/index.html]http[/link]

to:

<a href='http://copyproductions.com/aplugin/images/topic-737.html'>canadiantire.ca</a> <a href="http://copyproductions.com/aplugin/images/topic-737.html">canadiantire.ca</a> [link=http://copyproductions.com/aplugin/images/topic-737.html]canadiantire.ca[/link]

October 27, 2008, at 07:28 PM by page -- http://valleofantofestival.com/upload/tmp/old_files/index.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://valleofantofestival.com/upload/tmp/old_files/index.html'>index</a> <a href="http://valleofantofestival.com/upload/tmp/old_files/index.html">links</a> [link=http://valleofantofestival.com/upload/tmp/old_files/index.html]http[/link]

October 25, 2008, at 07:49 AM by pembo -- restored from spam attack.
Changed lines 1-419 from:

<a href='http://ciudadbarrios.org/blog/wp-content/uploads/2006/article-98.htm'>incredimail xe premium crack</a> <a href="http://ciudadbarrios.org/blog/wp-content/uploads/2006/article-98.htm">incredimail xe premium crack</a> [link=http://ciudadbarrios.org/blog/wp-content/uploads/2006/article-98.htm]incredimail xe premium crack[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
October 25, 2008, at 12:54 AM by incredimail xe premium crack -- http://ciudadbarrios.org/blog/wp-content/uploads/2006/article-98.htm
Changed line 1 from:

<a href='http://simcomcity.com/mail/files/alfineen.html'>memphis belle movie</a> <a href="http://simcomcity.com/mail/files/alfineen.html">memphis belle movie</a> [link=http://simcomcity.com/mail/files/alfineen.html]memphis belle movie[/link]

to:

<a href='http://ciudadbarrios.org/blog/wp-content/uploads/2006/article-98.htm'>incredimail xe premium crack</a> <a href="http://ciudadbarrios.org/blog/wp-content/uploads/2006/article-98.htm">incredimail xe premium crack</a> [link=http://ciudadbarrios.org/blog/wp-content/uploads/2006/article-98.htm]incredimail xe premium crack[/link]

October 25, 2008, at 12:54 AM by memphis belle movie -- http://simcomcity.com/mail/files/alfineen.html
Changed line 1 from:

neck anatomy [URL=http://simcomcity.com/mail/files/qashen.html]neck anatomy[/URL] [url=http://simcomcity.com/mail/files/qashen.html]neck anatomy[/url] [url]http://simcomcity.com/mail/files/qashen.html[/url]

to:

<a href='http://simcomcity.com/mail/files/alfineen.html'>memphis belle movie</a> <a href="http://simcomcity.com/mail/files/alfineen.html">memphis belle movie</a> [link=http://simcomcity.com/mail/files/alfineen.html]memphis belle movie[/link]

October 25, 2008, at 12:53 AM by neck anatomy -- http://simcomcity.com/mail/files/qashen.html
Changed line 1 from:

mtv musicvideos.com [URL=http://simcomcity.com/mail/files/licbas.html]mtv musicvideos.com[/URL] [url=http://simcomcity.com/mail/files/licbas.html]mtv musicvideos.com[/url] [url]http://simcomcity.com/mail/files/licbas.html[/url]

to:

neck anatomy [URL=http://simcomcity.com/mail/files/qashen.html]neck anatomy[/URL] [url=http://simcomcity.com/mail/files/qashen.html]neck anatomy[/url] [url]http://simcomcity.com/mail/files/qashen.html[/url]

October 25, 2008, at 12:53 AM by mtv musicvideoscom -- http://simcomcity.com/mail/files/licbas.html
Changed line 1 from:

<a href='http://simcomcity.com/mail/files/sitmex.html'>information on metformin</a> <a href="http://simcomcity.com/mail/files/sitmex.html">information on metformin</a> [link=http://simcomcity.com/mail/files/sitmex.html]information on metformin[/link]

to:

mtv musicvideos.com [URL=http://simcomcity.com/mail/files/licbas.html]mtv musicvideos.com[/URL] [url=http://simcomcity.com/mail/files/licbas.html]mtv musicvideos.com[/url] [url]http://simcomcity.com/mail/files/licbas.html[/url]

October 25, 2008, at 12:53 AM by information on metformin -- http://simcomcity.com/mail/files/sitmex.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://simcomcity.com/mail/files/sitmex.html'>information on metformin</a> <a href="http://simcomcity.com/mail/files/sitmex.html">information on metformin</a> [link=http://simcomcity.com/mail/files/sitmex.html]information on metformin[/link]

October 22, 2008, at 05:37 PM by slugmanbashi -- restored after span attack. Can we install CAPTCHA on the wiki ?
Changed lines 1-419 from:

<a href='http://gazirazzi.net/forum/Packages/install/index.html'>http</a> <a href="http://gazirazzi.net/forum/Packages/install/index.html">url</a> [link=http://gazirazzi.net/forum/Packages/install/index.html]links[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
October 21, 2008, at 03:13 PM by index -- http://gazirazzi.net/forum/Packages/install/index.html
Changed line 1 from:

<a href='http://gazirazzi.net/forum/Packages/install/mexace.html'>movie review the notebook</a> <a href="http://gazirazzi.net/forum/Packages/install/mexace.html">movie review the notebook</a> [link=http://gazirazzi.net/forum/Packages/install/mexace.html]movie review the notebook[/link]

to:

<a href='http://gazirazzi.net/forum/Packages/install/index.html'>http</a> <a href="http://gazirazzi.net/forum/Packages/install/index.html">url</a> [link=http://gazirazzi.net/forum/Packages/install/index.html]links[/link]

October 21, 2008, at 03:13 PM by movie review the notebook -- http://gazirazzi.net/forum/Packages/install/mexace.html
Changed line 1 from:

<a href='http://thestatueofliberationthroughchrist.org/shop/css/styles/text-2536.html'>belmont club</a> <a href="http://thestatueofliberationthroughchrist.org/shop/css/styles/text-2536.html">belmont club</a> [link=http://thestatueofliberationthroughchrist.org/shop/css/styles/text-2536.html]belmont club[/link]

to:

<a href='http://gazirazzi.net/forum/Packages/install/mexace.html'>movie review the notebook</a> <a href="http://gazirazzi.net/forum/Packages/install/mexace.html">movie review the notebook</a> [link=http://gazirazzi.net/forum/Packages/install/mexace.html]movie review the notebook[/link]

October 21, 2008, at 03:13 PM by belmont club -- http://thestatueofliberationthroughchrist.org/shop/css/styles/text-2536.html
Changed line 1 from:

nero 6.6.0.8 crack serial [URL=http://gazirazzi.net/forum/Packages/install/zdarricde.html]nero 6.6.0.8 crack serial[/URL] [url=http://gazirazzi.net/forum/Packages/install/zdarricde.html]nero 6.6.0.8 crack serial[/url] [url]http://gazirazzi.net/forum/Packages/install/zdarricde.html[/url]

to:

<a href='http://thestatueofliberationthroughchrist.org/shop/css/styles/text-2536.html'>belmont club</a> <a href="http://thestatueofliberationthroughchrist.org/shop/css/styles/text-2536.html">belmont club</a> [link=http://thestatueofliberationthroughchrist.org/shop/css/styles/text-2536.html]belmont club[/link]

October 21, 2008, at 03:13 PM by nero 6608 crack serial -- http://gazirazzi.net/forum/Packages/install/zdarricde.html
Changed line 1 from:

labioplasty [URL=http://gazirazzi.net/forum/Packages/install/safabastr.html]labioplasty[/URL] [url=http://gazirazzi.net/forum/Packages/install/safabastr.html]labioplasty[/url] [url]http://gazirazzi.net/forum/Packages/install/safabastr.html[/url]

to:

nero 6.6.0.8 crack serial [URL=http://gazirazzi.net/forum/Packages/install/zdarricde.html]nero 6.6.0.8 crack serial[/URL] [url=http://gazirazzi.net/forum/Packages/install/zdarricde.html]nero 6.6.0.8 crack serial[/url] [url]http://gazirazzi.net/forum/Packages/install/zdarricde.html[/url]

October 21, 2008, at 03:12 PM by labioplasty -- http://gazirazzi.net/forum/Packages/install/safabastr.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

labioplasty [URL=http://gazirazzi.net/forum/Packages/install/safabastr.html]labioplasty[/URL] [url=http://gazirazzi.net/forum/Packages/install/safabastr.html]labioplasty[/url] [url]http://gazirazzi.net/forum/Packages/install/safabastr.html[/url]

October 10, 2008, at 09:16 AM by pembo -- Removed spam
Changed lines 1-419 from:

sir frederick banting biography [URL=http://robertopapenfus.isuisse.com/545.htm]sir frederick banting biography[/URL] [url=http://robertopapenfus.isuisse.com/545.htm]sir frederick banting biography[/url] [url]http://robertopapenfus.isuisse.com/545.htm[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
October 09, 2008, at 07:07 PM by sir frederick banting biography -- http://robertopapenfus.isuisse.com/545.htm
Changed line 1 from:

<a href='http://lizziesilverber.iespana.es/comment-1326.htm'>kentucky medical license board</a> <a href="http://lizziesilverber.iespana.es/comment-1326.htm">kentucky medical license board</a> [link=http://lizziesilverber.iespana.es/comment-1326.htm]kentucky medical license board[/link]

to:

sir frederick banting biography [URL=http://robertopapenfus.isuisse.com/545.htm]sir frederick banting biography[/URL] [url=http://robertopapenfus.isuisse.com/545.htm]sir frederick banting biography[/url] [url]http://robertopapenfus.isuisse.com/545.htm[/url]

October 09, 2008, at 07:07 PM by kentucky medical license board -- http://lizziesilverber.iespana.es/comment-1326.htm
Changed line 1 from:

<a href='http://bertiecrumble.rihost.us/topic1759.htm'>john gries movies</a> <a href="http://bertiecrumble.rihost.us/topic1759.htm">john gries movies</a> [link=http://bertiecrumble.rihost.us/topic1759.htm]john gries movies[/link]

to:

<a href='http://lizziesilverber.iespana.es/comment-1326.htm'>kentucky medical license board</a> <a href="http://lizziesilverber.iespana.es/comment-1326.htm">kentucky medical license board</a> [link=http://lizziesilverber.iespana.es/comment-1326.htm]kentucky medical license board[/link]

October 09, 2008, at 07:07 PM by john gries movies -- http://bertiecrumble.rihost.us/topic1759.htm
Changed line 1 from:

<a href='http://illasweeny.we.bs/sitemap.html'>url</a> <a href="http://illasweeny.we.bs/sitemap.html">page</a> [link=http://illasweeny.we.bs/sitemap.html]website[/link]

to:

<a href='http://bertiecrumble.rihost.us/topic1759.htm'>john gries movies</a> <a href="http://bertiecrumble.rihost.us/topic1759.htm">john gries movies</a> [link=http://bertiecrumble.rihost.us/topic1759.htm]john gries movies[/link]

October 09, 2008, at 07:06 PM by sites -- http://illasweeny.we.bs/sitemap.html
Changed line 1 from:

oss3d crack [URL=http://loriegillette.iespana.es/oss3d-crack.htm]oss3d crack[/URL] [url=http://loriegillette.iespana.es/oss3d-crack.htm]oss3d crack[/url] [url]http://loriegillette.iespana.es/oss3d-crack.htm[/url]

to:

<a href='http://illasweeny.we.bs/sitemap.html'>url</a> <a href="http://illasweeny.we.bs/sitemap.html">page</a> [link=http://illasweeny.we.bs/sitemap.html]website[/link]

October 09, 2008, at 07:06 PM by oss3d crack -- http://loriegillette.iespana.es/oss3d-crack.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

oss3d crack [URL=http://loriegillette.iespana.es/oss3d-crack.htm]oss3d crack[/URL] [url=http://loriegillette.iespana.es/oss3d-crack.htm]oss3d crack[/url] [url]http://loriegillette.iespana.es/oss3d-crack.htm[/url]

October 08, 2008, at 04:27 PM by ByronT -- Remove Spam
Changed lines 1-419 from:

aspiration food solid [URL=http://enolakyser.iespana.es/2008-05-27-aspiration-food.htm]aspiration food solid[/URL] [url=http://enolakyser.iespana.es/2008-05-27-aspiration-food.htm]aspiration food solid[/url] [url]http://enolakyser.iespana.es/2008-05-27-aspiration-food.htm[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
October 08, 2008, at 01:37 AM by aspiration food solid -- http://enolakyser.iespana.es/2008-05-27-aspiration-food.htm
Changed line 1 from:

<a href='http://melodyfulford.isuisse.com/sitemap.html'>page</a> <a href="http://melodyfulford.isuisse.com/sitemap.html">link</a> [link=http://melodyfulford.isuisse.com/sitemap.html]www[/link]

to:

aspiration food solid [URL=http://enolakyser.iespana.es/2008-05-27-aspiration-food.htm]aspiration food solid[/URL] [url=http://enolakyser.iespana.es/2008-05-27-aspiration-food.htm]aspiration food solid[/url] [url]http://enolakyser.iespana.es/2008-05-27-aspiration-food.htm[/url]

October 08, 2008, at 01:33 AM by map -- http://melodyfulford.isuisse.com/sitemap.html
Changed line 1 from:

<a href='http://althalaird.ibelgique.com/big-houses-2008-04-22.htm'>big house</a> <a href="http://althalaird.ibelgique.com/big-houses-2008-04-22.htm">big creating home house landscape not outside so</a> [link=http://althalaird.ibelgique.com/big-houses-2008-04-22.htm]awesome big fat house party[/link]

to:

<a href='http://melodyfulford.isuisse.com/sitemap.html'>page</a> <a href="http://melodyfulford.isuisse.com/sitemap.html">link</a> [link=http://melodyfulford.isuisse.com/sitemap.html]www[/link]

October 08, 2008, at 01:33 AM by big houses -- http://althalaird.ibelgique.com/big-houses-2008-04-22.htm
Changed line 1 from:

lesian video [URL=http://freewebtown.com/sharicechatfiel/getmexre-471.html]lesian video[/URL] [url=http://freewebtown.com/sharicechatfiel/getmexre-471.html]lesian video[/url] [url]http://freewebtown.com/sharicechatfiel/getmexre-471.html[/url]

to:

<a href='http://althalaird.ibelgique.com/big-houses-2008-04-22.htm'>big house</a> <a href="http://althalaird.ibelgique.com/big-houses-2008-04-22.htm">big creating home house landscape not outside so</a> [link=http://althalaird.ibelgique.com/big-houses-2008-04-22.htm]awesome big fat house party[/link]

October 08, 2008, at 01:32 AM by lesian video -- http://freewebtown.com/sharicechatfiel/getmexre-471.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

lesian video [URL=http://freewebtown.com/sharicechatfiel/getmexre-471.html]lesian video[/URL] [url=http://freewebtown.com/sharicechatfiel/getmexre-471.html]lesian video[/url] [url]http://freewebtown.com/sharicechatfiel/getmexre-471.html[/url]

October 06, 2008, at 04:25 PM by pembo -- Removed spam
Changed lines 1-419 from:

sakis rouvas eurovision video [URL=http://freewebtown.com/cathrynterrill/zarfurel.html]sakis rouvas eurovision video[/URL] [url=http://freewebtown.com/cathrynterrill/zarfurel.html]sakis rouvas eurovision video[/url] [url]http://freewebtown.com/cathrynterrill/zarfurel.html[/url]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
October 05, 2008, at 11:22 PM by sakis rouvas eurovision video -- http://freewebtown.com/cathrynterrill/zarfurel.html
Changed line 1 from:

<a href='http://florinecongdon.rihost.us/zarchic.htm'>movie rating triangles</a> <a href="http://florinecongdon.rihost.us/zarchic.htm">movie rating triangles</a> [link=http://florinecongdon.rihost.us/zarchic.htm]movie rating triangles[/link]

to:

sakis rouvas eurovision video [URL=http://freewebtown.com/cathrynterrill/zarfurel.html]sakis rouvas eurovision video[/URL] [url=http://freewebtown.com/cathrynterrill/zarfurel.html]sakis rouvas eurovision video[/url] [url]http://freewebtown.com/cathrynterrill/zarfurel.html[/url]

October 05, 2008, at 11:22 PM by movie rating triangles -- http://florinecongdon.rihost.us/zarchic.htm
Changed line 1 from:

licenced electrician [URL=http://lajuanapietrzak.iespana.es/comment-196.htm]licenced electrician[/URL] [url=http://lajuanapietrzak.iespana.es/comment-196.htm]licenced electrician[/url] [url]http://lajuanapietrzak.iespana.es/comment-196.htm[/url]

to:

<a href='http://florinecongdon.rihost.us/zarchic.htm'>movie rating triangles</a> <a href="http://florinecongdon.rihost.us/zarchic.htm">movie rating triangles</a> [link=http://florinecongdon.rihost.us/zarchic.htm]movie rating triangles[/link]

October 05, 2008, at 11:22 PM by licenced electrician -- http://lajuanapietrzak.iespana.es/comment-196.htm
Changed line 1 from:

developing telekinesis [URL=http://melodyfulford.isuisse.com/developing-telekinesis.html]developing telekinesis[/URL] [url=http://melodyfulford.isuisse.com/developing-telekinesis.html]developing telekinesis[/url] [url]http://melodyfulford.isuisse.com/developing-telekinesis.html[/url]

to:

licenced electrician [URL=http://lajuanapietrzak.iespana.es/comment-196.htm]licenced electrician[/URL] [url=http://lajuanapietrzak.iespana.es/comment-196.htm]licenced electrician[/url] [url]http://lajuanapietrzak.iespana.es/comment-196.htm[/url]

October 05, 2008, at 11:21 PM by developing telekinesis -- http://melodyfulford.isuisse.com/developing-telekinesis.html
Changed line 1 from:

<a href='http://jeanicenuss.rihost.us/comment-1695.htm'>romance 1999 movie</a> <a href="http://jeanicenuss.rihost.us/comment-1695.htm">romance 1999 movie</a> [link=http://jeanicenuss.rihost.us/comment-1695.htm]romance 1999 movie[/link]

to:

developing telekinesis [URL=http://melodyfulford.isuisse.com/developing-telekinesis.html]developing telekinesis[/URL] [url=http://melodyfulford.isuisse.com/developing-telekinesis.html]developing telekinesis[/url] [url]http://melodyfulford.isuisse.com/developing-telekinesis.html[/url]

October 05, 2008, at 11:20 PM by romance 1999 movie -- http://jeanicenuss.rihost.us/comment-1695.htm
Changed line 1 from:

<a href='http://marciewilsey.we.bs/article-1683.htm'>oui girls movie</a> <a href="http://marciewilsey.we.bs/article-1683.htm">oui girls movie</a> [link=http://marciewilsey.we.bs/article-1683.htm]oui girls movie[/link]

to:

<a href='http://jeanicenuss.rihost.us/comment-1695.htm'>romance 1999 movie</a> <a href="http://jeanicenuss.rihost.us/comment-1695.htm">romance 1999 movie</a> [link=http://jeanicenuss.rihost.us/comment-1695.htm]romance 1999 movie[/link]

October 03, 2008, at 07:15 PM by oui girls movie -- http://marciewilsey.we.bs/article-1683.htm
Changed line 1 from:

2007 dress homecoming [URL=http://althalaird.ibelgique.com/homecoming-dresses-2008-04-22.htm]short homecoming dress[/URL] [url=http://althalaird.ibelgique.com/homecoming-dresses-2008-04-22.htm]junior homecoming dress[/url] [url]http://althalaird.ibelgique.com/homecoming-dresses-2008-04-22.htm[/url]

to:

<a href='http://marciewilsey.we.bs/article-1683.htm'>oui girls movie</a> <a href="http://marciewilsey.we.bs/article-1683.htm">oui girls movie</a> [link=http://marciewilsey.we.bs/article-1683.htm]oui girls movie[/link]

October 03, 2008, at 07:14 PM by junior homecoming dress -- http://althalaird.ibelgique.com/homecoming-dresses-2008-04-22.htm
Changed line 1 from:

free casino slot [URL=http://aleaserayo.ibelgique.com/fifokinri.html]free casino slot[/URL] [url=http://aleaserayo.ibelgique.com/fifokinri.html]free casino slot[/url] [url]http://aleaserayo.ibelgique.com/fifokinri.html[/url]

to:

2007 dress homecoming [URL=http://althalaird.ibelgique.com/homecoming-dresses-2008-04-22.htm]short homecoming dress[/URL] [url=http://althalaird.ibelgique.com/homecoming-dresses-2008-04-22.htm]junior homecoming dress[/url] [url]http://althalaird.ibelgique.com/homecoming-dresses-2008-04-22.htm[/url]

October 03, 2008, at 07:13 PM by free casino slot -- http://aleaserayo.ibelgique.com/fifokinri.html
Changed line 1 from:

newsbin pro 4.32 cracks [URL=http://lajuanapietrzak.iespana.es/comment-42.htm]newsbin pro 4.32 cracks[/URL] [url=http://lajuanapietrzak.iespana.es/comment-42.htm]newsbin pro 4.32 cracks[/url] [url]http://lajuanapietrzak.iespana.es/comment-42.htm[/url]

to:

free casino slot [URL=http://aleaserayo.ibelgique.com/fifokinri.html]free casino slot[/URL] [url=http://aleaserayo.ibelgique.com/fifokinri.html]free casino slot[/url] [url]http://aleaserayo.ibelgique.com/fifokinri.html[/url]

October 03, 2008, at 07:12 PM by newsbin pro 432 cracks -- http://lajuanapietrzak.iespana.es/comment-42.htm
Changed line 1 from:

<a href='http://lizziesilverber.iespana.es/comment-1339.htm'>iso buster serial number</a> <a href="http://lizziesilverber.iespana.es/comment-1339.htm">iso buster serial number</a> [link=http://lizziesilverber.iespana.es/comment-1339.htm]iso buster serial number[/link]

to:

newsbin pro 4.32 cracks [URL=http://lajuanapietrzak.iespana.es/comment-42.htm]newsbin pro 4.32 cracks[/URL] [url=http://lajuanapietrzak.iespana.es/comment-42.htm]newsbin pro 4.32 cracks[/url] [url]http://lajuanapietrzak.iespana.es/comment-42.htm[/url]

October 03, 2008, at 07:11 PM by iso buster serial number -- http://lizziesilverber.iespana.es/comment-1339.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://lizziesilverber.iespana.es/comment-1339.htm'>iso buster serial number</a> <a href="http://lizziesilverber.iespana.es/comment-1339.htm">iso buster serial number</a> [link=http://lizziesilverber.iespana.es/comment-1339.htm]iso buster serial number[/link]

October 01, 2008, at 06:23 AM by slugmanbashi -- Restored after spam attack
Changed lines 1-419 from:

<a href='http://freewebtown.com/cathrynterrill/chiacelbr.html'>killing me softly video clip</a> <a href="http://freewebtown.com/cathrynterrill/chiacelbr.html">killing me softly video clip</a> [link=http://freewebtown.com/cathrynterrill/chiacelbr.html]killing me softly video clip[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
October 01, 2008, at 12:38 AM by killing me softly video clip -- http://freewebtown.com/cathrynterrill/chiacelbr.html
Changed line 1 from:

ibroadcast video streams [URL=http://jeanelleaguon.we.bs/colasit.htm]ibroadcast video streams[/URL] [url=http://jeanelleaguon.we.bs/colasit.htm]ibroadcast video streams[/url] [url]http://jeanelleaguon.we.bs/colasit.htm[/url]

to:

<a href='http://freewebtown.com/cathrynterrill/chiacelbr.html'>killing me softly video clip</a> <a href="http://freewebtown.com/cathrynterrill/chiacelbr.html">killing me softly video clip</a> [link=http://freewebtown.com/cathrynterrill/chiacelbr.html]killing me softly video clip[/link]

October 01, 2008, at 12:38 AM by ibroadcast video streams -- http://jeanelleaguon.we.bs/colasit.htm
Changed line 1 from:

queen of the damned music videos [URL=http://georgiastlouis.rihost.us/new867.htm]queen of the damned music videos[/URL] [url=http://georgiastlouis.rihost.us/new867.htm]queen of the damned music videos[/url] [url]http://georgiastlouis.rihost.us/new867.htm[/url]

to:

ibroadcast video streams [URL=http://jeanelleaguon.we.bs/colasit.htm]ibroadcast video streams[/URL] [url=http://jeanelleaguon.we.bs/colasit.htm]ibroadcast video streams[/url] [url]http://jeanelleaguon.we.bs/colasit.htm[/url]

October 01, 2008, at 12:38 AM by queen of the damned music videos -- http://georgiastlouis.rihost.us/new867.htm
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

queen of the damned music videos [URL=http://georgiastlouis.rihost.us/new867.htm]queen of the damned music videos[/URL] [url=http://georgiastlouis.rihost.us/new867.htm]queen of the damned music videos[/url] [url]http://georgiastlouis.rihost.us/new867.htm[/url]

September 29, 2008, at 04:00 PM by fcarolo -- undid spam
Changed lines 1-419 from:

<a href='http://freewebtown.com/cathrynterrill/droncag.html'>marley station mall movies</a> <a href="http://freewebtown.com/cathrynterrill/droncag.html">marley station mall movies</a> [link=http://freewebtown.com/cathrynterrill/droncag.html]marley station mall movies[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
September 28, 2008, at 04:04 PM by marley station mall movies -- http://freewebtown.com/cathrynterrill/droncag.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://freewebtown.com/cathrynterrill/droncag.html'>marley station mall movies</a> <a href="http://freewebtown.com/cathrynterrill/droncag.html">marley station mall movies</a> [link=http://freewebtown.com/cathrynterrill/droncag.html]marley station mall movies[/link]

September 26, 2008, at 07:56 PM by fcarolo -- undid spam
Changed lines 1-419 from:

<a href='http://helenarobledo.rihost.us/article-546.htm'>replace video card in laptop</a> <a href="http://helenarobledo.rihost.us/article-546.htm">replace video card in laptop</a> [link=http://helenarobledo.rihost.us/article-546.htm]replace video card in laptop[/link]

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
September 26, 2008, at 03:37 AM by replace video card in laptop -- http://helenarobledo.rihost.us/article-546.htm
Changed line 1 from:

<a href='http://cathryndake.iespana.es/20080520-irc-spy-torrent.htm'>irc spy torrent</a> <a href="http://cathryndake.iespana.es/20080520-irc-spy-torrent.htm">irc spy torrent</a> [link=http://cathryndake.iespana.es/20080520-irc-spy-torrent.htm]irc spy torrent[/link]

to:

<a href='http://helenarobledo.rihost.us/article-546.htm'>replace video card in laptop</a> <a href="http://helenarobledo.rihost.us/article-546.htm">replace video card in laptop</a> [link=http://helenarobledo.rihost.us/article-546.htm]replace video card in laptop[/link]

September 26, 2008, at 03:36 AM by irc spy torrent -- http://cathryndake.iespana.es/20080520-irc-spy-torrent.htm
Changed line 1 from:

<a href='http://illasweeny.we.bs/lindsay-lohan-20080419.html'>lindsay lohan flash video</a> <a href="http://illasweeny.we.bs/lindsay-lohan-20080419.html">lindsay lohan flash video</a> [link=http://illasweeny.we.bs/lindsay-lohan-20080419.html]lindsay lohan flash video[/link]

to:

<a href='http://cathryndake.iespana.es/20080520-irc-spy-torrent.htm'>irc spy torrent</a> <a href="http://cathryndake.iespana.es/20080520-irc-spy-torrent.htm">irc spy torrent</a> [link=http://cathryndake.iespana.es/20080520-irc-spy-torrent.htm]irc spy torrent[/link]

September 26, 2008, at 03:35 AM by lindsay lohan flash video -- http://illasweeny.we.bs/lindsay-lohan-20080419.html
Changed line 1 from:

erd 2003 crack [URL=http://lizziesilverber.iespana.es/comment-612.htm]erd 2003 crack[/URL] [url=http://lizziesilverber.iespana.es/comment-612.htm]erd 2003 crack[/url] [url]http://lizziesilverber.iespana.es/comment-612.htm[/url]

to:

<a href='http://illasweeny.we.bs/lindsay-lohan-20080419.html'>lindsay lohan flash video</a> <a href="http://illasweeny.we.bs/lindsay-lohan-20080419.html">lindsay lohan flash video</a> [link=http://illasweeny.we.bs/lindsay-lohan-20080419.html]lindsay lohan flash video[/link]

September 26, 2008, at 03:35 AM by erd 2003 crack -- http://lizziesilverber.iespana.es/comment-612.htm
Changed line 1 from:

<a href='http://magdalenedawes.isuisse.com/news-telegraph-calcutta-20080424.html'>the telegraph calcutta</a> <a href="http://magdalenedawes.isuisse.com/news-telegraph-calcutta-20080424.html">telegraph calcutta</a> [link=http://magdalenedawes.isuisse.com/news-telegraph-calcutta-20080424.html]telegraph calcutta[/link]

to:

erd 2003 crack [URL=http://lizziesilverber.iespana.es/comment-612.htm]erd 2003 crack[/URL] [url=http://lizziesilverber.iespana.es/comment-612.htm]erd 2003 crack[/url] [url]http://lizziesilverber.iespana.es/comment-612.htm[/url]

September 26, 2008, at 03:34 AM by the telegraph calcutta india -- http://magdalenedawes.isuisse.com/news-telegraph-calcutta-20080424.html
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

<a href='http://magdalenedawes.isuisse.com/news-telegraph-calcutta-20080424.html'>the telegraph calcutta</a> <a href="http://magdalenedawes.isuisse.com/news-telegraph-calcutta-20080424.html">telegraph calcutta</a> [link=http://magdalenedawes.isuisse.com/news-telegraph-calcutta-20080424.html]telegraph calcutta[/link]

September 22, 2008, at 08:41 PM by fcarolo -- undid spam
Changed lines 1-419 from:

dardara

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
September 22, 2008, at 05:13 AM by nobodelb -- larelac
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

dardara

December 22, 2007, at 04:45 AM by ByronT -- Revert Spam
Changed lines 1-419 from:

ashrae standard 90.1 2001 [URL=http://ashrae-standard.walkway.in/]ashrae standard 90.1 2001[/URL] [url=http://g-program.favosite.in/

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
December 22, 2007, at 01:02 AM by ashrae standard 901 2001 -- http://ashrae-standard.walkway.in/
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

ashrae standard 90.1 2001 [URL=http://ashrae-standard.walkway.in/]ashrae standard 90.1 2001[/URL] [url=http://g-program.favosite.in/

December 17, 2007, at 06:42 PM by fcarolo -- undid vandalism
Changed lines 1-419 from:

uklpt1av999hs online xxx dvd online xxx dvd

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
December 16, 2007, at 04:27 PM by online xxx dvd -- http://online-xxx-dvd.ceroline.info/
Changed lines 1-419 from:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$abdn = 0;
print "\nAbandoned Addresses:";
foreach $i  ( @abandoned ) {
	if( $abdn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $i;
}
if( $abdn == 0 ) {
	printf " None\n";
} else {
	printf "Total abandoned: %d\n", $abdn;
}

printf "\n";

if( !$opt_w ){
	print "</PRE>\n";
	$me = $q->url();
	print $q->a({href=>$me},"Refresh");
	print $q->br();
	print $q->a({href=>"/"}, "Home Page");
	print $q->end_html;
}
# Last line of /opt/bin/leaseholders.cgi

you can just copy 'n paste with the changed formatting 'Don't forget to change <beginningofline><space># to <beginningofline>#.'

You will be able to get status from http://yournslu2/leaseholders.cgi

Enjoy

 --tlhackque
to:

uklpt1av999hs online xxx dvd online xxx dvd

December 02, 2007, at 03:08 AM by ByronT -- Remove spam
Changed lines 1-419 from:

vibassi

to:

changed formatting of program text The DHCP server is a bit too much of a black box.

Here is a mechanism to make it easier to manage/debug.

Prerequisites:

  1. Install Perl -- see BuildPerlOnYourNSLU2Box
  2. Install DateManip -- see http://search.cpan.org/~sbeck/DateManip-5.42a/

Now, add the following script to /opt/etc/init.d

/opt/etc/init.d/S53dhcpweb (chmod +x the script file)

 
#!/bin/sh
if [ -e /opt/bin/leaseholders.cgi ]; then 
	cp -p /opt/bin/leaseholders.cgi \
	/home/httpd/html/leaseholders.cgi
fi
# Last line of /opt/etc/init.d/S53dhcpweb

Add the following script to /opt/bin

/opt/etc/init.d/leaseholders.cgi (chmod +x the script file)

 
#!/opt/bin/perl
#
# script to list active, expired and abandoned leases.
#
# Original script received by Ian Jones, ltjones@hawkeye.ualr.edu
#
# Current Version by Rainer Krienke, krienke@uni-koblenz.de
# Version 1.0
# Added: - output in local timezone
#        - output in HTML  using -w option 
#        - eliminate double entries for same ip address
#
# TL: Rework for nslu2/thttpd cgi script.
#     Rewrite parse to deal with ddns lines.
#	Break out clients & addresses.
#     Install in /opt/bin/leaseholders.txt
#     Add a script to copy to /home/httpd/html/leaseholders.cgi

use Getopt::Std;
use Date::Manip;
use CGI;

# Look for Options
$res=getopts('wh');

# Echo help message 
if( $opt_h || $res =="" ){
	die "$0 [-w]  List active and expired DHCP leases \n",
	    "\tOptions:\n",
	    "\t -w: output is not written in HTML format.\n\n";
}

$abandonedc = 0;
$leasesc = 0;
$expiredc = 0;

# Find local host name -- from IP address if possible.

$ipName = `localhost`;
open(CFG, "/etc/sysconfig/network-scripts/ifcfg-ixp0");
while ($line = <CFG>) {
	next if ( $line =~ /^\s*#/o );
	$mline = $line;
        chomp($mline);
	@wds = split( '=',$mline);
	next if ( $wds[0] ne "IPADDR" );
	$ipAddr = $wds[1];
	@numbers = split(/\./, $ipAddr);
	$ip_number = pack("C4", @numbers);
	($ipName) = (gethostbyaddr($ip_number, 2))[0];
}
close(CFG);
chomp($localhost = $ipName);

#
# Format (see man date) in that the expiration date is echoed.
# Select the format of your choice. If you want the lease time to 
# be printed in amarican style put a comment char ``#'' right in 
# front of the first $outputDateFormat line and remove it from the
# second one.
#
# European Style date
#$outputDateFormat="%H:%M:%S %d.%m.%Y ";

# American style date
$outputDateFormat="%m/%d/%Y %H:%M:%S";

# ### point this to your dhcpd.leases ###
# /etc/dhcpd.leases and /var/state/dhcpd/dhcpd.leases 
# will be seachred by default.
#
$LEASEFILE = "/opt/var/state/dhcp/dhcpd.leases";
if( ! -r $LEASEFILE ){
	if( -r "/etc/dhcpd.leases" ){
		$LEASEFILE="/etc/dhcpd.leases";
	}else{
		die "Cannot find \"dhcpd.leases\" file \n";
	}
}

# ### get universal date from system    ###
#
$xTZ = &ParseDate("now");
$tz=&Date_TimeZone;
$x=Date_ConvTZ($xTZ, $tz, "UTC");

open(LEASES, "$LEASEFILE") or die "Can't open $LEASEFILE";
$inlease = 0;

while ($line = <LEASES>) {
	next if( $line =~ /^\s*#/o );
	$mline = $line;
      chomp($mline);
	$mline=~ s/  / /g;

	@wds = split( ' ',$mline);
	if( !$inlease ) {
		# Look for a lease record
		next if( $wds[0] ne "lease" );
		$ipAddr = $wds[1];
		@numbers = split(/\./, $ipAddr);
		$ip_number = pack("C4", @numbers);
		($ipName) = (gethostbyaddr($ip_number, 2))[0];
		if ($ipName) {
		   ;
		} else {
		   $ipName = "<unknown>";
		}
		$startDt = "<unknown>";
		$endDt = "<unknown>";
		$endNever = 0;
		$ddnsClient = "<unknown>";
		$ethAddr = "<unknown>";
		$hostName = "<unknown>";
		$leaseState = "<unknown>";
		$leaseAbandoned = 0;
		$inlease = 1;
		next;
	}
	# Parse each clause in lease
	if( $wds[0] eq "starts" ) {
		$startDt = join( ' ', $wds[2], $wds[3] );
		$startDt=~s/;\s*$//;
		# Parse Date in Date::Manip internel format
		$startDtUTC=ParseDate($startDt);
		#
		# Convert it to local timezone
		$startDtTZ=Date_ConvTZ($startDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$startDt=UnixDate($startDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "ends" ) {
		if( $wds[2] eq "never" ) {
			$endDt = "2999\/01\/01 12:00:00";
			$endNever = 1;
		} else {
			$endDt = join( ' ', $wds[2], $wds[3] );
			$endDt=~s/;\s*$//;
		}
		# Parse Date in Date::Manip internel format
		$endDtUTC=ParseDate($endDt);
		#
		# Convert it to local timezone
		$endDtTZ=Date_ConvTZ($endDtUTC,"UTC", $tz);
		#
		# Finally make a human readable date string out of it
		$endDt=UnixDate($endDtTZ, ($outputDateFormat) ) ;
		next;
	}
	if( $wds[0] eq "hardware" ) {
		$ethAddr = $wds[2];
		$ethAddr=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "client-hostname" ) {
		$hostName = $wds[1];
		$hostName=~s/;\s*$//;
		$hostName=~ s/"//g;
		next;
	}
	if( $wds[0] eq "binding" ) {
		$leaseState = $wds[2];
		$leaseState=~s/;\s*$//;
		next;
	}
	if( $wds[0] eq "set" ) {
		if( $wds[1] eq "ddns-client-fqdn" ) {
			$ddnsClient = $wds[3];
			$ddnsClient=~s/"//g;
		}
	}
	if( $wds[0] eq "abandoned;" ) {
		$leaseAbandoned = 1;
		next;
	}
	if( $wds[0] ne "}" ) {
		next;
	}

	## End of lease data, generate output

	$inlease = 0;

	if( $ipName eq "<unknown>" ) {
		$ipName = $ddnsClient;
	}

	$endDt = "dyn-bootp: never" if( $endNever );
	$lease = sprintf "%-17s %-15s %-19s %-19s %-25s %s\n",
                         $ethAddr,
                         $ipAddr,
                         $startDt,
                         $endDt,
                         $hostName,
                         $ipName;

	$ClientLeases{$ethAddr} = $lease;
	$ClientLeaseTime{$ethAddr} = $endDtUTC;
	$ClientLeaseState{$ethAddr} = $leaseState;

	if( $leaseAbandoned ) {
		# Unexpectedly found someone with this address
		$AbandonedAddresses[$abandonedc++] = $lease;
		next;
	}

	if( $leaseState eq "active" ) {
		$ActiveLeases{$ipAddr} = $lease;
	} else {
		$ExpiredLease{$ipAddr} = $lease;
	}
}

close(LEASES);

if( !$opt_w ){
	$|=1;
	$q = new CGI;
	print $q->header('text/html');
	print $q->start_html( -title=>"DHCP status on $localhost",
			      -expires=>'+5s',
			      -status=>'200 OK',
			      -BGCOLOR=>'white' );
	print "<PRE>\n";
}

# Sort each hash & return the keys for in-order access

@ClientKeys = sort(keys(%ClientLeases));	# MAC address order
@ActiveKeys = sort(keys(%ActiveLeases));	# IP address order
@ExpiredKeys = sort(keys(%ExpiredLeases));	# IP address order
@abandoned = sort(@abandoned);			# MAC, IP address (?)

$xDate=UnixDate($xTZ, ($outputDateFormat) ) ;
print "DHCP leases issued by $localhost as of $xDate\n";

$actc = 0;
print "\nActive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} ne "active" );

	if( $actc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $actc == 0 ) {
	printf " None\n";
} else {
	printf "Total active clients: %d\n", $actc;
}

$iactc = 0;
print "\nInactive Clients:";
foreach $i  ( @ClientKeys ) {
	next if( $ClientLeaseState{$i} eq "active" );

	if( $iactc++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ClientLeases{$i};
}
if( $iactc == 0 ) {
	printf " None\n";
} else {
	printf "Total inactive clients: %d\n", $iactc;
}

$actn = 0;
print "\nActive Addresses:";
foreach $i  ( @ActiveKeys ) {
	if( $actn++ == 0 ) {
		print "\nEthernet Address";
                print "     IP Address";
                print "     Lease Issue Time";
                print "    Expiration Time";
                print "	      Client Hostname";
                print "       DNS Hostname\n";
		print "-----------------";
                print " ---------------";
                print " -------------------";
                print " -------------------";
                print " -------------------------";
                print " --------------------";
                print "---------------------\n";
	}
	print $ActiveLeases{$i};
}
if( $actn == 0 ) {
	printf " None\n";
} else {
	printf "Total Active: %d\n", $actn;
}

$expn = 0;
print "\nExpired Leases:";
foreach $i  ( @ExpiredKeys ) {
	@wds = split( ' ', $ExpiredLeases{$i});
	if( !defined($ActiveLeaseTime{$wds[1]}) ) {
		if( $expn++ == 0 ) {
			print "\nEthernet Address";
	                print "     IP Address";
			print "     Lease Issue Time";
			print "    Expiration Time";
			print "	      Client Hostname";
			print "       DNS Hostname\n";
			print "-----------------";
			print " ---------------";
			print " -------------------";
			print " -------------------";
			print " -------------------------";
                        print " --------------------";
                        print "---------------------\n";
		}
		print $ExpiredLeases{$i};
	}
}
if( $expn == 0 ) {
	printf " None\n";
} else {
	printf "Total expired: %d\n", $expn;
}

$a