Ejemplo n.º 1
0
function GenerateGraph($farmid, $role_name, $rrddbpath, $watchername, $graph_type)
{
    if (CONFIG::$RRD_GRAPH_STORAGE_TYPE == RRD_STORAGE_TYPE::AMAZON_S3) {
        $image_path = APPPATH . "/cache/stats/{$farmid}/{$role_name}.{$watchername}.{$graph_type}.gif";
    } else {
        $image_path = CONFIG::$RRD_GRAPH_STORAGE_PATH . "/{$farmid}/{$role_name}_{$watchername}.{$graph_type}.gif";
    }
    @mkdir(dirname($image_path), 0777, true);
    $graph_info = GetGraphicInfo($graph_type);
    if (file_exists($image_path)) {
        clearstatcache();
        $time = filemtime($image_path);
        if ($time > time() - $graph_info['update_every']) {
            return;
        }
    }
    // Plot daily graphic
    try {
        $Reflect = new ReflectionClass("{$watchername}Watcher");
        $PlotGraphicMethod = $Reflect->getMethod("PlotGraphic");
        $PlotGraphicMethod->invoke(NULL, $rrddbpath, $image_path, $graph_info);
    } catch (Exception $e) {
        Logger::getLogger('STATS')->fatal("Cannot plot graphic: {$e->getMessage()}");
        return;
    }
}
Ejemplo n.º 2
0
function GenerateGraph($farmid, $role_name, $rrddbpath, $watchername, $graph_type)
{
    $image_path = \Scalr::config('scalr.stats_poller.images_path') . "/{$farmid}/{$role_name}_{$watchername}.{$graph_type}.gif";
    if (!@file_exists(dirname($image_path))) {
        @mkdir(dirname($image_path), 0777, true);
    }
    $graph_info = GetGraphicInfo($graph_type);
    if (file_exists($image_path)) {
        clearstatcache();
        $time = filemtime($image_path);
        if ($time > time() - $graph_info['update_every']) {
            return;
        }
    }
    // Plot daily graphic
    try {
        $Reflect = new ReflectionClass("{$watchername}Watcher");
        $PlotGraphicMethod = $Reflect->getMethod("PlotGraphic");
        $PlotGraphicMethod->invoke(NULL, $rrddbpath, $image_path, $graph_info);
    } catch (Exception $e) {
        Logger::getLogger('STATS')->fatal("Cannot plot graphic: {$e->getMessage()}");
        return;
    }
}