• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP exec_background函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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");
}
开发者ID:andrei1489,项目名称:cacti,代码行数:39,代码来源:0_8_7g_to_0_8_7h.php


示例2: hmib_poller_bottom

function hmib_poller_bottom()
{
    global $config;
    include_once $config["base_path"] . "/lib/poller.php";
    exec_background(read_config_option("path_php_binary"), " -q " . $config["base_path"] . "/plugins/hmib/poller_hmib.php -M");
}
开发者ID:khoimt,项目名称:cacti-sample,代码行数:6,代码来源:setup.php


示例3: run_command

function run_command($socket, $command, $multiprocess)
{
    global $config, $eol, $rrdtool_pipe, $rrd_path, $php_binary_path, $rrd_update_path, $rrdupdates_in_process;
    $output = 'OK';
    /* process the command, don't accept bad commands */
    if (substr_count(strtolower($command), 'quit')) {
        close_connection($socket, 'Host Disconnect Request Received.');
        return 'OK';
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'update')) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'graph')) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'tune')) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'create')) {
        /* ok to run, check for structured paths */
        if (read_config_option('extended_paths') == 'on') {
            $parts = explode(' ', $command);
            $data_source_path = $parts[1];
            if (!is_dir(dirname($data_source_path))) {
                if (mkdir(dirname($data_source_path), 0775)) {
                    if ($config['cacti_server_os'] != 'win32') {
                        $owner_id = fileowner($config['rra_path']);
                        $group_id = filegroup($config['rra_path']);
                        if (chown(dirname($data_source_path), $owner_id) && chgrp(dirname($data_source_path), $group_id)) {
                            /* permissions set ok */
                        } else {
                            cacti_log("ERROR: Unable to set directory permissions for '" . dirname($data_source_path) . "'", FALSE);
                        }
                    }
                } else {
                    cacti_log("ERROR: Unable to create directory '" . dirname($data_source_path) . "'", FALSE);
                }
            }
        }
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'status')) {
        close_connection($socket, 'Server Status OK');
        return 'OK';
    } else {
        close_connection($socket, "WARNING: Unknown RRD Command '" . $command . "' This activity will be logged!! Goodbye.");
        return 'OK';
    }
    boost_svr_log("RRD Command '" . $command . "'");
    /* update/create the rrd */
    if (!$multiprocess) {
        boost_rrdtool_execute_internal($command, false, RRDTOOL_OUTPUT_STDOUT, 'BOOST SERVER');
    } else {
        /* store the correct information in the array */
        $rrdupdates_in_process[intval($socket)]['socket'] = $socket;
        if (strlen($rrd_update_path) && !substr_count($command, 'create ')) {
            $command = str_replace('update ', '', $command);
            exec_background($php_binary_path, 'boost_rrdupdate.php ' . intval($socket) . ' ' . $rrd_update_path . ' ' . $command);
        } else {
            exec_background($php_binary_path, 'boost_rrdupdate.php ' . intval($socket) . ' ' . $rrd_path . ' ' . $command);
        }
    }
    /* send the output back to the cleint if not multiprocess */
    if (!$multiprocess) {
        socket_write($socket, $output . $eol, strlen($output . $eol));
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:61,代码来源:boost_server.php


示例4: boost_poller_bottom

function boost_poller_bottom()
{
    global $config;
    include_once $config['library_path'] . '/poller.php';
    chdir($config['base_path']);
    if (read_config_option('boost_rrd_update_enable') == 'on') {
        $command_string = read_config_option('path_php_binary');
        if (read_config_option('path_boost_log') != '') {
            if ($config['cacti_server_os'] == 'unix') {
                $extra_args = '-q ' . $config['base_path'] . '/poller_boost.php >> ' . read_config_option('path_boost_log') . ' 2>&1';
            } else {
                $extra_args = '-q ' . $config['base_path'] . '/poller_boost.php >> ' . read_config_option('path_boost_log');
            }
        } else {
            $extra_args = '-q ' . $config['base_path'] . '/poller_boost.php';
        }
        exec_background($command_string, $extra_args);
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:19,代码来源:boost.php


示例5: syslog_poller_bottom

function syslog_poller_bottom()
{
    global $config;
    $command_string = read_config_option('path_php_binary');
    $extra_args = ' -q ' . $config['base_path'] . '/plugins/syslog/syslog_process.php';
    exec_background($command_string, $extra_args);
}
开发者ID:Cacti,项目名称:plugin_syslog,代码行数:7,代码来源:setup.php


示例6: poller_maintenance

function poller_maintenance()
{
    global $config;
    $command_string = trim(read_config_option('path_php_binary'));
    // If its not set, just assume its in the path
    if (trim($command_string) == '') {
        $command_string = 'php';
    }
    $extra_args = ' -q ' . $config['base_path'] . '/poller_maintenance.php';
    exec_background($command_string, $extra_args);
}
开发者ID:MrWnn,项目名称:cacti,代码行数:11,代码来源:functions.php


示例7: read_config_option

		}

		rrd_close($rrdtool_pipe);

		/* process poller commands */
		if (db_fetch_cell("select count(*) from poller_command") > 0) {
			$command_string = read_config_option("path_php_binary");
			$extra_args = "-q " . $config["base_path"] . "/poller_commands.php";
			exec_background($command_string, "$extra_args");
		}

		/* graph export */
		if ((read_config_option("export_type") != "disabled") && (read_config_option("export_timing") != "disabled")) {
			$command_string = read_config_option("path_php_binary");
			$extra_args = "-q " . $config["base_path"] . "/poller_export.php";
			exec_background($command_string, "$extra_args");
		}

		if ($method == "spine") {
			chdir(read_config_option("path_webroot"));
		}
	}else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM) {
		cacti_log("NOTE: There are no items in your poller for this polling cycle!", TRUE, "POLLER");
	}

	$poller_runs_completed++;

	/* record the start time for this loop */
	list($micro,$seconds) = split(" ", microtime());
	$loop_end = $seconds + $micro;
