Infoblox::DHCP::Statistics - Manages DHCP statistics.


NAME

Infoblox::DHCP::Statistics - Manages DHCP statistics.


DESCRIPTION

The DHCP statistics object is used to view the DHCP statistics of the network in an Infoblox appliance.


CONSTRUCTOR

The Infoblox::DHCP::Statistics object is automatically generated upon the successful creation of the Infoblox::DHCP::Network object. It does not require manual construction.


SESSION METHODS

This section describes all the methods in an Infoblox::Session that can be applied to a DHCP statistics object.

Infoblox::Session->get( )

Use this method to retrieve the existing objects from an Infoblox appliance. See Infoblox::Session->get() for parameters and return values.

Key Reference
 Apply the following attributes to get the DHCP statistics:
 statistics_object - Required. An object returned via Infoblox::Session->get() or Infoblox::Session->search(). Supported objects are Infoblox::DHCP::Network, Infoblox::DHCP::Range, Infoblox::DHCP::SharedNetwork, and Infoblox::DHCP::MSSuperscope.
Example
  # API can return more than 1 answer for DHCP::Statistics
  # for each member of the network
  my @network_stats = $session->get(
           object            => "Infoblox::DHCP::Statistics",
           statistics_object => $network);


METHODS

This section describes all the methods that can be used to retrieve the attribute values of a DHCP statistics object.

available_hosts( )

Use this method to retrieve the number of available IP addresses in the given network.

Parameter

none

Returns

The method returns the attribute value.

Example
 #Get available_hosts
 my $available_hosts = $network_stats->available_hosts();

dynamic_hosts( )

Use this method to retrieve number of hosts which are assigned dynamic IP address.

Parameter

none

Returns

The method returns the attribute value.

Example
 #Get dynamic_hosts
 my $dynamic_hosts = $network_stats->dynamic_hosts();

dhcp_utilization_status( )

Use this method to retrieve the DHCP utilization status.

Parameter

none

Returns

The method returns the attribute value. The returned value is one of "FULL", "HIGH", "LOW" or "NORMAL".

Example
 #Get member
 my $status = $network_stats->dhcp_utilization_status();

static_hosts( )

Use this method to retrieve the number of hosts with fixed addresses.

Parameter

none

Returns

The method returns the attribute value.

Example
 #Get static_hosts
 my $static_hosts = $network_stats->static_hosts();

usage( )

Use this method to retrieve the percentage used of DHCP addresses in the network.

Parameter

none

Returns

The method returns the attribute value.

Example
 #Get usage
 my $usage = $network_stats->usage();


SAMPLE CODE

The following sample code demonstrates the get session method on a DHCP statistics object. Also, this sample code also includes error handling for the operations.

 #PROGRAM STARTS: Include all the modules that will be used
 use strict;
 use Infoblox;

#Preparation prior to getting DHCP statistics

 #Create a session to the Infoblox appliance
 my $session = Infoblox::Session->new(
     master   => "192.168.1.2",
     username => "admin",
     password => "infoblox"
 );
 unless ($session) {
    die("Construct session failed: ",
        Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Session created successfully\n";
 my $member = Infoblox::DHCP::Member->new(
     name     => "infoblox.localdomain",
     ipv4addr => "192.168.1.2",
 );
 unless($member) {
      die("Construct member failed: ",
            Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Member object created successfully\n";
 #Create a Network View object
 my $network_view = Infoblox::DHCP::View->new(
                     name => "my_network_view",
 );
 unless($network_view) {
             die("Construct Network View object failed: ",
                   Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Network View object created successfully\n";
 #Add the Network View object into the Infoblox appliance through a session
 $session->add($network_view)
      or die("Add Network View object failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "Network View added successfully\n";
 #Create the Network object with this member
 my $network = Infoblox::DHCP::Network->new(
                     network => "1.0.0.0/255.0.0.0",
                     members => [ $member ],
                     network_view => $network_view,
 );
 unless($network) {
             die("Construct Network object failed: ",
                   Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Network object created successfully\n";
 #Add the Network object into the Infoblox appliance through a session
 $session->add($network)
      or die("Add Network object failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "Network added successfully\n";
 #Create the DHCP Range object with this member
 my $dhcp_range = Infoblox::DHCP::Range->new(
     network    => "1.0.0.0/8",
     start_addr => "1.0.0.1",
     end_addr   => "1.0.0.10",
     member     => $member,
     network_view => $network_view,
 );
 unless($dhcp_range) {
      die("Construct DHCP Range failed: ",
            Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "DHCP range object created successfully\n";
 $session->add($dhcp_range)
      or die("Add DHCP range object failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "DHCP range added successfully\n";
 #Create the Fixed Address object
 my $fixed_address = Infoblox::DHCP::FixedAddr->new(
                                                "network" => "1.0.0.0/8",
                                                "ipv4addr" => "1.0.0.2",
                                                "mac" => "22:22:22:22:22:22",
                                                "network_view" => $network_view,
                                                );
 unless($fixed_address) {
      die("Construct DHCP Fixed address failed: ",
            Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "DHCP Fixed address object created successfully\n";
 $session->add($fixed_address)
      or die("Add DHCP Fixed address object failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "DHCP Fixed address added successfully\n";

#Get the DHCP statistics

  my  @result_array = $session->get(
      object  => "Infoblox::DHCP::Network",
      network => "1.0.0.0/8",
      network_view => "my_network_view");
  my $network = $result_array[0];
  unless ($network) {
      die("Get Network failed: ",
          $session->status_code() . ":" . $session->status_detail());
  }
  @result_array = $session->get(
                                object  => "Infoblox::DHCP::Statistics",
                                statistics_object  => $network,
                               );
  my $network_stats = $result_array[0];
  unless ($network_stats) {
      die("Get Network statistics failed: ",
          $session->status_code() . ":" . $session->status_detail());
  }
  print "Get Network Statistics successful\n";

#Clean up # Remove the Network Statistics object that was just retrieved $session->remove($network_stats);

  # Retrieve and remove the Network View object
  my $network_view = $session->get(
          object => "Infoblox::DHCP::View",
          name => "my_network_view",
  );
  unless ($network_view) {
       die("Get Network View failed: ",
             $session->status_code() . ":" . $session->status_detail());
  }
  $session->remove($network_view);
 ####PROGRAM ENDS####


AUTHOR

Infoblox Inc. http://www.infoblox.com/


SEE ALSO

Infoblox::Session, Infoblox::DHCP::Network,Infoblox::DHCP::View,Infoblox::DHCP::FixedAddr,Infoblox::DHCP::Range,Infoblox::Session->add(),Infoblox::Session->get()


COPYRIGHT

Copyright (c) 2017 Infoblox Inc.