当前位置: 首页>>代码示例>>PHP>>正文


PHP snmp2_real_walk函数代码示例

本文整理汇总了PHP中snmp2_real_walk函数的典型用法代码示例。如果您正苦于以下问题:PHP snmp2_real_walk函数的具体用法?PHP snmp2_real_walk怎么用?PHP snmp2_real_walk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了snmp2_real_walk函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Walk

function Walk($ip, $ver, $cm, $oid, $t = 1000000, $r = 2)
{
    global $debug, $comms;
    if ($ver == 3 and $comms[$cm]['pprot']) {
        if ($debug) {
            echo "<div class=\"textpad noti \">snmpwalk -v3 -c{$cm} " . $comms[$cm]['aprot'] . "/" . $comms[$cm]['pprot'] . " {$ip} {$oid} ({$t} usec * {$r})</div>";
        }
        return snmp3_real_walk($ip, $cm, 'authPriv', $comms[$cm]['aprot'], $comms[$cm]['apass'], $comms[$cm]['pprot'], $comms[$cm]['ppass'], ".{$oid}", $t);
    } elseif ($ver == 3 and $comms[$cm]['aprot']) {
        if ($debug) {
            echo "<div class=\"textpad noti \">snmpwalk -v3 -c{$cm} " . $comms[$cm]['aprot'] . " {$ip} {$oid} ({$t} usec * {$r})</div>";
        }
        return snmp3_real_walk($ip, $cm, 'authNoPriv', $comms[$cm]['aprot'], $comms[$cm]['apass'], 'DES', '', ".{$oid}", $t);
    } elseif ($ver == 2) {
        if ($debug) {
            echo "<div class=\"textpad noti \">snmpwalk -v2c -c{$cm} {$ip} {$oid} ({$t} usec * {$r})</div>";
        }
        return snmp2_real_walk($ip, $cm, ".{$oid}", $t);
    } else {
        if ($debug) {
            echo "<div class=\"textpad noti \">snmpwalk -v1 -c{$cm} {$ip} {$oid} ({$t} usec * {$r})</div>";
        }
        return snmprealwalk($ip, $cm, ".{$oid}", $t);
    }
}
开发者ID:pl0o0f,项目名称:nedi-puppet,代码行数:25,代码来源:libsnmp.php

示例2: walk

 function walk($oid)
 {
     // We're using realwalk so that we can build iterators with map_oids(), see:
     // walk     [0] => eth0
     // realwalk [IF-MIB::ifDescr.2] => eth0
     if ($this->version == "1") {
         $snmp_result = snmprealwalk($this->ip, $this->community, $oid);
     } else {
         if ($this->version == "2c") {
             $snmp_result = snmp2_real_walk($this->ip, $this->community, $oid);
         }
     }
     $result = $this->clear_snmp_string($snmp_result);
     return $result;
 }
开发者ID:engeld,项目名称:snmphp,代码行数:15,代码来源:snmputils.php

示例3: readmac6248

function readmac6248($switchf, $macarrayf)
{
    $a = snmp2_real_walk("{$switchf}", "public", "SNMPv2-SMI::mib-2.17.7.1.2.2.1.3.1");
    foreach (array_keys($a) as $val) {
        $pattern = '/([0-9]*)\\.([0-9]*)\\.([0-9]*)\\.([0-9]*)\\.([0-9]*)\\.([0-9]*)$/';
        preg_match($pattern, $val, &$mac);
        $rmac = sprintf("%02X:%02X:%02X:%02X:%02X:%02X", $mac[1], $mac[2], $mac[3], $mac[4], $mac[5], $mac[6]);
        $ip_ = $switchf;
        $npattern = '/([0-9]*)\\.([0-9]*)\\.([0-9]*)\\.([0-9]*)$/';
        preg_match($npattern, $ip_, &$ip);
        $network = $ip[2] . "." . $ip[3];
        if ($network == "43.128") {
            $network = "43.28";
        }
        if ($network == "43.126") {
            $network = "43.26";
        }
        $macarrayf[] = "" . $rmac . ";" . $network . "";
    }
    return $macarrayf;
}
开发者ID:nicox,项目名称:noaa,代码行数:21,代码来源:functions.php