开发者ID:songchin,项目名称:Cacti,代码行数:30,代码来源:poller.php


示例8: reports_poller_bottom

/**
 * define the reports code that will be processed at the end of each polling event
 */
function reports_poller_bottom()
{
    global $config;
    include_once $config["base_path"] . "/lib/poller.php";
    $command_string = read_config_option("path_php_binary");
    $extra_args = "-q " . $config["base_path"] . "/poller_reports.php";
    exec_background($command_string, "{$extra_args}");
}
开发者ID:MrWnn,项目名称:cacti,代码行数:11,代码来源:reports.php


示例9: mikrotik_poller_bottom

function mikrotik_poller_bottom()
{
    global $config;
    include_once $config['base_path'] . '/lib/poller.php';
    exec_background(read_config_option('path_php_binary'), ' -q ' . $config['base_path'] . '/plugins/mikrotik/poller_mikrotik.php -M');
}
开发者ID:Cacti,项目名称:plugin_mikrotik,代码行数:6,代码来源:setup.php


示例10: read_config_option

     /* process poller commands */
     if (db_fetch_cell('SELECT COUNT(*) FROM poller_command') > 0) {
         $command_string = read_config_option('path_php_binary');
         $extra_args = '-q "' . $config['base_path'] . '/poller_commands.php"';
         exec_background($command_string, $extra_args);
     } else {
         /* no re-index or Rechache present on this run
          * in case, we have more PCOMMANDS than recaching, this has to be moved to poller_commands.php
          * but then we'll have to call it each time to make sure, stats are updated */
         db_execute("REPLACE INTO settings (name,value) VALUES ('stats_recache','RecacheTime:0.0 DevicesRecached:0')");
     }
     /* graph export */
     if (read_config_option('export_type') != 'disabled' && read_config_option('export_timing') != 'disabled') {
         $command_string = read_config_option('path_php_binary');
         $extra_args = '-q "' . $config['base_path'] . '/poller_export.php"';
         exec_background($command_string, $extra_args);
     }
     if ($method == 'spine') {
         chdir(read_config_option('path_webroot'));
     }
 } else {
     if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
         cacti_log('NOTE: There are no items in your poller for this polling cycle!', true, 'POLLER');
     }
 }
 $poller_runs_completed++;
 /* record the start time for this loop */
 list($micro, $seconds) = explode(' ', microtime());
 $loop_end = $seconds + $micro;
 $loop_time = $loop_end - $loop_start;
 if ($loop_time < $poller_interval) {
开发者ID:MrWnn,项目名称:cacti,代码行数:31,代码来源:poller.php


示例11: error_reporting

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
$exe = 'php';
$args = '-c C:\\wamp\\bin\\apache\\Apache2.2.10\\bin\\php.ini socket.php';
exec_background($exe, $args);
function exec_background($exe, $args = '')
{
    if (substr(php_uname(), 0, 7) == "Windows") {
        pclose(popen("start \"bla\" \"" . $exe . "\" " . $args, "r"));
    } else {
        exec($exe . " " . $args . " > /dev/null &");
    }
}
echo date(DATE_ATOM);
开发者ID:vietlethanh,项目名称:KooKooBackEnd,代码行数:16,代码来源:create-socket.php


示例12: dsstats_poller_bottom

function dsstats_poller_bottom()
{
    global $config;
    include_once $config["library_path"] . "/poller.php";
    chdir($config["base_path"]);
    if (read_config_option('dsstats_enable') == 'on') {
        $command_string = read_config_option("path_php_binary");
        if (read_config_option("path_dsstats_log") != "") {
            if ($config["cacti_server_os"] == "unix") {
                $extra_args = "-q " . $config["base_path"] . "/poller_dsstats.php >> " . read_config_option("path_dsstats_log") . " 2>&1";
            } else {
                $extra_args = "-q " . $config["base_path"] . "/poller_dsstats.php >> " . read_config_option("path_dsstats_log");
            }
        } else {
            $extra_args = "-q " . $config["base_path"] . "/poller_dsstats.php";
        }
        exec_background($command_string, "{$extra_args}");
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:19,代码来源:dsstats.php


示例13: run_command

function run_command($socket, $command, $multiprocess)
{
    global $config, $eol, $rrdtool_pipe, $rrd_path, $php_binary_path, $rrd_update_path, $rrdupdates_in_process;
    $output = "OK";
    /* process the command, don't accept bad commands */
    if (substr_count(strtolower($command), "quit")) {
        close_connection($socket, "Host Disconnect Request Received.");
        return "OK";
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "update")) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "graph")) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "tune")) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "create")) {
        /* ok to run, check for structured paths */
        if (read_config_option("extended_paths") == "on") {
            $parts = explode(" ", $command);
            $data_source_path = $parts[1];
            if (!is_dir(dirname($data_source_path))) {
                if (mkdir(dirname($data_source_path), 0775)) {
                    if ($config["cacti_server_os"] != "win32") {
                        $owner_id = fileowner($config["rra_path"]);
                        $group_id = filegroup($config["rra_path"]);
                        if (chown(dirname($data_source_path), $owner_id) && chgrp(dirname($data_source_path), $group_id)) {
                            /* permissions set ok */
                        } else {
                            cacti_log("ERROR: Unable to set directory permissions for '" . dirname($data_source_path) . "'", FALSE);
                        }
                    }
                } else {
                    cacti_log("ERROR: Unable to create directory '" . dirname($data_source_path) . "'", FALSE);
                }
            }
        }
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "status")) {
        close_connection($socket, "Server Status OK");
        return "OK";
    } else {
        close_connection($socket, "WARNING: Unknown RRD Command '" . $command . "' This activity will be logged!! Goodbye.");
        return "OK";
    }
    boost_svr_log("RRD Command '" . $command . "'");
    /* update/create the rrd */
    if (!$multiprocess) {
        boost_rrdtool_execute_internal($command, false, RRDTOOL_OUTPUT_STDOUT, "BOOST SERVER");
    } else {
        /* store the correct information in the array */
        $rrdupdates_in_process[intval($socket)]["socket"] = $socket;
        if (strlen($rrd_update_path) && !substr_count($command, "create ")) {
            $command = str_replace("update ", "", $command);
            exec_background($php_binary_path, "plugins/boost/boost_rrdupdate.php " . intval($socket) . " " . $rrd_update_path . " " . $command);
        } else {
            exec_background($php_binary_path, "plugins/boost/boost_rrdupdate.php " . intval($socket) . " " . $rrd_path . " " . $command);
        }
    }
    /* send the output back to the cleint if not multiprocess */
    if (!$multiprocess) {
        socket_write($socket, $output . $eol, strlen($output . $eol));
    }
}
开发者ID:resmon,项目名称:resmon-cacti,代码行数:61,代码来源:boost_server.php


