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


PHP cacti_snmp_get函数代码示例

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


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

示例1: ss_host_disk

function ss_host_disk($hostname, $host_id, $snmp_auth, $cmd, $arg1 = "", $arg2 = "")
{
    $snmp = explode(":", $snmp_auth);
    $snmp_version = $snmp[0];
    $snmp_port = $snmp[1];
    $snmp_timeout = $snmp[2];
    $ping_retries = $snmp[3];
    $max_oids = $snmp[4];
    $snmp_auth_username = "";
    $snmp_auth_password = "";
    $snmp_auth_protocol = "";
    $snmp_priv_passphrase = "";
    $snmp_priv_protocol = "";
    $snmp_context = "";
    $snmp_community = "";
    if ($snmp_version == 3) {
        $snmp_auth_username = $snmp[6];
        $snmp_auth_password = $snmp[7];
        $snmp_auth_protocol = $snmp[8];
        $snmp_priv_passphrase = $snmp[9];
        $snmp_priv_protocol = $snmp[10];
        $snmp_context = $snmp[11];
    } else {
        $snmp_community = $snmp[5];
    }
    $oids = array("total" => ".1.3.6.1.2.1.25.2.3.1.5", "used" => ".1.3.6.1.2.1.25.2.3.1.6", "failures" => ".1.3.6.1.2.1.25.2.3.1.7", "index" => ".1.3.6.1.2.1.25.2.3.1.1", "description" => ".1.3.6.1.2.1.25.2.3.1.3", "sau" => ".1.3.6.1.2.1.25.2.3.1.4");
    if ($cmd == "index") {
        $return_arr = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER));
        for ($i = 0; $i < sizeof($return_arr); $i++) {
            print $return_arr[$i] . "\n";
        }
    } elseif ($cmd == "num_indexes") {
        $return_arr = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER));
        print sizeof($return_arr);
    } elseif ($cmd == "query") {
        $arg = $arg1;
        $arr_index = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER));
        $arr = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids[$arg], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER));
        for ($i = 0; $i < sizeof($arr_index); $i++) {
            print $arr_index[$i] . "!" . $arr[$i] . "\n";
        }
    } elseif ($cmd == "get") {
        $arg = $arg1;
        $index = $arg2;
        if ($arg == "total" || $arg == "used") {
            $sau = preg_replace("/[^0-9]/i", "", db_fetch_cell("select field_value from host_snmp_cache where host_id={$host_id} and field_name='hrStorageAllocationUnits' and snmp_index='{$index}'"));
            $snmp_data = cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".{$index}", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, SNMP_POLLER);
            if ($snmp_data < 0) {
                return ($snmp_data + 4294967296) * $sau;
            } else {
                return $snmp_data * $sau;
            }
        } else {
            return cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".{$index}", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, SNMP_POLLER);
        }
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:57,代码来源:ss_host_disk.php

示例2: ss_host_disk

function ss_host_disk($hostname, $host_id, $snmp_auth, $cmd, $arg1 = "", $arg2 = "")
{
    $snmp = explode(":", $snmp_auth);
    $snmp_version = $snmp[0];
    $snmp_port = $snmp[1];
    $snmp_timeout = $snmp[2];
    $snmp_auth_username = "";
    $snmp_auth_password = "";
    $snmp_auth_protocol = "";
    $snmp_priv_passphrase = "";
    $snmp_priv_protocol = "";
    $snmp_context = "";
    $snmp_community = "";
    if ($snmp_version == 3) {
        $snmp_auth_username = $snmp[4];
        $snmp_auth_password = $snmp[5];
        $snmp_auth_protocol = $snmp[6];
        $snmp_priv_passphrase = $snmp[7];
        $snmp_priv_protocol = $snmp[8];
        $snmp_context = $snmp[9];
    } else {
        $snmp_community = $snmp[3];
    }
    $oids = array("total" => ".1.3.6.1.2.1.25.2.3.1.5", "totalin" => ".1.3.6.1.2.1.25.2.3.1.5", "used" => ".1.3.6.1.2.1.25.2.3.1.6", "failures" => ".1.3.6.1.2.1.25.2.3.1.7", "index" => ".1.3.6.1.2.1.25.2.3.1.1", "description" => ".1.3.6.1.2.1.25.2.3.1.3", "sau" => ".1.3.6.1.2.1.25.2.3.1.4");
    if ($cmd == "index") {
        $return_arr = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, read_config_option("snmp_retries"), SNMP_POLLER));
        for ($i = 0; $i < sizeof($return_arr); $i++) {
            print $return_arr[$i] . "\n";
        }
    } elseif ($cmd == "query") {
        $arg = $arg1;
        $arr_index = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, read_config_option("snmp_retries"), SNMP_POLLER));
        $arr = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids[$arg], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, read_config_option("snmp_retries"), SNMP_POLLER));
        for ($i = 0; $i < sizeof($arr_index); $i++) {
            print $arr_index[$i] . "!" . $arr[$i] . "\n";
        }
    } elseif ($cmd == "get") {
        $arg = $arg1;
        $index = $arg2;
        $value = api_plugin_hook_function('hmib_get_disk', array("host_id" => $host_id, "arg" => $arg, "index" => $index));
        if (is_array($value)) {
            if ($arg == "total" || $arg == "used") {
                $sau = eregi_replace("[^0-9]", "", db_fetch_cell("select field_value from host_snmp_cache where host_id={$host_id} and field_name='hrStorageAllocationUnits' and snmp_index='{$index}'"));
                return cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".{$index}", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, read_config_option("snmp_retries"), SNMP_POLLER) * $sau;
            } else {
                return cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".{$index}", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, read_config_option("snmp_retries"), SNMP_POLLER);
            }
        } else {
            return $value;
        }
    }
}
开发者ID:khoimt,项目名称:cacti-sample,代码行数:52,代码来源:ss_host_disk.php

