if (!$ProdPic) { $ProdPic = "ext_inc/noc/switch.gif"; } // Set the manufacturer Picture $smarty->assign('image', $ProdPic); //Mac-Addressen auslesen $noc->getMacAddress($row["ip"], $row["readcommunity"], $row["id"], $row["sysDescr"]); // Get the Ports and display 'em $db->qry("SELECT name FROM %prefix%noc_devices WHERE id = %int%", $_GET["deviceid"]); $row = $db->fetch_array(); // Ports are all saved into 1 template variable $ports = "<tr align=\"center\">"; $port_query = $db->qry("SELECT portnr, portid, linkstatus, adminstatus, speed, type, indexname FROM %prefix%noc_ports WHERE deviceid = %int% AND type != 'system' ORDER BY portnr ASC", $_GET["deviceid"]); $Portcount = 1; while ($row = $db->fetch_array($port_query)) { $Port["LinkStatus"] = $noc->getSNMPValue($device_ip, $readcommunity, ".1.3.6.1.2.1.2.2.1.8." . $row["portnr"]); $Port["AdminStatus"] = $noc->getSNMPValue($device_ip, $readcommunity, ".1.3.6.1.2.1.2.2.1.7." . $row["portnr"]); if ($Port["LinkStatus"] != $row["linkstatus"]) { $db->qry_first("UPDATE %prefix%noc_ports SET linkstatus=%string% WHERE portid=%int%", $Port["LinkStatus"], $row["portid"]); $row["linkstatus"] = $Port["LinkStatus"]; } if ($Port["AdminStatus"] != $row["adminstatus"]) { $db->qry_first("UPDATE %prefix%noc_ports SET adminstatus=%string% WHERE portid=%int%", $Port["AdminStatus"], $row["portid"]); $row["adminstatus"] = $Port["AdminStatus"]; } // LWL Ports are as double as wide as rj45 ports if ($row["type"] == "lwl") { $colspan = "2"; } if ($row["type"] == "rj45") { $colspan = "1";
$dsp->AddContent(); } //port exists break; case 2: $func->question(t('Bist du sicher, dass du den Status dieses Ports ändern willst?'), "index.php?mod=noc&action=port_details&portid={$_GET["portid"]}&step=3", "index.php?mod=noc&action=port_details&portid={$_GET["portid"]}"); break; // 3 stands for change the port "status" (deactivate it, regulate the speed, and so on) // 3 stands for change the port "status" (deactivate it, regulate the speed, and so on) case 3: $port = $db->qry_first("SELECT portid, deviceid, portnr, adminstatus FROM %prefix%noc_ports WHERE portid = %int%", $_GET["portid"]); if ($port["portid"] == "") { $func->error(t('Dieser Port existiert nicht')); } else { $device = $db->qry_first("SELECT name, readcommunity, writecommunity, ip FROM %prefix%noc_devices WHERE id = %int%", $port['deviceid']); $status = $noc->getSNMPValue($device["ip"], $device["readcommunity"], ".1.3.6.1.2.1.2.2.1.7.{$port["portnr"]}"); switch ($status) { case "1": case "up": case "up(1)": $newstatus = "2"; $statusdescr = "<font color=\"red\">" . t('deaktiviert') . "</font>"; $statusdb = "down(2)"; break; case "2": case "down": case "down(2)": $newstatus = "1"; $statusdescr = "<font color=\"green\">" . t('aktiviert') . "</font>"; $statusdb = "up(1)"; break;
case 2: if ($noc->checkSNMPDevice($_POST["device_ip"], $_POST["device_read"]) != 1) { $func->error(t('HTML_NEWLINEDas Device konnte nicht erreicht werden. Mögl. Ursachen:HTML_NEWLINEHTML_NEWLINE - Das Device hat keinen StromHTML_NEWLINE - Das Device hat noch keine IP-AdresseHTML_NEWLINE - Das Device unterstützt kein SNMPHTML_NEWLINE - Du hast eine falsche Read-Community angegebenHTML_NEWLINE - Du hast eine falsche IP-Adresse angegebenHTML_NEWLINE - Du hast vergessen, SNMP am device einzuschaltenHTML_NEWLINE - Dieses PHP unterstützt kein SNMP, kompilieren sie es mit SNMPHTML_NEWLINE oder laden sie sich ein vorkompiliertes PHP mit SNMP vonHTML_NEWLINE <a href="http://de.php.net">Der Deutschen PHP Seite</a> herunterHTML_NEWLINE, '), "index.php?mod=noc&action=add_device&step=1"); break; } // Fetched Vars from SNMP from tha device $sysDescr = $noc->getSNMPValue($_POST["device_ip"], $_POST["device_read"], ".1.3.6.1.2.1.1.1.0"); $sysContact = $noc->getSNMPValue($_POST["device_ip"], $_POST["device_read"], ".1.3.6.1.2.1.1.4.0"); $sysUpTime = $noc->getSNMPValue($_POST["device_ip"], $_POST["device_read"], ".1.3.6.1.2.1.1.3.0"); $sysLocation = $noc->getSNMPValue($_POST["device_ip"], $_POST["device_read"], ".1.3.6.1.2.1.1.6.0"); $sysName = $noc->getSNMPValue($_POST["device_ip"], $_POST["device_read"], ".1.3.6.1.2.1.1.5.0"); $ports = $noc->getSNMPwalk($_POST["device_ip"], $_POST["device_read"], ".1.3.6.1.2.1.2.2.1.1"); $numport = count($ports); // Store the device into a SQL table $add_query = $db->qry("INSERT INTO %prefix%noc_devices SET\n name = %string%,\n ip = %string%,\n readcommunity = %string%,\n writecommunity = %string%,\n sysDescr = %string%,\n sysContact = %string%,\n sysUpTime = %string%,\n sysLocation = %string%,\n sysName = %string%,\n ports = %string%\n ", $_POST['device_caption'], $_POST['device_ip'], $_POST['device_read'], $_POST['device_write'], $sysDescr, $sysContact, $sysUpTime, $sysLocation, $sysName, $numport); $db->qry("SELECT id, ip, readcommunity FROM %prefix%noc_devices WHERE name=%string%", $_POST["device_caption"]); $row = $db->fetch_array(); for ($ActualPort = 0; $ActualPort < count($ports); $ActualPort++) { $Port[$ActualPort]["deviceid"] = $row["id"]; $Port[$ActualPort]["PortNr"] = $noc->getSNMPValue($row["ip"], $row["readcommunity"], ".1.3.6.1.2.1.2.2.1.1." . $ports[$ActualPort]); $Port[$ActualPort]["BytesIn"] = $noc->getSNMPValue($row["ip"], $row["readcommunity"], ".1.3.6.1.2.1.2.2.1.10." . $ports[$ActualPort]); $Port[$ActualPort]["BytesOut"] = $noc->getSNMPValue($row["ip"], $row["readcommunity"], ".1.3.6.1.2.1.2.2.1.16." . $ports[$ActualPort]);