' . __('Module') . ' ' .
$module['module_name'];
if ($module['utimestamp'] == 0 && (($module['module_type'] < 21 ||
$module['module_type'] > 23) && $module['module_type'] != 100)) {
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_NO_DATA,
__('NOT INIT'), true);
}
elseif ($module["estado"] == 0) {
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_OK,
__('NORMAL') . ": " . $module["datos"], true);
}
elseif ($module["estado"] == 1) {
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_CRITICAL,
__('CRITICAL') . ": " . $module["datos"], true);
}
elseif ($module["estado"] == 2) {
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_WARNING,
__('WARNING') . ": " . $module["datos"], true);
}
else {
$last_status = modules_get_agentmodule_last_status(
$module['id_agente_modulo']);
switch($last_status) {
case 0:
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_UNKNOWN,
__('UNKNOWN') . " - " . __('Last status') . " " .
__('NORMAL') . ": " . $module["datos"], true);
break;
case 1:
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_UNKNOWN,
__('UNKNOWN') . " - " . __('Last status') ." " .
__('CRITICAL') . ": " . $module["datos"], true);
break;
case 2:
$row[5] = $row[__('Status')] = ui_print_status_image(STATUS_MODULE_UNKNOWN,
__('UNKNOWN') . " - " . __('Last status') . " " .
__('WARNING') . ": " . $module["datos"], true);
break;
}
}
$row[4] = $row[__('Interval')] =
($module['module_interval'] == 0) ? human_time_description_raw($module['agent_interval']) : human_time_description_raw($module['module_interval']);
$row[4] = $row[__('Interval')] = '' . __('Interval.') . ' ' .
$row[__('Interval')] .
'';
$row[6] = $row[__('Timestamp')] =
' ' . __('Last update.') . ' ' .
ui_print_timestamp($module["utimestamp"], true) . '';
if (is_numeric($module["datos"])) {
$output = format_numeric($module["datos"]);
// Show units ONLY in numeric data types
if (isset($module["unit"])) {
$output .= " " .
''. io_safe_output($module["unit"]) . '';
}
}
else {
$is_web_content_string =
(bool)db_get_value_filter('id_agente_modulo',
'tagente_modulo',
array('id_agente_modulo' => $module['id_agente_modulo'],
'id_tipo_modulo' => $id_type_web_content_string));
//Fixed the goliat sends the strings from web
//without HTML entities
if ($is_web_content_string) {
$module['datos'] = io_safe_input($module['datos']);
}
//Fixed the data from Selenium Plugin
if ($module['datos'] != strip_tags($module['datos'])) {
$module['datos'] = io_safe_input($module['datos']);
}
if ($is_web_content_string) {
$module_value = $module["datos"];
}
else {
$module_value = io_safe_output($module["datos"]);
}
$sub_string = substr(io_safe_output($module["datos"]), 0, 12);
if ($module_value == $sub_string) {
$output = $module_value;
}
else {
$output = $sub_string;
}
}
$row[7] = $row[__('Data')] =
'' .
'' . $row[__('Status')] . ' ' .
'id_agent . '">' .
'' . html_print_image('images/chart_curve.png', true, array ("style" => 'vertical-align: middle;')) . '' .
' ' . $output . '' . '';
if (!$ajax) {
if ($this->columns['agent']) {
unset($row[0]);
}
unset($row[1]);
unset($row[2]);
unset($row[4]);
unset($row[5]);
unset($row[6]);
unset($row[7]);
}
$modules[$module['id_agente_modulo']] = $row;
}
}
return array('modules' => $modules, 'total' => $total);
}
public function listModulesHtml($page = 0, $return = false) {
$system = System::getInstance();
$ui = Ui::getInstance();
$listModules = $this->getListModules($page);
//$ui->debug($listModules, true);
if ($listModules['total'] == 0) {
$html = '' . __('No modules') . '
';
if (!$return) {
$ui->contentAddHtml($html);
}
}
else {
if (!$return) {
$table = new Table();
$table->id = 'list_Modules';
$table->importFromHash($listModules['modules']);
$ui->contentAddHtml($table->getHTML());
}
else {
foreach ($listModules['modules'] as $key => $module) {
$listModules['modules'][$key][__('Status')] .=
'' .
$listModules['modules'][$key][__('Data')] .
'';
}
$table = new Table();
$table->id = 'list_Modules_Embedded';
$table->importFromHash($listModules['modules']);
$html = $table->getHTML();
return $html;
}
if (!$this->all_modules) {
if ($system->getPageSize() < $listModules['total']) {
$ui->contentAddHtml('' .
html_print_image('images/spinner.gif', true) .
' ' . __('Loading...') .
'
');
$this->addJavascriptAddBottom();
}
}
}
}
private function addJavascriptAddBottom() {
$ui = Ui::getInstance();
$ui->contentAddHtml("");
}
private function filterEventsGetString() {
if ($this->default) {
return __("(Default)");
}
else {
$filters_to_serialize = array();
if (!$this->default_filters['group']) {
$filters_to_serialize[] = sprintf(__("Group: %s"),
groups_get_name($this->group, true));
}
if (!$this->default_filters['module_group']) {
$module_group = db_get_value('name',
'tmodule_group', 'id_mg', $this->module_group);
$module_group = io_safe_output($module_group);
$filters_to_serialize[] = sprintf(__("Module group: %s"),
$module_group);
}
if (!$this->default_filters['status']) {
$filters_to_serialize[] = sprintf(__("Status: %s"),
$this->list_status[$this->status]);
}
if (!$this->default_filters['free_search']) {
$filters_to_serialize[] = sprintf(__("Free Search: %s"),
$this->free_search);
}
$string = '(' . implode(' - ', $filters_to_serialize) . ')';
//~ $status = $this->list_status[$this->status];
//~
//~ $group = groups_get_name($this->group, true);
//~
//~ $module_group = db_get_value('name',
//~ 'tmodule_group', 'id_mg', $this->module_group);
//~ $module_group = io_safe_output($module_group);
//~
//~ $string = sprintf(
//~ __("(Status: %s - Group: %s - Module group: %s - Free Search: %s)"),
//~ $status, $group, $module_group, $this->free_search);
return $string;
}
}
}
?>