示例3: ss_mikrotik_snmpget

function ss_mikrotik_snmpget($hostid = '', $oid = '')
{
    global $config;
    include_once $config['base_path'] . '/lib/snmp.php';
    if ($hostid > 0) {
        $host = db_fetch_row("SELECT hostname, snmp_community, snmp_version, snmp_username, snmp_password, \n\t\t\tsnmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_context, \n\t\t\tsnmp_port, snmp_timeout, max_oids \n\t\t\tFROM host \n\t\t\tWHERE id={$hostid}");
        if (sizeof($host)) {
            $get = cacti_snmp_get($host['hostname'], $host['snmp_community'], $oid, $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI);
            if (!empty($get)) {
                return $get;
            }
        }
    }
    return '0';
}
开发者ID:Cacti,项目名称:plugin_mikrotik,代码行数:15,代码来源:ss_mikrotik_snmpget.php

示例4: ss_host_disk

function ss_host_disk($hostname, $snmp_community, $snmp_version, $host_id, $cmd, $arg1 = "", $arg2 = "", $snmp_port = 161, $snmp_timeout = 500) {
	$oids = array(
		"total" => ".1.3.6.1.2.1.25.2.3.1.5",
		"used" => ".1.3.6.1.2.1.25.2.3.1.6",
		"failures" => ".1.3.6.1.2.1.25.2.3.1.7",
		"index" => ".1.3.6.1.2.1.25.2.3.1.1",
		"description" => ".1.3.6.1.2.1.25.2.3.1.3",
		"sau" => ".1.3.6.1.2.1.25.2.3.1.4"
		);

	if ((func_num_args() == "9") || (func_num_args() == "7") || (func_num_args() == "6") || (func_num_args() == "5")) {
		if ($cmd == "index") {
			$return_arr = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, "", "", $snmp_port, $snmp_timeout, SNMP_POLLER));

			for ($i=0;($i<sizeof($return_arr));$i++) {
				print $return_arr[$i] . "\n";
			}
		}elseif ($cmd == "query") {
			$arg = $arg1;

			$arr_index = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, "", "", $snmp_port, $snmp_timeout, SNMP_POLLER));
			$arr = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids[$arg], $snmp_version, "", "", $snmp_port, $snmp_timeout, SNMP_POLLER));

			for ($i=0;($i<sizeof($arr_index));$i++) {
				print $arr_index[$i] . "!" . $arr[$i] . "\n";
			}
		}elseif ($cmd == "get") {
			$arg = $arg1;
			$index = $arg2;

			if (($arg == "total") || ($arg == "used")) {
				/* get hrStorageAllocationUnits from the snmp cache since it is faster */
				$sau = eregi_replace("[^0-9]", "", db_fetch_cell("select field_value from host_snmp_cache where host_id=$host_id and field_name='hrStorageAllocationUnits' and snmp_index='$index'"));

				return cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, "", "", $snmp_port, $snmp_timeout, SNMP_POLLER) * $sau;
			}else{
				return cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, "", "", $snmp_port, $snmp_timeout, SNMP_POLLER);
			}
		}
	} else {
		return "ERROR: Invalid Parameters\n";
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:43,代码来源:ss_host_disk.php

示例5: ping_snmp

	function ping_snmp() {
		/* initialize variables */
		$this->snmp_status   = "down";
		$this->snmp_response = "Host did not respond to SNMP";
		$output              = "";

		/* get start time */
		$this->start_time();

		/* poll sysUptime for status */
		$retry_count = 0;

		/* getnext does not work in php versions less than 5 */
		if (version_compare("5", phpversion(), "<")) {
			$oid = ".1.3";
		}else{
			$oid = ".1.3.6.1.2.1.1.3.0";
		}

		while (1) {
			if ($retry_count >= $this->retries) {
				$this->snmp_status   = "down";
				$this->snmp_response = "Host did not respond to SNMP";

				return false;
			}

			/* getnext does not work in php versions less than 5 */
			if (version_compare("5", phpversion(), "<")) {
				$output = cacti_snmp_getnext($this->host["hostname"],
					$this->host["snmp_community"],
					$oid,
					$this->host["snmp_version"],
					$this->host["snmp_username"],
					$this->host["snmp_password"],
					$this->host["snmp_auth_protocol"],
					$this->host["snmp_priv_passphrase"],
					$this->host["snmp_priv_protocol"],
					$this->host["snmp_context"],
					$this->host["snmp_port"],
					$this->host["snmp_timeout"],
					SNMP_CMDPHP);
			}else{
				$output = cacti_snmp_get($this->host["hostname"],
					$this->host["snmp_community"],
					$oid,
					$this->host["snmp_version"],
					$this->host["snmp_username"],
					$this->host["snmp_password"],
					$this->host["snmp_auth_protocol"],
					$this->host["snmp_priv_passphrase"],
					$this->host["snmp_priv_protocol"],
					$this->host["snmp_context"],
					$this->host["snmp_port"],
					$this->host["snmp_timeout"],
					SNMP_CMDPHP);
			}

			/* determine total time +- ~10% */
			$this->time = $this->get_time($this->precision);

			/* check result for uptime */
			if (strlen($output)) {
				/* calculte total time */
				$this->snmp_status   = $this->time*1000;
				$this->snmp_response = "Host responded to SNMP";

				return true;
			}

			if ($retry_count == 0) {
				$oid = ".1.3.6.1.2.1.1.3.0";
			}else{
				$oid = ".1.3.6.1.2.1.1.1.0";
			}

			$retry_count++;
		}
	} /* ping_snmp */
开发者ID:songchin,项目名称:Cacti,代码行数:79,代码来源:ping.php

示例6: ping_host

function ping_host()
{
    input_validate_input_number($_REQUEST['id']);
    if (empty($_REQUEST['id'])) {
        return "";
    }
    $host = db_fetch_row_prepared('SELECT * FROM host WHERE id = ?', array($_REQUEST['id']));
    $am = $host['availability_method'];
    $anym = false;
    if ($am == AVAIL_SNMP || $am == AVAIL_SNMP_GET_NEXT || $am == AVAIL_SNMP_GET_SYSDESC || $am == AVAIL_SNMP_AND_PING || $am == AVAIL_SNMP_OR_PING) {
        $anym = true;
        print "SNMP Information<br>\n";
        print "<span style='font-size: 10px; font-weight: normal; font-family: monospace;'>\n";
        if ($host['snmp_community'] == '' && $host['snmp_username'] == '' || $host['snmp_version'] == 0) {
            print "<span style='color: #ab3f1e; font-weight: bold;'>SNMP not in use</span>\n";
        } else {
            $snmp_system = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.1.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI);
            /* modify for some system descriptions */
            /* 0000937: System output in host.php poor for Alcatel */
            if (substr_count($snmp_system, '00:')) {
                $snmp_system = str_replace('00:', '', $snmp_system);
                $snmp_system = str_replace(':', ' ', $snmp_system);
            }
            if ($snmp_system == '') {
                print "<span class='hostDown'>SNMP error</span>\n";
            } else {
                $snmp_uptime = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.3.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI);
                $snmp_hostname = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.5.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI);
                $snmp_location = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.6.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI);
                $snmp_contact = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.4.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI);
                print '<strong>System:</strong>' . html_split_string($snmp_system) . "<br>\n";
                $days = intval($snmp_uptime / (60 * 60 * 24 * 100));
                $remainder = $snmp_uptime % (60 * 60 * 24 * 100);
                $hours = intval($remainder / (60 * 60 * 100));
                $remainder = $remainder % (60 * 60 * 100);
                $minutes = intval($remainder / (60 * 100));
                print "<strong>Uptime:</strong> {$snmp_uptime}";
                print "&nbsp;({$days} days, {$hours} hours, {$minutes} minutes)<br>\n";
                print "<strong>Hostname:</strong> {$snmp_hostname}<br>\n";
                print "<strong>Location:</strong> {$snmp_location}<br>\n";
                print "<strong>Contact:</strong> {$snmp_contact}<br>\n";
            }
        }
        print "</span>\n";
    }
    if ($am == AVAIL_PING || $am == AVAIL_SNMP_AND_PING || $am == AVAIL_SNMP_OR_PING) {
        $anym = true;
        /* create new ping socket for host pinging */
        $ping = new Net_Ping();
        $ping->host = $host;
        $ping->port = $host['ping_port'];
        /* perform the appropriate ping check of the host */
        $ping_results = $ping->ping(AVAIL_PING, $host['ping_method'], $host['ping_timeout'], $host['ping_retries']);
        if ($ping_results == true) {
            $host_down = false;
            $class = 'hostUp';
        } else {
            $host_down = true;
            $class = 'hostDown';
        }
        print "Ping Results<br>\n";
        print "<span class='" . $class . "'>" . $ping->ping_response . "</span>\n";
    }
    if ($anym == false) {
        print "No Ping or SNMP Availability Check In Use<br><br>\n";
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:67,代码来源:host.php

示例7: ss_host_disk

function ss_host_disk($hostname, $host_id, $snmp_auth, $cmd, $arg1 = "", $arg2 = "") {
	$snmp = explode(":", $snmp_auth);
	$snmp_version = $snmp[0];
	$snmp_port = $snmp[1];
	$snmp_timeout = $snmp[2];

	$snmpv3_auth_username = "";
	$snmpv3_auth_password = "";
	$snmpv3_auth_protocol = "";
	$snmpv3_priv_passphrase = "";
	$snmpv3_priv_protocol = "";
	$snmp_community = "";

	if ($snmp_version == 3) {
		$snmpv3_auth_username = $snmp[4];
		$snmpv3_auth_password = $snmp[5];
		$snmpv3_auth_protocol = $snmp[6];
		$snmpv3_priv_passphrase = $snmp[7];
		$snmpv3_priv_protocol = $snmp[8];
	}else{
		$snmp_community = $snmp[3];
	}

	$oids = array(
		"total" => ".1.3.6.1.2.1.25.2.3.1.5",
		"used" => ".1.3.6.1.2.1.25.2.3.1.6",
		"failures" => ".1.3.6.1.2.1.25.2.3.1.7",
		"index" => ".1.3.6.1.2.1.25.2.3.1.1",
		"description" => ".1.3.6.1.2.1.25.2.3.1.3",
		"sau" => ".1.3.6.1.2.1.25.2.3.1.4"
		);

	if ($cmd == "index") {
		$return_arr = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmp_port, $snmp_timeout, SNMP_POLLER));

		for ($i=0;($i<sizeof($return_arr));$i++) {
			print $return_arr[$i] . "\n";
		}
	}elseif ($cmd == "query") {
		$arg = $arg1;

		$arr_index = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmp_port, $snmp_timeout, SNMP_POLLER));
		$arr = ss_host_disk_reindex(cacti_snmp_walk($hostname, $snmp_community, $oids[$arg], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmp_port, $snmp_timeout, SNMP_POLLER));

		for ($i=0;($i<sizeof($arr_index));$i++) {
			print $arr_index[$i] . "!" . $arr[$i] . "\n";
		}
	}elseif ($cmd == "get") {
		$arg = $arg1;
		$index = $arg2;

		if (($arg == "total") || ($arg == "used")) {
			/* get hrStorageAllocationUnits from the snmp cache since it is faster */
			$sau = eregi_replace("[^0-9]", "", db_fetch_cell("select field_value from host_snmp_cache where host_id=$host_id and field_name='hrStorageAllocationUnits' and snmp_index='$index'"));

			return cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmp_port, $snmp_timeout, SNMP_POLLER) * $sau;
		}else{
			return cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmp_port, $snmp_timeout, SNMP_POLLER);
		}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:61,代码来源:ss_host_disk.php

