コード例 #1
0
ファイル: monitoring.php プロジェクト: DarneoStudio/bitrix
    protected static function getNetParams($hostname)
    {
        $dir = new \Bitrix\Main\IO\Directory(static::$rrdPath . "/" . $hostname);
        if (!$dir->isExists()) {
            return array();
        }
        $arChildren = $dir->getChildren();
        $result = array();
        foreach ($arChildren as $child) {
            if (!$child->isFile()) {
                continue;
            }
            $name = $child->getName();
            $pos1 = strpos($name, "-if_");
            $pos2 = strpos($name, "-up-");
            if ($pos1 !== false && $pos2 !== false) {
                $pos1 += 4;
                $dev = substr($name, $pos1, $pos2 - $pos1);
                $result[$dev] = array("NAME" => $dev . " " . Loc::getMessage("SCALE_MONITORING_NET_PARAMS"), "RRD" => $hostname . "-if_" . $dev . "-up-d.rrd", "OPTIONS" => array("DEF:in=" . static::$rrdPath . "/" . $hostname . "/" . $hostname . "-if_" . $dev . "-up-d.rrd:42:AVERAGE:start=now-600;end=now", "DEF:out=" . static::$rrdPath . "/" . $hostname . "/" . $hostname . "-if_" . $dev . "-down-d.rrd:42:AVERAGE:start=now-600;end=now", "VDEF:vin=in,TOTAL", "VDEF:vout=out,TOTAL", "PRINT:vin:%1.2lf", "PRINT:vout:%1.2lf"), "DATA_FUNC" => '
					$result = false;
					if(isset($data["calcpr"][0]) && isset($data["calcpr"][1]))
					{
						$result = \\Bitrix\\Scale\\Monitoring::formatSize($data["calcpr"][0]/600).
							" / ".
							\\Bitrix\\Scale\\Monitoring::formatSize($data["calcpr"][1]/600)." ' . Helper::nbsp(Loc::getMessage("SCALE_MONITORING_NET_SEC")) . '";
					}
					return $result;');
            }
        }
        return $result;
    }