示例14: mactrack_poller_bottom

function mactrack_poller_bottom()
{
    global $config;
    include_once $config['base_path'] . '/lib/poller.php';
    include_once $config['base_path'] . '/lib/data_query.php';
    include_once $config['base_path'] . '/lib/graph_export.php';
    include_once $config['base_path'] . '/lib/rrd.php';
    $command_string = read_config_option('path_php_binary');
    $extra_args = '-q ' . $config['base_path'] . '/plugins/mactrack/poller_mactrack.php';
    exec_background($command_string, $extra_args);
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:11,代码来源:setup.php


示例15: collect_mactrack_data


//.........这里部分代码省略.........

							/* create the mac address */
							$mac = $mac_ad[0] . $delim . $mac_ad[1] . $delim . $mac_ad[2] . $delim . $mac_ad[3] . $delim . $mac_ad[4] . $delim . $mac_ad[5];

							/* update the array */
							$mac_ip_dns[$mac]["ip"]  = $line[1];
							$mac_ip_dns[$mac]["dns"] = $line[3];
						}
					}
					fclose($arp_dat);

					mactrack_debug("ARPWATCH: IP, DNS & MAC collection complete with ArpWatch");
				}else{
					cacti_log("ERROR: cannot open file ArpWatch database '$arp_db'");exit;
				}
			}
		}

		/* scan through all devices */
		$j = 0;
		$i = 0;
		$last_time = strtotime("now");
		$processes_available = $concurrent_processes;
		while ($j < $total_devices) {
			/* retreive the number of concurrent mac_track processes to run */
			/* default to 10 for now */
			$concurrent_processes = db_fetch_cell("SELECT value FROM settings WHERE name='mt_processes'");

			for ($i = 0; $i < $processes_available; $i++) {
				if (($j+$i) >= $total_devices) break;

				$extra_args = " -q " . $config["base_path"] . "/plugins/mactrack/mactrack_scanner.php -id=" . $device_ids[$i+$j]["device_id"] . $e_debug;
				mactrack_debug("CMD: " . $command_string . $extra_args);
				exec_background($command_string, $extra_args);
			}
			$j = $j + $i;

			/* launch the dns resolver if it hasn't been yet */
			if (($dns_resolver_required) && (!$resolver_launched)) {
				sleep(2);
				exec_background($command_string, " -q " . $config["base_path"] . "/plugins/mactrack/mactrack_resolver.php" . $e_debug . $e_site);
				$resolver_launched = TRUE;
				mactrack_debug("DNS Resolver process launched");
			}

			mactrack_debug("A process cycle launch just completed.");

			/* wait the correct number of seconds for proccesses prior to
			   attempting to update records */
			sleep(2);
			$current_time = strtotime("now");
			if (($current_time - $last_time) > read_config_option("mt_dns_prime_interval")) {
				/* resolve some ip's to mac addresses to let the resolver knock them out */
				db_execute("UPDATE mac_track_temp_ports
							INNER JOIN mac_track_ips
							ON (mac_track_temp_ports.mac_address=mac_track_ips.mac_address
							AND mac_track_temp_ports.site_id=mac_track_ips.site_id)
							SET mac_track_temp_ports.ip_address=mac_track_ips.ip_address,
							mac_track_temp_ports.updated=1
							WHERE mac_track_temp_ports.updated=0 AND mac_track_ips.scan_date='$scan_date'");
				mactrack_debug("Interum IP addresses to MAC addresses association pass complete.");

				$last_time = $current_time;
			}

			$processes_running = db_fetch_cell("SELECT count(*) FROM mac_track_processes");
开发者ID:avillaverdec,项目名称:cacti,代码行数:67,代码来源:poller_mactrack_backup.php


示例16: iper_poller_bottom

function iper_poller_bottom()
{
    global $config;
    $command_string = read_config_option("path_php_binary");
    $extra_args = "-q " . $config["base_path"] . "/plugins/iper/poller.php";
    exec_background($command_string, "{$extra_args}");
}
开发者ID:khoimt,项目名称:cacti-sample,代码行数:7,代码来源:setup.php


示例17: snmpagent_notification

function snmpagent_notification($notification, $mib, $varbinds, $severity = SNMPAGENT_EVENT_SEVERITY_MEDIUM)
{
    global $config;
    if (isset($config["snmpagent"]["notifications"]["ignore"][$notification])) {
        return false;
    }
    $path_snmptrap = read_config_option("snmpagent_path_snmptrap");
    if (!in_array($severity, array(SNMPAGENT_EVENT_SEVERITY_LOW, SNMPAGENT_EVENT_SEVERITY_MEDIUM, SNMPAGENT_EVENT_SEVERITY_HIGH, SNMPAGENT_EVENT_SEVERITY_CRITICAL))) {
        if (read_config_option('log_verbosity') > POLLER_VERBOSITY_NONE) {
            cacti_log('ERROR: Unknown event severity: "' . $severity . '" for ' . $notification . ' (' . $mib . ')', false, 'SNMPAGENT');
        }
        return false;
    }
    $enterprise_oid = db_fetch_cell("SELECT oid from snmpagent_cache where `name` = '" . $notification . "' AND `mib` = '" . $mib . "'");
    if (!$enterprise_oid) {
        /* system does not know this event */
        if (read_config_option('log_verbosity') > POLLER_VERBOSITY_NONE) {
            cacti_log('ERROR: Unknown event: ' . $notification . ' (' . $mib . ')', false, 'SNMPAGENT');
        }
        return false;
    } else {
        $branches = explode(".", $enterprise_oid);
        $specific_trap_number = array_pop($branches);
    }
    /* generate a list of SNMP notification receivers listening for this notification */
    $sql = "SELECT snmpagent_managers.*\n\t\t\t\tFROM snmpagent_managers_notifications\n\t\t\t\t\tINNER JOIN snmpagent_managers\n\t\t\t\t\tON (\n\t\t\t\t\t\tsnmpagent_managers.id = snmpagent_managers_notifications.manager_id\n\t\t\t\t\t)\n\t\t\t\tWHERE snmpagent_managers.disabled = 0 AND snmpagent_managers_notifications.notification = '{$notification}' AND snmpagent_managers_notifications.mib = '{$mib}'";
    $notification_managers = db_fetch_assoc($sql);
    if (!$notification_managers) {
        /* To bad! Nobody wants to hear our message. :( */
        if (in_array($severity, array(SNMPAGENT_EVENT_SEVERITY_HIGH, SNMPAGENT_EVENT_SEVERITY_CRITICAL))) {
            if (read_config_option('log_verbosity') > POLLER_VERBOSITY_NONE) {
                cacti_log('WARNING: No notification receivers configured for event: ' . $notification . ' (' . $mib . ')', false, 'SNMPAGENT');
            }
        } else {
            /* keep notifications of a lower/medium severity in mind to make a quicker decision next time */
            $config["snmpagent"]["notifications"]["ignore"][$notification] = 1;
        }
        return false;
    }
    $registered_var_binds = array();
    /* get a list of registered var binds */
    $sql = "SELECT\n\t\t\t\tsnmpagent_cache_notifications.attribute,\n\t\t\t\tsnmpagent_cache.oid,\n\t\t\t\tsnmpagent_cache.type,\n\t\t\t\tsnmpagent_cache_textual_conventions.type as tcType\n\t\t\tFROM snmpagent_cache_notifications\n\t\t\t\tLEFT JOIN snmpagent_cache\n\t\t\t\tON (\n\t\t\t\t\tsnmpagent_cache.mib = snmpagent_cache_notifications.mib\n\t\t\t\t\tAND\n\t\t\t\t\tsnmpagent_cache.name = snmpagent_cache_notifications.attribute\n\t\t\t\t)\n\t\t\t\tLEFT JOIN snmpagent_cache_textual_conventions\n\t\t\t\tON (\n\t\t\t\t\tsnmpagent_cache.mib = snmpagent_cache_textual_conventions.mib\n\t\t\t\t\tAND\n\t\t\t\t\tsnmpagent_cache.type = snmpagent_cache_textual_conventions.name\n\t\t\t\t)\n\t\t\tWHERE snmpagent_cache_notifications.name = '{$notification}' AND snmpagent_cache_notifications.mib = '{$mib}'\n\t\t\tORDER BY snmpagent_cache_notifications.sequence_id";
    $reg_var_binds = db_fetch_assoc($sql);
    if ($reg_var_binds && sizeof($reg_var_binds) > 0) {
        foreach ($reg_var_binds as $reg_var_bind) {
            $registered_var_binds[$reg_var_bind["attribute"]] = array("oid" => $reg_var_bind["oid"], "type" => $reg_var_bind["tcType"] ? $reg_var_bind["tcType"] : $reg_var_bind["type"]);
        }
    }
    $difference = array_diff(array_keys($registered_var_binds), array_keys($varbinds));
    if (sizeof($difference) == 0) {
        /* order the managers by message type to send out all notifications immmediately. Informs
        		   will take more processing time.
        		*/
        $sql = "SELECT snmpagent_managers.* FROM snmpagent_managers_notifications\n\t\t\t\t\tINNER JOIN snmpagent_managers\n\t\t\t\t\tON (\n\t\t\t\t\t\tsnmpagent_managers.id = snmpagent_managers_notifications.manager_id\n\t\t\t\t\t)\n\t\t\t\tWHERE snmpagent_managers_notifications.notification = '{$notification}' AND snmpagent_managers_notifications.mib = '{$mib}'\n\t\t\t\tORDER BY snmpagent_managers.snmp_message_type";
        $notification_managers = db_fetch_assoc($sql);
        if ($notification_managers && sizeof($notification_managers) > 0) {
            include_once $config["library_path"] . "/poller.php";
            /*
            TYPE: one of i, u, t, a, o, s, x, d, b
            	i: INTEGER, u: unsigned INTEGER, t: TIMETICKS, a: IPADDRESS
            	o: OBJID, s: STRING, x: HEX STRING, d: DECIMAL STRING, b: BITS
            	U: unsigned int64, I: signed int64, F: float, D: double
            */
            $smi2netsnmp_datatypes = array("integer" => "i", "integer32" => "i", "unsigned32" => "u", "gauge" => "i", "gauge32" => "i", "counter" => "i", "counter32" => "i", "counter64" => "I", "timeticks" => "t", "octect string" => "s", "opaque" => "s", "object identifier" => "o", "ipaddress" => "a", "networkaddress" => "IpAddress", "bits" => "b", "displaystring" => "s", "physaddress" => "s", "macaddress" => "s", "truthvalue" => "i", "testandincr" => "i", "autonomoustype" => "o", "variablepointer" => "o", "rowpointer" => "o", "rowstatus" => "i", "timestamp" => "t", "timeinterval" => "i", "dateandtime" => "s", "storagetype" => "i", "tdomain" => "o", "taddress" => "s");
            $log_notification_varbinds = "";
            $snmp_notification_varbinds = "";
            foreach ($notification_managers as $notification_manager) {
                if (!$snmp_notification_varbinds) {
                    foreach ($registered_var_binds as $name => $attributes) {
                        $snmp_notification_varbinds .= " " . $attributes["oid"] . " " . $smi2netsnmp_datatypes[strtolower($attributes["type"])] . " \"" . str_replace('"', "'", $varbinds[$name]) . "\"";
                        $log_notification_varbinds .= $name . ":\"" . str_replace('"', "'", $varbinds[$name]) . "\" ";
                    }
                }
                if ($notification_manager["snmp_version"] == 1) {
                    $args = " -v 1 -c " . $notification_manager["snmp_community"] . " " . $notification_manager["hostname"] . ":" . $notification_manager["snmp_port"] . " " . $enterprise_oid . " \"\" 6 " . $specific_trap_number . " \"\"" . $snmp_notification_varbinds;
                } else {
                    if ($notification_manager["snmp_version"] == 2) {
                        $args = " -v 2c -c " . $notification_manager["snmp_community"] . ($notification_manager["snmp_message_type"] == 2 ? " -Ci " : "") . " " . $notification_manager["hostname"] . ":" . $notification_manager["snmp_port"] . " \"\" " . $enterprise_oid . $snmp_notification_varbinds;
                    } else {
                        if ($notification_manager["snmp_version"] == 3) {
                            $args = " -v 3 " . ($notification_manager["snmp_message_type"] == 2 ? " -Ci " : "") . " -u " . $notification_manager["snmp_username"];
                            if ($notification_manager["snmp_auth_password"] && $notification_manager["snmp_priv_password"]) {
                                $snmp_security_level = "authPriv";
                            } elseif ($notification_manager["snmp_auth_password"] && !$notification_manager["snmp_priv_password"]) {
                                $snmp_security_level = "authNoPriv";
                            } else {
                                $snmp_security_level = "noAuthNoPriv";
                            }
                            $args .= " -l " . $snmp_security_level . ($snmp_security_level != "noAuthNoPriv" ? " -a " . $notification_manager["snmp_auth_protocol"] . " -A " . $notification_manager["snmp_auth_password"] : "") . ($snmp_security_level == "authPriv" ? " -x " . $notification_manager["snmp_priv_protocol"] . " -X " . $notification_manager["snmp_priv_password"] : "") . " " . $notification_manager["hostname"] . ":" . $notification_manager["snmp_port"] . " \"\" " . $enterprise_oid . $snmp_notification_varbinds;
                        }
                    }
                }
                /* execute net-snmp to generate this notification in the background */
                exec_background(escapeshellcmd($path_snmptrap), escapeshellcmd($args));
                /* insert a new entry into the notification log for that SNMP receiver */
                $save = array();
                $save["id"] = 0;
                $save["time"] = time();
                $save["severity"] = $severity;
                $save["manager_id"] = $notification_manager["id"];
//.........这里部分代码省略.........
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:snmpagent.php


示例18: read_config_option

                         $smsalert = "Sev:" . $severities[$alert["severity"]] . ", Host:" . $a["host"] . ", URL:" . read_config_option("alert_base_url") . "plugins/syslog/syslog.php?tab=current&id=" . $sequence;
                         syslog_sendemail(trim($alert['email']), '', 'Event Alert - ' . $alert['name'], $html ? $htmlm : $alertm, $smsalert);
                         if ($alert['open_ticket'] == 'on' && strlen(read_config_option("syslog_ticket_command"))) {
                             if (is_executable(read_config_option("syslog_ticket_command"))) {
                                 exec(read_config_option("syslog_ticket_command") . " --alert-name='" . clean_up_name($alert['name']) . "'" . " --severity='" . $alert['severity'] . "'" . " --hostlist='" . implode(",", $hostlist) . "'" . " --message='" . $alert['message'] . "'");
                             }
                         }
                     }
                 } else {
                     /* get a list of hosts impacted */
                     $hostlist[] = $a['host'];
                 }
                 if (trim($alert['command']) != "" && !$ignore) {
                     $command = alert_replace_variables($alert, $a);
                     cacti_log("SYSLOG NOTICE: Executing '{$command}'", true, "SYSTEM");
                     exec_background("/bin/sh", $command);
                 }
             }
             $htmlm .= "</table></body></html>";
             $alertm .= "-----------------------------------------------\n\n";
             if ($alert["method"] == 1) {
                 $sequence = syslog_log_alert($alert["id"], $alert["name"] . " [" . $alert["message"] . "]", $alert["severity"], $at[0], sizeof($at), $htmlm);
                 $smsalert = "Sev:" . $severities[$alert["severity"]] . ", Count:" . sizeof($at) . ", URL:" . read_config_option("alert_base_url") . "plugins/syslog/syslog.php?tab=current&id=" . $sequence;
             }
             syslog_debug("Alert Rule '" . $alert['name'] . "' has been activated");
         }
     }
 }
 if ($alertm != '' && $alert['method'] == 1) {
     $resend = true;
     if ($alert['repeat_alert'] > 0) {
开发者ID:khoimt,项目名称:cacti-sample,代码行数:31,代码来源:syslog_process.php


示例19: process_graphs

function process_graphs()
{
    global $config, $debug, $start, $forcerun;
    exec_background(read_config_option("path_php_binary"), " -q " . $config["base_path"] . "/plugins/hmib/poller_graphs.php" . ($forcerun ? " --force" : "") . ($debug ? " --debug" : ""));
}
开发者ID:khoimt,项目名称:cacti-sample,代码行数:5,代码来源:poller_hmib.php


示例20: process_graphs

function process_graphs()
{
    global $config, $debug, $start, $forcerun;
    exec_background(read_config_option('path_php_binary'), ' -q ' . $config['base_path'] . '/plugins/mikrotik/poller_graphs.php' . ($forcerun ? ' --force' : '') . ($debug ? ' --debug' : ''));
}
开发者ID:Cacti,项目名称:plugin_mikrotik,代码行数:5,代码来源:poller_mikrotik.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP exec_filter函数代码示例发布时间:2022-05-15
下一篇:
PHP exec_action函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap