本文整理汇总了PHP中rrdtool_function_graph函数的典型用法代码示例。如果您正苦于以下问题:PHP rrdtool_function_graph函数的具体用法?PHP rrdtool_function_graph怎么用?PHP rrdtool_function_graph使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rrdtool_function_graph函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_mail
function send_mail($to, $from, $subject, $message, $filename = '', $headers = '')
{
global $config;
include_once $config["base_path"] . "/plugins/settings/include/mailer.php";
$message = str_replace('<SUBJECT>', $subject, $message);
$message = str_replace('<TO>', $to, $message);
$message = str_replace('<FROM>', $from, $message);
$how = read_config_option("settings_how");
if ($how < 0 || $how > 2) {
$how = 0;
}
if ($how == 0) {
$Mailer = new Mailer(array('Type' => 'PHP'));
} else {
if ($how == 1) {
$sendmail = read_config_option('settings_sendmail_path');
$Mailer = new Mailer(array('Type' => 'DirectInject', 'DirectInject_Path' => $sendmail));
} else {
if ($how == 2) {
$smtp_host = read_config_option("settings_smtp_host");
$smtp_port = read_config_option("settings_smtp_port");
$smtp_username = read_config_option("settings_smtp_username");
$smtp_password = read_config_option("settings_smtp_password");
$Mailer = new Mailer(array('Type' => 'SMTP', 'SMTP_Host' => $smtp_host, 'SMTP_Port' => $smtp_port, 'SMTP_Username' => $smtp_username, 'SMTP_Password' => $smtp_password));
}
}
}
if ($from == '') {
$from = read_config_option('settings_from_email');
$fromname = read_config_option('settings_from_name');
if ($from == "") {
if (isset($_SERVER['HOSTNAME'])) {
$from = 'Cacti@' . $_SERVER['HOSTNAME'];
} else {
$from = 'Cacti@cactiusers.org';
}
}
if ($fromname == "") {
$fromname = "Cacti";
}
$from = $Mailer->email_format($fromname, $from);
if ($Mailer->header_set('From', $from) === false) {
print "ERROR: " . $Mailer->error() . "\n";
return $Mailer->error();
}
} else {
$from = $Mailer->email_format('Cacti', $from);
if ($Mailer->header_set('From', $from) === false) {
print "ERROR: " . $Mailer->error() . "\n";
return $Mailer->error();
}
}
if ($to == '') {
return "Mailer Error: No <b>TO</b> address set!!<br>If using the <i>Test Mail</i> link, please set the <b>Alert e-mail</b> setting.";
}
$to = explode(',', $to);
foreach ($to as $t) {
if (trim($t) != '' && !$Mailer->header_set("To", $t)) {
print "ERROR: " . $Mailer->error() . "\n";
return $Mailer->error();
}
}
$wordwrap = read_config_option("settings_wordwrap");
if ($wordwrap == '') {
$wordwrap = 76;
}
if ($wordwrap > 9999) {
$wordwrap = 9999;
}
if ($wordwrap < 0) {
$wordwrap = 76;
}
$Mailer->Config["Mail"]["WordWrap"] = $wordwrap;
if (!$Mailer->header_set("Subject", $subject)) {
print "ERROR: " . $Mailer->error() . "\n";
return $Mailer->error();
}
if (is_array($filename) && !empty($filename) && strstr($message, '<GRAPH>') !== 0) {
foreach ($filename as $val) {
$graph_data_array = array("output_flag" => RRDTOOL_OUTPUT_STDOUT);
$data = @rrdtool_function_graph($val['local_graph_id'], $val['rra_id'], $graph_data_array);
if ($data != "") {
$cid = $Mailer->content_id();
if ($Mailer->attach($data, $val['filename'] . '.png', "image/png", "inline", $cid) == false) {
print "ERROR: " . $Mailer->error() . "\n";
return $Mailer->error();
}
$message = str_replace('<GRAPH>', "<br><br><img src='cid:{$cid}'>", $message);
} else {
$message = str_replace('<GRAPH>', "<br><img src='" . $val['file'] . "'><br>Could not open!<br>" . $val['file'], $message);
}
}
}
$text = array('text' => '', 'html' => '');
if ($filename == '') {
$message = str_replace('<br>', "\n", $message);
$message = str_replace('<BR>', "\n", $message);
$message = str_replace('</BR>', "\n", $message);
$text['text'] = strip_tags($message);
} else {
//.........这里部分代码省略.........
示例2: getGraphImage
/**
* Output interface utilisation graph for given switch & ports
* @see function rrdtool_function_graph in lib/rrd.php
* @param integer $switch
* @param integer $port
* @param array $data graph data, allowed keys:
* from - plot graph from
* to - plot graph to
* rra_id - use instead of from/to - plot graph based on rra
* @return png image
*/
public function getGraphImage($switch, $port, $data = array())
{
//1st determine graph that switch & port have one generated for
$graph_data_array = array();
if (!empty($data["from"]) && $data["from"] < 1600000000) {
$graph_data_array["graph_start"] = $data["from"];
}
/* override: graph end time (unix time) */
if (!empty($data["to"]) && $data["to"] < 1600000000) {
$graph_data_array["graph_end"] = $data["to"];
}
$gid = $this->getGraphID($switch, $port);
if (!$gid) {
return false;
}
print rrdtool_function_graph($gid, array_key_exists("rra_id", $data) ? $data["rra_id"] : null, $graph_data_array);
}
示例3: graph_edit
//.........这里部分代码省略.........
# print "<form method='post' action='graphs.php'>\n";
/* only display the "inputs" area if we are using a graph template for this graph */
if (!empty($graphs["graph_template_id"])) {
html_start_box("<strong>" . __("Supplemental Graph Template Data") . "</strong>", "100", $colors["header"], "0", "center", "");
draw_nontemplated_fields_graph($graphs["graph_template_id"], $graphs, "|field|", "<strong>" . __("Graph Fields") . "</strong>", true, true, 0);
draw_nontemplated_fields_graph_item($graphs["graph_template_id"], get_request_var("id"), "|field|_|id|", "<strong>" . __("Graph Item Fields") ."</strong>", true);
html_end_box();
}
/* graph item list goes here */
if ((!empty($_GET["id"])) && (!array_key_exists("graph_template_id", $graphs))) {
graph_template_item();
}
if (!empty($_GET["id"])) {
?>
<table width="100%" align="center">
<tr>
<td align="center" class="textInfo" colspan="2">
<img src="<?php print htmlspecialchars("graph_image.php?action=edit&local_graph_id=" . get_request_var("id") . "&rra_id=" . read_graph_config_option("default_rra_id"));?>" alt="">
</td>
<?php
if ((isset($_SESSION["graph_debug_mode"])) && (isset($_GET["id"]))) {
$graph_data_array = array();
$graph_data_array["output_flag"] = RRDTOOL_OUTPUT_STDERR;
/* make rrdtool_function_graph to only print the command without executing it */
$graph_data_array["print_source"] = 1;
?>
<td>
<span class="textInfo"><?php print __("RRDTool Command:");?></span><br>
<pre><?php print rrdtool_function_graph(get_request_var("id"), read_graph_config_option("default_rra_id"), $graph_data_array);?></pre>
<span class="textInfo"><?php print __("RRDTool Says:");?></span><br>
<?php /* make rrdtool_function_graph to generate AND execute the rrd command, but only for fetching the "return code" */
unset($graph_data_array["print_source"]);?>
<pre><?php print rrdtool_function_graph(get_request_var("id"), read_graph_config_option("default_rra_id"), $graph_data_array);?></pre>
</td>
<?php
}
?>
</tr>
</table>
<?php
}
if (((isset($_GET["id"])) || (isset($_GET["new"]))) && (empty($graphs["graph_template_id"]))) {
html_start_box("<strong>" . __("Graph Configuration") . "</strong>", "100", $colors["header"], "0", "center", "");
############
html_start_box("<strong>" . __("Labels") . "</strong>", "100", $colors["header"], "0", "center", "", true);
draw_template_edit_form('header_graph_labels', graph_labels_form_list(), $graphs, $use_graph_template);
html_end_box(false);
/* TODO: we should not use rrd version in the code, when going data-driven */
if ( read_config_option("rrdtool_version") != RRD_VERSION_1_0 && read_config_option("rrdtool_version") != RRD_VERSION_1_2) {
html_start_box("<strong>" . __("Right Axis Settings") . "</strong>", "100", $colors["header"], "0", "center", "", true, "table_graph_template_right_axis");
draw_template_edit_form('header_graph_right_axis', graph_right_axis_form_list(), $graphs, $use_graph_template);
}
html_end_box(false);
html_start_box("<strong>" . __("Graph Template Size") . "</strong>", "100", $colors["header"], "0", "center", "", true, "table_graph_template_size");
draw_template_edit_form('header_graph_size', graph_size_form_list(), $graphs, $use_graph_template);
html_end_box(false);
html_start_box("<strong>" . __("Graph Template Limits") . "</strong>", "100", $colors["header"], "0", "center", "", true, "table_graph_template_limits");
draw_template_edit_form('header_graph_limits', graph_limits_form_list(), $graphs, $use_graph_template);
html_end_box(false);
示例4: mailer
//.........这里部分代码省略.........
$mail->addBCC($bc);
}
}
} else {
foreach ($bcc as $email => $name) {
$mail->addBCC($email, $name);
}
}
if (!is_array($replyto)) {
if ($replyto != '') {
$mail->replyTo($replyto);
}
} else {
$mail->replyTo($replyto[0], $replyto[1]);
}
// Set the wordwrap limits
$wordwrap = read_config_option('settings_wordwrap');
if ($wordwrap == '') {
$wordwrap = 76;
}
if ($wordwrap > 9999) {
$wordwrap = 9999;
}
if ($wordwrap < 0) {
$wordwrap = 76;
}
$mail->WordWrap = $wordwrap;
$mail->setWordWrap();
$i = 0;
// Handle Graph Attachments
if (is_array($attachments) && sizeof($attachments) && substr_count($body, '<GRAPH>') > 0) {
foreach ($attachments as $val) {
$graph_data_array = array('output_flag' => RRDTOOL_OUTPUT_STDOUT);
$data = rrdtool_function_graph($val['local_graph_id'], $val['rra_id'], $graph_data_array);
if ($data != '') {
/* get content id and create attachment */
$cid = getmypid() . '_' . $i . '@' . 'localhost';
/* attempt to attach */
if ($mail->addStringEmbededImage($data, $cid, $val['filename'] . '.png', 'base64', 'image/png', 'inline') === false) {
cacti_log('ERROR: ' . $mail->ErrorInfo, false);
return $mail->ErrorInfo;
}
$body = str_replace('<GRAPH>', "<br><br><img src='cid:{$cid}'>", $body);
} else {
$body = str_replace('<GRAPH>', "<br><img src='" . $val['file'] . "'><br>Could not open!<br>" . $val['file'], $body);
}
$i++;
}
} elseif (is_array($attachments) && sizeof($attachments) && substr_count($body, '<GRAPH:') > 0) {
foreach ($attachments as $attachment) {
if ($attachment['attachment'] != '') {
/* get content id and create attachment */
$cid = getmypid() . '_' . $i . '@' . 'localhost';
/* attempt to attach */
if ($mail->addStringEmbeddedImage($attachment['attachment'], $cid, $attachment['filename'], 'base64', $attachment['mime_type'], $attachment['inline']) === false) {
cacti_log('ERROR: ' . $mail->ErrorInfo, false);
return $mail->ErrorInfo;
}
/* handle the body text */
switch ($attachment['inline']) {
case 'inline':
$body = str_replace('<GRAPH:' . $attachment['graphid'] . ':' . $attachment['timespan'] . '>', "<img border='0' src='cid:{$cid}' >", $body);
break;
case 'attachment':
$body = str_replace('<GRAPH:' . $attachment['graphid'] . ':' . $attachment['timespan'] . '>', '', $body);
break;
示例5: graph_edit
//.........这里部分代码省略.........
}
/* modify for multi user end */
draw_edit_form(array("config" => array(), "fields" => $form_array));
html_end_box();
/* only display the "inputs" area if we are using a graph template for this graph */
if (!empty($graphs["graph_template_id"])) {
html_start_box("<strong>Supplemental Graph Template Data</strong>", "100%", $colors["header"], "3", "center", "");
draw_nontemplated_fields_graph($graphs["graph_template_id"], $graphs, "|field|", "<strong>Graph Fields</strong>", true, true, 0);
draw_nontemplated_fields_graph_item($graphs["graph_template_id"], $_GET["id"], "|field|_|id|", "<strong>Graph Item Fields</strong>", true);
html_end_box();
}
/* graph item list goes here */
if (!empty($_GET["id"]) && empty($graphs["graph_template_id"])) {
item();
}
if (!empty($_GET["id"])) {
?>
<table width="100%" align="center">
<tr>
<td align="center" class="textInfo" colspan="2">
<img src="<?php
print htmlspecialchars("graph_image.php?action=edit&local_graph_id=" . $_GET["id"] . "&rra_id=" . read_graph_config_option("default_rra_id"));
?>
" alt="">
</td>
<?php
if (isset($_SESSION["graph_debug_mode"]) && isset($_GET["id"])) {
$graph_data_array["output_flag"] = RRDTOOL_OUTPUT_STDERR;
$graph_data_array["print_source"] = 1;
?>
<td>
<span class="textInfo">RRDTool Command:</span><br>
<pre><?php
print @rrdtool_function_graph($_GET["id"], 1, $graph_data_array);
?>
</pre>
<span class="textInfo">RRDTool Says:</span><br>
<?php
unset($graph_data_array["print_source"]);
?>
<pre><?php
print @rrdtool_function_graph($_GET["id"], 1, $graph_data_array);
?>
</pre>
</td>
<?php
}
?>
</tr>
</table>
<br>
<?php
}
if ((isset($_GET["id"]) || isset($_GET["new"])) && empty($graphs["graph_template_id"])) {
html_start_box("<strong>Graph Configuration</strong>", "100%", $colors["header"], "3", "center", "");
$form_array = array();
while (list($field_name, $field_array) = each($struct_graph)) {
$form_array += array($field_name => $struct_graph[$field_name]);
$form_array[$field_name]["value"] = isset($graphs) ? $graphs[$field_name] : "";
$form_array[$field_name]["form_id"] = isset($graphs) ? $graphs["id"] : "0";
if (!($use_graph_template == false || $graphs_template["t_" . $field_name] == "on")) {
$form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
$form_array[$field_name]["description"] = "";
}
}
draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => $form_array));
示例6: graph_edit
//.........这里部分代码省略.........
html_end_box();
/* only display the "inputs" area if we are using a graph template for this graph */
if (!empty($graphs["graph_template_id"])) {
html_start_box("<strong>Supplemental Graph Template Data</strong>", "100%", $colors["header"], "3", "center", "");
print "<form method='post' action='graphs.php'>\n";
draw_nontemplated_fields_graph($graphs["graph_template_id"], $graphs, "|field|", "<strong>Graph Fields</strong>", true, true, 0);
draw_nontemplated_fields_graph_item($graphs["graph_template_id"], $_GET["id"], "|field|_|id|", "<strong>Graph Item Fields</strong>", true);
html_end_box();
}
/* graph item list goes here */
if ((!empty($_GET["id"])) && (empty($graphs["graph_template_id"]))) {
item();
}
if (!empty($_GET["id"])) {
?>
<table width="100%" align="center">
<tr>
<td align="center" class="textInfo" colspan="2">
<img src="graph_image.php?action=edit&local_graph_id=<?php print $_GET["id"];?>&rra_id=<?php print read_graph_config_option("default_rra_id");?>" alt="">
</td>
<?php
if ((isset($_SESSION["graph_debug_mode"])) && (isset($_GET["id"]))) {
$graph_data_array["output_flag"] = RRDTOOL_OUTPUT_STDERR;
$graph_data_array["print_source"] = 1;
?>
<td>
<span class="textInfo">RRDTool Command:</span><br>
<pre><?php print rrdtool_function_graph($_GET["id"], 1, $graph_data_array);?></pre>
<span class="textInfo">RRDTool Says:</span><br>
<?php unset($graph_data_array["print_source"]);?>
<pre><?php print rrdtool_function_graph($_GET["id"], 1, $graph_data_array);?></pre>
</td>
<?php
}
?>
</tr>
</table>
<br>
<?php
}
if (((isset($_GET["id"])) || (isset($_GET["new"]))) && (empty($graphs["graph_template_id"]))) {
html_start_box("<strong>Graph Configuration</strong>", "100%", $colors["header"], "3", "center", "");
$form_array = array();
while (list($field_name, $field_array) = each($struct_graph)) {
$form_array += array($field_name => $struct_graph[$field_name]);
$form_array[$field_name]["value"] = (isset($graphs) ? $graphs[$field_name] : "");
$form_array[$field_name]["form_id"] = (isset($graphs) ? $graphs["id"] : "0");
if (!(($use_graph_template == false) || ($graphs_template{"t_" . $field_name} == "on"))) {
$form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
$form_array[$field_name]["description"] = "";
}
}
draw_edit_form(
array(
示例7: rrdtool_function_graph
if (!empty($_GET["graph_start"]) && $_GET["graph_start"] < 1600000000) {
$graph_data_array["graph_start"] = $_GET["graph_start"];
}
/* override: graph end time (unix time) */
if (!empty($_GET["graph_end"]) && $_GET["graph_end"] < 1600000000) {
$graph_data_array["graph_end"] = $_GET["graph_end"];
}
/* override: graph height (in pixels) */
if (!empty($_GET["graph_height"]) && $_GET["graph_height"] < 3000) {
$graph_data_array["graph_height"] = $_GET["graph_height"];
}
/* override: graph width (in pixels) */
if (!empty($_GET["graph_width"]) && $_GET["graph_width"] < 3000) {
$graph_data_array["graph_width"] = $_GET["graph_width"];
}
/* override: skip drawing the legend? */
if (!empty($_GET["graph_nolegend"])) {
$graph_data_array["graph_nolegend"] = $_GET["graph_nolegend"];
}
/* print RRDTool graph source? */
if (!empty($_GET["show_source"])) {
$graph_data_array["print_source"] = $_GET["show_source"];
}
print rrdtool_function_graph(get_request_var("local_graph_id"), (array_key_exists("rra_id", $_GET) ? get_request_var("rra_id") : null), $graph_data_array);
示例8: export_tree_graphs_and_graph_html
function export_tree_graphs_and_graph_html($path, $tree_id)
{
global $colors, $config;
include_once $config["library_path"] . "/tree.php";
include_once $config["library_path"] . "/data_query.php";
/* start the count of graphs */
$total_graphs_created = 0;
$exported_files = array();
$cacti_export_path = read_config_option("path_html_export");
/* auth check for hosts on the trees */
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . read_config_option("export_user_id"));
if (!export_is_tree_allowed($tree_id)) {
return 0;
}
$sql_join = "LEFT JOIN graph_local ON (graph_templates_graph.local_graph_id=graph_local.id)\n\t\tLEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)\n\t\tLEFT JOIN host ON (host.id=graph_local.host_id)\n\t\tLEFT JOIN user_auth_perms ON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=" . $current_user["id"] . "))";
$sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
$sql_where = empty($sql_where) ? "" : "AND {$sql_where}";
$graphs = array();
if ($tree_id == 0) {
$hosts = db_fetch_assoc("SELECT DISTINCT host_id FROM graph_tree_items");
} else {
$hosts = db_fetch_assoc("SELECT DISTINCT host_id FROM graph_tree_items WHERE graph_tree_id=" . $tree_id);
}
/* get a list of host graphs first */
if (sizeof($hosts)) {
foreach ($hosts as $host) {
$hosts_sql = "SELECT DISTINCT\n\t\t\tgraph_templates_graph.id,\n\t\t\tgraph_templates_graph.local_graph_id,\n\t\t\tgraph_templates_graph.height,\n\t\t\tgraph_templates_graph.width,\n\t\t\tgraph_templates_graph.title_cache,\n\t\t\tgraph_templates.name,\n\t\t\tgraph_local.host_id\n\t\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t\t{$sql_join}\n\t\t\tWHERE ((graph_templates_graph.local_graph_id<>0)\n\t\t\t{$sql_where}\n\t\t\tAND (graph_local.host_id=" . $host["host_id"] . ")\n\t\t\tAND (graph_templates_graph.export='on'))\n\t\t\tORDER BY graph_templates_graph.title_cache";
$host_graphs = db_fetch_assoc($hosts_sql);
if (sizeof($host_graphs)) {
if (sizeof($graphs)) {
$graphs = array_merge($host_graphs, $graphs);
} else {
$graphs = $host_graphs;
}
}
}
}
/* now get the list of graphs placed within the tree */
if ($tree_id == 0) {
$sql_where = "WHERE graph_templates_graph.local_graph_id!=0\n\t\t\t{$sql_where}\n\t\t\tAND graph_templates_graph.export='on'";
} else {
$sql_where = "WHERE graph_tree_items.graph_tree_id =" . $tree_id . "\n\t\t\t{$sql_where}\n\t\t\tAND graph_templates_graph.local_graph_id!=0\n\t\t\tAND graph_templates_graph.export='on'";
}
$non_host_sql = "SELECT\n\t\tgraph_templates_graph.id,\n\t\tgraph_templates_graph.local_graph_id,\n\t\tgraph_templates_graph.height,\n\t\tgraph_templates_graph.width,\n\t\tgraph_templates_graph.title_cache,\n\t\tgraph_templates.name,\n\t\tgraph_local.host_id,\n\t\tgraph_tree_items.id AS gtid\n\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tAND graph_tree_items.local_graph_id = graph_templates_graph.local_graph_id\n\t\tAND graph_templates_graph.export='on'\n\t\tORDER BY graph_templates_graph.title_cache";
$non_host_graphs = db_fetch_assoc($non_host_sql);
if (sizeof($non_host_graphs)) {
if (sizeof($graphs)) {
$graphs = array_merge($non_host_graphs, $graphs);
} else {
$graphs = $non_host_graphs;
}
}
/* open a pipe to rrdtool for writing */
$rrdtool_pipe = rrd_init();
/* for each graph... */
$i = 0;
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
$rras = get_associated_rras($graph["local_graph_id"]);
/* settings for preview graphs */
$graph_data_array["graph_height"] = read_config_option("export_default_height");
$graph_data_array["graph_width"] = read_config_option("export_default_width");
$graph_data_array["graph_nolegend"] = true;
$graph_data_array["export"] = true;
if (read_config_option("export_tree_isolation") == "on") {
$graph_data_array["export_filename"] = "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
$export_filename = $cacti_export_path . "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
} else {
$graph_data_array["export_filename"] = "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
$export_filename = $cacti_export_path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
}
if (!array_search($export_filename, $exported_files)) {
/* add the graph to the exported list */
array_push($exported_files, $export_filename);
export_log("Creating Graph '" . $cacti_export_path . $graph_data_array["export_filename"] . "'");
/* generate the graph */
rrdtool_function_graph($graph["local_graph_id"], 0, $graph_data_array, $rrdtool_pipe);
$total_graphs_created++;
/* generate html files for each graph */
if (read_config_option("export_tree_isolation") == "on") {
export_log("Creating File '" . $cacti_export_path . "/" . $path . "/graph_" . $graph["local_graph_id"] . ".html'");
$fp_graph_index = fopen($cacti_export_path . "/" . $path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
} else {
export_log("Creating File '" . $cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html'");
$fp_graph_index = fopen($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
}
fwrite($fp_graph_index, HTML_HEADER_TREE);
/* write the code for the tree at the left */
draw_html_left_tree($fp_graph_index, $tree_id);
fwrite($fp_graph_index, HTML_GRAPH_HEADER_ONE_TREE);
fwrite($fp_graph_index, "<strong>Graph - " . $graph["title_cache"] . "</strong></td></tr>");
fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO_TREE);
fwrite($fp_graph_index, "<td>");
/* reset vars for actual graph image creation */
reset($rras);
unset($graph_data_array);
/* generate graphs for each rra */
foreach ($rras as $rra) {
$graph_data_array["export"] = true;
if (read_config_option("export_tree_isolation") == "on") {
//.........这里部分代码省略.........
示例9: header
header('Content-type: image/png');
/* flush the headers now */
ob_end_clean();
session_write_close();
$graph_data_array = array();
/* override: graph start time (unix time) */
if (!empty($_REQUEST['graph_start']) && $_REQUEST['graph_start'] < 1600000000) {
$graph_data_array['graph_start'] = $_REQUEST['graph_start'];
}
/* override: graph end time (unix time) */
if (!empty($_REQUEST['graph_end']) && $_REQUEST['graph_end'] < 1600000000) {
$graph_data_array['graph_end'] = $_REQUEST['graph_end'];
}
/* override: graph height (in pixels) */
if (!empty($_REQUEST['graph_height']) && $_REQUEST['graph_height'] < 3000) {
$graph_data_array['graph_height'] = $_REQUEST['graph_height'];
}
/* override: graph width (in pixels) */
if (!empty($_REQUEST['graph_width']) && $_REQUEST['graph_width'] < 3000) {
$graph_data_array['graph_width'] = $_REQUEST['graph_width'];
}
/* override: skip drawing the legend? */
if (!empty($_REQUEST['graph_nolegend'])) {
$graph_data_array['graph_nolegend'] = $_REQUEST['graph_nolegend'];
}
/* print RRDTool graph source? */
if (!empty($_REQUEST['show_source'])) {
$graph_data_array['print_source'] = $_REQUEST['show_source'];
}
print @rrdtool_function_graph($_REQUEST['local_graph_id'], array_key_exists('rra_id', $_REQUEST) ? $_REQUEST['rra_id'] : null, $graph_data_array);
示例10: elseif
// remove favorite
} elseif ($permission == GRAPH_OTHER + GRAPH_PUBLIC) {
$tree_item_id = db_fetch_cell("SELECT graph_tree_items.id FROM graph_tree_items WHERE graph_tree_id = '" . $_SESSION["private_tree_id"] . "' AND local_graph_id = '" . $_GET["local_graph_id"] . "'");
print " <a href=\"./tree.php?action=item_remove&id=" . $tree_item_id . "&tree_id=" . $_SESSION["public_tree_id"] . "\"><img src=\"images/fav_disable_icon.png\" style=\"border:none;vertical-align:text-bottom;\">Remove from favorites</a>";
}
}
if ($permission != GRAPH_PRIVATE) {
// url
$url = "http://" . $_SERVER["SERVER_NAME"] . "/gi.php?g=" . $_GET["local_graph_id"] . "&r=" . $_GET["rra_id"];
print " <font class='textEditTitle'>URL:</font><input type=\"text\" value=\"{$url}\" size=\"50\" onClick=\"javascript:this.select();\">";
// widget
$widget = htmlspecialchars("<script src=\"http://" . $_SERVER["SERVER_NAME"] . "/include/widget.js\"></script><script>cactiWidget(" . $_GET["local_graph_id"] . "," . $_GET["rra_id"] . ");</script><div id=\"" . $_GET["local_graph_id"] . "_" . $_GET["rra_id"] . "\"></div>");
print " <font class='textEditTitle'>Widget:</font><input type=\"text\" value=\"{$widget}\" size=\"50\" onClick=\"javascript:this.select();\">";
}
} else {
print trim(@rrdtool_function_graph(get_request_var_request("local_graph_id"), get_request_var_request("rra_id"), $graph_data_array));
}
/* modify for multi user end */
?>
</td>
</tr>
<?php
}
global $graph_views;
load_current_session_value("action", "sess_cacti_graph_action", $graph_views[read_graph_config_option("default_tree_view_mode")]);
?>
<tr>
<?php
if (basename($_SERVER["PHP_SELF"]) == "graph_view.php" && read_graph_config_option("default_tree_view_mode") == 2 && ($_REQUEST["action"] == "tree" || isset($_REQUEST["view_type"]) && $_REQUEST["view_type"] == "tree")) {
?>
<td valign="top" style="padding: 5px; border-right: #aaaaaa 1px solid;background-repeat:repeat-y;background-color:#efefef;" bgcolor='#efefef' width='<?php
示例11: read_config_option
/* print RRDTool graph source? */
if (!empty($_REQUEST['show_source'])) {
$graph_data_array['print_source'] = $_REQUEST['show_source'];
}
/* check ds */
if ($graph_data_array['ds_step'] < 1) {
$graph_data_array['ds_step'] = read_config_option('realtime_interval');
}
/* call poller */
$command = read_config_option('path_php_binary');
$args = sprintf('poller_realtime.php --graph=%s --interval=%d --poller_id=' . session_id(), $_REQUEST['local_graph_id'], $graph_data_array['ds_step']);
shell_exec("{$command} {$args}");
/* construct the image name */
$graph_data_array['export_realtime'] = read_config_option('realtime_cache_path') . '/user_' . session_id() . '_lgi_' . $_REQUEST['local_graph_id'] . '.png';
$graph_data_array['output_flag'] = RRDTOOL_OUTPUT_GRAPH_DATA;
rrdtool_function_graph($_REQUEST['local_graph_id'], '', $graph_data_array);
/* send text information back to browser as well as image information */
$return_array = array('local_graph_id' => $_REQUEST['local_graph_id'], 'top' => $_REQUEST['top'], 'left' => $_REQUEST['left'], 'ds_step' => isset($_SESSION['sess_realtime_ds_step']) ? $_SESSION['sess_realtime_ds_step'] : $graph_data_array['ds_step'], 'graph_start' => isset($_SESSION['sess_realtime_graph_start']) ? $_SESSION['sess_realtime_graph_start'] : $graph_data_array['graph_start']);
print json_encode($return_array);
exit;
break;
case 'view':
$graph_rrd = read_config_option('realtime_cache_path') . '/user_' . session_id() . '_lgi_' . $_REQUEST['local_graph_id'] . '.png';
if (file_exists($graph_rrd)) {
header('Content-type: image/png');
print file_get_contents($graph_rrd);
}
exit;
break;
}
/* ================= input validation ================= */
示例12: graph_edit
//.........这里部分代码省略.........
html_start_box("<strong>Graph Template Selection</strong> {$header_label}", '100%', '', '3', 'center', '');
$form_array = array('graph_template_id' => array('method' => 'drop_sql', 'friendly_name' => 'Selected Graph Template', 'description' => 'Choose a Graph Template to apply to this Graph. Please note that Graph Data may be lost if you change the Graph Template after one is already applied.', 'value' => isset($graphs) ? $graphs['graph_template_id'] : '0', 'none_value' => 'None', 'sql' => 'SELECT graph_templates.id,graph_templates.name FROM graph_templates ORDER BY name'), 'host_id' => array('method' => 'drop_callback', 'friendly_name' => 'Device', 'description' => 'Choose the Device that this Graph belongs to.', 'sql' => "SELECT id,CONCAT_WS('',description,' (',hostname,')') as name FROM host ORDER BY description,hostname", 'action' => 'ajax_hosts_noany', 'id' => isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : $host_id, 'value' => db_fetch_cell_prepared('SELECT description AS name FROM host WHERE id = ?', isset($_REQUEST['host_id']) ? array($_REQUEST['host_id']) : array($host_id))), 'graph_template_graph_id' => array('method' => 'hidden', 'value' => isset($graphs) ? $graphs['id'] : '0'), 'local_graph_id' => array('method' => 'hidden', 'value' => isset($graphs) ? $graphs['local_graph_id'] : '0'), 'local_graph_template_graph_id' => array('method' => 'hidden', 'value' => isset($graphs) ? $graphs['local_graph_template_graph_id'] : '0'), '_graph_template_id' => array('method' => 'hidden', 'value' => isset($graphs) ? $graphs['graph_template_id'] : '0'), '_host_id' => array('method' => 'hidden', 'value' => isset($host_id) ? $host_id : '0'));
draw_edit_form(array('config' => array(), 'fields' => $form_array));
html_end_box();
/* only display the "inputs" area if we are using a graph template for this graph */
if (!empty($graphs['graph_template_id'])) {
html_start_box('<strong>Supplemental Graph Template Data</strong>', '100%', '', '3', 'center', '');
draw_nontemplated_fields_graph($graphs['graph_template_id'], $graphs, '|field|', '<strong>Graph Fields</strong>', true, true, 0);
draw_nontemplated_fields_graph_item($graphs['graph_template_id'], $_REQUEST['id'], '|field|_|id|', '<strong>Graph Item Fields</strong>', true, $locked);
html_end_box();
}
/* graph item list goes here */
if (!empty($_REQUEST['id']) && empty($graphs['graph_template_id'])) {
item();
}
if (!empty($_REQUEST['id'])) {
?>
<table width="100%" align="center">
<tr>
<td align="center" class="textInfo" colspan="2">
<img src="<?php
print htmlspecialchars('graph_image.php?action=edit&local_graph_id=' . $_REQUEST['id'] . '&rra_id=' . read_graph_config_option('default_rra_id'));
?>
" alt="">
</td>
<?php
if (isset($_SESSION['graph_debug_mode']) && isset($_REQUEST['id'])) {
$graph_data_array['output_flag'] = RRDTOOL_OUTPUT_STDERR;
$graph_data_array['print_source'] = 1;
?>
<td>
<span class="textInfo">RRDTool Command:</span><br>
<pre><?php
print @rrdtool_function_graph($_REQUEST['id'], 1, $graph_data_array);
?>
</pre>
<span class="textInfo">RRDTool Says:</span><br>
<?php
unset($graph_data_array['print_source']);
?>
<pre><?php
print @rrdtool_function_graph($_REQUEST['id'], 1, $graph_data_array);
?>
</pre>
</td>
<?php
}
?>
</tr>
</table>
<br>
<?php
}
if ((isset($_REQUEST['id']) || isset($_REQUEST['new'])) && empty($graphs['graph_template_id'])) {
html_start_box('<strong>Graph Configuration</strong>', '100%', '', '3', 'center', '');
$form_array = array();
while (list($field_name, $field_array) = each($struct_graph)) {
$form_array += array($field_name => $struct_graph[$field_name]);
$form_array[$field_name]['value'] = isset($graphs) ? $graphs[$field_name] : '';
$form_array[$field_name]['form_id'] = isset($graphs) ? $graphs['id'] : '0';
if (!($use_graph_template == false || $graphs_template['t_' . $field_name] == 'on')) {
$form_array[$field_name]['method'] = 'template_' . $form_array[$field_name]['method'];
$form_array[$field_name]['description'] = '';
}
}
draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
示例13: generate_report
/** generate_report create the complete mail for a single report and send it
* @param array $report - complete row of reports table for the report to work upon
* @param bool $force - when forced, lastsent time will not be entered (e.g. Send Now)
*/
function generate_report($report, $force = false)
{
global $config, $alignment;
include_once $config["base_path"] . "/lib/time.php";
include_once $config["base_path"] . "/lib/rrd.php";
reports_log(__FUNCTION__ . ", report_id: " . $report["id"], false, "REPORTS TRACE", POLLER_VERBOSITY_MEDIUM);
$body = reports_generate_html($report["id"], REPORTS_OUTPUT_EMAIL);
$time = time();
# get config option for first-day-of-the-week
$first_weekdayid = read_graph_config_option("first_weekdayid");
$offset = 0;
$graphids = array();
$attachments = array();
while (true) {
$pos = strpos($body, "<GRAPH:", $offset);
if ($pos) {
$offset = $pos + 7;
$graph = substr($body, $pos + 7, 10);
$arr = explode(":", $graph);
$arr1 = explode(">", $arr[1]);
$graphid = $arr[0];
$timespan = $arr1[0];
$graphids[$graphid . ":" . $timespan] = $graphid;
} else {
break;
}
}
if (sizeof($graphids)) {
foreach ($graphids as $key => $graphid) {
$arr = explode(":", $key);
$timesp = $arr[1];
$timespan = array();
# get start/end time-since-epoch for actual time (now()) and given current-session-timespan
get_timespan($timespan, $time, $timesp, $first_weekdayid);
# provide parameters for rrdtool graph
$graph_data_array = array('graph_start' => $timespan["begin_now"], 'graph_end' => $timespan["end_now"], 'graph_width' => $report["graph_width"], 'graph_height' => $report["graph_height"], 'output_flag' => RRDTOOL_OUTPUT_STDOUT);
if ($report["thumbnails"] == "on") {
$graph_data_array['graph_nolegend'] = true;
}
switch ($report["attachment_type"]) {
case REPORTS_TYPE_INLINE_PNG:
$attachments[] = array('attachment' => @rrdtool_function_graph($graphid, "", $graph_data_array), 'filename' => 'graph_' . $graphid . ".png", 'mime_type' => 'image/png', 'graphid' => $graphid, 'timespan' => $timesp, 'inline' => 'inline');
break;
case REPORTS_TYPE_INLINE_JPG:
$attachments[] = array('attachment' => png2jpeg(@rrdtool_function_graph($graphid, "", $graph_data_array)), 'filename' => 'graph_' . $graphid . ".jpg", 'mime_type' => 'image/jpg', 'graphid' => $graphid, 'timespan' => $timesp, 'inline' => 'inline');
break;
case REPORTS_TYPE_INLINE_GIF:
$attachments[] = array('attachment' => png2gif(@rrdtool_function_graph($graphid, "", $graph_data_array)), 'filename' => 'graph_' . $graphid . ".gif", 'mime_type' => 'image/gif', 'graphid' => $graphid, 'timespan' => $timesp, 'inline' => 'inline');
break;
case REPORTS_TYPE_ATTACH_PNG:
$attachments[] = array('attachment' => @rrdtool_function_graph($graphid, "", $graph_data_array), 'filename' => 'graph_' . $graphid . ".png", 'mime_type' => 'image/png', 'graphid' => $graphid, 'timespan' => $timesp, 'inline' => 'attachment');
break;
case REPORTS_TYPE_ATTACH_JPG:
$attachments[] = array('attachment' => png2jpeg(@rrdtool_function_graph($graphid, "", $graph_data_array)), 'filename' => 'graph_' . $graphid . ".jpg", 'mime_type' => 'image/jpg', 'graphid' => $graphid, 'timespan' => $timesp, 'inline' => 'attachment');
break;
case REPORTS_TYPE_ATTACH_GIF:
$attachments[] = array('attachment' => png2gif(@rrdtool_function_graph($graphid, "", $graph_data_array)), 'filename' => 'graph_' . $graphid . ".gif", 'mime_type' => 'image/gif', 'graphid' => $graphid, 'timespan' => $timesp, 'inline' => 'attachment');
break;
case REPORTS_TYPE_INLINE_PNG_LN:
$attachments[] = array('attachment' => @rrdtool_function_graph($graphid, "", $graph_data_array), 'filename' => '', 'mime_type' => 'image/png', 'graphid' => $graphid, 'timespan' => $timesp, 'inline' => 'inline');
break;
case REPORTS_TYPE_INLINE_JPG_LN:
$attachments[] = array('attachment' => png2jpeg(@rrdtool_function_graph($graphid, "", $graph_data_array)), 'filename' => '', 'mime_type' => 'image/jpg', 'graphid' => $graphid, 'timespan' => $timesp, 'inline' => 'inline');
break;
case REPORTS_TYPE_INLINE_GIF_LN:
$attachments[] = array('attachment' => png2gif(@rrdtool_function_graph($graphid, "", $graph_data_array)), 'filename' => '', 'mime_type' => 'image/gif', 'graphid' => $graphid, 'timespan' => $timesp, 'inline' => 'inline');
break;
case REPORTS_TYPE_ATTACH_PDF:
# $attachments[] = array(
# 'attachment' => png2gif(@rrdtool_function_graph($graphid, "", $graph_data_array)),
# 'filename' => 'graph_' . $graphid . ".gif",
# 'mime_type' => 'image/gif',
# 'graphid' => $graphid,
# 'timespan' => $timesp,
# 'inline' => 'attachment'
# );
break;
}
}
}
if ($report["subject"] != '') {
$subject = $report["subject"];
} else {
$subject = $report["name"];
}
if (!isset($report['bcc'])) {
$report['bcc'] = '';
}
$v = db_fetch_cell("SELECT cacti FROM version");
$headers['User-Agent'] = 'Cacti-Reports-v' . $v;
$error = mailer(array($report['from_email'], $report['from_name']), $report['email'], '', $report['bcc'], '', $subject, $body, 'Cacti Reporting Requires and HTML Email Client', $attachments, $headers);
session_start();
if (strlen($error)) {
if (isset($_REQUEST["id"])) {
$_SESSION['reports_error'] = "Problems sending Report '" . $report['name'] . "'. Problem with e-mail Subsystem Error is '{$error}'";
if (!isset($_POST["selected_items"])) {
//.........这里部分代码省略.........
示例14: rrdtool_function_xport
function rrdtool_function_xport($local_graph_id, $rra_id, $xport_data_array, &$xport_meta)
{
global $config, $consolidation_functions;
return rrdtool_function_graph($local_graph_id, $rra_id, $xport_data_array, "", $xport_meta);
}
示例15: trim
<tr>
<td valign="top" height="1" colspan="3" bgcolor="#<?php
print $colors['graph_menu_background'];
?>
">
<?php
$graph_data_array["print_source"] = true;
/* override: graph start time (unix time) */
if (!empty($_GET["graph_start"])) {
$graph_data_array["graph_start"] = $_GET["graph_start"];
}
/* override: graph end time (unix time) */
if (!empty($_GET["graph_end"])) {
$graph_data_array["graph_end"] = $_GET["graph_end"];
}
print trim(rrdtool_function_graph($_GET["graph_id"], $_GET["rra_id"], $graph_data_array));
?>
</td>
</tr>
<?php
}
?>
<tr>
<?php
if (read_graph_config_option("default_tree_view_mode") == "2" && ($_REQUEST["action"] == "tree" || (isset($_REQUEST["view_type"]) ? $_REQUEST["view_type"] : "") == "tree")) {
?>
<td valign="top" style="padding: 5px; border-right: #<?php
print $colors['graph_menu_border'];
?>
1px solid;" bgcolor="#<?php