コード例 #1
0
ファイル: 0_8_7g_to_0_8_7h.php プロジェクト: andrei1489/cacti
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");
}
コード例 #2
0
ファイル: setup.php プロジェクト: khoimt/cacti-sample
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");
}
コード例 #3
0
ファイル: boost_server.php プロジェクト: MrWnn/cacti
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));
    }
}
コード例 #4
0
ファイル: boost.php プロジェクト: MrWnn/cacti
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);
    }
}
コード例 #5
0
ファイル: setup.php プロジェクト: Cacti/plugin_syslog
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);
}
コード例 #6
0
ファイル: functions.php プロジェクト: MrWnn/cacti
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);
}
コード例 #7
0
ファイル: poller.php プロジェクト: songchin/Cacti
		}

		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;
コード例 #8
0
ファイル: reports.php プロジェクト: MrWnn/cacti
/**
 * 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}");
}
コード例 #9
0
ファイル: setup.php プロジェクト: Cacti/plugin_mikrotik
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');
}
コード例 #10
0
ファイル: poller.php プロジェクト: MrWnn/cacti
     /* 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) {
コード例 #11
0
<?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);
コード例 #12
0
ファイル: dsstats.php プロジェクト: MrWnn/cacti
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}");
    }
}
コード例 #13
0
ファイル: boost_server.php プロジェクト: resmon/resmon-cacti
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));
    }
}
コード例 #14
0
ファイル: setup.php プロジェクト: Cacti/plugin_mactrack
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);
}
コード例 #15
0
function collect_mactrack_data($start, $site_id = 0) {
	global $max_run_duration, $config, $debug, $scan_date;

	if (defined('CACTI_BASE_PATH')) {
		$config["base_path"] = CACTI_BASE_PATH;
	}

	/* reset the processes table */
	db_execute("TRUNCATE TABLE mac_track_processes");

	/* dns resolver binary */
	$resolver_launched = FALSE;

	if (read_config_option("mt_reverse_dns") == "on") {
		$dns_resolver_required = TRUE;
	}else{
		$dns_resolver_required = FALSE;
	}

	/* get php binary path */
	$command_string = read_config_option("path_php_binary");

	/* save the scan date information */
	if ($site_id == '') {
		$scan_date = date("Y-m-d H:i:s");
		db_execute("REPLACE INTO settings (name, value) VALUES ('mt_scan_date', '$scan_date')");
	}

	/* just in case we've run too long */
	$exit_mactrack = FALSE;

	/* start mainline processing, order by site_id to keep routers grouped with switches */
	if ($site_id > 0) {
		$device_ids = db_fetch_assoc("SELECT device_id FROM mac_track_devices WHERE site_id='" . $site_id . "' and disabled=''");
	}else{
		$device_ids = db_fetch_assoc("SELECT device_id FROM mac_track_devices WHERE disabled='' ORDER BY site_id");
	}

	$total_devices = sizeof($device_ids);

	$concurrent_processes = read_config_option("mt_processes");

	if ($debug == TRUE) {
		$e_debug = " -d";
	}else{
		$e_debug = "";
	}

	if ($site_id) {
		$e_site = " -sid=$site_id";
	}else{
		$e_site = "";
	}

	/* add the parent process to the process list */
	db_process_add("-1");

	if ($total_devices > 0) {
		/* grab arpwatch data */
		if (read_config_option("mt_arpwatch") == "on") {
			$arp_db     = read_config_option("mt_arpwatch_path");
			$delim      = read_config_option("mt_mac_delim");
			$mac_ip_dns = array();

			if (file_exists($arp_db)) {
				$arp_dat = fopen($arp_db, "r");

				if ($arp_dat) {
					while (!feof($arp_dat)) {
						$line = fgets($arp_dat, 4096);

						if ($line != null) {
							$line = explode ("	", $line);

							$mac_ad = explode(":",$line[0]);
							for ($k=0;$k<6;$k++) {
								$mac_ad[$k] = strtoupper($mac_ad[$k]);
								if (1 == strlen($mac_ad[$k])) {
									$mac_ad[$k] = "0" . $mac_ad[$k];
								}
							}

							/* 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");

			if ($dns_resolver_required) {
				$processes_available = $concurrent_processes - $processes_running + 1;
			}else{
				$processes_available = $concurrent_processes - $processes_running;
			}

			/* take time to check for an exit condition */
			list($micro,$seconds) = explode(" ", microtime());
			$current = $seconds + $micro;

			/* exit if we've run too long */
			if (($current - $start) > $max_run_duration) {
				$exit_mactrack = TRUE;
				cacti_log("ERROR: MacTracking timed out during main script processing.\n");
				db_execute("DELETE FROM settings WHERE name='mactrack_process_status'");
				db_process_remove("-1");
				break;
			}else{
				db_execute("REPLACE INTO settings SET name='mactrack_process_status', value='Total:$total_devices Completed:$j'");
			}
		}

		/* wait for last process to exit */
		$processes_running = db_fetch_cell("SELECT count(*) FROM mac_track_processes WHERE device_id > 0");
		while (($processes_running > 0) && (!$exit_mactrack)) {
			$processes_running = db_fetch_cell("SELECT count(*) FROM mac_track_processes WHERE device_id > 0");
			$devices_running = db_fetch_cell("SELECT group_concat(CAST(`device_id` as CHAR) SEPARATOR ', ') as t FROM mac_track_processes;");
			/* 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.");
			}

			/* take time to check for an exit condition */
			list($micro,$seconds) = explode(" ", microtime());
			$current = $seconds + $micro;

			/* exit if we've run too long */
			if (($current - $start) > $max_run_duration) {
				$exit_mactrack = TRUE;
				cacti_log("ERROR: MacTracking timed out during main script processing.\n");
				break;
			}

			mactrack_debug("Waiting on " . $processes_running . " with id = [" . $devices_running ."] to complete prior to exiting.");
		}

		/* if arpwatch is enabled, let's let it pick up the stragglers, based upon IP address first */
		if ((read_config_option("mt_arpwatch") == "on") && (sizeof($mac_ip_dns))) {
			$ports = db_fetch_assoc("SELECT site_id, device_id, mac_address
				FROM mac_track_temp_ports
				WHERE updated=0");

			if (sizeof($ports)) {
			foreach($ports as $port) {
				if (isset($mac_ip_dns[$port["mac_address"]])) {
					db_execute("UPDATE mac_track_temp_ports
						SET updated=1, ip_address='" . $mac_ip_dns[$port["mac_address"]]["ip"] . "'" .
						($mac_ip_dns[$port["mac_address"]]["dns"] != '' ? ", dns_hostname='" . $mac_ip_dns[$port["mac_address"]]["dns"] . "'" : "") . "
						WHERE site_id=" . $port["site_id"] . "
						AND device_id=" . $port["device_id"] . "
						AND mac_address='" . $port["mac_address"] . "'");
				}
			}
			}
		}

		/* 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
					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.");

		/* populate the vendor_macs for this pass */
		db_execute("UPDATE mac_track_temp_ports SET vendor_mac=SUBSTRING(mac_address,1,8);");
		mactrack_debug("MAC addresses to Vendor MACS association pass complete.");

		/* update the vlan id's table */
		db_execute("UPDATE mac_track_vlans SET present='0'");
		db_execute("INSERT INTO mac_track_vlans (vlan_id, site_id, device_id, vlan_name, present) SELECT vlan_id, site_id, device_id, vlan_name, '1' AS present FROM mac_track_temp_ports ON DUPLICATE KEY UPDATE vlan_name=VALUES(vlan_name), present=VALUES(present);");
		db_execute("DELETE FROM mac_track_vlans WHERE present='0'");
		mactrack_debug("MAC VLAN's in VLAN Table Updated.");

		/* let the resolver know that the parent process is finished and then wait
		   for the resolver if applicable */
		db_process_remove("-1");

		while (!$exit_mactrack) {
			/* checking to see if the resolver is running */
			$resolver_running = db_fetch_row("SELECT * FROM mac_track_processes WHERE device_id=0");

			if (sizeof($resolver_running) == 0) {
				break;
			}

			/* take time to check for an exit condition */
			list($micro,$seconds) = explode(" ", microtime());
			$current = $seconds + $micro;

			/* exit if we've run too long */
			if (($current - $start) > $max_run_duration) {
				$exit_mactrack = TRUE;
				cacti_log("ERROR: MacTracking timed out during main script processing.\n");
				break;
			}
		}

		/* transfer temp port results into permanent table */
		db_execute("INSERT INTO mac_track_ports
					(site_id, device_id, hostname, dns_hostname, device_name,
					vlan_id, vlan_name, mac_address, vendor_mac, ip_address,
					port_number, port_name, scan_date, authorized)
					SELECT site_id, device_id, hostname, dns_hostname, device_name,
					vlan_id, vlan_name, mac_address, vendor_mac, ip_address,
					port_number, port_name, scan_date, authorized
					FROM mac_track_temp_ports
					ON DUPLICATE KEY UPDATE site_id=VALUES(site_id), hostname=VALUES(hostname),
					device_name=VALUES(device_name), vlan_id=VALUES(vlan_id), vlan_name=VALUES(vlan_name),
					vendor_mac=VALUES(vendor_mac), ip_address=VALUES(ip_address), dns_hostname=VALUES(dns_hostname),
					port_name=VALUES(port_name), authorized=VALUES(authorized)");
		mactrack_debug("Finished transferring scan results to main table.");

		/* transfer the subnet information, although primative, into the ip_ranges table */
		$ip_ranges = db_fetch_assoc("SELECT SUBSTRING_INDEX(`ip_address`,'.',3) AS ip_range,
					site_id,
					COUNT(DISTINCT ip_address) AS ips_current,
					scan_date AS ips_current_date
					FROM mac_track_temp_ports
					WHERE ip_address != ''
					GROUP BY ip_range, site_id");

		if (is_array($ip_ranges)) {
			foreach($ip_ranges as $ip_range) {
				$range_record = db_fetch_row("SELECT * FROM mac_track_ip_ranges WHERE ip_range='" . $ip_range["ip_range"] .
					"' AND site_id='" . $ip_range["site_id"] . "'");

				if (sizeof($range_record) == 0) {
					db_execute("REPLACE INTO `mac_track_ip_ranges`
						(ip_range, site_id, ips_current, ips_current_date)
						VALUES ('" .
						$ip_range["ip_range"] . "'," .
						$ip_range["site_id"] . ",'" .
						$ip_range["ips_current"] . "','" .
						$ip_range["ips_current_date"] . "')");
				}else{
					db_execute("UPDATE `mac_track_ip_ranges`
						SET ips_current='" . $ip_range["ips_current"] . "', " .
						"ips_current_date='" . $ip_range["ips_current_date"] . "'" .
						"WHERE ip_range='" . $range_record["ip_range"] . "' AND " .
						"site_id='" . $range_record["site_id"] . "'");
				}
			}
		}

		/* update the max values if required */
		db_execute("UPDATE `mac_track_ip_ranges`
					SET ips_max=ips_current, ips_max_date=ips_current_date
					WHERE ips_current > ips_max");

		/* collect statistics */
		if ($site_id == 0) {
			$stats = db_fetch_assoc("SELECT site_id,
							count(device_id) as total_devices,
							sum(ports_active) as total_oper_ports,
							sum(macs_active) as total_macs,
							sum(ports_total) as total_user_ports
							FROM mac_track_devices
							GROUP BY site_id");
		}else{
			$stats = db_fetch_assoc("SELECT site_id,
							count(device_id) as total_devices,
							sum(ports_active) as total_oper_ports,
							sum(macs_active) as total_macs,
							sum(ports_total) as total_user_ports
							FROM mac_track_devices
							WHERE site_id='$site_id'
							GROUP BY site_id");
		}

		/* collect total device errors */
		$errors = db_fetch_assoc("SELECT site_id, snmp_status, count(device_id) as total_device_errors
						FROM mac_track_devices
						GROUP BY site_id, snmp_status");

		$ips = array_rekey(db_fetch_assoc("SELECT site_id, count(ip_address) as total_ips
						FROM mac_track_ips
						WHERE scan_date='$scan_date'
						GROUP BY site_id"), "site_id", "total_ips");

		foreach($errors as $error) {
			if (!isset($error_count[$error["site_id"]])) {
				$error_count[$error["site_id"]] = 0;
			}
			if ($error["snmp_status"] <> 3) {
				$error_count[$error["site_id"]] += $error["total_device_errors"];
			}
		}

		foreach($stats as $stat) {
			$num_ips = @$ips[$stat["site_id"]];
			if (empty($num_ips)) $num_ips = 0;

			$update_string = "UPDATE mac_track_sites SET " .
				"total_devices='" . $stat["total_devices"] . "', " .
				"total_ips='" . $num_ips . "', " .
				"total_macs='" . $stat["total_macs"] . "', " .
				"total_oper_ports='" . $stat["total_oper_ports"] . "', " .
				"total_user_ports='" . $stat["total_user_ports"] . "', " .
				"total_device_errors='" . $error_count[$stat["site_id"]] . "' " .
				"WHERE site_id='" . $stat["site_id"] . "'";

			db_execute($update_string);
		}
		mactrack_debug("Finished updating site table with collection statistics.");

		/* process macwatch data */
		$macwatches = db_fetch_assoc("SELECT * FROM mac_track_macwatch");
		if (sizeof($macwatches)) {
			$from     = read_config_option("mt_from_email");
			$fromname = read_config_option("mt_from_name");

			foreach($macwatches as $record) {
				/* determine if we should check this one */
				$found = db_fetch_row("SELECT *
					FROM mac_track_temp_ports
					WHERE mac_address='" . $record["mac_address"] . "'");

				if (sizeof($found)) {
					/* set the subject */
					$subject = "MACAUTH Notification: Mac Address '" . $record["mac_address"] . "' Found, For: '" . $record["name"] . "'";

					/* set the message with replacements */
					$message = str_replace("<IP>", $found["ip_address"], $record["description"]);
					$message = str_replace("<MAC>", $found["mac_address"], $message);
					$message = str_replace("<TICKET>", $record["ticket_number"], $message);
					$message = str_replace("<SITENAME>", db_fetch_cell("SELECT site_name FROM mac_track_sites WHERE site_id=" . $found["site_id"]), $message);
					$message = str_replace("<DEVICEIP>", $found["hostname"], $message);
					$message = str_replace("<DEVICENAME>", $found["device_name"], $message);
					$message = str_replace("<PORTNUMBER>", $found["port_number"], $message);
					$message = str_replace("<PORTNAME>", $found["port_name"], $message);

					/* send out the email */
					if (!$record["discovered"] || $record["notify_schedule"] >= "2") {
						$mail = true;

						if ($record["notify_schedule"] > 2) {
							if (strtotime($record["date_last_notif"]) + $record["notify_schedule"] > time()) {
								$mail = false;
							}
						}

						if ($mail) {
							mactrack_mail($record["email_addresses"], $from, $fromname, $subject, $message, $headers = '');
						}
					}

					/* update the the correct information */
					db_execute("UPDATE mac_track_macwatch
						SET
							discovered=1,
							date_last_seen=NOW()" .
							(strtotime($record["date_first_seen"]) == 0 ? ", date_first_seen=NOW()":"") . "
						WHERE mac_address='" . $record["mac_address"] . "'");
				}
			}
		}

		/* process macauth data */
		$mac_auth_frequency = read_config_option("mt_macauth_email_frequency");
		if ($mac_auth_frequency != "disabled") {
			$last_macauth_time = read_config_option("mt_last_macauth_time");

			/* if it's time to e-mail */
			if (($last_macauth_time + ($mac_auth_frequency*60) > time()) ||
				($mac_auth_frequency == 0)) {
				mactrack_process_mac_auth_report($mac_auth_frequency, $last_macauth_time);
			}
		}

		/* process aggregated data */
		db_execute("UPDATE mac_track_aggregated_ports SET active_last=0;");
		db_execute("INSERT INTO mac_track_aggregated_ports
			(site_id, device_id, hostname, device_name,
			vlan_id, vlan_name, mac_address, vendor_mac, ip_address, dns_hostname,
			port_number, port_name, date_last, first_scan_date, count_rec, active_last, authorized)
			SELECT site_id, device_id, hostname, device_name,
			vlan_id, vlan_name, mac_address, vendor_mac, ip_address, dns_hostname,
			port_number, port_name, scan_date, scan_date, 1, 1, authorized
			FROM mac_track_temp_ports
			ON DUPLICATE KEY UPDATE count_rec=count_rec+1, active_last=1, date_last=mac_track_temp_ports.scan_date");

		/* purge the ip address and temp port table */
		db_execute("TRUNCATE TABLE mac_track_temp_ports");
		db_execute("DELETE FROM mac_track_ips WHERE scan_date<'$scan_date'");
		db_execute("OPTIMIZE TABLE mac_track_ips");
		db_execute("TRUNCATE TABLE mac_track_scan_dates");
		db_execute("REPLACE INTO mac_track_scan_dates (SELECT DISTINCT scan_date from mac_track_ports);");
	}else{
		cacti_log("NOTE: MACTRACK has no devices to process at this time\n");
	}
}
コード例 #16
0
ファイル: setup.php プロジェクト: khoimt/cacti-sample
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}");
}
コード例 #17
0
ファイル: snmpagent.php プロジェクト: MrWnn/cacti
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"];
                $save["notification"] = $notification;
                $save["mib"] = $mib;
                $save["varbinds"] = mysql_real_escape_string(substr($log_notification_varbinds, 0, 5000));
                sql_save($save, 'snmpagent_notifications_log');
                /* log the net-snmp command for Cacti admins if they wish for */
                if (read_config_option('log_verbosity') > POLLER_VERBOSITY_MEDIUM) {
                    cacti_log("NOTE: {$path_snmptrap} " . str_replace(array($notification_manager["snmp_auth_password"], $notification_manager["snmp_priv_password"]), '********', $args), false, 'SNMPAGENT');
                }
            }
        }
    } else {
        /* mismatching number of var binds */
        if (read_config_option('log_verbosity') > POLLER_VERBOSITY_NONE) {
            cacti_log('ERROR: Incomplete number of varbinds given for event: ' . $notification . ' (' . $mib . ')', false, 'SNMPAGENT');
        }
        return false;
    }
}
コード例 #18
0
                         $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) {
コード例 #19
0
ファイル: poller_hmib.php プロジェクト: khoimt/cacti-sample
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" : ""));
}
コード例 #20
0
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' : ''));
}
コード例 #21
0
                         $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['severity'], $at[0], sizeof($at), $htmlm, $hostlist);
                 $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) {
コード例 #22
0
ファイル: poller.php プロジェクト: songchin/Cacti
		if ($change_files) {
			exec_background($command_string, "$extra_args $first_host $last_host");

			$host_count = 1;
			$change_files = False;
			$process_file_number++;
			$first_host = 0;
			$last_host = 0;
		} /* End change_files */
	} /* End For Each */

	if ($host_count > 1) {
		$last_host = $item["id"];

		exec_background($command_string, "$extra_args $first_host $last_host");
		$process_file_number++;
	}

	/* insert the current date/time for graphs */
	db_execute("replace into settings (name,value) values ('date',NOW())");

	if ($poller == "1") {
		$max_threads = "N/A";
	}

	/* open a pipe to rrdtool for writing */
	$rrdtool_pipe = rrd_init();

	$loop_count = 0;
	while (1) {
コード例 #23
0
ファイル: setup.php プロジェクト: resmon/resmon-cacti
function boost_poller_bottom($output)
{
    global $config;
    include_once $config["base_path"] . "/lib/poller.php";
    $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"] . "/plugins/boost/poller_boost.php >> " . read_config_option("path_boost_log") . " 2>&1";
        } else {
            $extra_args = "-q " . $config["base_path"] . "/plugins/boost/poller_boost.php >> " . read_config_option("path_boost_log");
        }
    } else {
        $extra_args = "-q " . $config["base_path"] . "/plugins/boost/poller_boost.php";
    }
    exec_background($command_string, "{$extra_args}");
}
コード例 #24
0
ファイル: setup.php プロジェクト: Cacti/plugin_flowview
function flowview_poller_bottom()
{
    global $config;
    include_once $config['library_path'] . '/database.php';
    $time = time() - 3600;
    db_execute("delete from plugin_flowview_dnscache where time > 0 and time < {$time}");
    $t = time();
    $schedules = db_fetch_assoc("SELECT * FROM plugin_flowview_schedules WHERE enabled='on' AND ({$t} - sendinterval > lastsent)");
    if (!empty($schedules)) {
        $command_string = trim(read_config_option('path_php_binary'));
        if (trim($command_string) == '') {
            $command_string = 'php';
        }
        $extra_args = ' -q ' . $config['base_path'] . '/plugins/flowview/flowview_process.php';
        exec_background($command_string, $extra_args);
    }
}
コード例 #25
0
ファイル: setup.php プロジェクト: avillaverdec/cacti
function mactrack_poller_bottom () {
	global $config;

	if (defined('CACTI_BASE_PATH')) {
		$config["base_path"] = CACTI_BASE_PATH;
	}

	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");
}
コード例 #26
0
ファイル: setup.php プロジェクト: resmon/resmon-cacti
function rrdclean_poller_bottom()
{
    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'] . '/plugins/rrdclean/rrdmove.php';
    exec_background($command_string, $extra_args);
}