Build a custom log entry on a DHCPACK CentOS 6.

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Build a custom log entry on a DHCPACK CentOS 6.

Mark Haney
We've got a custom log entry created that's based on whether the agent.circuit-id exists.  The problem is that the circuit-id gets included in DHCPDISCOVER and DHCPOFFER, so we're getting duplicate custom messages logged.  

What we want to do it create this custom log file, with the circuit-id only on the DHCPACK.  The log creation params are below.  We use this so that customers can get a web interface view of the current leases.  

Is there a way to do this with the latest CentOS 6 dhcpd package?

----
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }


--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:(919)%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • mark.haney@...
www.neonova.net    

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Build a custom log entry on a DHCPACK CentOS 6.

Bob Harold

On Fri, May 26, 2017 at 11:38 AM, Mark Haney <[hidden email]> wrote:
We've got a custom log entry created that's based on whether the agent.circuit-id exists.  The problem is that the circuit-id gets included in DHCPDISCOVER and DHCPOFFER, so we're getting duplicate custom messages logged.  

What we want to do it create this custom log file, with the circuit-id only on the DHCPACK.  The log creation params are below.  We use this so that customers can get a web interface view of the current leases.  

Is there a way to do this with the latest CentOS 6 dhcpd package?

----
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }


--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:(919)%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • mark.haney@...
www.neonova.net    


Try wrapping that with:
   on commit {
   ...
   }

Then it should only happen once, when the lease is granted.

-- 
Bob Harold
 

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Build a custom log entry on a DHCPACK CentOS 6.

Mark Haney
Okay, let me see if I get this straight, I should wrap the entire if statement inside an 'on commit {}' block?  

On Fri, May 26, 2017 at 2:56 PM, Bob Harold <[hidden email]> wrote:

On Fri, May 26, 2017 at 11:38 AM, Mark Haney <[hidden email]> wrote:
We've got a custom log entry created that's based on whether the agent.circuit-id exists.  The problem is that the circuit-id gets included in DHCPDISCOVER and DHCPOFFER, so we're getting duplicate custom messages logged.  

What we want to do it create this custom log file, with the circuit-id only on the DHCPACK.  The log creation params are below.  We use this so that customers can get a web interface view of the current leases.  

Is there a way to do this with the latest CentOS 6 dhcpd package?

----
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }


--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:(919)%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • mark.haney@...
www.neonova.net    


Try wrapping that with:
   on commit {
   ...
   }

Then it should only happen once, when the lease is granted.

-- 
Bob Harold
 

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users



--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:(919)%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • [hidden email]
www.neonova.net    

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Build a custom log entry on a DHCPACK CentOS 6.

Bob Harold

On Fri, May 26, 2017 at 3:08 PM, Mark Haney <[hidden email]> wrote:
Okay, let me see if I get this straight, I should wrap the entire if statement inside an 'on commit {}' block?  


Yes

on commit {
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }
}

-- 
Bob Harold
 
On Fri, May 26, 2017 at 2:56 PM, Bob Harold <[hidden email]> wrote:

On Fri, May 26, 2017 at 11:38 AM, Mark Haney <[hidden email]> wrote:
We've got a custom log entry created that's based on whether the agent.circuit-id exists.  The problem is that the circuit-id gets included in DHCPDISCOVER and DHCPOFFER, so we're getting duplicate custom messages logged.  

What we want to do it create this custom log file, with the circuit-id only on the DHCPACK.  The log creation params are below.  We use this so that customers can get a web interface view of the current leases.  

Is there a way to do this with the latest CentOS 6 dhcpd package?

----
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }


--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:(919)%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • mark.haney@...
www.neonova.net    


Try wrapping that with:
   on commit {
   ...
   }

Then it should only happen once, when the lease is granted.

-- 
Bob Harold
 

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users



--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:(919)%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • [hidden email]
www.neonova.net    


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Build a custom log entry on a DHCPACK CentOS 6.

