/**
  */
 public function handleRebuildNowStep2($request, $appObject)
 {
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "all.php";
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "poller-common.php";
     WMCactiAPI::pageTopConsole();
     print "<h3>Rebuilding all maps</h3><strong>NOTE: Because your Cacti poller process probably doesn't run as ";
     print "the same user as your webserver, it's possible this will fail with file permission problems even ";
     print "though the normal poller process runs fine. In some situations, it MAY have memory_limit problems, if ";
     print "your mod_php/ISAPI module uses a different php.ini to your command-line PHP.</strong><hr><pre>";
     weathermap_run_maps(realpath(dirname(__FILE__) . "/.."));
     print "</pre>";
     print "<hr /><h3>Done.</h3>";
     WMCactiAPI::pageBottom();
 }
	print "<h3>REALLY Rebuild all maps?</h3><strong>NOTE: Because your Cacti poller process probably doesn't run as the same user as your webserver, it's possible this will fail with file permission problems even though the normal poller process runs fine. In some situations, it MAY have memory_limit problems, if your mod_php/ISAPI module uses a different php.ini to your command-line PHP.</strong><hr>";

	print "<p>It is recommended that you don't use this feature, unless you understand and accept the problems it may cause.</p>";
	print "<h4><a href=\"weathermap-cacti-plugin-mgmt.php?action=rebuildnow2\">YES</a></h4>";
	print "<h1><a href=\"weathermap-cacti-plugin-mgmt.php\">NO</a></h1>";
	include_once($config["base_path"]."/include/bottom_footer.php");
	break;

case 'rebuildnow2':
	include_once(dirname(__FILE__).DIRECTORY_SEPARATOR."Weathermap.class.php");
	include_once(dirname(__FILE__).DIRECTORY_SEPARATOR."lib".DIRECTORY_SEPARATOR."poller-common.php");

		include_once($config["base_path"]."/include/top_header.php");
	print "<h3>Rebuilding all maps</h3><strong>NOTE: Because your Cacti poller process probably doesn't run as the same user as your webserver, it's possible this will fail with file permission problems even though the normal poller process runs fine. In some situations, it MAY have memory_limit problems, if your mod_php/ISAPI module uses a different php.ini to your command-line PHP.</strong><hr><pre>";
	weathermap_run_maps(dirname(__FILE__));
	print "</pre>";
	print "<hr /><h3>Done.</h3>";
	include_once($config["base_path"]."/include/bottom_footer.php");

		break;

	// by default, just list the map setup
default:
	include_once($config["base_path"]."/include/top_header.php");
	maplist();
	weathermap_footer_links();	
	include_once($config["base_path"]."/include/bottom_footer.php");
	break;
}
                break;
        }
    }
}
// check if the goalposts have moved
if (is_dir($cacti_base) && file_exists($cacti_base . "/include/global.php")) {
    // include the cacti-config, so we know about the database
    include_once $cacti_base . "/include/global.php";
} elseif (is_dir($cacti_base) && file_exists($cacti_base . "/include/config.php")) {
    // include the cacti-config, so we know about the database
    include_once $cacti_base . "/include/config.php";
} else {
    echo "Couldn't find a usable Cacti config";
}
if ($list_ids) {
    print 'PHP Network Weathermap v' . $WEATHERMAP_VERSION . "\n";
    print "Available map ids:\n";
    $SQL = "select m.*, g.name as groupname from weathermap_maps m,weathermap_groups g where m.group_id=g.id ";
    $SQL .= "order by id";
    $queryrows = db_fetch_assoc($SQL);
    // build a list of the maps that we're actually going to run
    if (is_array($queryrows)) {
        foreach ($queryrows as $map) {
            printf("%4d - %8s - %-30s %s\n", $map['id'], $map['active'] == 'on' ? 'enabled' : 'disabled', $map['configfile'], $map['filehash']);
        }
    }
    exit;
}
weathermap_setup_table();
weathermap_run_maps(dirname(__FILE__), $map_id);
// vim:ts=4:sw=4:
示例#4
0
function weathermap_poller_bottom()
{
    global $config;
    global $weathermap_debugging, $WEATHERMAP_VERSION;
    include_once $config["library_path"] . DIRECTORY_SEPARATOR . "database.php";
    include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "poller-common.php";
    weathermap_setup_table();
    $renderperiod = read_config_option("weathermap_render_period");
    $rendercounter = read_config_option("weathermap_render_counter");
    $quietlogging = read_config_option("weathermap_quiet_logging");
    if ($renderperiod < 0) {
        // manual updates only
        if ($quietlogging == 0) {
            cacti_log("Weathermap {$WEATHERMAP_VERSION} - no updates ever", true, "WEATHERMAP");
        }
        return;
    } else {
        // if we're due, run the render updates
        if ($renderperiod == 0 || $rendercounter % $renderperiod == 0) {
            weathermap_run_maps(dirname(__FILE__));
        } else {
            if ($quietlogging == 0) {
                cacti_log("Weathermap {$WEATHERMAP_VERSION} - no update in this cycle ({$rendercounter})", true, "WEATHERMAP");
            }
        }
        # cacti_log("Weathermap counter is $rendercounter. period is $renderperiod.", true, "WEATHERMAP");
        // increment the counter
        $newcount = ($rendercounter + 1) % 1000;
        db_execute("replace into settings values('weathermap_render_counter'," . $newcount . ")");
    }
}