示例8: db_fetch_cell

		print $arr_index[$i] . "!" . $arr[$i] . "\n";
	}

/*
 * process GET requests
 */
}elseif ($cmd == "get") {
	$arg = $_SERVER["argv"][5];
	$index = $_SERVER["argv"][6];

	if (($arg == "total") || ($arg == "used")) {
		/* get hrStorageAllocationUnits from the snmp cache since it is faster */
		$sau = db_fetch_cell("select field_value from device_snmp_cache where device_id=$device_id and field_name='hrStorageAllocationUnits' and snmp_index='$index'");

		print (cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol,$snmp_priv_passphrase,$snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, SNMP_POLLER)* $sau);
	}else{
		print (cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol,$snmp_priv_passphrase,$snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, SNMP_POLLER));
	}
}

function reindex($arr) {
	$return_arr = array();

	for ($i=0;($i<sizeof($arr));$i++) {
		$return_arr[$i] = $arr[$i]["value"];
	}

	return $return_arr;
}

?>
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:query_host_partitions.php

示例9: host_edit

function host_edit()
{
    global $colors, $fields_host_edit, $reindex_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    /* ==================================================== */
    display_output_messages();
    if (!empty($_GET["id"])) {
        $host = db_fetch_row("select * from host where id=" . $_GET["id"]);
        $header_label = "[edit: " . $host["description"] . "]";
    } else {
        $header_label = "[new]";
    }
    if (!empty($host["id"])) {
        ?>
		<table width="100%" align="center">
			<tr>
				<td class="textInfo" colspan="2">
					<?php 
        print $host["description"];
        ?>
 (<?php 
        print $host["hostname"];
        ?>
)
				</td>
			</tr>
			<tr>
				<td class="textHeader">
				<?php 
        if ($host["availability_method"] == AVAIL_SNMP || $host["availability_method"] == AVAIL_SNMP_AND_PING || $host["availability_method"] == AVAIL_SNMP_OR_PING) {
            ?>
					SNMP Information<br>

					<span style="font-size: 10px; font-weight: normal; font-family: monospace;">
					<?php 
            if ($host["snmp_community"] == "" && $host["snmp_username"] == "" || $host["snmp_version"] == 0) {
                print "<span style='color: #ab3f1e; font-weight: bold;'>SNMP not in use</span>\n";
            } else {
                $snmp_system = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.1.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                /* modify for some system descriptions */
                /* 0000937: System output in hosts.php poor for Alcatel */
                if (substr_count($snmp_system, "00:")) {
                    $snmp_system = str_replace("00:", "", $snmp_system);
                    $snmp_system = str_replace(":", " ", $snmp_system);
                }
                if ($snmp_system == "") {
                    print "<span style='color: #ff0000; font-weight: bold;'>SNMP error</span>\n";
                } else {
                    $snmp_uptime = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.3.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                    $snmp_hostname = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.5.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                    $snmp_location = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.6.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                    $snmp_contact = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.4.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                    print "<strong>System:</strong>" . html_split_string($snmp_system) . "<br>\n";
                    $days = intval($snmp_uptime / (60 * 60 * 24 * 100));
                    $remainder = $snmp_uptime % (60 * 60 * 24 * 100);
                    $hours = intval($remainder / (60 * 60 * 100));
                    $remainder = $remainder % (60 * 60 * 100);
                    $minutes = intval($remainder / (60 * 100));
                    print "<strong>Uptime:</strong> {$snmp_uptime}";
                    print "&nbsp;({$days} days, {$hours} hours, {$minutes} minutes)<br>\n";
                    print "<strong>Hostname:</strong> {$snmp_hostname}<br>\n";
                    print "<strong>Location:</strong> {$snmp_location}<br>\n";
                    print "<strong>Contact:</strong> {$snmp_contact}<br>\n";
                }
            }
            ?>
					</span>
				<?php 
        }
        if ($host["availability_method"] == AVAIL_PING || $host["availability_method"] == AVAIL_SNMP_AND_PING || $host["availability_method"] == AVAIL_SNMP_OR_PING) {
            /* create new ping socket for host pinging */
            $ping = new Net_Ping();
            $ping->host = $host;
            $ping->port = $host["ping_port"];
            /* perform the appropriate ping check of the host */
            if ($ping->ping($host["availability_method"], $host["ping_method"], $host["ping_timeout"], $host["ping_retries"])) {
                $host_down = false;
                $color = "#000000";
            } else {
                $host_down = true;
                $color = "#ff0000";
            }
            ?>
					<br>Ping Results<br>
					<span style="font-size: 10px; font-weight: normal; color: <?php 
            print $color;
            ?>
; font-family: monospace;">
					<?php 
            print $ping->ping_response;
            ?>
					</span>
				<?php 
        } else {
            if ($host["availability_method"] == AVAIL_NONE) {
                ?>
					No Availability Check In Use<br>
				<?php 
            }
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:host.php

示例10: update_reindex_cache

function update_reindex_cache($host_id, $data_query_id)
{
    global $config;
    include_once $config["library_path"] . "/data_query.php";
    include_once $config["library_path"] . "/snmp.php";
    /* will be used to keep track of sql statements to execute later on */
    $recache_stack = array();
    $host = db_fetch_row("select hostname, snmp_community, snmp_version, snmp_username, snmp_password, snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_context, snmp_port, snmp_timeout from host where id={$host_id}");
    $data_query = db_fetch_row("select reindex_method, sort_field from host_snmp_query where host_id={$host_id} and snmp_query_id={$data_query_id}");
    $data_query_type = db_fetch_cell("select data_input.type_id from (data_input,snmp_query) where data_input.id=snmp_query.data_input_id and snmp_query.id={$data_query_id}");
    $data_query_xml = get_data_query_array($data_query_id);
    switch ($data_query["reindex_method"]) {
        case DATA_QUERY_AUTOINDEX_NONE:
            break;
        case DATA_QUERY_AUTOINDEX_BACKWARDS_UPTIME:
            /* the uptime backwards method requires snmp, so make sure snmp is actually enabled
             * on this device first */
            if ($host["snmp_version"] > 0) {
                if (isset($data_query_xml["oid_uptime"])) {
                    $oid_uptime = $data_query_xml["oid_uptime"];
                } elseif (isset($data_query_xml["uptime_oid"])) {
                    $oid_uptime = $data_query_xml["uptime_oid"];
                } else {
                    $oid_uptime = ".1.3.6.1.2.1.1.3.0";
                }
                $assert_value = cacti_snmp_get($host["hostname"], $host["snmp_community"], $oid_uptime, $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], SNMP_POLLER);
                $recache_stack[] = "('{$host_id}', '{$data_query_id}'," . POLLER_ACTION_SNMP . ", '<', '{$assert_value}', '{$oid_uptime}', '1')";
            }
            break;
        case DATA_QUERY_AUTOINDEX_INDEX_NUM_CHANGE:
            /* this method requires that some command/oid can be used to determine the
             * current number of indexes in the data query
             * pay ATTENTION to quoting!
             * the script parameters are usually enclosed in single tics: '
             * so we have to enclose the whole list of parameters in double tics: "
             * */
            /* the assert_value counts the number of distinct indexes currently available in host_snmp_cache
             * we do NOT make use of <oid_num_indexes> or the like!
             * this works, even if no <oid_num_indexes> was given
             */
            $assert_value = sizeof(db_fetch_assoc("select snmp_index from host_snmp_cache where host_id={$host_id} and snmp_query_id={$data_query_id} group by snmp_index"));
            /* now, we have to build the (list of) commands that are later used on a recache event
             * the result of those commands will be compared to the assert_value we have just computed
             * on a comparison failure, a reindex event will be generated
             */
            switch ($data_query_type) {
                case DATA_INPUT_TYPE_SNMP_QUERY:
                    if (isset($data_query_xml["oid_num_indexes"])) {
                        /* we have a specific OID for counting indexes */
                        $recache_stack[] = "({$host_id}, {$data_query_id}," . POLLER_ACTION_SNMP . ", '=', '{$assert_value}', '" . $data_query_xml["oid_num_indexes"] . "', '1')";
                    } else {
                        /* count all indexes found */
                        $recache_stack[] = "({$host_id}, {$data_query_id}," . POLLER_ACTION_SNMP_COUNT . ", '=', '{$assert_value}', '" . $data_query_xml["oid_index"] . "', '1')";
                    }
                    break;
                case DATA_INPUT_TYPE_SCRIPT_QUERY:
                    if (isset($data_query_xml["arg_num_indexes"])) {
                        /* we have a specific request for counting indexes */
                        /* escape path (windows!) and parameters for use with database sql; TODO: replace by db specific escape function like mysql_real_escape_string? */
                        $recache_stack[] = "({$host_id}, {$data_query_id}," . POLLER_ACTION_SCRIPT . ", '=', '{$assert_value}', '" . addslashes(get_script_query_path((isset($data_query_xml["arg_prepend"]) ? $data_query_xml["arg_prepend"] . " " : "") . $data_query_xml["arg_num_indexes"], $data_query_xml["script_path"], $host_id)) . "', '1')";
                    } else {
                        /* count all indexes found */
                        /* escape path (windows!) and parameters for use with database sql; TODO: replace by db specific escape function like mysql_real_escape_string? */
                        $recache_stack[] = "({$host_id}, {$data_query_id}," . POLLER_ACTION_SCRIPT_COUNT . ", '=', '{$assert_value}', '" . addslashes(get_script_query_path((isset($data_query_xml["arg_prepend"]) ? $data_query_xml["arg_prepend"] . " " : "") . $data_query_xml["arg_index"], $data_query_xml["script_path"], $host_id)) . "', '1')";
                    }
                    break;
                case DATA_INPUT_TYPE_QUERY_SCRIPT_SERVER:
                    if (isset($data_query_xml["arg_num_indexes"])) {
                        /* we have a specific request for counting indexes */
                        /* escape path (windows!) and parameters for use with database sql; TODO: replace by db specific escape function like mysql_real_escape_string? */
                        $recache_stack[] = "({$host_id}, {$data_query_id}," . POLLER_ACTION_SCRIPT_PHP . ", '=', '{$assert_value}', '" . addslashes(get_script_query_path($data_query_xml["script_function"] . " " . (isset($data_query_xml["arg_prepend"]) ? $data_query_xml["arg_prepend"] . " " : "") . $data_query_xml["arg_num_indexes"], $data_query_xml["script_path"], $host_id)) . "', '1')";
                    } else {
                        /* count all indexes found */
                        # TODO: push the correct assert value
                        /* escape path (windows!) and parameters for use with database sql; TODO: replace by db specific escape function like mysql_real_escape_string? */
                        #$recache_stack[] = "($host_id, $data_query_id," . POLLER_ACTION_SCRIPT_PHP_COUNT . ", '=', '$assert_value', '" . addslashes(get_script_query_path($data_query_xml["script_function"] . " " . (isset($data_query_xml["arg_prepend"]) ? $data_query_xml["arg_prepend"] . " ": "") . $data_query_xml["arg_index"], $data_query_xml["script_path"], $host_id)) . "', '1')";
                        # omit the assert value until we are able to run an 'index' command through script server
                    }
                    break;
            }
            break;
        case DATA_QUERY_AUTOINDEX_FIELD_VERIFICATION:
            $primary_indexes = db_fetch_assoc("select snmp_index,oid,field_value from host_snmp_cache where host_id={$host_id} and snmp_query_id={$data_query_id} and field_name='" . $data_query["sort_field"] . "'");
            if (sizeof($primary_indexes) > 0) {
                foreach ($primary_indexes as $index) {
                    $assert_value = $index["field_value"];
                    if ($data_query_type == DATA_INPUT_TYPE_SNMP_QUERY) {
                        $recache_stack[] = "({$host_id}, {$data_query_id}," . POLLER_ACTION_SNMP . ", '=', '{$assert_value}', '" . $data_query_xml["fields"][$data_query["sort_field"]]["oid"] . "." . $index["snmp_index"] . "', '1')";
                    } else {
                        if ($data_query_type == DATA_INPUT_TYPE_SCRIPT_QUERY) {
                            $recache_stack[] = "('{$host_id}', '{$data_query_id}'," . POLLER_ACTION_SCRIPT . ", '=', '{$assert_value}', '" . get_script_query_path((isset($data_query_xml["arg_prepend"]) ? $data_query_xml["arg_prepend"] . " " : "") . $data_query_xml["arg_get"] . " " . $data_query_xml["fields"][$data_query["sort_field"]]["query_name"] . " " . $index["snmp_index"], $data_query_xml["script_path"], $host_id) . "', '1')";
                        }
                    }
                }
            }
            break;
    }
    if (sizeof($recache_stack)) {
        poller_update_poller_reindex_from_buffer($host_id, $data_query_id, $recache_stack);
    }
//.........这里部分代码省略.........
开发者ID:teddywen,项目名称:cacti,代码行数:101,代码来源:poller.php

示例11: collectHostIndexedOid

function collectHostIndexedOid(&$host, $tree, $table, $name)
{
    global $cnn_id;
    static $types;
    debug("Beginning Processing for '" . $host["description"] . "[" . $host["hostname"] . "]', Table '{$name}'");
    if (!sizeof($types)) {
        $types = array_rekey(db_fetch_assoc("SELECT id, oid, description FROM plugin_hmib_types"), "oid", array("id", "description"));
    }
    if (sizeof($host)) {
        /* mark for deletion */
        db_execute("UPDATE {$table} SET present=0 WHERE host_id=" . $host["id"]);
        debug("Polling {$name} from '" . $host["description"] . "[" . $host["hostname"] . "]'");
        $hostMib = array();
        foreach ($tree as $mname => $oid) {
            if ($name == "hrProcessor") {
                $retrieval = SNMP_VALUE_PLAIN;
            } elseif ($mname == "date") {
                $retrieval = SNMP_VALUE_LIBRARY;
            } elseif ($mname != "baseOID") {
                $retrieval = SNMP_VALUE_PLAIN;
            } else {
                continue;
            }
            $walk = cacti_snmp_walk($host["hostname"], $host["snmp_community"], $oid, $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), $host["max_oids"], $retrieval, SNMP_WEBUI);
            $hostMib = array_merge($hostMib, $walk);
        }
        $set_string = "";
        $values = "";
        $sql_suffix = "";
        $sql_prefix = "INSERT INTO {$table}";
        if (sizeof($tree)) {
            foreach ($tree as $bname => $oid) {
                if ($bname != "baseOID" && $bname != "index") {
                    $values .= (strlen($values) ? "`, `" : "`") . $bname;
                    $sql_suffix .= (!strlen($sql_suffix) ? " ON DUPLICATE KEY UPDATE `index`=VALUES(`index`), `" : ", `") . $bname . "`=VALUES(`" . $bname . "`)";
                }
            }
        }
        $sql_prefix .= " (`host_id`, `index`, " . $values . "`) VALUES ";
        $sql_suffix .= ", present=1";
        // Locate the values names
        $prevIndex = "";
        $new_array = array();
        $wonky = false;
        $hrProcValid = false;
        $effective = 0;
        if (sizeof($hostMib)) {
            foreach ($hostMib as $mib) {
                /* do some cleanup */
                if (substr($mib["oid"], 0, 1) != ".") {
                    $mib["oid"] = "." . $mib["oid"];
                }
                if (substr($mib["value"], 0, 4) == "OID:") {
                    $mib["value"] = trim(str_replace("OID:", "", $mib["value"]));
                }
                $splitIndex = hmib_splitBaseIndex($mib["oid"]);
                if (sizeof($splitIndex)) {
                    $index = $splitIndex[1];
                    $oid = $splitIndex[0];
                    $key = array_search($oid, $tree);
                    /* issue workaround for snmp issues */
                    if ($name == "hrProcessor" && $mib["value"] == ".0.0") {
                        if ($wonky) {
                            $key = "load";
                            $mib["value"] = $effective;
                        } elseif (!$hrProcValid) {
                            if (db_fetch_cell("SELECT count(*) FROM plugin_hmib_hrSystem WHERE sysDescr LIKE '%Linux%' AND host_id=" . $host["id"])) {
                                /* look for the hrProcessorLoad value */
                                $temp_mib = $hostMib;
                                foreach ($temp_mib as $kk => $vv) {
                                    if (substr_count($kk, ".1.3.6.1.2.1.25.3.3.1.2")) {
                                        $hrProcValid = true;
                                    }
                                }
                                if (!$hrProcValid) {
                                    $user = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.4.1.2021.11.9.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), $host["max_oids"], SNMP_VALUE_LIBRARY, SNMP_WEBUI);
                                    $system = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.4.1.2021.11.10.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), $host["max_oids"], SNMP_VALUE_LIBRARY, SNMP_WEBUI);
                                    $effective = ($user + $system) * 2 / sizeof($mib);
                                    $key = "load";
                                    $mib["value"] = $effective;
                                    $wonky = true;
                                }
                            } else {
                                $effective = 0;
                            }
                        }
                    }
                    if (!empty($key)) {
                        if ($key == "type") {
                            $value = explode("(", $mib["value"]);
                            if (sizeof($value) > 1) {
                                $value = trim($value[1], " \n\r)");
                                if ($table != "plugin_hmib_hrSWInstalled" && $table != "plugin_hmib_hrSWRun") {
                                    $new_array[$index][$key] = isset($types[$value]) ? $types[$value]["id"] : 0;
                                } else {
                                    $new_array[$index][$key] = $value;
                                }
                            } else {
                                if ($table != "plugin_hmib_hrSWInstalled" && $table != "plugin_hmib_hrSWRun") {
                                    $new_array[$index][$key] = isset($types[$value[0]]) ? $types[$value[0]]["id"] : 0;
//.........这里部分代码省略.........
开发者ID:khoimt,项目名称:cacti-sample,代码行数:101,代码来源:poller_hmib.php

示例12: update_system_mibs

function update_system_mibs($host_id)
{
    $system_mibs = array('snmp_sysDescr' => '.1.3.6.1.2.1.1.1.0', 'snmp_sysObjectID' => '.1.3.6.1.2.1.1.2.0', 'snmp_sysUpTimeInstance' => '.1.3.6.1.2.1.1.3.0', 'snmp_sysContact' => '.1.3.6.1.2.1.1.4.0', 'snmp_sysName' => '.1.3.6.1.2.1.1.5.0', 'snmp_sysLocation' => '.1.3.6.1.2.1.1.6.0');
    $h = db_fetch_row_prepared('SELECT * FROM host WHERE id = ?', array($host_id));
    if (sizeof($h)) {
        foreach ($system_mibs as $name => $oid) {
            $value = cacti_snmp_get($h['hostname'], $h['snmp_community'], $oid, $h['snmp_version'], $h['snmp_username'], $h['snmp_password'], $h['snmp_auth_protocol'], $h['snmp_priv_passphrase'], $h['snmp_priv_protocol'], $h['snmp_context'], $h['snmp_port'], $h['snmp_timeout'], read_config_option('snmp_retries'), SNMP_CMDPHP);
            if (!empty($value)) {
                db_execute_prepared("UPDATE host SET {$name} = ? WHERE id = ?", array($value, $host_id));
            }
        }
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:13,代码来源:functions.php

示例13: ping_snmp

	function ping_snmp() {
		/* initialize variables */
		$this->snmp_status = "down";
		$this->snmp_response = "Host did not respond to SNMP";
		$output = "";

		/* get start time */
		$this->start_time();

		/* poll sysUptime for status */
		$retry_count = 0;
		while (1) {
			if ($retry_count >= $this->retries) {
				$this->snmp_status   = "down";
				$this->snmp_response = "Host did not respond to SNMP";
				return false;
			}

			$output = cacti_snmp_get($this->host["hostname"],
				$this->host["snmp_community"],
				".1.3.6.1.2.1.1.3.0" ,
				$this->host["snmp_version"],
				$this->host["snmp_username"],
				$this->host["snmp_password"],
				$this->host["snmp_port"],
				$this->host["snmp_timeout"],
				SNMP_CMDPHP);

			/* determine total time +- ~10% */
			$this->time = $this->get_time($this->precision);

			/* check result for uptime */
			if (!empty($output)) {
				/* calculte total time */
				$this->snmp_status = $this->time*1000;
				$this->snmp_response = "Host responded to SNMP";
				return true;
			}

			$retry_count++;
		}
	} /* ping_snmp */
开发者ID:songchin,项目名称:Cacti,代码行数:42,代码来源:ping.php

示例14: xform_enterasys_N7_vlan_associations

function xform_enterasys_N7_vlan_associations(&$device, $snmp_readstring = "")
{
    /* get raw index data */
    if ($snmp_readstring == "") {
        $snmp_readstring = $device["snmp_readstring"];
    }
    /* initialize the output array */
    $output_array = array();
    /* obtain vlan associations: dot1qTpFdbStatus from dot1qTpFdbTable */
    $xformArray = cacti_snmp_walk($device["hostname"], $snmp_readstring, ".1.3.6.1.2.1.17.7.1.2.2.1.2", $device["snmp_version"], "", "", "", "", "", "", $device["snmp_port"], $device["snmp_timeout"]);
    $i = 0;
    foreach ($xformArray as $xformItem) {
        //print_r($xformItem);
        /* peel off the beginning of the OID */
        $key = $xformItem["oid"];
        //print ("========= key=[$key]");
        $key = str_replace("iso", "1", $key);
        $key = str_replace("1.3.6.1.2.1.17.7.1.2.2.1.2.", "", $key);
        //print ("========= key=[$key]\n");
        /* now grab the VLAN Id */
        $perPos = strpos($key, ".", 1);
        //print ("========= perPos=[$perPos]\n");
        $output_array[$i]["vlan_id"] = substr($key, 1, $perPos - 1);
        //print ("========= i=[$i] [" . $output_array[$i]["vlan_id"] . "]\n");
        /* save the key=MAC Address for association with the dot1d table */
        $output_array[$i]["key"] = substr($key, $perPos);
        /* get VLAN name, if any: dot1qVlanStaticName from dot1qVlanStaticTable */
        $vlan_name = @cacti_snmp_get($device["hostname"], $snmp_readstring, ".1.3.6.1.2.1.17.7.1.4.3.1.1." . $output_array[$i]["vlan_id"], $device["snmp_version"], "", "", "", "", "", "", $device["snmp_port"], $device["snmp_timeout"]);
        $output_array[$i]["vlan_name"] = $vlan_name;
        //print ("========= i=[$i] [" . $output_array[$i]["vlan_id"] . "] name=[" . $output_array[$i]["vlan_name"] . "]\n");
        $i++;
    }
    return array_rekey($output_array, "key", "vlan_id");
    #return $output_array;
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:35,代码来源:mactrack_enterasys_N7.php

示例15: db_fetch_cell

	for ($i=0;($i<sizeof($arr_index));$i++) {
		print $arr_index[$i] . "!" . $arr[$i] . "\n";
	}
}elseif ($cmd == "get") {
	$arg = $_SERVER["argv"][10];
	$index = $_SERVER["argv"][11];

	if (($arg == "total") || ($arg == "used")) {
		/* get hrStorageAllocationUnits from the snmp cache since it is faster */
		$host_id = db_fetch_cell("select id from host where hostname='$hostname' and snmp_community='$snmp_community'");
		$sau = db_fetch_cell("select field_value from host_data_query_cache where host_id=$host_id and field_name='hrStorageAllocationUnits' and index_value='$index'");

		print (cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol, 161, 1000) * $sau);
	}else{
		print (cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol, 161, 1000));
	}
}

function reindex($arr) {
	$return_arr = array();

	for ($i=0;($i<sizeof($arr));$i++) {
		$return_arr[$i] = $arr[$i]["value"];
	}

	return $return_arr;
}

?>
开发者ID:songchin,项目名称:Cacti,代码行数:29,代码来源:query_host_partitions.php


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