本文整理汇总了PHP中cacti_log函数的典型用法代码示例。如果您正苦于以下问题:PHP cacti_log函数的具体用法?PHP cacti_log怎么用?PHP cacti_log使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cacti_log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_auth_cookie
function check_auth_cookie()
{
if (isset($_COOKIE['cacti_remembers']) && read_config_option('auth_cache_enabled') == 'on') {
$parts = explode(',', $_COOKIE['cacti_remembers']);
$user = $parts[0];
if ($user != '') {
$user_info = db_fetch_row_prepared('SELECT id, username
FROM user_auth
WHERE username = ?', array($user));
if (!empty($user_info)) {
if (isset($parts[1])) {
$nssecret = $parts[1];
$secret = hash('sha512', $nssecret, false);
$found = db_fetch_cell_prepared('SELECT user_id
FROM user_auth_cache
WHERE user_id = ? AND token = ?', array($user_info['id'], $secret));
if (empty($found)) {
return false;
} else {
set_auth_cookie($user_info);
cacti_log("LOGIN: User '" . $user_info['username'] . "' Authenticated via Authentication Cookie", false, 'AUTH');
db_execute_prepared('INSERT INTO user_log
(username, user_id, result, ip, time)
VALUES
(?, ?, 2, ?, NOW())', array($user, $user_info['id'], $_SERVER['REMOTE_ADDR']));
return $user_info['id'];
}
}
}
}
}
return false;
}
示例2: log
public static function log($message)
{
if (func_num_args() > 1) {
$args = func_get_args();
$message = call_user_func_array('sprintf', $args);
}
if (function_exists('debug_log_insert')) {
cacti_log("DEBUG: " . rtrim($message), true, "WEATHERMAP");
}
}
示例3: sig_handler
function sig_handler($signo)
{
switch ($signo) {
case SIGTERM:
case SIGINT:
cacti_log('WARNING: Thold Sub Process terminated by user', FALSE, 'thold');
exit;
break;
default:
/* ignore all other signals */
}
}
示例4: upgrade_to_0_8_8
function upgrade_to_0_8_8()
{
/* speed up the joins */
$_columns = array_rekey(db_fetch_assoc("SHOW COLUMNS FROM `poller_item`"), "Field", "Field");
if (in_array("host_id", $_columns)) {
db_install_execute("0.8.8", "ALTER TABLE `poller_item` MODIFY COLUMN `host_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0'");
cacti_log(__FUNCTION__ . " upgrade table poller_item", false, "UPGRADE");
}
$_keys = array_rekey(db_fetch_assoc("SHOW KEYS FROM `poller_output`"), "Key_name", "Key_name");
if (in_array("PRIMARY", $_keys)) {
db_install_execute("0.8.8", "ALTER TABLE `poller_output` DROP PRIMARY KEY");
cacti_log(__FUNCTION__ . " table poller_output: dropping old PRIMARY KEY", false, "UPGRADE");
}
/* now the KEY we want to create is definitively NOT present
* MySQL < 5.00.60 requires a different syntax, this was fixed in MySQL 5.00.60, so take care */
db_install_execute("0.8.8", "ALTER TABLE `poller_output` ADD PRIMARY KEY (`local_data_id`, `rrd_name`, `time`) /*!50060 USING BTREE */");
cacti_log(__FUNCTION__ . " upgrade table poller_output", false, "UPGRADE");
/* speed up user management */
$_keys = array_rekey(db_fetch_assoc("SHOW KEYS FROM `user_log`"), "Key_name", "Key_name");
if (!in_array("user_id", $_keys)) {
db_install_execute("0.8.8", "ALTER TABLE `user_log` ADD KEY `user_id` (`user_id`)");
cacti_log(__FUNCTION__ . " upgrade table user_log", false, "UPGRADE");
}
/* Plugin Architecture
* be prepared to find those data already present
* in case of upgrade of a cacti+PIA installation */
$sql = "CREATE TABLE IF NOT EXISTS `plugin_config` (\n\t\t\t\t`id` \t\tint(8) unsigned NOT NULL auto_increment,\n\t\t\t\t`directory` varchar(32) \tNOT NULL default '',\n\t\t\t\t`name` \t\tvarchar(64) \tNOT NULL default '',\n\t\t\t\t`status`\ttinyint(2) \t\tNOT NULL default 0,\n\t\t\t\t`author`\tvarchar(64) \tNOT NULL default '',\n\t\t\t\t`webpage`\tvarchar(255) \tNOT NULL default '',\n\t\t\t\t`version`\tvarchar(8) \t\tNOT NULL default '',\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tKEY `status` (`status`),\n\t\t\t\tKEY `directory` (`directory`)\n\t\t\t\t) ENGINE=MyISAM COMMENT='Plugin Configuration'";
db_install_execute("0.8.8", $sql);
cacti_log(__FUNCTION__ . " install table plugin_config", false, "UPGRADE");
$sql = "CREATE TABLE IF NOT EXISTS `plugin_db_changes` (\n\t\t\t\t`id` \t\tint(10) unsigned NOT NULL auto_increment,\n\t\t\t\t`plugin` \tvarchar(16) \tNOT NULL default '',\n\t\t\t\t`table` \tvarchar(64) \tNOT NULL default '',\n\t\t\t\t`column`\tvarchar(64) \tNOT NULL default '',\n\t\t\t\t`method` \tvarchar(16) \tNOT NULL default '',\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tKEY `plugin` (`plugin`),\n\t\t\t\tKEY `method` (`method`)\n\t\t\t\t) ENGINE=MyISAM COMMENT='Plugin Database Changes'";
db_install_execute("0.8.8", $sql);
cacti_log(__FUNCTION__ . " install table plugin_db_changes", false, "UPGRADE");
$sql = "CREATE TABLE IF NOT EXISTS `plugin_hooks` (\n\t\t\t\t`id` \t\tint(8) unsigned NOT NULL auto_increment,\n\t\t\t\t`name` \t\tvarchar(32) \tNOT NULL default '',\n\t\t\t\t`hook` \t\tvarchar(64) \tNOT NULL default '',\n\t\t\t\t`file`\t\tvarchar(255) \tNOT NULL default '',\n\t\t\t\t`function` \tvarchar(128) \tNOT NULL default '',\n\t\t\t\t`status`\tint(8) \t\t\tNOT NULL default 0,\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tKEY `hook` (`hook`),\n\t\t\t\tKEY `status` (`status`)\n\t\t\t\t) ENGINE=MyISAM COMMENT='Plugin Hooks'";
db_install_execute("0.8.8", $sql);
cacti_log(__FUNCTION__ . " install table plugin_hooks", false, "UPGRADE");
$sql = "CREATE TABLE IF NOT EXISTS `plugin_realms` (\n\t\t\t\t`id` \t\tint(8) unsigned NOT NULL auto_increment,\n\t\t\t\t`plugin` \tvarchar(32) \tNOT NULL default '',\n\t\t\t\t`file`\t\ttext\t\t \tNOT NULL,\n\t\t\t\t`display` \tvarchar(64) \tNOT NULL default '',\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tKEY `plugin` (`plugin`)\n\t\t\t\t) ENGINE=MyISAM COMMENT='Plugin Realms'";
db_install_execute("0.8.8", $sql);
cacti_log(__FUNCTION__ . " install table plugin_realms", false, "UPGRADE");
/* fill initial data into plugin tables
* be prepared to find those data already present
* in case of upgrade of a cacti+PIA installation */
db_install_execute("0.8.8", "REPLACE INTO `plugin_realms` VALUES (1, 'internal', 'plugins.php', 'Plugin Management')");
db_install_execute("0.8.8", "REPLACE INTO `plugin_hooks` VALUES (1, 'internal', 'config_arrays', '', 'plugin_config_arrays', 1)");
db_install_execute("0.8.8", "REPLACE INTO `plugin_hooks` VALUES (2, 'internal', 'draw_navigation_text', '', 'plugin_draw_navigation_text', 1)");
/* allow admin user to access Plugin Management */
db_install_execute("0.8.8", "REPLACE INTO user_auth_realm VALUES (101,1)");
/* create index on data_template_data on data_input_id */
$_keys = array_rekey(db_fetch_assoc("SHOW KEYS FROM `data_template_data`"), "Key_name", "Key_name");
if (!in_array("data_input_id", $_keys)) {
db_install_execute("0.8.8", "ALTER TABLE `data_template_data` ADD KEY `data_input_id` (`data_input_id`)");
cacti_log(__FUNCTION__ . " upgrade table data_template_data", false, "UPGRADE");
}
}
示例5: sig_handler
function sig_handler($signo)
{
switch ($signo) {
case SIGTERM:
case SIGINT:
cacti_log('WARNING: DSStats Poller terminated by user', FALSE, 'dsstats');
/* tell the main poller that we are done */
db_execute("REPLACE INTO settings (name, value) VALUES ('dsstats_poller_status', 'terminated - end time:" . date('Y-m-d G:i:s') . "')");
exit;
break;
default:
/* ignore all other signals */
}
}
示例6: sig_handler
function sig_handler($signo)
{
switch ($signo) {
case SIGTERM:
case SIGINT:
cacti_log('WARNING: Cacti Poller process terminated by user', true);
/* record the process as having completed */
record_cmdphp_done();
exit;
break;
default:
/* ignore all other signals */
}
}
示例7: sig_handler
function sig_handler($signo)
{
global $include_file, $function, $parameters;
switch ($signo) {
case SIGTERM:
case SIGINT:
case SIGABRT:
case SIGQUIT:
case SIGSEGV:
cacti_log("WARNING: Script Server terminated with signal '{$signo}' in file:'" . basename($include_file) . "', function:'{$function}', params:'{$parameters}'", FALSE, 'PHPSVR');
exit;
break;
default:
cacti_log("WARNING: Script Server received signal '{$signo}' in file:'{$include_file}', function:'{$function}', params:'{$parameters}'", FALSE, 'PHPSVR');
break;
}
}
示例8: warn
function warn($string, $notice_only = FALSE)
{
global $weathermap_map;
global $weathermap_warncount;
$message = "";
if (!$notice_only) {
$weathermap_warncount++;
$message .= "WARNING: ";
}
$message .= ($weathermap_map == '' ? '' : $weathermap_map . ": ") . rtrim($string);
// use Cacti's debug log, if we are running from the poller
if (function_exists('cacti_log') && !function_exists('show_editor_startpage')) {
cacti_log($message, true, "WEATHERMAP");
} else {
$stderr = fopen('php://stderr', 'w');
fwrite($stderr, $message . "\n");
fclose($stderr);
}
}
示例9: db_connect_real
function db_connect_real($host,$user,$pass,$db_name,$db_type, $retries = 20) {
global $cnn_id;
$i = 1;
$cnn_id = NewADOConnection($db_type);
while ($i <= $retries) {
if ($cnn_id->Connect($host,$user,$pass,$db_name)) {
return(1);
}
$i++;
usleep(100000);
}
cacti_log("ERROR: Cannot connect to MySQL server on '$host'. Please make sure you have specified a valid MySQL database name in 'include/config.php'.");
die("<br>Cannot connect to MySQL server on '$host'. Please make sure you have specified a valid MySQL database name in 'include/config.php'.");
return(0);
}
示例10: upgrade_to_0_8_7h
function upgrade_to_0_8_7h()
{
global $config;
require_once $config["base_path"] . "/lib/poller.php";
/* speed up the reindexing */
$_columns = array_rekey(db_fetch_assoc("SHOW COLUMNS FROM host_snmp_cache"), "Field", "Field");
if (!in_array("present", $_columns)) {
db_install_execute("0.8.7h", "ALTER TABLE host_snmp_cache ADD COLUMN present tinyint NOT NULL DEFAULT '1' AFTER `oid`");
db_install_execute("0.8.7h", "ALTER TABLE host_snmp_cache ADD INDEX present (present)");
cacti_log(__FUNCTION__ . " upgrade table host_snmp_cache", false, "UPGRADE");
}
$_columns = array_rekey(db_fetch_assoc("SHOW COLUMNS FROM poller_item"), "Field", "Field");
if (!in_array("present", $_columns)) {
db_install_execute("0.8.7h", "ALTER TABLE poller_item ADD COLUMN present tinyint NOT NULL DEFAULT '1' AFTER `action`");
db_install_execute("0.8.7h", "ALTER TABLE poller_item ADD INDEX present (present)");
cacti_log(__FUNCTION__ . " upgrade table poller_item", false, "UPGRADE");
}
$_columns = array_rekey(db_fetch_assoc("SHOW COLUMNS FROM poller_reindex"), "Field", "Field");
if (!in_array("present", $_columns)) {
db_install_execute("0.8.7h", "ALTER TABLE poller_reindex ADD COLUMN present tinyint NOT NULL DEFAULT '1' AFTER `action`");
db_install_execute("0.8.7h", "ALTER TABLE poller_reindex ADD INDEX present (present)");
cacti_log(__FUNCTION__ . " upgrade table poller_reindex", false, "UPGRADE");
}
$_columns = array_rekey(db_fetch_assoc("SHOW COLUMNS FROM host"), "Field", "Field");
if (!in_array("device_threads", $_columns)) {
db_install_execute("0.8.7h", "ALTER TABLE host ADD COLUMN device_threads tinyint(2) unsigned NOT NULL DEFAULT '1' AFTER max_oids;");
cacti_log(__FUNCTION__ . " upgrade table host", false, "UPGRADE");
}
$_keys = array_rekey(db_fetch_assoc("SHOW KEYS FROM data_template_rrd"), "Key_name", "Key_name");
if (!in_array("duplicate_dsname_contraint", $_keys)) {
db_install_execute("0.8.7h", "ALTER TABLE `data_template_rrd` ADD UNIQUE INDEX `duplicate_dsname_contraint` (`local_data_id`, `data_source_name`, `data_template_id`)");
cacti_log(__FUNCTION__ . " upgrade table data_template_rrd", false, "UPGRADE");
}
/* update the reindex cache, as we now introduced more options for "index count changed" */
$command_string = read_config_option("path_php_binary");
$extra_args = "-q \"" . $config["base_path"] . "/cli/poller_reindex_hosts.php\" --id=all";
exec_background($command_string, "{$extra_args}");
cacti_log(__FUNCTION__ . " running {$command_string} {$extra_args}", false, "UPGRADE");
}
示例11: proc_close
if (($using_proc_function == true) && ($script_server_calls > 0)) {
// close php server process
fwrite($pipes[0], "quit\r\n");
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
$return_value = proc_close($cactiphp);
}
if (($print_data_to_stdout) || (read_config_option("log_verbosity") >= POLLER_VERBOSITY_MEDIUM)) {
/* take time and log performance data */
list($micro,$seconds) = split(" ", microtime());
$end = $seconds + $micro;
cacti_log(sprintf("Time: %01.4f s, " .
"Theads: N/A, " .
"Hosts: %s",
round($end-$start,4),
$host_count),$print_data_to_stdout);
}
}else{
cacti_log("ERROR: Either there are no items in the cache or polling is disabled",$print_data_to_stdout);
}
/* Let the poller server know about cmd.php being finished */
db_execute("insert into poller_time (poller_id, start_time, end_time) values (0, NOW(), NOW())");
?>
示例12: db_fetch_assoc
function db_fetch_assoc($sql) {
global $cnn_id;
if (read_config_option("log_verbosity") == POLLER_VERBOSITY_DEBUG) {
cacti_log("DEBUG: SQL Assoc: \"" . str_replace("\n", "", str_replace("\r", "", str_replace("\t", " ", $sql))) . "\"", FALSE);
}
$data = array();
$cnn_id->SetFetchMode(ADODB_FETCH_ASSOC);
$query = $cnn_id->Execute($sql);
if ($query) {
while ((!$query->EOF) && ($query)) {
$data{sizeof($data)} = $query->fields;
$query->MoveNext();
}
return($data);
}else{
cacti_log("ERROR: SQL Assoc Failed \"" . str_replace("\n", "", str_replace("\r", "", str_replace("\t", " ", $sql))) . "\"");
}
}
示例13: export_log
function export_log($stMessage) {
if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_HIGH) {
cacti_log($stMessage, true, "EXPORT");
}
}
示例14: upgrade_to_0_8_8
//.........这里部分代码省略.........
`lst` smallint(4) unsigned NOT NULL COMMENT 'Label Grid Timespan Steps',
`lpr` int(12) unsigned NOT NULL COMMENT 'Label Placement Relative',
`lfm` varchar(100) NOT NULL COMMENT 'Label Format',
PRIMARY KEY (`id`)
) ENGINE=MyISAM COMMENT='Items for X-Axis Presets'");
db_install_execute("0.8.8", "INSERT INTO `graph_templates_xaxis_items` VALUES(1, '60c2066a1c45fab021d32fe72cbf4f49', 'Day', 1, 86400, 'HOUR', 4, 'HOUR', 2, 'HOUR', 2, 23200, '%H')");
db_install_execute("0.8.8", "INSERT INTO `graph_templates_xaxis_items` VALUES(2, 'd867f8fc2730af212d0fd6708385cf89', 'Week', 1, 604800, 'DAY', 1, 'DAY', 1, 'DAY', 1, 259200, '%d')");
db_install_execute("0.8.8", "INSERT INTO `graph_templates_xaxis_items` VALUES(3, '06304a1840da88f3e0438ac147219003', 'Month', 1, 2678400, 'WEEK', 1, 'WEEK', 1, 'WEEK', 1, 1296000, '%W')");
db_install_execute("0.8.8", "INSERT INTO `graph_templates_xaxis_items` VALUES(4, '33ac10e60fd855e74736bee43bda4134', 'Year', 1, 31622400, 'MONTH', 2, 'MONTH', 1, 'MONTH', 2, 15811200, '%m')");
/* upgrade to the graph trees */
db_install_execute("0.8.8", "ALTER TABLE `graph_tree_items`
ADD COLUMN `parent_id` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0' AFTER `id`,
ADD COLUMN `site_id` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0' AFTER `title`;");
/* make tree's a per user object. System tree's have a user_id of 0 */
db_install_execute("0.8.8", "ALTER TABLE `graph_tree` ADD COLUMN `user_id` INTEGER UNSIGNED NOT NULL DEFAULT '0' AFTER `id`, ADD INDEX `user_id`(`user_id`);");
/* get all nodes whose parent_id is not 0 */
$tree_items = db_fetch_assoc("SELECT * FROM graph_tree_items WHERE order_key NOT LIKE '___000%';");
if (sizeof($tree_items)) {
foreach($tree_items AS $item) {
$translated_key = rtrim($item["order_key"], "0\r\n");
$missing_len = strlen($translated_key) % CHARS_PER_TIER;
if ($missing_len > 0) {
$translated_key .= substr("000", 0, $missing_len);
}
$parent_key_len = strlen($translated_key) - CHARS_PER_TIER;
$parent_key = substr($translated_key, 0, $parent_key_len);
$parent_id = db_fetch_cell("SELECT id FROM graph_tree_items WHERE graph_tree_id=" . $item["graph_tree_id"] . " AND order_key LIKE '" . $parent_key . "000%'");
if ($parent_id != "") {
db_execute("UPDATE graph_tree_items SET parent_id=$parent_id WHERE id=" . $item["id"]);
}else{
cacti_log("Some error occurred processing children", false);
}
}
}
/* make the poller's ip address varchar() */
db_install_execute("0.8.8", "ALTER TABLE poller CHANGE COLUMN ip_address ip_address varchar(30) not null default ''");
/* insert the default poller into the database */
db_install_execute("0.8.8", "INSERT INTO `poller` VALUES (1,'','Main Poller','localhost','127.0.0.1','0000-00-00 00:00:00');");
/* update all devices to use poller 1, or the main poller */
db_install_execute("0.8.8", "UPDATE host SET poller_id=1 WHERE poller_id=0");
/* update the poller_items table to reflect the host change */
db_install_execute("0.8.8", "UPDATE poller_item SET poller_id=1 WHERE poller_id=0");
/* rename host -> device for tables and columns
* we have some updates to those tables in this file already
* so please take care not to change sequence */
$_indexes = db_fetch_assoc("SHOW INDEX FROM data_local WHERE `Column_name`='host_id'");
if (sizeof($_indexes)) {
foreach($_indexes as $_index) {
db_install_execute("0.8.8", "ALTER TABLE data_local DROP INDEX " . $_index["Key_name"]);
}
}
db_install_execute("0.8.8", "ALTER TABLE data_local CHANGE `host_id` `device_id` MEDIUMINT(8) UNSIGNED NOT NULL, ADD INDEX `device_id` ( `device_id` )");
db_install_execute("0.8.8", "ALTER TABLE graph_local DROP INDEX `host_id`");
db_install_execute("0.8.8", "ALTER TABLE graph_local CHANGE `host_id` `device_id` MEDIUMINT(8) UNSIGNED NOT NULL, ADD INDEX `device_id` ( `device_id` )");
db_install_execute("0.8.8", "ALTER TABLE graph_tree_items DROP INDEX `host_id`");
db_install_execute("0.8.8", "ALTER TABLE graph_tree_items CHANGE `host_id` `device_id` MEDIUMINT(8) UNSIGNED NOT NULL, ADD INDEX `device_id` ( `device_id` ), CHANGE `host_grouping_type` `device_grouping_type` TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
db_install_execute("0.8.8", "RENAME TABLE `host` TO `device`");
db_install_execute("0.8.8", "ALTER TABLE `device` CHANGE `host_template_id` `device_template_id` MEDIUMINT(8) UNSIGNED NOT NULL");
示例15: cacti_snmp_walk
function cacti_snmp_walk($hostname, $community, $oid, $version, $username, $password, $auth_proto, $priv_pass, $priv_proto, $context, $port = 161, $timeout = 500, $retries = 0, $max_oids = 10, $method = SNMP_VALUE_LIBRARY, $environ = SNMP_POLLER)
{
global $config, $banned_snmp_strings;
$snmp_oid_included = true;
$snmp_auth = '';
$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;
}
}
/* do not attempt to poll invalid combinations */
if ($version == 0 || !is_numeric($version) || !is_numeric($max_oids) || !is_numeric($port) || !is_numeric($retries) || !is_numeric($timeout) || $community == '' && $version != 3) {
return array();
}
$path_snmpbulkwalk = read_config_option('path_snmpbulkwalk');
if (snmp_get_method($version) == SNMP_METHOD_PHP && (!strlen($context) || $version != 3) && ($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 */
cacti_oid_numeric_format();
snmp_set_quick_print(0);
/* set the output format to numeric */
snmp_set_valueretrieval($method);
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 {
if ($priv_proto == '[None]') {
$proto = 'authNoPriv';
$priv_proto = '';
} else {
$proto = 'authPriv';
}
$temp_array = @snmp3_real_walk("{$hostname}:{$port}", "{$username}", $proto, $auth_proto, "{$password}", $priv_proto, "{$priv_pass}", "{$oid}", $timeout * 1000, $retries);
}
if ($temp_array === false) {
cacti_log("WARNING: SNMP Walk Timeout for Host:'{$hostname}', and OID:'{$oid}'", false);
}
/* check for bad entries */
if (is_array($temp_array) && sizeof($temp_array)) {
foreach ($temp_array as $key => $value) {
foreach ($banned_snmp_strings as $item) {
if (strstr($value, $item) != '') {
unset($temp_array[$key]);
continue 2;
}
}
}
$o = 0;
for (reset($temp_array); $i = key($temp_array); next($temp_array)) {
if ($temp_array[$i] != 'NULL') {
$snmp_array[$o]['oid'] = preg_replace('/^\\./', '', $i);
$snmp_array[$o]['value'] = format_snmp_string($temp_array[$i], $snmp_oid_included);
}
$o++;
}
}
} else {
/* ucd/net snmp want the timeout in seconds */
$timeout = ceil($timeout / 1000);
if ($version == '1') {
$snmp_auth = '-c ' . snmp_escape_string($community);
/* v1/v2 - community string */
} elseif ($version == '2') {
$snmp_auth = '-c ' . snmp_escape_string($community);
/* v1/v2 - community string */
$version = '2c';
/* ucd/net snmp prefers this over '2' */
} elseif ($version == '3') {
if ($priv_proto == '[None]') {
$proto = 'authNoPriv';
$priv_proto = '';
} else {
$proto = 'authPriv';
}
if (strlen($priv_pass)) {
$priv_pass = '-X ' . snmp_escape_string($priv_pass) . ' -x ' . snmp_escape_string($priv_proto);
} else {
$priv_pass = '';
}
if (strlen($context)) {
$context = '-n ' . snmp_escape_string($context);
} else {
$context = '';
}
$snmp_auth = trim('-u ' . snmp_escape_string($username) . ' -l ' . snmp_escape_string($proto) . ' -a ' . snmp_escape_string($auth_proto) . ' -A ' . snmp_escape_string($password) . ' ' . $priv_pass . ' ' . $context);
/* v3 - username/password */
}
if (file_exists($path_snmpbulkwalk) && $version > 1 && $max_oids > 1) {
$temp_array = exec_into_array(cacti_escapeshellcmd($path_snmpbulkwalk) . " -O Qn {$snmp_auth} -v {$version} -t {$timeout} -r {$retries} -Cr{$max_oids} " . cacti_escapeshellarg($hostname) . ":{$port} " . cacti_escapeshellarg($oid));
} else {
$temp_array = exec_into_array(cacti_escapeshellcmd(read_config_option('path_snmpwalk')) . " -O Qn {$snmp_auth} -v {$version} -t {$timeout} -r {$retries} " . cacti_escapeshellarg($hostname) . ":{$port} " . cacti_escapeshellarg($oid));
}
if (substr_count(implode(' ', $temp_array), 'Timeout:')) {
cacti_log("WARNING: SNMP Walk Timeout for Host:'{$hostname}', and OID:'{$oid}'", false);
//.........这里部分代码省略.........