Mark Haney
Well, I'm getting closer, though now the log is entered twice in syslog.  Which, I'm not at all certain as to why that would be.  This has cut way down on these entries being created, but can still screw up the reporting for the customer's web reporting tool.  I'm still unsure why the ACK message type is being ignored.



On Fri, May 26, 2017 at 3:23 PM, Bob Harold <[hidden email]> wrote:

On Fri, May 26, 2017 at 3:08 PM, Mark Haney <[hidden email]> wrote:
Okay, let me see if I get this straight, I should wrap the entire if statement inside an 'on commit {}' block?  


Yes

on commit {
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }
}

-- 
Bob Harold
 
On Fri, May 26, 2017 at 2:56 PM, Bob Harold <[hidden email]> wrote:

On Fri, May 26, 2017 at 11:38 AM, Mark Haney <[hidden email]> wrote:
We've got a custom log entry created that's based on whether the agent.circuit-id exists.  The problem is that the circuit-id gets included in DHCPDISCOVER and DHCPOFFER, so we're getting duplicate custom messages logged.  

What we want to do it create this custom log file, with the circuit-id only on the DHCPACK.  The log creation params are below.  We use this so that customers can get a web interface view of the current leases.  

Is there a way to do this with the latest CentOS 6 dhcpd package?

----
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }


--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:(919)%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • mark.haney@...
www.neonova.net    


Try wrapping that with:
   on commit {
   ...
   }

Then it should only happen once, when the lease is granted.

-- 
Bob Harold
 

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users



--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:(919)%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • [hidden email]
www.neonova.net    


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users



--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:(919)%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • [hidden email]
www.neonova.net    

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Build a custom log entry on a DHCPACK CentOS 6.

Mark Haney
In reply to this post by Bob Harold

Well, it sort of works that way.  The issue now is it is logging it twice.  Which doesn't make sense to me in any way.  I only posted half the 'if' statement, but logically the else shouldn't matter.  Why is /on commit/ logging 2 (and sometimes 3) entries for one DHCPACK? 



On 05/26/2017 03:23 PM, Bob Harold wrote:

On Fri, May 26, 2017 at 3:08 PM, Mark Haney <[hidden email]> wrote:
Okay, let me see if I get this straight, I should wrap the entire if statement inside an 'on commit {}' block?  


Yes

on commit {
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }
}

-- 
Bob Harold
 
On Fri, May 26, 2017 at 2:56 PM, Bob Harold <[hidden email]> wrote:

On Fri, May 26, 2017 at 11:38 AM, Mark Haney <[hidden email]> wrote:
We've got a custom log entry created that's based on whether the agent.circuit-id exists.  The problem is that the circuit-id gets included in DHCPDISCOVER and DHCPOFFER, so we're getting duplicate custom messages logged.  

What we want to do it create this custom log file, with the circuit-id only on the DHCPACK.  The log creation params are below.  We use this so that customers can get a web interface view of the current leases.  

Is there a way to do this with the latest CentOS 6 dhcpd package?

----
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }


--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:%28919%29%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank" moz-do-not-send="true">919-460-3330 (opt 1) • mark.haney@...
www.neonova.net    


Try wrapping that with:
   on commit {
   ...
   }

Then it should only happen once, when the lease is granted.

-- 
Bob Harold
 

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users



--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:%28919%29%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank" moz-do-not-send="true">919-460-3330 (opt 1) • [hidden email]
www.neonova.net    



_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Build a custom log entry on a DHCPACK CentOS 6.

Bob Harold

On Tue, May 30, 2017 at 8:02 AM, Mark Haney <[hidden email]> wrote:

Well, it sort of works that way.  The issue now is it is logging it twice.  Which doesn't make sense to me in any way.  I only posted half the 'if' statement, but logically the else shouldn't matter.  Why is /on commit/ logging 2 (and sometimes 3) entries for one DHCPACK?  

That is really strange.  I am not seeing that behavior on my server.

-- 
Bob Harold

 
On 05/26/2017 03:23 PM, Bob Harold wrote:

On Fri, May 26, 2017 at 3:08 PM, Mark Haney <[hidden email]> wrote:
Okay, let me see if I get this straight, I should wrap the entire if statement inside an 'on commit {}' block?  


Yes

on commit {
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }
}

-- 
Bob Harold
 
On Fri, May 26, 2017 at 2:56 PM, Bob Harold <[hidden email]> wrote:

On Fri, May 26, 2017 at 11:38 AM, Mark Haney <[hidden email]> wrote:
We've got a custom log entry created that's based on whether the agent.circuit-id exists.  The problem is that the circuit-id gets included in DHCPDISCOVER and DHCPOFFER, so we're getting duplicate custom messages logged.  

What we want to do it create this custom log file, with the circuit-id only on the DHCPACK.  The log creation params are below.  We use this so that customers can get a web interface view of the current leases.  

Is there a way to do this with the latest CentOS 6 dhcpd package?

----
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }


--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:%28919%29%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • mark.haney@...
www.neonova.net    


Try wrapping that with:
   on commit {
   ...
   }

Then it should only happen once, when the lease is granted.

-- 
Bob Harold
 

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users



--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:%28919%29%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • [hidden email]
www.neonova.net    



_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Build a custom log entry on a DHCPACK CentOS 6.

Anderson, Charles R
On Tue, May 30, 2017 at 12:05:53PM -0400, Bob Harold wrote:
> On Tue, May 30, 2017 at 8:02 AM, Mark Haney <[hidden email]> wrote:
>
> > Well, it sort of works that way.  The issue now is it is logging it
> > twice.  Which doesn't make sense to me in any way.  I only posted half the
> > 'if' statement, but logically the else shouldn't matter.  Why is /on
> > commit/ logging 2 (and sometimes 3) entries for one DHCPACK?
> >
> That is really strange.  I am not seeing that behavior on my server.

How many relay agents do you have?
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Build a custom log entry on a DHCPACK CentOS 6.

Mark Haney
In reply to this post by Bob Harold

Well, I think I've found the issue, and it's not with dhcpd.  We originally had the log-facility option set to local7.  I'm thinking that this, coupled with the fact that the custom log we're creating caused it to log twice.  Once I removed the local7 logging most of that stopped. 

Now it only logs on a DHCPACK for most leases.  Turns out, we have a few of our customers with multiple routes to devices and that certain leases are being handled by two routers.  So, we'll get an ACK going out from the dhcp server to two different IPs.  So, it's not actually duplicate logging, just logging the same data from two different router IPs. 

So, everything looks good now.  Thanks for the help.


On 05/30/2017 12:05 PM, Bob Harold wrote:

On Tue, May 30, 2017 at 8:02 AM, Mark Haney <[hidden email]> wrote:

Well, it sort of works that way.  The issue now is it is logging it twice.  Which doesn't make sense to me in any way.  I only posted half the 'if' statement, but logically the else shouldn't matter.  Why is /on commit/ logging 2 (and sometimes 3) entries for one DHCPACK?  

That is really strange.  I am not seeing that behavior on my server.

-- 
Bob Harold

 
On 05/26/2017 03:23 PM, Bob Harold wrote:

On Fri, May 26, 2017 at 3:08 PM, Mark Haney <[hidden email]> wrote:
Okay, let me see if I get this straight, I should wrap the entire if statement inside an 'on commit {}' block?  


Yes

on commit {
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }
}

-- 
Bob Harold
 
On Fri, May 26, 2017 at 2:56 PM, Bob Harold <[hidden email]> wrote:

On Fri, May 26, 2017 at 11:38 AM, Mark Haney <[hidden email]> wrote:
We've got a custom log entry created that's based on whether the agent.circuit-id exists.  The problem is that the circuit-id gets included in DHCPDISCOVER and DHCPOFFER, so we're getting duplicate custom messages logged.  

What we want to do it create this custom log file, with the circuit-id only on the DHCPACK.  The log creation params are below.  We use this so that customers can get a web interface view of the current leases.  

Is there a way to do this with the latest CentOS 6 dhcpd package?

