// Finished updating devices or creating them. Refresh the object with data from the DB $dev->GetDevice(); // Get any tags associated with this device $tags = $dev->GetTags(); if (count($tags) > 0) { // We have some tags so build the javascript elements we need to create the tags themselves $taginsert = "\t\ttags: {items: " . json_encode($tags) . "},\n"; } // Since a device exists we're gonna need some additional info, but only if it's not a copy if (!$copy) { // clearing errors for now $LastWattage = $LastRead = $upTime = 0; $pwrConnection->DeviceID = $dev->ParentDevice > 0 ? $dev->GetRootDeviceID() : $dev->DeviceID; $pwrCords = $pwrConnection->getPorts(); if ($dev->DeviceType == 'Switch') { $linkList = SwitchInfo::getPortStatus($dev->DeviceID); } elseif ($dev->DeviceType == 'CDU') { $pdu->PDUID = $dev->DeviceID; $pdu->GetPDU(); $lastreading = $pdu->GetLastReading(); $LastWattage = $lastreading ? $lastreading->Wattage : 0; $LastRead = $lastreading ? strftime("%c", strtotime($lastreading->LastRead)) : "Never"; } } if ($dev->ChassisSlots > 0 || $dev->RearChassisSlots > 0) { $childList = $dev->GetDeviceChildren(); } if ($dev->ParentDevice > 0) { $pDev = new Device(); $pDev->DeviceID = $dev->ParentDevice; $pDev->GetDevice();
static function getPortAlias($DeviceID, $portid = null) { if (!($dev = SwitchInfo::BasicTests($DeviceID))) { return false; } $baseOID = ".1.3.6.1.2.1.31.1.1.1.18."; $baseOID = "IF-MIB::ifAlias"; $aliasList = self::OSS_SNMP_Lookup($dev, "aliases", $portid, $baseOID); if (is_array($aliasList)) { $saving = false; $newList = array(); foreach ($aliasList as $i => $alias) { if ($i == $dev->FirstPortNum) { $saving = true; } if ($saving) { $newList[sizeof($newList) + 1] = $alias; } if (sizeof($newList) == $dev->Ports) { break; } } $aliasList = $newList; } return $aliasList; }
if ($devRow->Cabinet != $lastCabinet) { $cab->CabinetID = $devRow->Cabinet; $cab->GetCabinet(); $lastCabinet = $cab->CabinetID; $cabinet = $cab->Location; } if ($cab->DataCenterID != $lastDC) { $dc->DataCenterID = $cab->DataCenterID; $dc->GetDataCenter(); $lastDC = $dc->DataCenterID; $dataCenter = $dc->Name; } $port->DeviceID = $devRow->DeviceID; $activeCount = intval($port->getActivePortCount()); $portList = $port->getPorts(); $statusList = SwitchInfo::getPortStatus($devRow->DeviceID); if (sizeof($statusList) == sizeof($portList) && sizeof($portList) > 0) { for ($n = 0; $n <= sizeof($portList); $n++) { // The return from getPorts() is not a sequential array, it's associative, so you can't iterate through by number $currPort = array_shift($portList); if ($statusList[$n + 1] == "up" && ($currPort->Notes == "" && $currPort->ConnectedDeviceID == null) || $statusList[$n + 1] == "down" && ($currPort->Notes != "" || $currPort->ConnectedDeviceID != null)) { if ($currPort->ConnectedDeviceID > 0) { $dev->DeviceID = $currPort->ConnectedDeviceID; $dev->GetDevice(); $devAnchor = "<a href=\"" . $urlBase . "devices.php?DeviceID=" . $dev->DeviceID . "\">" . $dev->Label . "</a>"; $port->DeviceID = $currPort->ConnectedDeviceID; $port->PortNumber = $currPort->ConnectedPort; $port->getPort(); $portName = $port->Label; } else { $devAnchor = " ";