示例4: walk

 static function walk($host, $object_id, $cache_ttl = null)
 {
     if ($cache_ttl) {
         $cache_var = str_replace('.', '_', $host->ip . $object_id);
         $cache = new CacheAPC();
         $resultCache = $cache->load($cache_var);
         if ($resultCache !== null) {
             return $resultCache;
         }
     }
     snmp_set_oid_output_format(self::$oid_format);
     $snmp = $host->snmpTemplate;
     if ($snmp instanceof SnmpTemplate) {
         switch ($snmp->version) {
             case "1":
                 $result = @snmprealwalk($host->ip, $snmp->community, $object_id, $snmp->timeout, $snmp->retries);
                 break;
             case "2":
             case "2c":
                 $result = @snmp2_real_walk($host->ip, $snmp->community, $object_id, $snmp->timeout, $snmp->retries);
                 break;
             case "3":
                 $result = @snmp3_real_walk($host->ip, $snmp->security_name, $snmp->security_level, $snmp->auth_protocol, $snmp->auth_passphrase, $snmp->priv_protocol, $snmp->priv_passphrase, $object_id, $snmp->timeout, $snmp->retries);
                 break;
             default:
                 throw new Exception('SNMP Template not implemented yet');
         }
     }
     if (is_array($result)) {
         if ($cache_var && $cache_ttl) {
             $cache->save($cache_var, $result, $cache_ttl);
         }
         return $result;
     } else {
         //throw new Exception("Sem resposta SNMP");
         return array();
     }
 }
开发者ID:romero1989,项目名称:phpnetmap,代码行数:38,代码来源:PNMSnmp.php

示例5: cacti_snmp_walk

function cacti_snmp_walk($hostname, $community, $oid, $version, $v3username, $v3password, $v3authproto = "", $v3privpassphrase = "", $v3privproto = "", $port = 161, $timeout = 500, $environ = SNMP_POLLER) {
	require_once(CACTI_BASE_PATH . "/lib/sys/exec.php");

	$snmp_array = array();
	$temp_array = array();

	/* determine default retries */
	$retries = read_config_option("snmp_retries");
	if ($retries == "") $retries = 3;

	/* get rid of quotes in privacy passphrase */
	$v3privpassphrase = str_replace("#space#", " ", $v3privpassphrase);

	if ($v3privproto == "[None]") {
		$v3privproto = "";
	}

	$path_snmpbulkwalk = read_config_option("path_snmpbulkwalk");

	if ((snmp_get_method($version) == SNMP_METHOD_PHP) &&
		(($version == 1) ||
		(version_compare(phpversion(), "5.1") >= 0) ||
		(!file_exists($path_snmpbulkwalk)))) {
		/* make sure snmp* is verbose so we can see what types of data
		we are getting back */
		snmp_set_quick_print(0);

		/* force php to return numeric oid's */
		if (function_exists("snmp_set_oid_numeric_print")) {
			snmp_set_oid_numeric_print(1);
		}

		if ($version == "1") {
			$temp_array = @snmprealwalk("$hostname:$port", $community, trim($oid), ($timeout * 1000), $retries);
		}elseif ($version == "2") {
			$temp_array = @snmp2_real_walk("$hostname:$port", $community, trim($oid), ($timeout * 1000), $retries);
		}else{
			$temp_array = @snmp3_real_walk("$hostname:$port", $v3username, snmp_get_v3authpriv($v3privproto), $v3authproto,
				$v3password, $v3privproto, $v3privpassphrase, trim($oid), ($timeout * 1000), $retries);
		}

		$o = 0;
		for (@reset($temp_array); $i = @key($temp_array); next($temp_array)) {
			$snmp_array[$o]["oid"] = ereg_replace("^\.", "", $i);
			$snmp_array[$o]["value"] = format_snmp_string($temp_array[$i]);
			$o++;
		}
	}else{
		/* ucd/net snmp want the timeout in seconds */
		$timeout = ceil($timeout / 1000);

		if ($version == "1") {
			$snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */
		}elseif ($version == "2") {
			$snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */
			$version = "2c"; /* ucd/net snmp prefers this over '2' */
		}elseif ($version == "3") {
			$snmp_auth = "-u $v3username -A $v3password -a $v3authproto -X $v3privpassphrase -x $v3privproto -l " . snmp_get_v3authpriv($v3privproto); /* v3 - username/password/etc... */
		}

		if (read_config_option("snmp_version") == "ucd-snmp") {
			$temp_array = exec_into_array(read_config_option("path_snmpwalk") . " -v$version -t $timeout -r $retries $hostname:$port $snmp_auth $oid");
		}else {
			if (strlen(trim($path_snmpbulkwalk)) && ($version > 1)) {
				$temp_array = exec_into_array(read_config_option("path_snmpbulkwalk") . " -O QfntUe $snmp_auth -v $version -t $timeout -r $retries -Cr50 $hostname:$port $oid");
			}else{
				$temp_array = exec_into_array(read_config_option("path_snmpwalk") . " -O QfntUe $snmp_auth -v $version -t $timeout -r $retries $hostname:$port $oid");
			}
		}

		if ((sizeof($temp_array) == 0) ||
			(substr_count($temp_array[0], "No Such Object")) ||
			(substr_count($temp_array[0], "No more variables"))) {
			return array();
		}

		for ($i=0; $i < count($temp_array); $i++) {
			$snmp_array[$i]["oid"] = trim(ereg_replace("(.*) =.*", "\\1", $temp_array[$i]));
			$snmp_array[$i]["value"] = format_snmp_string($temp_array[$i]);
		}
	}

	return $snmp_array;
}
开发者ID:songchin,项目名称:Cacti,代码行数:84,代码来源:snmp.php