----
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }


--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:%28919%29%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank" moz-do-not-send="true">919-460-3330 (opt 1) • mark.haney@...
www.neonova.net    


Try wrapping that with:
   on commit {
   ...
   }

Then it should only happen once, when the lease is granted.

-- 
Bob Harold
 

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users



--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:%28919%29%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank" moz-do-not-send="true">919-460-3330 (opt 1) • [hidden email]
www.neonova.net    




_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Build a custom log entry on a DHCPACK CentOS 6.

Bob Harold
Glad to hear that you figured it out.

I usually have 2 routers on each subnet (HSRP), and each forwards to both DHCP servers in a failover pair.  But the servers know which should be answering and usually only log the commit once, although I see 4 copies of any broadcast packets from the client. (DHCPDISCOVER, and sometimes DHCPREQUEST).

-- 
Bob Harold


On Tue, May 30, 2017 at 12:40 PM, Mark Haney <[hidden email]> wrote:

Well, I think I've found the issue, and it's not with dhcpd.  We originally had the log-facility option set to local7.  I'm thinking that this, coupled with the fact that the custom log we're creating caused it to log twice.  Once I removed the local7 logging most of that stopped. 

Now it only logs on a DHCPACK for most leases.  Turns out, we have a few of our customers with multiple routes to devices and that certain leases are being handled by two routers.  So, we'll get an ACK going out from the dhcp server to two different IPs.  So, it's not actually duplicate logging, just logging the same data from two different router IPs. 

So, everything looks good now.  Thanks for the help.


On 05/30/2017 12:05 PM, Bob Harold wrote:

On Tue, May 30, 2017 at 8:02 AM, Mark Haney <[hidden email]> wrote:

Well, it sort of works that way.  The issue now is it is logging it twice.  Which doesn't make sense to me in any way.  I only posted half the 'if' statement, but logically the else shouldn't matter.  Why is /on commit/ logging 2 (and sometimes 3) entries for one DHCPACK?  

That is really strange.  I am not seeing that behavior on my server.

-- 
Bob Harold

 
On 05/26/2017 03:23 PM, Bob Harold wrote:

On Fri, May 26, 2017 at 3:08 PM, Mark Haney <[hidden email]> wrote:
Okay, let me see if I get this straight, I should wrap the entire if statement inside an 'on commit {}' block?  


Yes

on commit {
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }
}

-- 
Bob Harold
 
On Fri, May 26, 2017 at 2:56 PM, Bob Harold <[hidden email]> wrote:

On Fri, May 26, 2017 at 11:38 AM, Mark Haney <[hidden email]> wrote:
We've got a custom log entry created that's based on whether the agent.circuit-id exists.  The problem is that the circuit-id gets included in DHCPDISCOVER and DHCPOFFER, so we're getting duplicate custom messages logged.  

What we want to do it create this custom log file, with the circuit-id only on the DHCPACK.  The log creation params are below.  We use this so that customers can get a web interface view of the current leases.  

Is there a way to do this with the latest CentOS 6 dhcpd package?

----
if exists agent.circuit-id
 {
        log (info, concat( "DHCPUSER:,", concat (suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 1, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "",substring( hardware, 2, 1))),2), ":", suffix (concat ("0", binary-to-ascii(16, 8, "", substring( hardware, 3, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 4, 1))),2),":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 5, 1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8, "", substring( hardware, 6, 1))),2)), ",IP:,", binary-to-ascii (10, 8, ".", leased-address), ",CID:,", option agent.circuit-id));
 }


--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:%28919%29%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • mark.haney@...
www.neonova.net    


Try wrapping that with:
   on commit {
   ...
   }

Then it should only happen once, when the lease is granted.

-- 
Bob Harold
 

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users



--
photo
Mark Haney
Network Engineer at NeoNova
<a href="tel:%28919%29%20460-3330" value="+19194603330" style="color:rgb(17,85,204)" target="_blank">919-460-3330 (opt 1) • [hidden email]
www.neonova.net 



_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users