dhcp status apps
Edward Mann
ed.mann at edmann.com
Sat Jan 5 00:29:10 UTC 2008
>> > > Subject: Re: dhcp status apps
>> > > From: chris_cox at stercomm.com
>> > > To: dhcp-users at isc.org
>> > > Date: Fri, 4 Jan 2008 13:16:21 -0600
>> > >
>> > > On Fri, 2008-01-04 at 11:25 -0500, J E wrote:
>> >> > > Recently a recommendation was given on the list for dhcpstatus (
>> http://dhcpstatus.sourceforge.net/
>> >> > > )by Glenn S. as a way to take a nicer look at leases, etc. And
>> while
>> >> > > it does seem to offer a nice view of some things, the project
>> hasn't
>> >> > > been touched in about 6 years. So v.3 support is minimal, and
>> not
>> >> > > complete - and of course there is no mention of v.4.
>> > >
>> > > I'm curious. What is it missing? You say it's "not complete".
>> > >
>> > > Just curious. We use it it here. We also wrote some stuff to web
>> > > display our DNS.
>> > >
>> >> > >
>> >> > > Can anyone give some recommendations for other products that may
>> have
>> >> > > similar, or even better features than dhcpstatus? I've checked
>> the
>> >> > > list archive, and done some googling but not seeing much that
>> isn't
>> >> > > part of some much larger project, tied into DDNS capabilities,
>> etc.
>> >> > > Free is best, but pay solutions may be OK too :)
>> >> > >
>> >> > > Thanks!
>> >> > >
>> >> > > jeff
>>
>> One thing that DHCPStatus is missing (very important, imho) is the
>> ability
>> to process "include" statements. We are running more than 250 subnets,
>> and
>> are using include statements in our dhcpd.conf that allow us to split up
>> the conf into manageable files. DHCPStatus does not include the
>> included
>> configs, so it is kind of useless in this sense. I am looking at the
>> code
>> to see if it is easy to modify, but I am not a perlmonger by any means
>> so
>> I
>> don't hold much hope! :)
>>
>> Alex
>>
>>
> Okay i did this one quick, and was not sure if i should even touch the
> thing. That is because of some of the messages i was reading. But here is
> the file.
> Note: There is a bug with the original if you have
> key DHCP-UPDATE-KEY {
> ...
> ...
> }
>
> it will not process the file. So once again i can see there are problems
> with this app. But i did not find that until i got the includes to work.
> Because my key is in an include file.
>
> Note2: I have not tested this code allot, and an "perlmonger" may banish
> me from ever writing perl code again for the public consumption.
>
> Take the following code and replace your get_symbols function with it.
>
> <code>
> #--------------------------------------------------------------------------
> # Read all the lines in a file, and also run the includes if there are
> # any.
> #
> sub get_symbols {
> my $file;
> if ( $#_ < 0 ) {
> $file = "/etc/dhcpd.conf";
> }
> else {
> $file = shift;
> }
>
> my @sym;
> our @includes;
> open( FILE, $file ) || die("Can't open $file\n");
> while ( defined(FILE) && ( my $line = <FILE> ) ) {
> push(@sym, process_sym($line));
>
> }
> close(FILE);
> if ( @includes > 0 ) {
> foreach $inc (@includes) {
> open( INC, $file ) || die("Can't open $file\n");
> while ( defined(INC) && ( my $line = <INC> ) ) {
> push(@sym, process_sym($line));
> }
> close(INC)
> }
> }
>
> return (@sym);
> }
>
> #--------------------------------------------------------------------------
> # Read the line, throw away comment line (ones starting with
> # "#", and get a list of "symbols".
> #
> sub process_sym {
> $line = shift;
> my $comment_index = index( $line, "#" ); # does this line contain a
> if ( $comment_index >= 0 ) { # comment ?
> if ( substr( $line, 0, 2 ) eq '#$' ) { # is it a subnet comment ?
> $line = &get_comment($line);
> }
> else { # ignore everything after the
> $line = substr( $line, 0, $comment_index ) . "\n"; # "#" sign.
> }
> }
> $line =~ s/^\s+//;
> if ( $line =~ m/^include/ ) {
> @line = split( /\s/, $line );
> $line[1] =~ s/"//g;
> $line[1] =~ s/;//;
> push( @includes, $line[1] );
> }
> else {
> $line =~ s/\n/ /g;
> $line =~ s/{/ { /g;
> $line =~ s/\t/ /g;
> $line =~ s/;/ ; /g;
> $line =~ s/,/ , /g;
> $line =~ s/"/ /g;
> return $line;
> }
> }
> </code>
>
> If this code is not satisfactory let me know. I only tested it with two
> includes. YMMV.
>
> Thanks.
>
>
>
I should have said this is in the common.pm file. Sorry that did not make
it in the original reply.
Thanks.
More information about the dhcp-users
mailing list