function _putcatalog()
    {
        parent::_putcatalog();
        if (count($this->outlines) > 0) {
            $this->_out('/Outlines ' . $this->OutlineRoot . ' 0 R');
            $this->_out('/PageMode /UseOutlines');
        }
    }
}
//
//
//	Begin Report Generation
//
//
$pan = new PowerPanel();
$pdu = new PowerDistribution();
$dev = new Device();
$cab = new Cabinet();
$dept = new Department();
$dc = new DataCenter();
$pdf = new PDF();
$pdf->AliasNbPages();
include_once "loadfonts.php";
$pdf->SetFont($config->ParameterArray['PDFfont'], '', 8);
$pdf->SetFillColor(0, 0, 0);
$pdf->SetTextColor(255);
$pdf->SetDrawColor(128, 0, 0);
$pdf->SetLineWidth(0.3);
$pdf->SetfillColor(224, 235, 255);
$pdf->SetTextColor(0);
$pdf->Bookmark('Data Centers');
예제 #2
0
<?php 
    include 'header.inc.php';
    ?>
	<div class="page">
<?php 
    include 'sidebar.inc.php';
    echo '		<div class="main">
			<div class="center">
				<div id="tablecontainer">';
    //
    //
    //	Begin Report Generation
    //
    //
    $pan = new PowerPanel();
    $pdu = new PowerDistribution();
    $dev = new Device();
    $cab = new Cabinet();
    $tmpPerson = new People();
    $dept = new Department();
    $dc = new DataCenter();
    // Make some quick user defined sort comparisons for this report only
    function compareCab($a, $b)
    {
        if ($a->Location == $b->Location) {
            return 0;
        }
        return $a->Location > $b->Location ? +1 : -1;
    }
    $dc->DataCenterID = intval($_REQUEST['datacenterid']);
    $dc->GetDataCenter();
예제 #3
0
 function GetDeviceDiversity()
 {
     global $dbh;
     $pc = new PowerConnection();
     $PDU = new PowerDistribution();
     // If this is a child (card slot) device, then only the parent will have power connections defined
     if ($this->ParentDevice > 0) {
         $tmpDev = new Device();
         $tmpDev->DeviceID = $this->ParentDevice;
         $sourceList = $tmpDev->GetDeviceDiversity();
     } else {
         $pc->DeviceID = $this->DeviceID;
         $pcList = $pc->GetConnectionsByDevice();
         $sourceList = array();
         $sourceCount = 0;
         foreach ($pcList as $pcRow) {
             $PDU->PDUID = $pcRow->PDUID;
             $powerSource = $PDU->GetSourceForPDU();
             if (!in_array($powerSource, $sourceList)) {
                 $sourceList[$sourceCount++] = $powerSource;
             }
         }
     }
     return $sourceList;
 }
