Skip to content

Commit

Permalink
Added a few StatsD calls in dhcp processor.
Browse files Browse the repository at this point in the history
  • Loading branch information
louismunro committed Jan 12, 2016
1 parent 6b28a9c commit f3a4447
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/pf/dhcp/processor.pm
Expand Up @@ -37,6 +37,8 @@ use pf::api::jsonrpcclient;
use NetAddr::IP;
use pf::SwitchFactory;
use pf::log;
use pf::util::statsd qw(called);

This comment has been minimized.

Copy link
@fdurand

fdurand Jan 13, 2016

Member

is it really useful ?

This comment has been minimized.

Copy link
@jrouzierinverse

jrouzierinverse Jan 13, 2016

Member

Not for this case

This comment has been minimized.

Copy link
@louismunro

louismunro Jan 13, 2016

Author Contributor

Good point.
I will remove it.

use pf::StatsD::Timer;

our $logger = get_logger;
my $ROGUE_DHCP_TRIGGER = '1100010';
Expand Down Expand Up @@ -129,6 +131,7 @@ Process a packet
=cut

sub process_packet {
my $timer = pf::StatsD::Timer->new();
my ( $self ) = @_;

my ($dhcp);
Expand Down Expand Up @@ -264,6 +267,7 @@ sub parse_dhcp_discover {
=cut

sub parse_dhcp_offer {
my $timer = pf::StatsD::Timer->new();
my ($self, $dhcp) = @_;

if ($dhcp->{'yiaddr'} =~ /^0\.0\.0\.0$/) {
Expand All @@ -281,6 +285,7 @@ sub parse_dhcp_offer {
=cut

sub parse_dhcp_request {
my $timer = pf::StatsD::Timer->new();
my ($self, $dhcp) = @_;
$logger->debug("DHCPREQUEST from $dhcp->{'chaddr'}");

Expand Down Expand Up @@ -322,6 +327,7 @@ sub parse_dhcp_request {
=cut

sub parse_dhcp_ack {
my $timer = pf::StatsD::Timer->new();
my ($self, $dhcp) = @_;

my $s_ip = $dhcp->{'src_ip'};
Expand Down Expand Up @@ -395,6 +401,7 @@ Handle the tasks related to a device getting an IP address
=cut

sub handle_new_ip {
my $timer = pf::StatsD::Timer->new();
my ($self, $client_mac, $client_ip, $lease_length) = @_;
$logger->info("Updating iplog and SSO for $client_mac -> $client_ip");
$self->update_iplog( $client_mac, $client_ip, $lease_length );
Expand All @@ -414,6 +421,7 @@ sub handle_new_ip {
=cut

sub parse_dhcp_release {
my $timer = pf::StatsD::Timer->new();
my ($self, $dhcp) = @_;
$logger->debug("DHCPRELEASE from $dhcp->{'chaddr'} ($dhcp->{ciaddr})");
$self->{api_client}->notify('close_iplog',$dhcp->{'ciaddr'});
Expand All @@ -437,6 +445,7 @@ Optional but very useful DHCP Server MAC
=cut

sub rogue_dhcp_handling {
my $timer = pf::StatsD::Timer->new();
my ($self, $dhcp_srv_ip, $dhcp_srv_mac, $offered_ip, $client_mac, $relay_ip) = @_;

return if (isdisabled($Config{'network'}{'rogue_dhcp_detection'}));
Expand Down Expand Up @@ -536,6 +545,7 @@ Option 82 is Relay Agent Information. Defined in RFC 3046.
=cut

sub parse_dhcp_option82 {
my $timer = pf::StatsD::Timer->new();
my ($self, $dhcp) = @_;

# slicing the hash to retrive the stuff we are interested in
Expand All @@ -556,6 +566,7 @@ Also handles the SSO stop if the IP changes
=cut

sub update_iplog {
my $timer = pf::StatsD::Timer->new();
my ( $self, $srcmac, $srcip, $lease_length ) = @_;
$logger->debug("$srcip && $srcmac");

Expand Down

0 comments on commit f3a4447

Please sign in to comment.