phpipam::report - Reporting module for phpIPAM
use phpipam::report;These are the steps to install the module
perl Makefile.PL
make
make installphpipam::report have some dependencies to other modules
This module will collect statistics from the phpIPAM database and generate a simple report with interesting information based on filters and thresholds given to the module.
None by default.
Create a new phpipam::report object
Get a summary of IP utilization within a subnet,section, or the entire phpIPAM. Default is to return a hash with utilization for all subnets in all sections. Options are
subnet => CIDR - IPv4 or IPv6 CIDR as stored in the database.
NOTE: phpipam::report does not do any calculations
on subnets, a subnet must exactly match what's in
the database.
section => section - Section name as stored in the database.
Section names are case sensitive.Get the number of free IP addresses. phpipam::report consider all unallocated addresses to be free, this means that * Active * Reserved * Offline * DHCP are all considered to be allocated addresses and are not counted. %options limit the scope to count for free addresses, options are
section => string - Section name as stored in the database.
Section names are case sensitive.
subnet => CIDR - IPv4 or IPv6 CIDR as stored in the database.
NOTE: phpipam does not do any calculations
on subnets, a subnet must exactly match what's in
the database.
vrf => [name|RD] - Name or Route-Distinguisher of the VRF to search in.
By default getFree will return all free addresses in all subnets.
my $free = $reporter->getFree({section => "Section1", subnet => "192.168.0.0/24"});getFree() will sort the subnets in VRF and Sections so you know what subnet you're currently looking at. An example structure will look something like this
$VAR1 = {
'GLOBAL' => {
'Section1' => {
'192.168.0.0/24' => bless( {
'value' => [
253
],
'sign' => '+'
}, 'Math::BigInt' ),
}
}
}Note that subnets that do not belong to any VRFs are automatically put in the GLOBAL vrf. Currently the number of free addresses are stored as a blessed Math::BigInt to be able to handle IPv6 subnets, as those numbers tend to be quite large... Just printing the number will be fine though
print "Free addresses: ". $free->{'GLOBAL'}->{'Section1'}->{'192.168.0.0/24'}."\n"Get the number of IP addresses that are marked as being 'Active' in $subnet.
$reporter->getActive("servers", "10.0.0.0/8");Get the number of IP addresses that are marked as being 'Reserved' in $subnet.
$reporter->getReserved("servers", "10.0.0.0/8");Get the number of IP addresses that are marked as being 'Offline' in $subnet.
$reporter->getOffline("servers", "10.0.0.0/8");Get the number of IP addresses that are marked as being 'DHCP' in $subnet.
$reporter->getDHCP("servers", "10.0.0.0/8");Get all IP addresses within a VRF, section or subnet that does not have a value for the required data column. This is useful if you have custom data fields that are mandatory in your phpIPAM installation. By default returns all addresses in all VRFs, sections and subnets if no options are given.
$reporter->getNoData({data => 'owner', section => "servers", subnet => "10.0.0.0/8"});%opts limit the scope for which addresses are searched, options are
section => string - Section name as stored in the database.
Section names are case sensitive.
subnet => CIDR - IPv4 or IPv6 CIDR as stored in the database.
NOTE: phpipam does not do any calculations
on subnets, a subnet must exactly match what's in
the database.
vrf => [name|RD] - Name or Route-Distinguisher of the VRF to search in.
data => name - A database column name in the ipaddresses table.
This can be any column, native or custom.By default getNoData will return all addresses in all subnets that does not have any a value set for the required data column.
my $addresses = $reporter->getNoData({data => 'dns_name'});getNoData() will sort the subnets in VRF and Sections so you know what subnet you're currently looking at. An example structure will look something like this
$VAR1 = {
'TestVRF' => {
'SectionA' => {
'192.168.0.0/24' => [
'192.168.0.1'
]
}
},
'GLOBAL' => {
'SectionB' => {
'172.20.1.0/24' => [
'172.20.1.10',
'172.20.1.11'
],
}
}
};Note that subnets that do not belong to any VRFs are automatically put in the GLOBAL vrf.
This is just a wrapper method to getNoData() for easier access. Actually, getNoDNS() calls getNoData() like this
return $self->getNoData({data => 'dns_name', %opts});All options and return values are exactly the same as to getNoData().
Perl module phpipam.
Diddi Oscarsson, <diddi@cyberbacon.net>
Copyright (C) 2013 by Diddi Oscarsson
The MIT License (MIT) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.