dhcp status apps

Shane Kerr Shane_Kerr at isc.org
Mon Jan 7 17:39:12 UTC 2008


Hey Alex,

It's not dhcpstatus, but I put together a script for a customer a couple weeks
ago that you might be able to use. I've attached it. Please let me know if it
helps. Thanks!


Alex Moen wrote:
> 
> Edward Mann wrote:
>>>>  > > 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.
>>
>>
> 
> Thanks for all the work, Edward... It is appreciated.
> 
> OK, I have implemented this... I can't get it to work. The server is a
> Sun V240 with a single UltraSPARC-IIIi and 2 gigs of memory.  It's
> running ISC named and dhcpd, but really not doing anything else. Load
> avg is at 0.04. Originally I had 194 includes (persistent host configs,
> known-host configs, classes, and subnets).  The script ran for half an
> hour, and then reported "Out of memory!".  So, I cut it down to 43
> subnet-only configs, same problem.
> 
> So I cut out all of the includes, and just have the initial subnet that
> the system sits on.  I get a HUGE list of
> "Use of uninitialized value in string ne at
> /usr/local/dhcpstatus/dhcpstatus/dhcpstatus.pm line 49"
> 
> If I copy the original common.pm file back, the output looks normal
> again.  It looks like the changes cause a problem while scanning the
> leases file.
> 
> Is there anything that I can add or send that will help troubleshoot
> this?  It would be great to get this script to work.
> 
> Thanks!
> 
> Alex
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: leaseinfo.pl
Type: application/x-perl
Size: 9926 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20080107/a971aa9e/attachment.bin>


More information about the dhcp-users mailing list