示例6: cacti_snmp_walk

function cacti_snmp_walk($hostname, $community, $oid, $version, $username, $password, $port = 161, $timeout = 500, $retries = 0, $environ = SNMP_POLLER) {
	global $config;

	$snmp_array = array();
	$temp_array = array();

	/* determine default retries */
	if (($retries == 0) || (!is_numeric($retries))) {
		$retries = read_config_option("snmp_retries");
		if ($retries == "") $retries = 3;
	}

	$path_snmpbulkwalk = read_config_option("path_snmpbulkwalk");

	if ((snmp_get_method($version) == SNMP_METHOD_PHP) &&
		(($version == 1) ||
		(version_compare(phpversion(), "5.1") >= 0) ||
		(!file_exists($path_snmpbulkwalk)))) {
		/* make sure snmp* is verbose so we can see what types of data
		we are getting back */

		/* force php to return numeric oid's */
		if (function_exists("snmp_set_oid_numeric_print")) {
			snmp_set_oid_numeric_print(TRUE);
		}

		snmp_set_quick_print(0);

		if ($version == "1") {
			$temp_array = @snmprealwalk("$hostname:$port", "$community", "$oid", ($timeout * 1000), $retries);
		}elseif ($version == "2") {
			$temp_array = @snmp2_real_walk("$hostname:$port", "$community", "$oid", ($timeout * 1000), $retries);
		}else{
			$temp_array = @snmp3_real_walk("$hostname:$port", $username, "authNoPriv", "MD5", $password, "", "", $oid, ($timeout * 1000), $retries);
		}

		$o = 0;
		for (@reset($temp_array); $i = @key($temp_array); next($temp_array)) {
			$snmp_array[$o]["oid"] = ereg_replace("^\.", "", $i);
			$snmp_array[$o]["value"] = format_snmp_string($temp_array[$i]);
			$o++;
		}
	}else{
		/* ucd/net snmp want the timeout in seconds */
		$timeout = ceil($timeout / 1000);

		if ($version == "1") {
			$snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */
		}elseif ($version == "2") {
			$snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */
			$version = "2c"; /* ucd/net snmp prefers this over '2' */
		}elseif ($version == "3") {
			$snmp_auth = "-u $username -l authNoPriv -a MD5 -A $password"; /* v3 - username/password */
		}

		if (read_config_option("snmp_version") == "ucd-snmp") {
			$temp_array = exec_into_array(read_config_option("path_snmpwalk") . " -v$version -t $timeout -r $retries $hostname:$port $snmp_auth $oid");
		}else {
			if (file_exists($path_snmpbulkwalk) && ($version > 1)) {
				$temp_array = exec_into_array($path_snmpbulkwalk . " -O n $snmp_auth -v $version -t $timeout -r $retries -Cr50 $hostname:$port $oid");
			}else{
				$temp_array = exec_into_array(read_config_option("path_snmpwalk") . " -O n $snmp_auth -v $version -t $timeout -r $retries $hostname:$port $oid");
			}
		}

		if ((sizeof($temp_array) == 0) ||
			(substr_count($temp_array[0], "No Such Object")) ||
			(substr_count($temp_array[0], "No more variables"))) {
			return array();
		}

		for ($i=0; $i < count($temp_array); $i++) {
			$snmp_array[$i]["oid"] = trim(ereg_replace("(.*) =.*", "\\1", $temp_array[$i]));
			$snmp_array[$i]["value"] = format_snmp_string($temp_array[$i]);
		}
	}

	return $snmp_array;
}
开发者ID:songchin,项目名称:Cacti,代码行数:79,代码来源:snmp.php

示例7: snmptable

function snmptable($host, $community, $oid)
{
    # This handy function was bought to you by scot at indievisible dot org
    # Found on the PHP.net documentation page for snmprealwalk.
    # The important thing about this function is that it fills in the blanks.
    # Regular SNMP walks leave out items so you can't blindly prod things into arrays any more.
    snmp_set_oid_numeric_print(TRUE);
    snmp_set_quick_print(TRUE);
    snmp_set_enum_print(TRUE);
    $retval = array();
    if (!($raw = snmp2_real_walk($host, $community, $oid))) {
        return false;
    }
    if (count($raw) == 0) {
        return false;
    }
    // no data
    $prefix_length = 0;
    $largest = 0;
    foreach ($raw as $key => $value) {
        if ($prefix_length == 0) {
            // don't just use $oid's length since it may be non-numeric
            $prefix_elements = count(explode('.', $oid));
            $tmp = '.' . strtok($key, '.');
            while ($prefix_elements > 1) {
                $tmp .= '.' . strtok('.');
                $prefix_elements--;
            }
            $tmp .= '.';
            $prefix_length = strlen($tmp);
        }
        $key = substr($key, $prefix_length);
        $index = explode('.', $key, 2);
        isset($retval[$index[1]]) or $retval[$index[1]] = array();
        if ($largest < $index[0]) {
            $largest = $index[0];
        }
        $retval[$index[1]][$index[0]] = $value;
    }
    if (count($retval) == 0) {
        return false;
    }
    // no data
    // fill in holes and blanks the agent may "give" you
    foreach ($retval as $k => $x) {
        for ($i = 1; $i <= $largest; $i++) {
            if (!isset($retval[$k][$i])) {
                $retval[$k][$i] = '';
            }
        }
        ksort($retval[$k]);
    }
    return $retval;
}
开发者ID:russss,项目名称:FITB,代码行数:54,代码来源:functions.php

示例8: error_reporting

<?php

