function boost_graph_set_file($data) { global $config, $boost_sock, $graph_data_array; /* suppress warnings */ if (defined("E_DEPRECATED")) { error_reporting(E_ALL ^ E_DEPRECATED); } else { error_reporting(E_ALL); } /* install the boost error handler */ set_error_handler("boost_error_handler"); if (isset($_SESSION["sess_current_timespan"])) { $timespan = $_SESSION["sess_current_timespan"]; } else { $timespan = 0; } /* check the graph cache and use it if it is valid, otherwise turn over to * cacti's graphing fucntions. */ if (read_config_option("boost_png_cache_enable") && boost_determine_caching_state()) { $cache_directory = read_config_option("boost_png_cache_directory"); if (strlen($cache_directory)) { if (is_dir($cache_directory)) { if ($data["rra_id"] > 0) { $cache_file = $cache_directory . "/lgi_" . $data["local_graph_id"] . "_rrai_" . $data["rra_id"]; } else { $cache_file = $cache_directory . "/lgi_" . $data["local_graph_id"] . "_rrai_" . $data["rra_id"] . "_tsi_" . $timespan; } if (isset($graph_data_array["graph_height"])) { $cache_file .= "_height_" . $graph_data_array["graph_height"]; } if (isset($graph_data_array["graph_width"])) { $cache_file .= "_width_" . $graph_data_array["graph_width"]; } if (isset($graph_data_array["graph_nolegend"])) { $cache_file .= "_thumb.png"; } else { $cache_file .= ".png"; } if (is_writable($cache_directory)) { /* if the cache file was created in a prior step, save it */ if (strlen($data["output"]) > 10) { if ($fileptr = fopen($cache_file, "w")) { fwrite($fileptr, $data["output"], strlen($data["output"])); fclose($fileptr); chmod($cache_file, 666); } } } else { cacti_log("ERROR: Boost Cache Directory is not writable! Can not cache images", FALSE, "BOOST"); } } else { cacti_log("ERROR: Boost Cache Directory does not exist! Can not cache images", FALSE, "BOOST"); } } else { cacti_log("ERROR: Boost Cache Directory variable is not set! Can not cache images", FALSE, "BOOST"); } } /* restore original error handler */ restore_error_handler(); }
function boost_graph_set_file(&$output, $local_graph_id, $rra_id) { global $config, $boost_sock, $graph_data_array; /* get access to the SNMP Cache of BOOST*/ $mc = new MibCache('CACTI-BOOST-MIB'); /* suppress warnings */ if (defined('E_DEPRECATED')) { error_reporting(E_ALL ^ E_DEPRECATED); } else { error_reporting(E_ALL); } /* install the boost error handler */ set_error_handler('boost_error_handler'); if (isset($_SESSION['sess_current_timespan'])) { $timespan = $_SESSION['sess_current_timespan']; } else { $timespan = 0; } /* check the graph cache and use it if it is valid, otherwise turn over to * cacti's graphing fucntions. */ if (read_config_option('boost_png_cache_enable') && boost_determine_caching_state()) { $cache_directory = read_config_option('boost_png_cache_directory'); if (strlen($cache_directory)) { if (is_dir($cache_directory)) { if ($rra_id > 0) { $cache_file = $cache_directory . '/lgi_' . $local_graph_id . '_rrai_' . $rra_id; } else { $cache_file = $cache_directory . '/lgi_' . $local_graph_id . '_rrai_' . $rra_id . '_tsi_' . $timespan; } if (isset($graph_data_array['graph_height'])) { $cache_file .= '_height_' . $graph_data_array['graph_height']; } if (isset($graph_data_array['graph_width'])) { $cache_file .= '_width_' . $graph_data_array['graph_width']; } if (isset($graph_data_array['graph_nolegend'])) { $cache_file .= '_thumb.png'; } else { $cache_file .= '.png'; } if (is_writable($cache_directory)) { /* if the cache file was created in a prior step, save it */ if (strlen($output) > 10) { if ($fileptr = fopen($cache_file, 'w')) { fwrite($fileptr, $output, strlen($output)); fclose($fileptr); chmod($cache_file, 0666); /* count the number of images that had to be cached */ $mc->object('boostStatsTotalsImagesCacheWrites')->count(); $mc->object('boostStatsLastUpdate')->set(time()); } } } else { cacti_log('ERROR: Boost Cache Directory is not writable! Can not cache images', false, 'BOOST'); } } else { cacti_log('ERROR: Boost Cache Directory does not exist! Can not cache images', false, 'BOOST'); } } else { cacti_log('ERROR: Boost Cache Directory variable is not set! Can not cache images', false, 'BOOST'); } } /* restore original error handler */ restore_error_handler(); }