예제 #1
0
function plugin_weathermap_install()
{
    api_plugin_register_hook('weathermap', 'config_arrays', 'weathermap_config_arrays', 'setup.php');
    api_plugin_register_hook('weathermap', 'config_settings', 'weathermap_config_settings', 'setup.php');
    api_plugin_register_hook('weathermap', 'top_header_tabs', 'weathermap_show_tab', 'setup.php');
    api_plugin_register_hook('weathermap', 'top_graph_header_tabs', 'weathermap_show_tab', 'setup.php');
    api_plugin_register_hook('weathermap', 'draw_navigation_text', 'weathermap_draw_navigation_text', 'setup.php');
    api_plugin_register_hook('weathermap', 'top_graph_refresh', 'weathermap_top_graph_refresh', 'setup.php');
    api_plugin_register_hook('weathermap', 'page_title', 'weathermap_page_title', 'setup.php');
    api_plugin_register_hook('weathermap', 'page_head', 'weathermap_page_head', 'setup.php');
    api_plugin_register_hook('weathermap', 'poller_top', 'weathermap_poller_top', 'setup.php');
    api_plugin_register_hook('weathermap', 'poller_output', 'weathermap_poller_output', 'setup.php');
    api_plugin_register_hook('weathermap', 'poller_bottom', 'weathermap_poller_bottom', 'setup.php');
    weathermap_setup_table();
}
                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:
예제 #3
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 . ")");
    }
}