From 77f3ff1ea11544be2fe4f073f7451061754a0dd4 Mon Sep 17 00:00:00 2001 From: slerena Date: Wed, 3 Sep 2008 12:11:53 +0000 Subject: [PATCH] 2008-09-03 Sancho Lerena * include/functions_reporting_pdf.php: Moved to contrib branch. * install.php: Update sample of use for homeurl variable. This should not contain HTTP:/x.x.x.x anymore. * operation/events/events_rss.php: Makes use of homeurl in the correct way. * operation/agentes/estado_agente.php: Fixed a sprintf typo. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1075 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 12 + .../include/functions_reporting_pdf.php | 357 ------------------ pandora_console/install.php | 4 +- .../operation/agentes/estado_agente.php | 3 +- .../operation/events/events_rss.php | 2 +- 5 files changed, 17 insertions(+), 361 deletions(-) delete mode 100644 pandora_console/include/functions_reporting_pdf.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9ba2e2f5b5..985bfd82c6 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2008-09-03 Sancho Lerena + + * include/functions_reporting_pdf.php: Moved to contrib branch. + + * install.php: Update sample of use for homeurl variable. This should + not contain HTTP:/x.x.x.x anymore. + + * operation/events/events_rss.php: Makes use of homeurl in the + correct way. + + * operation/agentes/estado_agente.php: Fixed a sprintf typo. + 2008-09-03 Esteban Sanchez * include/config_process.php: Checks in homeurl config variable. Style diff --git a/pandora_console/include/functions_reporting_pdf.php b/pandora_console/include/functions_reporting_pdf.php deleted file mode 100644 index 31b800dfeb..0000000000 --- a/pandora_console/include/functions_reporting_pdf.php +++ /dev/null @@ -1,357 +0,0 @@ -transaction('start'); - $ok=0; - while (!$ok) { - $thisPageNum = $pdf->ezPageCount; - $pdf->saveState(); - $pdf->setColor(0.9,0.9,0.9); - $pdf->filledRectangle($pdf->ez['leftMargin'],$pdf->y-$pdf->getFontHeight(16)+$pdf->getFontDecender(16),$pdf->ez['pageWidth']-$pdf->ez['leftMargin']-$pdf->ez['rightMargin'],$pdf->getFontHeight(16)); - $pdf->restoreState(); - $pdf->ezText (utf8_decode($title),14,array('justification'=>'left')); - $pdf->ezText ("\n",6); - if ($pdf->ezPageCount==$thisPageNum){ - $pdf->transaction('commit'); - $ok = 1; - } else { - // then we have moved onto a new page, bad bad, as the background colour will be on the old one - $pdf->transaction('rewind'); - $pdf->ezNewPage(); - } - } -} - -function doPageNumbering($pdf, $x=500, $y=25, $size=9) { - // Original code by Johny Mnemonic (mnemonic23 in SF site) - // God bless Sourceforge forums ! - - //count pages - $pages = count($pdf->ezPages); - //iterate through pages - for($pageno = 1; $pageno <= $pages; $pageno++) { - //build footer string - $foot = 'Page '.$pageno.' of '.$pages; - //open the page again - $pdf->reopenObject($pdf->ezPages[$pageno]); - //print the footer - $pdf->addText($x, $y, $size, $foot); - //close the page - $pdf->closeObject(); - } -} - -function doPageHeader ($pdf, $title){ - global $config; - - $pdf->addInfo("Title", $title); - $pdf->addInfo("Author","Pandora FMS 2.0"); - $pdf->addInfo("Creator","Pandora FMS with ezPDF engine"); - $pdf->addInfo("Subject","Automated Pandora FMS report for user defined report"); - - // Add header - $all = $pdf->openObject(); - $pdf->saveState(); - $pdf->addJpegFromFile($config["homedir"]."/images/pandora_logo.jpg",20,812,25); - $pdf->setStrokeColor(0,0,0,1); - $pdf->line(20,40,578,40); - $pdf->line(20,810,578,810); - $pdf->addText(25,25,8,'Pandora FMS 2.0 - http://pandora.sourceforge.net'); - $pdf->addText(50,815,10,"Pandora FMS - Report $title"); - $pdf->restoreState(); - $pdf->closeObject(); - $pdf->addObject($all,'all'); -} - -function get_pdf_report ($report) { - global $config; - $session_id = session_id (); - - $report_name = html_entity_decode ($report['name'], ENT_COMPAT, "iso-8859-15"); - $report_description = html_entity_decode ($report['description'], ENT_COMPAT, "iso-8859-15"); - $report_private= $report['private']; - $report_user = $report['id_user']; - - $date_today = date("Y/m/d H:i:s"); - $report_title = utf8_decode ("$report_name"); - - // Start PDF - $pdf = new Cezpdf (); - $pdf->selectFont ($config["homedir"].'/include/pdf/fonts/Times-Roman.afm', array('encoding'=>'utf-8')); - doPageHeader ($pdf, $report_title); - $pdf->ezSetCmMargins (2, 2, 2, 2); - $pdf->ezText ("$report_title ", 18); - $pdf->ezText ("Generated at $date_today", 8); - $pdf->ezText ("\n".$report_description, 10); - $pdf->ezText ("\n\n", 8); - $table_options = array ('width' => 450, - 'fontSize' => 9, - 'rowGap' => 2, - 'outerLineThickness' => 0.8, - 'innerLineThickness' => 0.2, - 'shaded' => 1); - $group_name = dame_grupo ($report['id_group']); - - $agents = get_agents_in_group ($report['id_group']); - - $sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $report['id_report']); - $contents = get_db_all_rows_sql ($sql); - foreach ($contents as $content) { - $module_name = utf8_decode (get_db_value ('nombre', 'tagente_modulo', 'id_agente_modulo', $content['id_agent_module'])); - $agent_name = utf8_decode (dame_nombre_agente_agentemodulo ($content['id_agent_module'])); - $period = human_time_description ($content['period']); - - switch ($content["type"]) { - case 1: - case 'simple_graph': - doTitle ($pdf, __('Module graph').': '.$agent_name. - ' - '.$module_name.' - '.$period); - $image = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"]. - '/reporting/fgraph.php?PHPSESSID='.$session_id. - '&tipo=sparse&id='.$content["id_agent_module"]. - '&height=180&width=780&period='.$content['period']. - '&avg_only=1&pure=1'; - //ezImage(image,[padding],[width],[resize],[justification],[array border] - $pdf->ezImage ($image,0,470,'none','left'); - - break; - case 2: - case 'custom_graph': - $graph = get_db_row ("tgraph", "id_graph", $content["id_gs"]); - $modules = array (); - $weights = array (); - $sql = sprintf ('SELECT * FROM tgraph_source - WHERE id_graph = %d', - $content["id_gs"]); - $result = mysql_query ($sql); - while ($content2 = mysql_fetch_array($result)) { - array_push ($modules, $content2['id_agent_module']); - array_push ($weights, $content2["weight"]); - } - doTitle ($pdf, __('Custom graph').': '.$graph["name"]. - ' - '.$period); - $image = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"]. - '/reporting/fgraph.php?PHPSESSID='.$session_id.'&tipo=combined&id='. - implode (',', $modules).'&weight_l='.implode (',', $weights). - '&height=230&width=720&period='.$content['period'].'&stacked='. - $graph["stacked"].'&pure=1'; - $pdf->ezImage ($image, 0, 470, 'none', 'left'); - - break; - case 3: - case 'SLA': - doTitle ($pdf, __('S.L.A').': '.$period); - - $slas = get_db_all_rows_field_filter ('treport_content_sla_combined', - 'id_report_content', $content['id_rc']); - if (sizeof ($slas) == 0) { - $pdf->ezText ("".__('There are no SLAs defined') . " %", 18); - } - $table->data = array (); - $table->head = array (__('Info'), - __('SLA result')); - $sla_failed = false; - foreach ($slas as $sla) { - $data = array (); - - $data[0] = __('Agent')." : ".dame_nombre_agente_agentemodulo ($sla['id_agent_module'])."\n"; - $data[0] .= __('Module')." : ".dame_nombre_modulo_agentemodulo ($sla['id_agent_module'])."\n"; - $data[0] .= __('SLA Max. (value)')." : ".$sla['sla_max']."\n"; - $data[0] .= __('SLA Min. (value)')." : ".$sla['sla_min']; - - $sla_value = get_agent_module_sla ($sla['id_agent_module'], $content['period'], - $sla['sla_min'], $sla['sla_max']); - if ($sla_value === false) { - $data[1] = __('Unknown'); - } else { - if ($sla_value < $sla['sla_limit']) { - $pdf->setColor (0, 1, 0, 0); // Red - $sla_failed = true; - } - $data[1] = format_numeric ($sla_value). " %"; - $pdf->setColor (0, 0, 0, 1); // Black - } - - array_push ($table->data, $data); - } - $pdf->ezTable ($table->data, $table->head, "", $table_options); - - if (! $sla_failed) { - $pdf->ezText (''.__('ok').'', 8); - } else { - $pdf->ezText (''.__('Fail').'', 8); - } - unset ($slas); - - break; - case 4: - case 'event_report': - doTitle ($pdf, __('Event report').' - '.$period); - $table_events = event_reporting ($report['id_group'], $content['period'], 0, true); - $pdf->ezTable ($table_events->data, $table_events->head, - "", $table_options); - - break; - case 5: - case 'alert_report': - $alerts = get_alerts_in_group ($report['id_group']); - $alerts_fired = get_alerts_fired ($alerts, $content['period']); - - doTitle ($pdf, __('Alert report').': '.$group_name. - ' - '.$period); - $fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2); - $not_fired_percentage = 100 - $fired_percentage; - $image = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"]. - '/reporting/fgraph.php?PHPSESSID='.$session_id. - '&tipo=alerts_fired_pipe&height=150&width=280&fired='. - $fired_percentage.'¬_fired='.$not_fired_percentage; - $pdf->ezImage ($image, 0, 150, 'none', 'left'); - $pdf->ezText (''.__('Alerts fired').': '.sizeof ($alerts_fired).'', 8); - $pdf->ezText (''.__('Total alerts monitored').': '.sizeof ($alerts).'', 8); - $pdf->ezText ("\n", 8); - - $table_alerts = get_fired_alerts_reporting_table ($alerts_fired); - $pdf->ezTable ($table_alerts->data, $table_alerts->head, - "", $table_options); - unset ($alerts); - unset ($alerts_fired); - - break; - case 6: - case 'monitor_report': - $value = get_agent_module_sla ($content["id_agent_module"], $content['period'], 1, 1); - doTitle ($pdf, __('Monitor report').': '.$agent_name.' - '.$module_name. - ' - '.$period); - $pdf->setColor (0, 0.9, 0, 0); // Red - $pdf->ezText (''.__('Up').': '.format_for_graph ($value, 2) . " %", 18); - $pdf->setColor (0.9, 0, 0, 1); // Grey - $pdf->ezText (''.__('Down').': '.format_numeric (100 - $value, 2) . " %", 18); - $pdf->setColor (0, 0, 0, 1); // Black - - break; - case 7: - case 'avg_value': - $value = get_agent_module_value_average ($content["id_agent_module"], $content['period']); - doTitle ($pdf, __('Avg. Value').': '.$agent_name.' - '. - $module_name.' - '.$period); - $pdf->ezText ("".format_for_graph ($value, 2)."", 18); - - break; - case 8: - case 'max_value': - $value = get_agent_module_value_max ($content["id_agent_module"], $content['period']); - doTitle ($pdf, __('Max. Value').': '.$agent_name. - ' - '.$module_name.' - '.$period); - $pdf->ezText ("".format_for_graph ($value, 2)."", 18); - - break; - case 9: - case 'min_value': - $value = get_agent_module_value_min ($content["id_agent_module"], $content['period']); - doTitle ($pdf, __('Min. Value').': '.$agent_name. - ' - '.$module_name.' - '.$period); - $pdf->ezText ("".format_for_graph ($value, 2)."", 18); - - break; - case 10: - case 'sumatory': - $value = get_agent_module_value_sumatory ($content["id_agent_module"], $content['period']); - doTitle ($pdf, __('Sumatory').': '.$agent_name. - ' - '.$module_name.' - '.$period); - $pdf->ezText ("".format_for_graph ($value, 2)."", 18); - - break; - case 11: - case 'general_group_report': - doTitle ($pdf, __('Group').': '.$group_name); - $pdf->ezText ("".__('Agents in group').': '.sizeof ($agents)."", 12); - - break; - case 12: - case 'monitor_health': - $monitors = get_monitors_in_group ($report['id_group']); - $monitors_down = get_monitors_down ($monitors, $content['period']); - - doTitle ($pdf, __('Monitor health').': '. - $group_name. ' - '.$period); - $down_percentage = round (sizeof ($monitors_down) / sizeof ($monitors) * 100, 2); - $not_down_percentage = 100 - $down_percentage; - $image = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"]. - '/reporting/fgraph.php?PHPSESSID='.$session_id. - '&tipo=monitors_health_pipe&height=150&width=280&down='. - $down_percentage.'¬_down='.$not_down_percentage; - $pdf->ezImage ($image, 0, 150, 'none', 'left'); - $pdf->ezText ("\n", 4); - $pdf->ezText (''.__('Total monitors').': '.sizeof ($monitors).'', 8); - $pdf->ezText (''.__('Monitors down on period').': '.sizeof ($monitors_down).'', 8); - $pdf->ezText ("\n", 8); - - $table_monitors = get_monitors_down_reporting_table ($monitors_down); - $pdf->ezTable ($table_monitors->data, $table_monitors->head, - "", $table_options); - unset ($monitors); - unset ($monitors_down); - - break; - case 13: - case 'agents_detailed': - doTitle ($pdf, __('Agents detailed view').': '. - $group_name.' '.__('Group')); - foreach ($agents as $agent) { - $pdf->ezText ("".$agent['nombre']."", 18); - $table = get_agent_modules_reporting_table ($agent['id_agente'], $content['period']); - $pdf->ezText ("".__('Modules')."", 12); - $pdf->ezText ("\n", 3); - $pdf->ezTable ($table->data, array (__('Name')), "", $table_options); - - $table = get_agent_alerts_reporting_table ($agent['id_agente'], $content['period']); - if (sizeof ($table->data)) { - $pdf->ezText ("".__('Alerts')."", 12); - $pdf->ezText ("\n", 3); - $pdf->ezTable ($table->data, $table->head, "", $table_options); - } - - $table = get_agent_monitors_reporting_table ($agent['id_agente'], $content['period']); - if (sizeof ($table->data)) { - $pdf->ezText ("".__('Monitors')."", 12); - $pdf->ezText ("\n", 3); - $pdf->ezTable ($table->data, $table->head, "", $table_options); - } - } - - break; - } - $pdf->ezText ("\n", 8); - } - - // End report - doPageNumbering ($pdf); - $pdf->ezStream (); -} -?> diff --git a/pandora_console/install.php b/pandora_console/install.php index afd9b04dfa..ff524eac2f 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -320,10 +320,10 @@ function install_step3() { value='/var/www/pandora_console/'>
Full local URL to Pandora FMS Console
- For example http://localhost/pandora_console + For example '/pandora_console'
+ value='/pandora_console'>
diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 71f68951fa..6bc28da70c 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -116,7 +116,7 @@ if ($ag_group > 1){ ORDER BY nombre, id_grupo LIMIT %d,%d", $search_sql, $offset, $config["block_size"]); - $sql2 = sprint ("SELECT COUNT(id_agente) + $sql2 = sprintf ("SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 %s ORDER BY nombre, id_grupo", $search_sql); @@ -142,6 +142,7 @@ if ($ag_group > 1){ } } + $result2 = mysql_query ($sql2); $row2 = mysql_fetch_array ($result2); $total_events = $row2[0]; diff --git a/pandora_console/operation/events/events_rss.php b/pandora_console/operation/events/events_rss.php index 25ae3166cc..ceca2eb1be 100644 --- a/pandora_console/operation/events/events_rss.php +++ b/pandora_console/operation/events/events_rss.php @@ -35,7 +35,7 @@ $result=mysql_query($sql); //$url = "https://".$_SERVER['HTTP_HOST']."/pandora_console"; -$url = $config["homeurl"]; +$url = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"]; $rss_feed = ' Pandora RSS Feed