예제 #4
0
                 $rpcolor = $rs;
             } elseif ($pp > $RealPowerYellow) {
                 $rpcolor = $ys;
             } else {
                 $rpcolor = $gs;
             }
             $tooltip .= "<li class=\"{$rpcolor}\">{$label}: {$pp}%</li>\n";
         }
         $tooltip .= "<li class=\"{$tcolor}\">" . __("Temperature") . ": {$labelte}</li>\n";
         $tooltip .= "<li class=\"{$hcolor}\">" . __("Humidity") . ": {$labelhu}</li></ul>\n";
     } else {
         $tooltip = __("Quit that! You don't have rights to view this.");
     }
 } elseif (isset($_POST['cdu']) || isset($_POST['dev'])) {
     if (isset($_POST['cdu']) && $config->ParameterArray["CDUToolTips"] == 'enabled') {
         $pdu = new PowerDistribution();
         $pdu->PDUID = $object;
         $pdu->GetPDU();
         $ttconfig = $dbh->query("SELECT * FROM fac_CDUToolTip WHERE Enabled=1 ORDER BY SortOrder ASC, Enabled DESC, Label ASC;");
         $tooltip = __("Name") . ": " . $pdu->Label . "<br>\n";
     } elseif ($config->ParameterArray["ToolTips"] == 'enabled') {
         $dev = new Device();
         $dev->DeviceID = $object;
         $dev->GetDevice();
         if ($dev->Rights == 'None') {
             print __("Details Restricted");
             exit;
         }
         $ttconfig = $dbh->query("SELECT * FROM fac_CabinetToolTip WHERE Enabled=1 ORDER BY SortOrder ASC, Enabled DESC, Label ASC;");
         $tooltip = __("Name") . ": " . $dev->Label . "<br>\n";
     }
예제 #5
0
        }
    }
    header('Content-Type: application/json');
    echo json_encode($wattage);
    exit;
}
// END AJAX
// These objects are used no matter what operation we're performing
$templ = new DeviceTemplate();
$mfg = new Manufacturer();
$esc = new Escalations();
$escTime = new EscalationTimes();
$contactList = $person->GetUserList();
$Dept = new Department();
$pwrConnection = new PowerPorts();
$pdu = new PowerDistribution();
$panel = new PowerPanel();
$pwrCords = null;
$chassis = "";
$copy = false;
$copyerr = __("This device is a copy of an existing device.  Remember to set the new location before saving.");
$childList = array();
// This page was called from somewhere so let's do stuff.
// If this page wasn't called then present a blank record for device creation.
if (isset($_REQUEST['action']) || isset($_REQUEST['DeviceID'])) {
    if (isset($_REQUEST['CabinetID'])) {
        $dev->Cabinet = $_REQUEST['CabinetID'];
        $cab->CabinetID = $dev->Cabinet;
        $cab->GetCabinet();
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'new') {
예제 #6
0
 function GetSmartCDUVersion()
 {
     if (!($dev = PowerDistribution::BasicTests($this->PDUID))) {
         return false;
     }
     if (!$this->GetPDU()) {
         return false;
     }
     $template = new CDUTemplate();
     $template->TemplateID = $this->TemplateID;
     if (!$template->GetTemplate()) {
         return false;
     }
     return self::OSS_SNMP_Lookup($dev, null, "{$template->VersionOID}");
 }
예제 #7
0
    // This cabinet belongs to a department you don't have affiliation with, so no viewing at all
    header('Location: ' . redirect());
    exit;
}
// If you're deleting the cabinet, no need to pull in the rest of the information, so get it out of the way
// Only a site administrator can create or delete a cabinet
if (isset($_POST["delete"]) && $_POST["delete"] == "yes" && $person->SiteAdmin) {
    $cab->DeleteCabinet();
    header('Content-Type: application/json');
    echo json_encode(array('url' => redirect("dc_stats.php?dc={$cab->DataCenterID}")));
    exit;
}
$head = $legend = $zeroheight = $body = $deptcolor = $AuditorName = "";
$audit = new CabinetAudit();
$dev = new Device();
$pdu = new PowerDistribution();
$pan = new PowerPanel();
$templ = new DeviceTemplate();
$tempPDU = new PowerDistribution();
$tempDept = new Department();
$dc = new DataCenter();
$dcID = $cab->DataCenterID;
$dc->DataCenterID = $dcID;
$dc->GetDataCenterbyID();
$audit->CabinetID = $cab->CabinetID;
// You just have WriteAccess in order to perform/certify a rack audit
if (isset($_POST["audit"]) && $_POST["audit"] == "yes" && $person->CanWrite($cab->AssignedTo)) {
    $audit->Comments = sanitize($_POST["comments"]);
    // Log the response
    $audit->CertifyAudit();
    // I'm lazy as f**k so retrieve what we just wrong
function processPDUList($list, $start, $increment)
{
    global $dbh;
    $dev = new Device();
    $cdu = new PowerDistribution();
    for ($n = $start; $n < sizeof($list); $n = $n + $increment) {
        $row = $list[$n];
        // Just send back zero if we don't get a result.
        $pollValue1 = $pollValue2 = $pollValue3 = 0;
        $dev->DeviceID = $row["PDUID"];
        $dev->GetDevice();
        $pollValue1 = floatval(OSS_SNMP_Lookup($dev, null, $row["OID1"]));
        // We won't use OID2 or 3 without the other so make sure both are set or just ignore them
        if ($row["OID2"] != "" && $row["OID3"] != "") {
            $pollValue2 = floatval(OSS_SNMP_Lookup($dev, null, $row["OID2"]));
            $pollValue3 = floatval(OSS_SNMP_Lookup($dev, null, $row["OID3"]));
            // Negativity test, it is required for APC 3ph modular PDU with IEC309-5W wires
            if ($pollValue2 < 0) {
                $pollValue2 = 0;
            }
            if ($pollValue3 < 0) {
                $pollValue3 = 0;
            }
        }
        // Have to reset this every time, otherwise the exec() will append
        unset($statsOutput);
        $amps = 0;
        $watts = 0;
        if ($pollValue1) {
            // The multiplier should be an int but no telling what voodoo the db might cause
            $multiplier = floatval($row["Multiplier"]);
            $voltage = intval($row["Voltage"]);
            switch ($row["ProcessingProfile"]) {
                case "SingleOIDAmperes":
                    $amps = $pollValue1 / $multiplier;
                    $watts = $amps * $voltage;
                    break;
                case "Combine3OIDAmperes":
                    $amps = ($pollValue1 + $pollValue2 + $pollValue3) / $multiplier;
                    $watts = $amps * $voltage;
                    break;
                case "Convert3PhAmperes":
                    // OO does this next formula need another set of () to be clear?
                    $amps = ($pollValue1 + $pollValue2 + $pollValue3) / $multiplier / 3;
                    $watts = $amps * 1.732 * $voltage;
                    break;
                case "Combine3OIDWatts":
                    $watts = ($pollValue1 + $pollValue2 + $pollValue3) / $multiplier;
                    break;
                default:
                    $watts = $pollValue1 / $multiplier;
                    break;
            }
        }
        $sql = "INSERT INTO fac_PDUStats SET PDUID={$row["PDUID"]}, Wattage={$watts}, \n\t\t\t\t\tLastRead=now() ON DUPLICATE KEY UPDATE Wattage={$watts}, LastRead=now();";
        if (!$dbh->query($sql)) {
            $info = $dbh->errorInfo();
            error_log("Poll_PDU_Stats-Multiprocess::PDO Error: {$info[2]} SQL={$sql}");
        }
    }
    $cdu->PDUID = $row["PDUID"];
    if ($ver = $cdu->GetSmartCDUVersion()) {
        $sql = "UPDATE fac_PowerDistribution SET FirmwareVersion=\"{$ver}\" WHERE PDUID={$cdu->PDUID};";
        if (!$dbh->query($sql)) {
            $info = $dbh->errorInfo();
            error_log("Poll_PDU_Stats-Multiprocess::PDO Error: {$info[2]} SQL={$sql}");
        }
    }
}
예제 #9
0
    if (isset($_POST['con']) && isset($_POST['pduid'])) {
        $pwrConnection = new PowerConnection();
        $pwrConnection->DeviceID = $_POST['DeviceID'];
        $pwrConnection->PDUID = $_POST['pduid'];
        $pwrConnection->PDUPosition = $_POST['con'];
        $pwrConnection->DeviceConnNumber = $_POST['power'];
        if (isset($_POST['e'])) {
            $pwrConnection->CreateConnection();
        } else {
            $pwrConnection->RemoveConnection();
        }
        echo 'ok';
    } else {
        $dev = new Device();
        $pwrConnection = new PowerConnection();
        $pdu = new PowerDistribution();
        $dev->DeviceID = $_POST['DeviceID'];
        $dev->GetDevice();
        $pwrConnection->DeviceID = $dev->ParentDevice > 0 ? $dev->ParentDevice : $dev->DeviceID;
        $pwrCords = $pwrConnection->GetConnectionsByDevice();
        print "<span>Server Name: {$dev->Label}</span><span># Power Supplies: {$dev->PowerSupplyCount}</span><div class=\"table border\">\n\t\t\t<div><div>" . __("Power Strip") . "</div><div>" . __("Plug #") . "</div><div>" . __("Power Supply") . "</div></div>";
        foreach ($pwrCords as $cord) {
            $pdu->PDUID = $cord->PDUID;
            $pdu->GetPDU();
            print "\t\t\t<div><div data=\"{$pdu->PDUID}\"><a href=\"power_pdu.php?pduid={$pdu->PDUID}\">{$pdu->Label}</a></div><div><a href=\"power_connection.php?pdu={$pdu->PDUID}&conn={$cord->PDUPosition}\">{$cord->PDUPosition}</a></div><div" . ($cord->DeviceConnNumber == $_POST['power'] ? ' class="bold"' : ' class="disabled"') . ">{$cord->DeviceConnNumber}</div></div>\n";
        }
        print "</div>";
    }
    exit;
}
if (isset($_POST['EndpointDeviceID'])) {
예제 #10
0
 function GetDCStatistics()
 {
     $this->GetDataCenter();
     $sql = "SELECT SUM(CabinetHeight) as TotalU FROM fac_Cabinet WHERE \n\t\t\tDataCenterID={$this->DataCenterID};";
     $dcStats["TotalU"] = ($test = $this->query($sql)->fetchColumn()) ? $test : 0;
     $sql = "SELECT SUM(a.Height) as TotalU FROM fac_Device a,fac_Cabinet b WHERE \n\t\t\ta.Cabinet=b.CabinetID AND b.DataCenterID={$this->DataCenterID} AND \n\t\t\ta.DeviceType NOT IN ('Server','Storage Array');";
     $dcStats["Infrastructure"] = ($test = $this->query($sql)->fetchColumn()) ? $test : 0;
     $sql = "SELECT SUM(a.Height) as TotalU FROM fac_Device a,fac_Cabinet b WHERE \n\t\t\ta.Cabinet=b.CabinetID AND b.DataCenterID={$this->DataCenterID} AND \n\t\t\ta.Reservation=false AND a.DeviceType IN ('Server', 'Storage Array');";
     $dcStats["Occupied"] = ($test = $this->query($sql)->fetchColumn()) ? $test : 0;
     $sql = "SELECT SUM(a.Height) FROM fac_Device a,fac_Cabinet b WHERE\n\t\t\ta.Cabinet=b.CabinetID AND a.Reservation=true AND b.DataCenterID={$this->DataCenterID};";
     $dcStats["Allocated"] = ($test = $this->query($sql)->fetchColumn()) ? $test : 0;
     $dcStats["Available"] = $dcStats["TotalU"] - $dcStats["Occupied"] - $dcStats["Infrastructure"] - $dcStats["Allocated"];
     // Perform two queries - one is for the wattage overrides (where NominalWatts > 0) and one for the template (default) values
     $sql = "SELECT SUM(NominalWatts) as TotalWatts FROM fac_Device a,fac_Cabinet b WHERE \n\t\t\ta.Cabinet=b.CabinetID AND a.NominalWatts>0 AND \n\t\t\tb.DataCenterID={$this->DataCenterID};";
     $dcStats["ComputedWatts"] = ($test = $this->query($sql)->fetchColumn()) ? $test : 0;
     $sql = "SELECT SUM(c.Wattage) as TotalWatts FROM fac_Device a, fac_Cabinet b, \n\t\t\tfac_DeviceTemplate c WHERE a.Cabinet=b.CabinetID AND \n\t\t\ta.TemplateID=c.TemplateID AND a.NominalWatts=0 AND \n\t\t\tb.DataCenterID={$this->DataCenterID};";
     $dcStats["ComputedWatts"] += ($test = $this->query($sql)->fetchColumn()) ? $test : 0;
     $sql = "SELECT AVG(NULLIF(a.Temperature, 0)) as AvgTemp FROM fac_SensorReadings a, fac_Cabinet b, fac_Device c\n\t\t\tWHERE a.DeviceID=c.DeviceID and c.Cabinet=b.CabinetID AND c.BackSide=0 AND\n\t\t\tb.DataCenterID={$this->DataCenterID};";
     $dcStats["AvgTemp"] = ($test = round($this->query($sql)->fetchColumn())) ? $test : 0;
     $sql = "SELECT AVG(NULLIF(a.Humidity, 0)) as AvgHumidity FROM fac_SensorReadings a, fac_Cabinet b, fac_Device c\n\t\t\tWHERE a.DeviceID=c.DeviceID and c.BackSide=0 and c.Cabinet=b.CabinetID AND\n\t\t\tb.DataCenterID={$this->DataCenterID};";
     $dcStats["AvgHumidity"] = ($test = round($this->query($sql)->fetchColumn())) ? $test : 0;
     $pdu = new PowerDistribution();
     $dcStats["MeasuredWatts"] = $pdu->GetWattageByDC($this->DataCenterID);
     return $dcStats;
 }
예제 #11
0
<?php

require 'db.inc.php';
require 'facilities.inc.php';
$PDU = new PowerDistribution();
$PDU->UpdateStats();