/* Datapump - Devices from NMS to GTS (SNMP Version) */
error_reporting(E_ALL ^ E_NOTICE);
// Read in mib
snmp_read_mib("/usr/share/snmp/mibs/IDIRECT-REMOTE-MIB.txt");
// SNMP Query NMS Server
$a = snmp2_real_walk("204.9.216.250", "dcsatnetwork", "1.3.6.1.4.1.13732");
// Convert returned data to usable array
foreach ($a as $idx => $val) {
    list($branch, $snmpid) = explode(".", $idx);
    list($tree, $node) = explode("::", $branch);
    list($type, $value) = explode(":", $val, 2);
    switch ($node) {
        case 'nmstate':
            $netmodem[$snmpid][$node] = substr($value, strpos($value, "(") + 1, 1);
            break;
        default:
            $netmodem[$snmpid][$node] = trim($value);
    }
}
//print_r($netmodem);
foreach ($netmodem as $nm) {
    if ($nm[typeid] == "remote(3)") {
        echo "Target[" . $nm[nmid] . "]: downstreamtotalKiloBytes." . $nm[nmdid] . "&upstreamtotalKiloBytes." . $nm[nmdid] . ":dcsatnetwork@204.9.216.250:::::2 * 1000\n";
        echo "MaxBytes[" . $nm[nmid] . "]: 100000\n";
        echo "RouterName[" . $nm[nmid] . "]: nmname." . $nm[nmdid] . "\n";
        echo "Title[" . $nm[nmid] . "]: " . $nm[nmname] . " Traffic\n";
        echo "YLegend[" . $nm[nmid] . "]: Bits per Second\n";
        echo "LegendI[" . $nm[nmid] . "]: Downstream:\n";
        echo "LegendO[" . $nm[nmid] . "]: Upstream:\n";
开发者ID:aldridged,项目名称:gtg-gts,代码行数:31,代码来源:create_mrtg_config.php

示例9: my_snmp_real_walk

 function my_snmp_real_walk($ip, $credentials, $oid)
 {
     $timeout = '30000000';
     $retries = '0';
     switch ($credentials->credentials->version) {
         case '1':
             $array = @snmprealwalk($ip, $credentials->credentials->community, $oid, $timeout, $retries);
             break;
         case '2':
             $array = @snmp2_real_walk($ip, $credentials->credentials->community, $oid, $timeout, $retries);
             break;
         case '3':
             $sec_name = $credentials->credentials->security_name ?: '';
             $sec_level = $credentials->credentials->security_level ?: '';
             $auth_protocol = $credentials->credentials->authentication_protocol ?: '';
             $auth_passphrase = $credentials->credentials->authentication_passphrase ?: '';
             $priv_protocol = $credentials->credentials->privacy_protocol ?: '';
             $priv_passphrase = $credentials->credentials->privacy_passphrase ?: '';
             $array = @snmp3_real_walk($ip, $sec_name, $sec_level, $auth_protocol, $auth_passphrase, $priv_protocol, $priv_passphrase, $oid, $timeout, $retries);
             break;
         default:
             return false;
             break;
     }
     if (!is_array($array)) {
         return false;
     }
     foreach ($array as $i => $value) {
         $array[$i] = trim($array[$i]);
         if ($array[$i] == '""') {
             $array[$i] = '';
         }
         if (strpos($array[$i], '.') === 0) {
             $array[$i] = substr($array[$i], 1);
         }
         // remove the first and last characters if they are "
         if (substr($array[$i], 0, 1) == "\"") {
             $array[$i] = substr($array[$i], 1, strlen($array[$i]));
         }
         if (substr($array[$i], -1, 1) == "\"") {
             $array[$i] = substr($array[$i], 0, strlen($array[$i]) - 1);
         }
         // remove some return strings
         if (strpos(strtolower($array[$i]), '/etc/snmp') !== false or strpos(strtolower($array[$i]), 'no such instance') !== false or strpos(strtolower($array[$i]), 'no such object') !== false or strpos(strtolower($array[$i]), 'not set') !== false or strpos(strtolower($array[$i]), 'unknown value type') !== false) {
             $array[$i] = '';
         }
         // remove any quotation marks
         $array[$i] = str_replace('"', ' ', $array[$i]);
         // replace any line breaks with spaces
         $array[$i] = str_replace(array("\r", "\n"), " ", $array[$i]);
     }
     return $array;
 }
开发者ID:Opmantek,项目名称:open-audit,代码行数:53,代码来源:snmp_helper.php

示例10: snmpget

 protected function snmpget($oid, $version = null, $community = null)
 {
     if (!$version) {
         $version = $this->getAgentVersion();
     }
     if (!$community) {
         $community = $this->getAgentReadCommunity();
     }
     switch ($version) {
         case 1:
             return @snmprealwalk($this->host, $community, $oid, $this->timeout * 1000000, $this->retries);
         case 2:
             return @snmp2_real_walk($this->host, $community, $oid, $this->timeout * 1000000, $this->retries);
         case 3:
             extract($this->version3);
             return @snmp3_real_walk($this->host, $secName, $secLevel, $authProtocol, $authPassphrase, $privProtocol, $privPassphrase, $oid, $this->timeout * 1000000, $this->retries);
         default:
             return false;
     }
 }
开发者ID:sad-systems,项目名称:cradle,代码行数:20,代码来源:Snmp.php

示例11: cacti_snmp_walk

function cacti_snmp_walk($hostname, $community, $oid, $version, $username, $password, $port = 161, $timeout = 500, $environ = SNMP_POLLER) {
	global $config;

	$snmp_array = array();
	$temp_array = array();
	/* determine default retries */
	$retries = read_config_option("snmp_retries");
	if ($retries == "") $retries = 3;

	if (snmp_get_method($version) == SNMP_METHOD_PHP) {
		/* make sure snmp* is verbose so we can see what types of data
		we are getting back */
		snmp_set_quick_print(0);

		if (function_exists("snmp_set_valueretrieval")) {
			snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
		}

		if ($version == "1") {
			$temp_array = @snmprealwalk("$hostname:$port", $community, $oid, ($timeout * 1000), $retries);
		} else {
			$temp_array = @snmp2_real_walk("$hostname:$port", $community, $oid, ($timeout * 1000), $retries);
		}

		$o = 0;
		for (@reset($temp_array); $i = @key($temp_array); next($temp_array)) {
			$snmp_array[$o]["oid"] = ereg_replace("^\.", "", $i);
			$snmp_array[$o]["value"] = format_snmp_string($temp_array[$i]);
			$o++;
		}
	}else{
		/* ucd/net snmp want the timeout in seconds */
		$timeout = ceil($timeout / 1000);

		if ($version == "1") {
			$snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */
		}elseif ($version == "2") {
			$snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */
			$version = "2c"; /* ucd/net snmp prefers this over '2' */
		}elseif ($version == "3") {
			$snmp_auth = "-u $username -l authPriv -a MD5 -A $password -x DES -X $password"; /* v3 - username/password */
		}

		if (read_config_option("snmp_version") == "ucd-snmp") {
			$temp_array = exec_into_array(read_config_option("path_snmpwalk") . " -v$version -t $timeout -r $retries $hostname:$port $snmp_auth $oid");
		}else {
			$temp_array = exec_into_array(read_config_option("path_snmpwalk") . " -O QfntUe $snmp_auth -v $version -t $timeout -r $retries $hostname:$port $oid");
		}

		if ((sizeof($temp_array) == 0) || (substr_count($temp_array[0], "No Such Object"))) {
			return array();
		}

		for ($i=0; $i < count($temp_array); $i++) {
			$snmp_array[$i]["oid"] = trim(ereg_replace("(.*) =.*", "\\1", $temp_array[$i]));
			$snmp_array[$i]["value"] = format_snmp_string($temp_array[$i]);
		}
	}

	return $snmp_array;
}
开发者ID:songchin,项目名称:Cacti,代码行数:61,代码来源:snmp.php

示例12: walk

 function walk($oid, $suffix_as_key = FALSE)
 {
     switch ($this->version) {
         case self::VERSION_1:
             if ($suffix_as_key) {
                 $this->result = snmpwalk($this->host, $this->community, $oid);
             } else {
                 $this->result = snmprealwalk($this->host, $this->community, $oid);
             }
             break;
         case self::VERSION_2C:
         case self::VERSION_2c:
             if ($suffix_as_key) {
                 $this->result = snmp2_walk($this->host, $this->community, $oid);
             } else {
                 $this->result = snmp2_real_walk($this->host, $this->community, $oid);
             }
             break;
         case self::VERSION_3:
             if ($suffix_as_key) {
                 $this->result = snmp3_walk($this->host, $this->community, $this->sec_level, $this->auth_protocol, $this->auth_passphrase, $this->priv_protocol, $this->priv_passphrase, $oid);
             } else {
                 $this->result = snmp3_real_walk($this->host, $this->community, $this->sec_level, $this->auth_protocol, $this->auth_passphrase, $this->priv_protocol, $this->priv_passphrase, $oid);
             }
             break;
     }
     return $this->result;
 }
开发者ID:dot-Sean,项目名称:racktables-contribs,代码行数:28,代码来源:snmpgeneric.php

示例13: realWalk

 /**
  * Proxy to the snmp2_real_walk command
  *
  * @param string $oid The OID to walk
  * @return array The results of the walk
  */
 public function realWalk($oid)
 {
     switch ($this->getVersion()) {
         case 1:
             return $this->_lastResult = @snmprealwalk($this->getHost(), $this->getCommunity(), $oid, $this->getTimeout(), $this->getRetry());
             break;
         case '2c':
             return $this->_lastResult = @snmp2_real_walk($this->getHost(), $this->getCommunity(), $oid, $this->getTimeout(), $this->getRetry());
             break;
         case '3':
             return $this->_lastResult = @snmp3_real_walk($this->getHost(), $this->getSecName(), $this->getSecLevel(), $this->getAuthProtocol(), $this->getAuthPassphrase(), $this->getPrivProtocol(), $this->getPrivPassphrase(), $oid, $this->getTimeout(), $this->getRetry());
             break;
         default:
             throw new Exception('Invalid SNMP version: ' . $this->getVersion());
     }
 }
开发者ID:lsqtongxin,项目名称:OSS_SNMP,代码行数:22,代码来源:SNMP.php

示例14: elseif

         $cpuCount++;
     }
 }
 $users = @snmp2_real_walk($host, "public", '.1.3.6.1.2.1.25.1.5', TIMEOUT, RETRIES);
 if (array_key_exists("HOST-RESOURCES-MIB::hrSystemNumUsers.0", $users)) {
     $userCount = $users["HOST-RESOURCES-MIB::hrSystemNumUsers.0"];
 } elseif (array_key_exists("iso.3.6.1.2.1.25.1.5.0", $users)) {
     $userCount = $users["iso.3.6.1.2.1.25.1.5.0"];
 } else {
     $userCount = array();
 }
 if (!empty($userCount)) {
     preg_match('/Gauge[0-9]*\\: (.*)/', $userCount, $matches);
     $hostInfo[$host]['User Count'] = $matches[1];
 }
 $procs = @snmp2_real_walk($host, "public", '.1.3.6.1.2.1.25.1.6', TIMEOUT, RETRIES);
 if (array_key_exists("HOST-RESOURCES-MIB::hrSystemProcesses.0", $procs)) {
     $procCount = $procs["HOST-RESOURCES-MIB::hrSystemProcesses.0"];
 } elseif (array_key_exists("iso.3.6.1.2.1.25.1.6.0", $procs)) {
     $procCount = $procs["iso.3.6.1.2.1.25.1.6.0"];
 } else {
     $procCount = array();
 }
 if (!empty($procCount)) {
     preg_match('/Gauge[0-9]*\\: (.*)/', $procCount, $matches);
     $hostInfo[$host]['Process Count'] = $matches[1];
 }
 foreach ($oid_simple as $name => $value) {
     $curResult = @snmp2_get($host, "public", $value, TIMEOUT, RETRIES);
     if (!empty($curResult)) {
         if (strpos($curResult, "STRING") !== false) {
开发者ID:haus,项目名称:CAT-Scripts,代码行数:31,代码来源:runaway.php

示例15: WriteVlanMacData

 /**
  * 
  * @return type
  */
 public function WriteVlanMacData()
 {
     $count = 0;
     if (!empty($this->allTerminators) and !empty($this->allVlanHosts)) {
         foreach ($this->allTerminators as $eachTerminator) {
             $ip = $eachTerminator["ip"];
             $vlanPoolId = $eachTerminator['vlanpoolid'];
             $data = snmp2_real_walk($ip, 'Magistral', '.1.3.6.1.4.1.9.9.380.1.4.1.1.3');
             foreach ($data as $each => $value) {
                 $decmac = str_replace('.1.3.6.1.4.1.9.9.380.1.4.1.1.3.', '', $each);
                 $vlanPlusMac = explode(".", $decmac, 2);
                 $vlan = $vlanPlusMac[0];
                 $mac = $this->dec2mac($vlanPlusMac[1]);
                 foreach ($this->allVlanHosts as $eachHost) {
                     if ($eachHost['vlanpoolid'] == $vlanPoolId and $eachHost['vlan'] == $vlan) {
                         $login = $eachHost['login'];
                     }
                 }
                 if (!empty($this->allHistory)) {
                     if ($this->allHistory[$login]['mac'] != $mac) {
                         $this->WriteHistory($login, $vlan, $mac);
                     }
                 } else {
                     $this->WriteHistory($login, $vlan, $mac);
                 }
                 $count++;
             }
         }
     }
     file_put_contents(self::FLAGPREFIX, $count);
 }
开发者ID:carriercomm,项目名称:Ubilling,代码行数:35,代码来源:api.vlan.php


注:本文中的snmp2_real_walk函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。