Exemplo n.º 1
0
<?php

/*
 * Script to print pie graph for subnet usage
 ********************************************/
# if slaves reset IP addresses!
$slaves = getAllSlaveSubnetsBySubnetId($subnetId);
# check number of hosts for all subnets, including sub-subnets!
if (sizeof($slaves) > 0) {
    $ipaddresses = getIpAddressesBySubnetIdSlavesSort($subnetId);
}
# for statistics we need to deduct 2 for each subnet bigger than /31
$d = 0;
foreach ($slaves as $s) {
    if ($s['mask'] < 31) {
        $d = $d + 2;
    }
}
# get offline, reserved and DHCP
$out['offline'] = 0;
$out['online'] = 0;
$out['reserved'] = 0;
$out['dhcp'] = 0;
foreach ($ipaddresses as $ip) {
    if ($ip['state'] == "0") {
        $out['offline']++;
    } else {
        if ($ip['state'] == "1") {
            $out['online']++;
        } else {
            if ($ip['state'] == "2") {
Exemplo n.º 2
0
/* verify that user is authenticated! */
isUserAuthenticated();
/* get all selected fields for IP print */
$setFields = getSelectedIPaddrFields();
/* format them to array! */
$setFields = explode(";", $setFields);
/**
 * Get all ip addresses in subnet and subnet details!
 */
$title = _("IP addresses in subnet ");
# prefix for multiple subnets
if (sizeof($slaves) == 0) {
    $ipaddresses = getIpAddressesBySubnetIdSort($subnetId, $sort['field'], $sort['direction']);
    $slavePing = false;
} else {
    $ipaddresses = getIpAddressesBySubnetIdSlavesSort($subnetId, $sort['field'], $sort['direction']);
    $title = _("All IP addresses belonging to ALL nested subnets");
    $slavePing = true;
}
$SubnetDetails = getSubnetDetailsById($subnetId);
/* die if empty! */
if (sizeof($SubnetDetails) == 0) {
    die('<div class="alert alert-danger">' . _('Subnet does not exist') . '!</div>');
}
/* get all selected fields */
$myFields = getCustomFields('ipaddresses');
$myFieldsSize = sizeof($myFields);
/* set size of selected fields */
$selFieldsSize = sizeof($setFields);
if (in_array('state', $setFields)) {
    $selFieldsSize--;
Exemplo n.º 3
0
 # reformat empty VLAN
 if (empty($slave['VLAN']) || $slave['VLAN'] == 0 || strlen($slave['VLAN']) == 0) {
     $slave['VLAN'] = "/";
 }
 # get VLAN details
 $slave['VLAN'] = subnetGetVLANdetailsById($slave['vlanId']);
 $slave['VLAN'] = $slave['VLAN']['number'];
 print "<tr>";
 print "\t<td class='small'>{$slave['VLAN']}</td>";
 print "\t<td class='small description'><a href='" . create_link("subnets", $section['id'], $slave['id']) . "'>{$slave['description']}</a></td>";
 print "\t<td><a href='" . create_link("subnets", $section['id'], $slave['id']) . "'>" . transform2long($slave['subnet']) . "/{$slave['mask']}</a></td>";
 # count IP addresses
 $hasSlaves = getAllSlaveSubnetsBySubnetId($slave['id']);
 # slaves details are provided with ipaddressprintslaves script
 if (sizeof($hasSlaves) > 0) {
     $ipCount = sizeof(getIpAddressesBySubnetIdSlavesSort($slave['id']));
 } else {
     $ipCount = countIpAddressesBySubnetId($slave['id']);
 }
 //ip count - direct subnet
 $calculate = calculateSubnetDetails(gmp_strval($ipCount), $slave['mask'], $slave['subnet']);
 print ' <td class="small hidden-xs hidden-sm">' . $calculate['used'] . '/' . $calculate['maxhosts'] . '</td>' . "\n";
 print '	<td class="small hidden-xs hidden-sm">' . $calculate['freehosts_percent'] . '</td>';
 # add to sum if IPv4
 if (IdentifyAddress($slave['subnet']) == "IPv4") {
     $usedSum = $usedSum + $calculate['used'];
     $allSum = $allSum + $calculate['maxhosts'];
 }
 # allow requests
 if ($slave['allowRequests'] == 1) {
     print '<td class="allowRequests small hidden-xs hidden-sm"><i class="fa fa-gray fa-check"></i></td>';