2009-02-26 Esteban Sanchez <estebans@artica.es>

* include/functions_events.php: Added get_events() function. Replaced
	"..." with html entity and reuse previously calculated value.

	* include/functions_reporting.php: Fixed get_agent_module_sla() to
	allow no max value to be checked. That was causing some errors on
	monitor reports.

	* operation/agentes/sla_view.php,
	operation/reporting/reporting_xml.php,
	operation/reporting/reporting_viewer.php: Do not use max value on
	monitor SLA.
	
	* operation/events/events.php: Replaced exit for return.

	* include/functions_db.php: Added support for arrays in
	format_array_to_update_sql() that will be transformed to a "IN ()"
	statement.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1489 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
esanchezm 2009-02-26 15:34:14 +00:00
parent 5f414fc66a
commit cd0111059c
8 changed files with 37 additions and 10 deletions

View File

@ -1,3 +1,23 @@
2009-02-26 Esteban Sanchez <estebans@artica.es>
* include/functions_events.php: Added get_events() function. Replaced
"..." with html entity and reuse previously calculated value.
* include/functions_reporting.php: Fixed get_agent_module_sla() to
allow no max value to be checked. That was causing some errors on
monitor reports.
* operation/agentes/sla_view.php,
operation/reporting/reporting_xml.php,
operation/reporting/reporting_viewer.php: Do not use max value on
monitor SLA.
* operation/events/events.php: Replaced exit for return.
* include/functions_db.php: Added support for arrays in
format_array_to_update_sql() that will be transformed to a "IN ()"
statement.
2009-02-26 Esteban Sanchez <estebans@artica.es> 2009-02-26 Esteban Sanchez <estebans@artica.es>
* include/config_process.php, index.php: Added generated timer count as * include/config_process.php, index.php: Added generated timer count as

View File

@ -1889,6 +1889,8 @@ function format_array_to_update_sql ($values) {
$sql = sprintf ("`%s` = %d", $field, $value); $sql = sprintf ("`%s` = %d", $field, $value);
} else if (is_float ($value) || is_double ($value)) { } else if (is_float ($value) || is_double ($value)) {
$sql = sprintf ("`%s` = %f", $field, $value); $sql = sprintf ("`%s` = %f", $field, $value);
} else if (is_array ($value)) {
$sql = sprintf ('`%s` IN ("%s")', $field, implode ('", "', $value));
} else { } else {
$sql = sprintf ("`%s` = '%s'", $field, $value); $sql = sprintf ("`%s` = '%s'", $field, $value);
} }

View File

@ -17,6 +17,10 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
function get_events ($filter = false, $fields = false) {
return get_db_all_rows_filter ('tevento', $filter, $fields);
}
/** /**
* Delete events in a transaction * Delete events in a transaction
* *
@ -231,8 +235,8 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return =
$wrap = floor ($width / 10); $wrap = floor ($width / 10);
$data[2] = '<span class="'.get_priority_class ($event["criticity"]).'f9" title="'.safe_input ($event["evento"]).'">'.safe_input (chunk_split (mb_substr ($event["evento"],0, $wrap),8, "&shy;")); $data[2] = '<span class="'.get_priority_class ($event["criticity"]).'f9" title="'.safe_input ($event["evento"]).'">'.safe_input (chunk_split (mb_substr ($event["evento"],0, $wrap),8, "&shy;"));
if (mb_strlen ($event["evento"]) > floor ($width / 10)) { if (mb_strlen ($event["evento"]) > $wrap) {
$data[2] .= "..."; $data[2] .= "&hellip;";
} }
$data[2] .= '</span>'; $data[2] .= '</span>';

View File

@ -27,12 +27,13 @@ require_once ($config["homedir"]."/include/functions_agents.php");
* @param int Agent module to calculate SLA * @param int Agent module to calculate SLA
* @param int Period to check the SLA compliance. * @param int Period to check the SLA compliance.
* @param int Minimum data value the module in the right interval * @param int Minimum data value the module in the right interval
* @param int Maximum data value the module in the right interval * @param int Maximum data value the module in the right interval. False will
* ignore max value
* @param int Beginning date of the report in UNIX time (current date by default). * @param int Beginning date of the report in UNIX time (current date by default).
* *
* @return int SLA percentage of the requested module. * @return int SLA percentage of the requested module.
*/ */
function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value, $date = 0) { function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value = false, $date = 0) {
if (empty ($date)) if (empty ($date))
$date = get_system_time (); $date = get_system_time ();
@ -83,7 +84,7 @@ function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value
} }
foreach ($datas as $data) { foreach ($datas as $data) {
if ($data["datos"] > $max_value || $data["datos"] < $min_value) { if ($data["datos"] < $min_value || ($max_value !== false && $data["datos"] > $max_value)) {
if ($interval_begin == 0) { if ($interval_begin == 0) {
$interval_begin = $data["utimestamp"]; $interval_begin = $data["utimestamp"];
} }

View File

@ -94,7 +94,7 @@ if (mysql_num_rows ($result_t)) {
echo "<td class='".$tdcolor."' title='".$est_description."'>".$est_modulo."</td>"; echo "<td class='".$tdcolor."' title='".$est_description."'>".$est_modulo."</td>";
echo "<td class='$tdcolor'>"; echo "<td class='$tdcolor'>";
$temp = get_agent_module_sla ($module_data["id_agente_modulo"], $config["sla_period"], 1, 2147483647); $temp = get_agent_module_sla ($module_data["id_agente_modulo"], $config["sla_period"], 1);
if ($temp === false) if ($temp === false)
echo __('N/A'); echo __('N/A');
else { else {

View File

@ -26,7 +26,7 @@ if (! give_acl ($config["id_user"], 0, "IR")) {
audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation",
"Trying to access event viewer"); "Trying to access event viewer");
require ("general/noaccess.php"); require ("general/noaccess.php");
exit; return;
} }
$delete = (bool) get_parameter ("delete"); $delete = (bool) get_parameter ("delete");

View File

@ -27,7 +27,7 @@ if (! $id_report) {
audit_db ($config['id_user'], $REMOTE_ADDR, "HACK Attempt", audit_db ($config['id_user'], $REMOTE_ADDR, "HACK Attempt",
"Trying to access graph viewer withoud ID"); "Trying to access graph viewer withoud ID");
include ("general/noaccess.php"); include ("general/noaccess.php");
exit; return;
} }
$report = get_db_row ('treport', 'id_report', $id_report); $report = get_db_row ('treport', 'id_report', $id_report);
@ -325,7 +325,7 @@ foreach ($contents as $content) {
} }
$data = array (); $data = array ();
$monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, 1, $datetime)); $monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'; $data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">';
$data[0] .= $monitor_value.' % <img src="images/b_green.png" height="32" width="32" /></p>'; $data[0] .= $monitor_value.' % <img src="images/b_green.png" height="32" width="32" /></p>';
$monitor_value = format_numeric (100 - $monitor_value, 2) ; $monitor_value = format_numeric (100 - $monitor_value, 2) ;

View File

@ -234,7 +234,7 @@ foreach ($contents as $content) {
case 6: case 6:
case 'monitor_report': case 'monitor_report':
$data["title"] = __('Monitor report'); $data["title"] = __('Monitor report');
$monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, 1, $datetime)); $monitor_value = format_numeric (get_agent_module_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime));
$data["objdata"]["good"] = $monitor_value; $data["objdata"]["good"] = $monitor_value;
$data["objdata"]["bad"] = format_numeric (100 - $monitor_value, 2); $data["objdata"]["bad"] = format_numeric (100 - $monitor_value, 2);
break; break;