2010-07-27 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_reporting.php: added new parameters in the function "get_agentmodule_sla", the parameters days of week to search and range of time. And use new parameteres in the call for SLA data in function "render_report_html_item". * pandoradb.sql, extras/pandoradb_migrate_v3.1_to_v3.2.sql: in table "treport_content" added the fields for set days of week and range time for SLA. * operation/reporting/reporting_xml.php: use new parameters in the call for SLA data. * godmode/reporting/reporting_builder.php: added source code for save, update new fields (days of week and time range). * godmode/reporting/reporting_builder.item_editor.php: added source code to show the fields (days of week and time range). Pending task: #3033457 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3070 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ccd952497e
commit
6e710c8614
|
@ -1,3 +1,24 @@
|
|||
2010-07-27 Miguel de Dios <miguel.dedios@artica.es>
|
||||
* include/functions_reporting.php: added new parameters in the function
|
||||
"get_agentmodule_sla", the parameters days of week to search and range of
|
||||
time. And use new parameteres in the call for SLA data in function
|
||||
"render_report_html_item".
|
||||
|
||||
* pandoradb.sql, extras/pandoradb_migrate_v3.1_to_v3.2.sql: in table
|
||||
"treport_content" added the fields for set days of week and range time
|
||||
for SLA.
|
||||
|
||||
* operation/reporting/reporting_xml.php: use new parameters in the call for
|
||||
SLA data.
|
||||
|
||||
* godmode/reporting/reporting_builder.php: added source code for save,
|
||||
update new fields (days of week and time range).
|
||||
|
||||
* godmode/reporting/reporting_builder.item_editor.php: added source code to
|
||||
show the fields (days of week and time range).
|
||||
|
||||
Pending task: #3033457
|
||||
|
||||
2010-07-27 Miguel de Dios <miguel.dedios@artica.es>
|
||||
* operation/agentes/exportdata.php: fixed the date into export, before it
|
||||
was 12 hour format, now it is 24 hour format.
|
||||
|
|
|
@ -22,3 +22,16 @@
|
|||
-- Table `tgrupo`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE `tgrupo` ADD COLUMN `propagate` tinyint(1) unsigned NOT NULL default '0';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `treport_content`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE `treport_content` ADD COLUMN `time_from` time default '00:00:00';
|
||||
ALTER TABLE `treport_content` ADD COLUMN `time_to` time default '00:00:00';
|
||||
ALTER TABLE `treport_content` ADD COLUMN `monday` tinyint(1) default 1;
|
||||
ALTER TABLE `treport_content` ADD COLUMN `tuesday` tinyint(1) default 1;
|
||||
ALTER TABLE `treport_content` ADD COLUMN `wednesday` tinyint(1) default 1;
|
||||
ALTER TABLE `treport_content` ADD COLUMN `thursday` tinyint(1) default 1;
|
||||
ALTER TABLE `treport_content` ADD COLUMN `friday` tinyint(1) default 1;
|
||||
ALTER TABLE `treport_content` ADD COLUMN `saturday` tinyint(1) default 1;
|
||||
ALTER TABLE `treport_content` ADD COLUMN `sunday` tinyint(1) default 1;
|
||||
|
|
|
@ -39,6 +39,16 @@ switch ($action) {
|
|||
$description = null;
|
||||
$sql = null;
|
||||
$group = null;
|
||||
|
||||
$monday = true;
|
||||
$tuesday = true;
|
||||
$wednesday = true;
|
||||
$thursday = true;
|
||||
$friday = true;
|
||||
$saturday = true;
|
||||
$sunday = true;
|
||||
$time_from = '00:00';
|
||||
$time_to = '23:59';
|
||||
break;
|
||||
default:
|
||||
$actionParameter = 'update';
|
||||
|
@ -66,6 +76,16 @@ switch ($action) {
|
|||
case 'SLA':
|
||||
$description = $item['description'];
|
||||
$period = $item['period'];
|
||||
|
||||
$monday = $item['monday'];
|
||||
$tuesday = $item['tuesday'];
|
||||
$wednesday = $item['wednesday'];
|
||||
$thursday = $item['thursday'];
|
||||
$friday = $item['friday'];
|
||||
$saturday = $item['saturday'];
|
||||
$sunday = $item['sunday'];
|
||||
$time_from = $item['time_from'];
|
||||
$time_to = $item['time_to'];
|
||||
break;
|
||||
case 'monitor_report':
|
||||
$description = $item['description'];
|
||||
|
@ -102,17 +122,6 @@ switch ($action) {
|
|||
$idAgentModule = $item['id_agent_module'];
|
||||
$period = $item['period'];
|
||||
break;
|
||||
// case 'agent_detailed':
|
||||
// $description = $item['description'];
|
||||
// $idAgent = $item['id_agent'];
|
||||
// $period = $item['period'];
|
||||
// break;
|
||||
// case 'agent_detailed_event':
|
||||
// $description = $item['description'];
|
||||
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
|
||||
// $idAgentModule = $item['id_agent_module'];
|
||||
// $period = $item['period'];
|
||||
// break;
|
||||
case 'text':
|
||||
$description = $item['description'];
|
||||
$text = $item['text'];
|
||||
|
@ -187,24 +196,6 @@ switch ($action) {
|
|||
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
|
||||
$period = $item['period'];
|
||||
break;
|
||||
// case 'list_events_module':
|
||||
// $description = $item['description'];
|
||||
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
|
||||
// $idAgentModule = $item['id_agent_module'];
|
||||
// break;
|
||||
// case 'list_events_agent':
|
||||
// $description = $item['description'];
|
||||
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
|
||||
// break;
|
||||
// case 'list_alerts_agent':
|
||||
// $description = $item['description'];
|
||||
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
|
||||
// break;
|
||||
// case 'list_alerts_module':
|
||||
// $description = $item['description'];
|
||||
// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
|
||||
// $idAgentModule = $item['id_agent_module'];
|
||||
// break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -247,6 +238,30 @@ print_input_hidden('id_item', $idItem);
|
|||
<td style="vertical-align: top;"><?php echo __('Period'); ?></td>
|
||||
<td style=""><?php print_extended_select_for_time ($intervals, 'period', $period, '', '', '0', 10); echo __(" seconds."); ?></td>
|
||||
</tr>
|
||||
<tr id="row_working_time">
|
||||
<td style="vertical-align: top;"><?php echo __('Working time');?></td>
|
||||
<td>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td><?php echo __('Monday'); print_checkbox('monday', 1, $monday);?></td>
|
||||
<td><?php echo __('Tuesday'); print_checkbox('tuesday', 1, $tuesday);?></td>
|
||||
<td><?php echo __('Wednesday'); print_checkbox('wednesday', 1, $wednesday);?></td>
|
||||
<td><?php echo __('Thursday'); print_checkbox('thursday', 1, $thursday);?></td>
|
||||
<td><?php echo __('Friday'); print_checkbox('friday', 1, $friday);?></td>
|
||||
<td><?php echo __('Saturday'); print_checkbox('saturday', 1, $saturday);?></td>
|
||||
<td><?php echo __('Sunday'); print_checkbox('sunday', 1, $sunday);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('Time from');?></td>
|
||||
<td colspan="6"><?php print_input_text ('time_from', $time_from, '', 7, 7);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('Time to');?></td>
|
||||
<td colspan="6"><?php print_input_text ('time_to', $time_to, '', 7, 7);?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row_group" style="" class="datos">
|
||||
<td style="vertical-align: top;"><?php echo __('Group');?></td>
|
||||
<td style=""><?php print_select(get_all_groups(), 'group', $group, '', __('All'), '0'); ?></td>
|
||||
|
@ -334,6 +349,7 @@ else {
|
|||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
require_jquery_file ('timeentry');
|
||||
require_jquery_file ('autocomplete');
|
||||
require_javascript_file('pandora');
|
||||
if ($enterpriseEnable) {
|
||||
|
@ -427,6 +443,13 @@ $(document).ready (function () {
|
|||
agent_module_autocomplete('#text-agent_sla', '#hidden-id_agent_sla', '#id_agent_module_sla');
|
||||
chooseType();
|
||||
chooseSQLquery();
|
||||
|
||||
$("#text-time_to, #text-time_from").timeEntry ({
|
||||
spinnerImage: 'images/time-entry.png',
|
||||
spinnerSize: [20, 20, 0],
|
||||
show24Hours: true
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function chooseSQLquery() {
|
||||
|
@ -553,6 +576,7 @@ function chooseType() {
|
|||
$("#sla_list").css('display', 'none');
|
||||
$("#row_custom_example").css('display', 'none');
|
||||
$("#row_group").css('display', 'none');
|
||||
$("#row_working_time").css('display', 'none');
|
||||
|
||||
switch (type) {
|
||||
case 'event_report_group':
|
||||
|
@ -575,6 +599,7 @@ function chooseType() {
|
|||
$("#row_description").css('display', '');
|
||||
$("#row_period").css('display', '');
|
||||
$("#sla_list").css('display', '');
|
||||
$("#row_working_time").css('display', '');
|
||||
break;
|
||||
case 'monitor_report':
|
||||
$("#row_description").css('display', '');
|
||||
|
@ -611,12 +636,6 @@ function chooseType() {
|
|||
$("#row_agent").css('display', '');
|
||||
$("#row_period").css('display', '');
|
||||
break;
|
||||
// case 'agent_detailed_event':
|
||||
// $("#row_description").css('display', '');
|
||||
// $("#row_agent").css('display', '');
|
||||
// $("#row_module").css('display', '');
|
||||
// $("#row_period").css('display', '');
|
||||
// break;
|
||||
case 'text':
|
||||
$("#row_description").css('display', '');
|
||||
$("#row_text").css('display', '');
|
||||
|
@ -687,24 +706,6 @@ function chooseType() {
|
|||
$("#row_module").css('display', '');
|
||||
$("#row_period").css('display', '');
|
||||
break;
|
||||
// case 'list_events_module':
|
||||
// $("#row_description").css('display', '');
|
||||
// $("#row_agent").css('display', '');
|
||||
// $("#row_module").css('display', '');
|
||||
// break;
|
||||
// case 'list_events_agent':
|
||||
// $("#row_description").css('display', '');
|
||||
// $("#row_agent").css('display', '');
|
||||
// break;
|
||||
// case 'list_alerts_agent':
|
||||
// $("#row_description").css('display', '');
|
||||
// $("#row_agent").css('display', '');
|
||||
// break;
|
||||
// case 'list_alerts_module':
|
||||
// $("#row_description").css('display', '');
|
||||
// $("#row_agent").css('display', '');
|
||||
// $("#row_module").css('display', '');
|
||||
// break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -171,7 +171,16 @@ switch ($action) {
|
|||
$values['text'] = get_parameter('text');
|
||||
$values['id_agent_module'] = get_parameter('id_agent_module');
|
||||
$values['type'] = get_parameter('type', null);
|
||||
|
||||
$values['monday'] = get_parameter('monday', 0);
|
||||
$values['tuesday'] = get_parameter('tuesday', 0);
|
||||
$values['wednesday'] = get_parameter('wednesday', 0);
|
||||
$values['thursday'] = get_parameter('thursday', 0);
|
||||
$values['friday'] = get_parameter('friday', 0);
|
||||
$values['saturday'] = get_parameter('saturday', 0);
|
||||
$values['sunday'] = get_parameter('sunday', 0);
|
||||
$values['time_from'] = get_parameter('time_from');
|
||||
$values['time_to'] = get_parameter('time_to');
|
||||
|
||||
if ($values['type'] == 'sql') {
|
||||
$values['treport_custom_sql_id'] = get_parameter('id_custom');
|
||||
if ($values['treport_custom_sql_id'] == 0) {
|
||||
|
@ -201,6 +210,15 @@ switch ($action) {
|
|||
$values['id_gs'] = get_parameter('id_custom_graph');
|
||||
$values['text'] = get_parameter('text');
|
||||
$values['id_agent_module'] = get_parameter('id_agent_module');
|
||||
$values['monday'] = get_parameter('monday', 0);
|
||||
$values['tuesday'] = get_parameter('tuesday', 0);
|
||||
$values['wednesday'] = get_parameter('wednesday', 0);
|
||||
$values['thursday'] = get_parameter('thursday', 0);
|
||||
$values['friday'] = get_parameter('friday', 0);
|
||||
$values['saturday'] = get_parameter('saturday', 0);
|
||||
$values['sunday'] = get_parameter('sunday', 0);
|
||||
$values['time_from'] = get_parameter('time_from');
|
||||
$values['time_to'] = get_parameter('time_to');
|
||||
|
||||
if ($values['type'] == 'sql') {
|
||||
$values['treport_custom_sql_id'] = get_parameter('id_custom');
|
||||
|
|
|
@ -305,11 +305,14 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
|
|||
* @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 array $dayWeek Array of days week to extract as array('monday' => false, 'tuesday' => true....), and by default is null.
|
||||
* @param string $timeFrom Time in the day to start to extract in mysql format, by default null.
|
||||
* @param string $timeTo Time in the day to end to extract in mysql format, by default null.
|
||||
*
|
||||
* @return float SLA percentage of the requested module. False if no data were
|
||||
* found
|
||||
*/
|
||||
function get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $date = 0) {
|
||||
function get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $date = 0, $daysWeek = null, $timeFrom = null, $timeTo = null) {
|
||||
global $config;
|
||||
|
||||
// Initialize variables
|
||||
|
@ -324,6 +327,48 @@ function get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $ma
|
|||
WHERE id_agente_modulo = %d
|
||||
AND utimestamp > %d AND utimestamp <= %d',
|
||||
$id_agent_module, $datelimit, $date);
|
||||
|
||||
//Add the working times (mon - tue - wed ...) and from time to time
|
||||
$days = array();
|
||||
//Translate to mysql week days
|
||||
foreach ($daysWeek as $key => $value) {
|
||||
if (!$value) {
|
||||
if ($key == 'monday') {
|
||||
$days[] = 2;
|
||||
}
|
||||
if ($key == 'tuesday') {
|
||||
$days[] = 3;
|
||||
}
|
||||
if ($key == 'wednesday') {
|
||||
$days[] = 4;
|
||||
}
|
||||
if ($key == 'thursday') {
|
||||
$days[] = 5;
|
||||
}
|
||||
if ($key == 'friday') {
|
||||
$days[] = 6;
|
||||
}
|
||||
if ($key == 'saturday') {
|
||||
$days[] = 7;
|
||||
}
|
||||
if ($key == 'sunday') {
|
||||
$days[] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($days) > 0) {
|
||||
$sql .= ' AND DAYOFWEEK(FROM_UNIXTIME(utimestamp)) NOT IN (' . implode(',', $days) . ')';
|
||||
}
|
||||
|
||||
if (!empty($timeFrom)) {
|
||||
$sql .= ' AND TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '"';
|
||||
}
|
||||
|
||||
if (!empty($timeTo)) {
|
||||
$sql .= ' AND TIME(FROM_UNIXTIME(utimestamp)) <= "' . $timeTo . '"';
|
||||
}
|
||||
|
||||
$interval_data = get_db_all_rows_sql ($sql, true);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
|
@ -1707,7 +1752,7 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
|
|||
$data[0] .= '<strong>'.__('SLA Limit')."</strong> : ";
|
||||
$data[0] .= $sla['sla_limit'];
|
||||
$sla_value = get_agentmodule_sla ($sla['id_agent_module'], $content['period'],
|
||||
$sla['sla_min'], $sla['sla_max'], $report["datetime"]);
|
||||
$sla['sla_min'], $sla['sla_max'], $report["datetime"], $content, $content['time_from'], $content['time_to']);
|
||||
if ($sla_value === false) {
|
||||
$data[1] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #0000FF;">';
|
||||
$data[1] .= __('Unknown');
|
||||
|
|
|
@ -219,13 +219,14 @@ foreach ($contents as $content) {
|
|||
|
||||
$data["objdata"]["sla"] = array ();
|
||||
$sla_failed = false;
|
||||
|
||||
foreach ($slas as $sla) {
|
||||
$sla_data = array ();
|
||||
$sla_data["agent"] = get_agentmodule_agent_name ($sla['id_agent_module']);
|
||||
$sla_data["module"] = get_agentmodule_name ($sla['id_agent_module']);
|
||||
$sla_data["max"] = $sla['sla_max'];
|
||||
$sla_data["min"] = $sla['sla_min'];
|
||||
$sla_value = get_agentmodule_sla ($sla['id_agent_module'], $content['period'], $sla['sla_min'], $sla['sla_max'], $datetime);
|
||||
$sla_value = get_agentmodule_sla ($sla['id_agent_module'], $content['period'], $sla['sla_min'], $sla['sla_max'], $datetime, $content, $content['time_from'], $content['time_to']);
|
||||
if ($sla_value === false) {
|
||||
$sla_data["error"] = __('Unknown');
|
||||
} else {
|
||||
|
@ -237,21 +238,6 @@ foreach ($contents as $content) {
|
|||
array_push ($data["objdata"]["sla"], $sla_data);
|
||||
}
|
||||
break;
|
||||
// case 4:
|
||||
// case 'event_report':
|
||||
// $data["title"] = __("Event report");
|
||||
// $table_report = event_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
// $data["objdata"] = "<![CDATA[";
|
||||
// $data["objdata"] .= print_table ($table_report, true);
|
||||
// $data["objdata"] .= "]]>";
|
||||
// break;
|
||||
// case 5:
|
||||
// case 'alert_report':
|
||||
// $data["title"] = __('Alert report');
|
||||
// $data["objdata"] = "<![CDATA[";
|
||||
// $data["objdata"] .= alert_reporting ($report['id_group'], $content['period'], $datetime, true);
|
||||
// $data["objdata"] .= "]]>";
|
||||
// break;
|
||||
case 6:
|
||||
case 'monitor_report':
|
||||
$data["title"] = __('Monitor report');
|
||||
|
|
|
@ -761,25 +761,37 @@ CREATE TABLE IF NOT EXISTS `treport` (
|
|||
PRIMARY KEY(`id_report`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `treport_content`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `treport_content` (
|
||||
`id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_report` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`id_gs` INTEGER UNSIGNED NULL default NULL,
|
||||
`id_agent_module` bigint(14) unsigned NULL default NULL,
|
||||
`type` varchar(30) default 'simple_graph',
|
||||
`period` int(11) NOT NULL default 0,
|
||||
`order` int (11) NOT NULL default 0,
|
||||
`description` mediumtext,
|
||||
`id_agent` int(10) unsigned NOT NULL default 0,
|
||||
`text` TEXT default NULL,
|
||||
`external_source` TinyText default NULL,
|
||||
`treport_custom_sql_id` INTEGER UNSIGNED default 0,
|
||||
`header_definition` TinyText default NULL,
|
||||
`column_separator` TinyText default NULL,
|
||||
`line_separator` TinyText default NULL,
|
||||
PRIMARY KEY(`id_rc`),
|
||||
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
`id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_report` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`id_gs` INTEGER UNSIGNED NULL default NULL,
|
||||
`id_agent_module` bigint(14) unsigned NULL default NULL,
|
||||
`type` varchar(30) default 'simple_graph',
|
||||
`period` int(11) NOT NULL default 0,
|
||||
`order` int (11) NOT NULL default 0,
|
||||
`description` mediumtext,
|
||||
`id_agent` int(10) unsigned NOT NULL default 0,
|
||||
`text` TEXT default NULL,
|
||||
`external_source` TinyText default NULL,
|
||||
`treport_custom_sql_id` INTEGER UNSIGNED default 0,
|
||||
`header_definition` TinyText default NULL,
|
||||
`column_separator` TinyText default NULL,
|
||||
`line_separator` TinyText default NULL,
|
||||
`time_from` time default '00:00:00',
|
||||
`time_to` time default '00:00:00',
|
||||
`monday` tinyint(1) default 1,
|
||||
`tuesday` tinyint(1) default 1,
|
||||
`wednesday` tinyint(1) default 1,
|
||||
`thursday` tinyint(1) default 1,
|
||||
`friday` tinyint(1) default 1,
|
||||
`saturday` tinyint(1) default 1,
|
||||
`sunday` tinyint(1) default 1,
|
||||
PRIMARY KEY(`id_rc`),
|
||||
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `treport_content_sla_combined` (
|
||||
|
|
Loading…
Reference in New Issue