Merge branch 'ent-5756-pantallas-de-configuracion-del-cluster' into 'develop'

Ent 5756 pantallas de configuracion del cluster

See merge request artica/pandorafms!3205
This commit is contained in:
Daniel Rodriguez 2020-06-01 09:47:25 +02:00
commit df1fe544a1
39 changed files with 2047 additions and 390 deletions

View File

@ -3,4 +3,15 @@ operation/users/webchat.php
include/javascript/webchat.js
attachment/pandora_chat.log.json.txt
attachment/pandora_chat.user_list.json.txt
attachment/pandora_chat.global_counter.txt
attachment/pandora_chat.global_counter.txt
enterprise/godmode/reporting/cluster_agent_check.php
enterprise/godmode/reporting/cluster_builder.main.php
enterprise/godmode/reporting/cluster_builder.php
enterprise/godmode/reporting/cluster_force.php
enterprise/godmode/reporting/cluster_list.php
enterprise/godmode/reporting/cluster_name_agents.php
enterprise/godmode/reporting/cluster_view.php
enterprise/include/ajax/clustermap.php
enterprise/include/functions_clustermap.php
enterprise/include/functions_clusters.php
enterprise/include/javascript/ClusterMapController.js

View File

@ -52,7 +52,7 @@ ui_print_info_message(['no_close' => true, 'message' => __('There are no cluster
if (check_acl($config['id_user'], 0, 'AW')) {
?>
<form action="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&step=1" method="post">
<form action='index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&op=new' method="post">
<input style="margin-bottom:20px;" type="submit" class="button_task" value="<?php echo __('Create Cluster'); ?>" />
</form>

View File

@ -139,7 +139,9 @@ font-size:10pt;
echo '<br/> <br/>';
echo __('Please know that all attempts to access this page are recorded in security logs of %s System Database', get_product_name());
if ($config['logged'] == false) {
session_destroy();
if (session_status() === PHP_SESSION_ACTIVE) {
session_destroy();
}
}
?>

View File

@ -556,9 +556,18 @@ if ($agents !== false) {
$agent['alias'] = $agent['nombre'];
}
if ($agent['id_os'] == 100) {
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']);
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.$agent['alias'].'</a>';
if ($agent['id_os'] == CLUSTER_OS_ID) {
if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id()
);
echo '<a href="'.$url.'">'.$agent['alias'].'</a>';
}
} else {
echo '<a alt ='.$agent['nombre']." href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=$main_tab&
@ -594,10 +603,19 @@ if ($agents !== false) {
echo '</span><div class="left actions" style="visibility: hidden; clear: left">';
if ($check_aw) {
if ($agent['id_os'] == 100) {
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']);
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.__('Edit').'</a>';
echo ' | ';
if ($agent['id_os'] == CLUSTER_OS_ID) {
if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id()
);
echo '<a href="'.$url.'">'.__('Edit').'</a>';
echo ' | ';
}
} else {
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main&
@ -618,8 +636,18 @@ if ($agents !== false) {
id_agente='.$agent['id_agente'].'">'.__('Alerts').'</a>';
echo ' | ';
if ($agent['id_os'] == 100) {
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id='.$cluster['id'].'">'.__('View').'</a>';
if ($agent['id_os'] == CLUSTER_OS_ID) {
if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=view&id='.$cluster->id()
);
echo '<a href="'.$url.'">'.__('View').'</a>';
}
} else {
echo '<a href="index.php?sec=estado
&sec2=operation/agentes/ver_agente

View File

@ -230,16 +230,6 @@ if ($delete_alert) {
'',
true
);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if ($id_cluster) {
if ($id_cluster[0]['cluster_type'] == 'AA') {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_delete_alert='.$result);
} else {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_delete_alert='.$result);
}
}
}
if ($add_action) {
@ -328,16 +318,6 @@ if ($delete_action) {
'',
true
);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if ($id_cluster) {
if ($id_cluster[0]['cluster_type'] == 'AA') {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_delete_action='.$result);
} else {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_delete_action='.$result);
}
}
}
if ($enable_alert) {
@ -359,16 +339,6 @@ if ($enable_alert) {
'',
true
);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if ($id_cluster) {
if ($id_cluster[0]['cluster_type'] == 'AA') {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_enable_alert='.$result);
} else {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_enable_alert='.$result);
}
}
}
if ($disable_alert) {
@ -390,16 +360,6 @@ if ($disable_alert) {
'',
true
);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if ($id_cluster) {
if ($id_cluster[0]['cluster_type'] == 'AA') {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_disable_alert='.$result);
} else {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_disable_alert='.$result);
}
}
}
if ($standbyon_alert) {
@ -421,16 +381,6 @@ if ($standbyon_alert) {
'',
true
);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if ($id_cluster) {
if ($id_cluster[0]['cluster_type'] == 'AA') {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_standbyon='.$result);
} else {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_standbyon='.$result);
}
}
}
if ($standbyoff_alert) {
@ -452,16 +402,6 @@ if ($standbyoff_alert) {
'',
true
);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if ($id_cluster) {
if ($id_cluster[0]['cluster_type'] == 'AA') {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_standbyoff='.$result);
} else {
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_standbyoff='.$result);
}
}
}
if ($id_agente) {

View File

@ -551,6 +551,13 @@ if (check_login()) {
include_once $config['homedir'].'/include/functions_tags.php';
include_once $config['homedir'].'/include/functions_clippy.php';
// Disable module edition in cluster module list.
$cluster_view = (bool) preg_match(
'/operation\/cluster\/cluster/',
$_SERVER['HTTP_REFERER']
);
$agent_a = check_acl($config['id_user'], 0, 'AR');
$agent_w = check_acl($config['id_user'], 0, 'AW');
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
@ -962,7 +969,9 @@ if (check_login()) {
$data[2] = servers_show_type($module['id_modulo']).'&nbsp;';
if (check_acl($config['id_user'], $id_grupo, 'AW')) {
if (check_acl($config['id_user'], $id_grupo, 'AW')
&& $cluster_view === false
) {
$data[2] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$id_agente.'&amp;tab=module&amp;id_agent_module='.$module['id_agente_modulo'].'&amp;edit_module='.$module['id_modulo'].'">'.html_print_image('images/config.png', true, ['alt' => '0', 'border' => '', 'title' => __('Edit'), 'class' => 'action_button_img']).'</a>';
}

View File

@ -161,14 +161,15 @@ class CredentialStore extends Wizard
if (! check_acl($config['id_user'], 0, 'AR')) {
db_pandora_audit(
'ACL Violation',
'Trying to access event viewer'
'Trying to access credential store'
);
if (is_ajax()) {
echo json_encode(['error' => 'noaccess']);
} else {
include 'general/noaccess.php';
}
include 'general/noaccess.php';
exit;
}

View File

@ -342,7 +342,7 @@ class HTML
*
* @return string
*/
public function error($message)
public static function error($message)
{
if (is_ajax()) {
echo json_encode(
@ -363,7 +363,7 @@ class HTML
*
* @return string HTML code for desired input.
*/
public function printInput($data)
public static function printInput($data)
{
global $config;
@ -398,7 +398,7 @@ class HTML
*
* @return void
*/
public function printGoBackButton($url=null)
public static function printGoBackButton($url=null)
{
if (isset($url) === false) {
$url = ui_get_full_url(
@ -425,7 +425,7 @@ class HTML
],
];
$this->printForm($form);
self::printForm($form);
}
@ -467,7 +467,7 @@ class HTML
*
* @return string HTML content.
*/
public function printBlock(
public static function printBlock(
array $input,
bool $return=false,
bool $direct=false
@ -487,6 +487,10 @@ class HTML
$direct = (bool) $input['direct'];
$toggle = (bool) $input['toggle'];
if (isset($input['label']) === true) {
$output .= '<span>'.$input['label'].'</span>';
}
// Print independent block of inputs.
$output .= '<li id="li-'.$input['block_id'].'" class="'.$class.'">';
@ -502,7 +506,7 @@ class HTML
$html = '';
foreach ($input['block_content'] as $in) {
$html .= $this->printBlock(
$html .= self::printBlock(
$in,
$return,
(bool) $direct
@ -548,15 +552,18 @@ class HTML
$output .= '<li id="'.$input['id'].'" class="'.$class.'">';
}
$output .= '<label>'.$input['label'].'</label>';
$output .= $this->printInput($input['arguments']);
if (isset($input['label']) === true) {
$output .= '<label>'.$input['label'].'</label>';
}
$output .= self::printInput($input['arguments']);
// Allow dynamic content.
$output .= $input['extra'];
if (!$direct) {
$output .= '</li>';
}
} else {
$output .= $this->printInput($input['arguments']);
$output .= self::printInput($input['arguments']);
// Allow dynamic content.
$output .= $input['extra'];
}
@ -578,7 +585,7 @@ class HTML
*
* @return string HTML content.
*/
public function printBlockAsGrid(array $input, bool $return=false)
public static function printBlockAsGrid(array $input, bool $return=false)
{
$output = '';
if ($input['hidden'] == 1) {
@ -596,7 +603,7 @@ class HTML
$output .= '<li id="'.$input['block_id'].'" class="'.$class.'">';
$output .= '<ul class="wizard '.$input['block_class'].'">';
foreach ($input['block_content'] as $input) {
$output .= $this->printBlockAsGrid($input, $return);
$output .= self::printBlockAsGrid($input, $return);
}
$output .= '</ul></li>';
@ -635,7 +642,7 @@ class HTML
if ($input['arguments']['type'] == 'text' || $input['arguments']['type'] == 'text_extended') {
$output .= '<div class="discovery_text_input">';
$output .= $this->printInput($input['arguments']);
$output .= self::printInput($input['arguments']);
$output .= '</div>';
} else if ($input['arguments']['inline'] == 'true') {
if (isset($input['extra'])) {
@ -646,7 +653,7 @@ class HTML
$output .= '<div style="float: right;">';
}
$output .= $this->printInput($input['arguments']);
$output .= self::printInput($input['arguments']);
$output .= '</div>';
$output .= '</div>';
@ -654,14 +661,14 @@ class HTML
$output .= '</div>';
}
} else {
$output .= $this->printInput($input['arguments']);
$output .= self::printInput($input['arguments']);
}
// Allow dynamic content.
$output .= $input['extra'];
$output .= '</div>';
} else {
$output .= $this->printInput($input['arguments']);
$output .= self::printInput($input['arguments']);
// Allow dynamic content.
$output .= $input['extra'];
}
@ -683,7 +690,7 @@ class HTML
*
* @return string HTML content.
*/
public function printBlockAsList(array $input, bool $return=false)
public static function printBlockAsList(array $input, bool $return=false)
{
$output = '';
if ($input['hidden'] == 1) {
@ -701,7 +708,7 @@ class HTML
$output .= '<li id="'.$input['block_id'].'" class="'.$class.'">';
$output .= '<ul class="wizard '.$input['block_class'].'">';
foreach ($input['block_content'] as $input) {
$output .= $this->printBlockAsList($input, $return);
$output .= self::printBlockAsList($input, $return);
}
$output .= '</ul></li>';
@ -711,12 +718,12 @@ class HTML
) {
$output .= '<li id="'.$input['id'].'" class="'.$class.'">';
$output .= '<label>'.$input['label'].'</label>';
$output .= $this->printInput($input['arguments']);
$output .= self::printInput($input['arguments']);
// Allow dynamic content.
$output .= $input['extra'];
$output .= '</li>';
} else {
$output .= $this->printInput($input['arguments']);
$output .= self::printInput($input['arguments']);
// Allow dynamic content.
$output .= $input['extra'];
}
@ -739,7 +746,7 @@ class HTML
*
* @return string HTML code.
*/
public function printForm(
public static function printForm(
array $data,
bool $return=false,
bool $print_white_box=false
@ -752,7 +759,12 @@ class HTML
$cb_function = $data['cb_function'];
$cb_args = $data['cb_args'];
$output_head = '<form id="'.$form['id'].'" class="discovery '.$form['class'].'" onsubmit="'.$form['onsubmit'].'" enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
$output_head = '';
if (empty($data['pre-content']) === false) {
$output_head .= $data['pre-content'];
}
$output_head .= '<form id="'.$form['id'].'" class="discovery '.$form['class'].'" onsubmit="'.$form['onsubmit'].'" enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
$output_head .= '" '.$form['extra'].'>';
if ($return === false) {
@ -781,9 +793,9 @@ class HTML
foreach ($inputs as $input) {
if ($input['arguments']['type'] != 'submit') {
$output .= $this->printBlock($input, true);
$output .= self::printBlock($input, true);
} else {
$output_submit .= $this->printBlock($input, true);
$output_submit .= self::printBlock($input, true);
}
}
@ -822,7 +834,7 @@ class HTML
*
* @return string HTML code.
*/
public function printFormAsGrid(array $data, bool $return=false)
public static function printFormAsGrid(array $data, bool $return=false)
{
$form = $data['form'];
@ -886,9 +898,9 @@ class HTML
foreach ($column['inputs'] as $input) {
if (is_array($input)) {
if ($input['arguments']['type'] != 'submit') {
$output .= $this->printBlockAsGrid($input, true);
$output .= self::printBlockAsGrid($input, true);
} else {
$output_submit .= $this->printBlockAsGrid($input, true);
$output_submit .= self::printBlockAsGrid($input, true);
}
} else {
$output .= $input;
@ -933,7 +945,7 @@ class HTML
*
* @return string HTML code.
*/
public function printFormAsList(array $data, bool $return=false)
public static function printFormAsList(array $data, bool $return=false)
{
$form = $data['form'];
$inputs = $data['inputs'];
@ -966,9 +978,9 @@ class HTML
foreach ($inputs as $input) {
if ($input['arguments']['type'] != 'submit') {
$output .= $this->printBlockAsList($input, true);
$output .= self::printBlockAsList($input, true);
} else {
$output_submit .= $this->printBlockAsList($input, true);
$output_submit .= self::printBlockAsList($input, true);
}
}

View File

@ -514,6 +514,8 @@ class NetworkMap
*/
public function createMap()
{
global $config;
// If exists, load from DB.
if ($this->idMap) {
$this->loadMap();
@ -1025,13 +1027,17 @@ class NetworkMap
// Handmade ones.
// Add also parent relationship.
if (isset($node['id_parent'])) {
$parent_id = $node['id_parent'];
$parent_id = NODE_AGENT.'_'.$node['id_parent'];
$parent_node = $this->nodes[$parent_id]['id_node'];
if ((int) $parent_id >= 0) {
$parent_node = $this->getNodeData(
(int) $parent_id,
'id_node'
);
if ($parent_node === null) {
$parent_id = NODE_MODULE.'_'.$node['id_parent'];
$parent_node = $this->nodes[$parent_id]['id_node'];
}
if ($parent_node === null) {
$parent_id = NODE_GENERIC.'_'.$node['id_parent'];
$parent_node = $this->nodes[$parent_id]['id_node'];
}
// Store relationship.
@ -1130,6 +1136,7 @@ class NetworkMap
$map_filter = $this->mapOptions['map_filter'];
$nooverlap = $this->mapOptions['nooverlap'];
$zoom = $this->mapOptions['zoom'];
$layout = $this->mapOptions['layout'];
if (isset($this->mapOptions['width'])
&& isset($this->mapOptions['height'])
@ -1152,7 +1159,7 @@ class NetworkMap
$size = $size_x.','.$size_y;
if ($size_canvas === null) {
if ($this->mapOptions['size_canvas'] !== null) {
$size = ($this->mapOptions['size_canvas']['x'] / 100);
$size .= ','.($this->mapOptions['size_canvas']['y'] / 100);
}
@ -1274,12 +1281,7 @@ class NetworkMap
$radius /= GRAPHVIZ_CONVERSION_FACTOR;
if (is_array($label)) {
$label = array_reduce(
function ($carry, $item) {
$carry .= $item;
return $carry;
}
);
$label = join('', $label);
}
if (strlen($label) > 16) {
@ -1295,7 +1297,7 @@ class NetworkMap
// retrieve X,Y positions from graphviz no for personalization.
$dot_str = $data['id_node'].' [ parent="'.$data['id_parent'].'"';
$dot_str .= ', color="'.$color.'", fontsize='.$font_size;
$dot_str .= ', shape="doublecircle"'.$url_node_link;
$dot_str .= ', shape="doublecircle"'.$data['url_node_link'];
$dot_str .= ', style="filled", fixedsize=true, width='.$radius;
$dot_str .= ', height='.$radius.', label="'.$label.'"]'."\n";
@ -1535,14 +1537,15 @@ class NetworkMap
/**
* Returns target color to be used based on the status received.
*
* @param integer $status Source information.
* @param integer $status Source information.
* @param boolean $force_module It's a module.
*
* @return string HTML tag for color.
*/
public static function getColorByStatus($status)
public static function getColorByStatus($status, ?bool $force_module=false)
{
include_once __DIR__.'/../functions_modules.php';
return modules_get_color_status($status);
return modules_get_color_status($status, $force_module);
}
@ -1596,6 +1599,7 @@ class NetworkMap
global $config;
$return = [];
$count_item_holding_area = 0;
foreach ($nodes as $node) {
$item = [];
$item['id'] = $node['id'];
@ -1658,6 +1662,10 @@ class NetworkMap
case NODE_MODULE:
$item['id_module'] = $node['source_data'];
$item['color'] = self::getColorByStatus(
$source_data['status'],
true
);
break;
case NODE_PANDORA:
@ -1669,8 +1677,11 @@ class NetworkMap
default:
foreach ($source_data as $k => $v) {
$node[$k] = $v;
$item[$k] = $v;
}
$item['id_agent'] = $node['id_agente'];
if (!empty($node['text'])) {
$node['style']['label'] = $node['text'];
} else {
@ -1681,7 +1692,8 @@ class NetworkMap
$item['color'] = $source_data['color'];
} else {
$item['color'] = self::getColorByStatus(
$node['status']
$node['status'],
(bool) $node['id_module']
);
}
break;
@ -2193,6 +2205,7 @@ class NetworkMap
$nodes = [];
$relations = [];
foreach ($content as $key => $line) {
// Reduce blank spaces.
$line = preg_replace('/\ +/', ' ', $line);
@ -2232,12 +2245,12 @@ class NetworkMap
}
$relations[] = [
'id_parent' => $target_node['id_node'],
'id_parent' => $fields[1],
'parent_type' => NODE_GENERIC,
'id_parent_source_data' => $mod_rel['module_b'],
'id_child' => $node['id_node'],
'id_parent_source_data' => $fields[3],
'id_child' => $fields[2],
'child_type' => NODE_GENERIC,
'id_child_source_data' => $mod_rel['module_a'],
'id_child_source_data' => null,
];
}
}
@ -2268,11 +2281,11 @@ class NetworkMap
case 'WIN32':
case 'WINNT':
case 'Windows':
$filename_dot = sys_get_temp_dir()."\\networkmap_".$filter;
$filename_dot = sys_get_temp_dir()."\\networkmap_".$this->filter;
break;
default:
$filename_dot = sys_get_temp_dir().'/networkmap_'.$filter;
$filename_dot = sys_get_temp_dir().'/networkmap_'.$this->filter;
break;
}
@ -2395,36 +2408,6 @@ class NetworkMap
}
/**
* Returns the most representative ID based on the tipe of node received.
*
* @param array $node Source data.
*
* @return integer Source id.
*/
private function auxGetIdByType($node)
{
if (!is_array($node)) {
return 0;
}
switch ($to_source['node_type']) {
case NODE_MODULE:
return $node['id_agente_modulo'];
case NODE_AGENT:
return $node['id_agente'];
case NODE_GENERIC:
return $node['id_node'];
case NODE_PANDORA:
default:
return 0;
}
}
/**
* Generates a nodes - relationships array using graphviz dot
* schema and stores nodes&relations into $this->graph.
@ -2551,6 +2534,7 @@ class NetworkMap
$node_tmp['id_agent'] = $source['id_agente'];
$node_tmp['id_module'] = $source['id_agente_modulo'];
$node_tmp['source_data'] = $source['id_source'];
$node_tmp['image'] = $source['image'];
break;
}
@ -3314,9 +3298,11 @@ class NetworkMap
/**
* Loads advanced map controller (JS).
*
* @param boolean $return Dumps to output if false.
*
* @return string HTML code for advanced controller.
*/
public function loadController()
public function loadController(?bool $return=true)
{
$output = '';
@ -3482,7 +3468,7 @@ class NetworkMap
$output .= ' style="position: absolute; left: 0px; top: 0px;">';
$output .= '<a title="'.__('Open Minimap').'" href="javascript: toggle_minimap();">';
$output .= html_print_image('/images/minimap_open_arrow.png', true, ['id' => 'arrow_minimap_'.$networkmap['id']]);
$output .= '</a><div></div></div>';
$output .= '</a></div></div>';
$output .= '<div id="hide_labels_'.$networkmap['id'].'"';
$output .= ' style="position: absolute; right: 10px; top: 10px;">';
@ -3514,6 +3500,8 @@ class NetworkMap
{
global $config;
$networkmap = $this->map;
// ACL.
$networkmap_read = check_acl(
$config['id_user'],

View File

@ -356,6 +356,9 @@ define('MODULE_PREDICTION_CLUSTER', 5);
define('MODULE_PREDICTION_CLUSTER_AA', 6);
define('MODULE_PREDICTION_CLUSTER_AP', 7);
// Forced agent OS ID for cluster agents.
define('CLUSTER_OS_ID', 100);
// Type of Webserver Modules.
define('MODULE_WEBSERVER_CHECK_LATENCY', 30);
define('MODULE_WEBSERVER_CHECK_SERVER_RESPONSE', 31);

View File

@ -19,7 +19,29 @@
require_once $config['homedir'].'/include/functions.php';
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_users.php';
require_once $config['homedir'].'/include/functions_users.php';/**
* Return the agent if exists in the DB.
*
* @param integer $id_agent The agent id.
* @param boolean $show_disabled Show the agent found althought it is disabled. By default false.
* @param boolean $force_meta
*
* @return boolean The result to check if the agent is in the DB.
*/
function agents_get_agent($id_agent, $show_disabled=true, $force_meta=false)
{
$agent = db_get_row_filter(
$force_meta ? 'tmetaconsole_agent' : 'tagente',
[
'id_agente' => $id_agent,
'disabled' => !$show_disabled,
]
);
return $agent;
}
/**
@ -3093,6 +3115,17 @@ function agents_get_agent_custom_field($agent_id, $custom_field_name)
}
/**
* Unverified documentation.
*
* @param integer $id_group Module group.
* @param array $id_agents Array of agent ids.
* @param boolean $selection Show common (false) or all modules (true).
* @param boolean $return Return (false) or dump to output (true).
* @param boolean $index_by_name Use module name as key.
*
* @return array With modules or null if error.
*/
function select_modules_for_agent_group(
$id_group,
$id_agents,

View File

@ -605,22 +605,24 @@ function html_print_select(
$output .= '<select id="'.$id.'" name="'.$name.'"'.$attributes.' '.$styleText.'>';
if ($nothing != '' || empty($fields)) {
if ($nothing == '') {
$nothing = __('None');
}
$output .= '<option value="'.$nothing_value.'"';
if ($nothing_value == $selected) {
$output .= ' selected="selected"';
} else if (is_array($selected)) {
if (in_array($nothing_value, $selected)) {
$output .= ' selected="selected"';
if ($nothing !== false) {
if ($nothing != '' || empty($fields)) {
if ($nothing == '') {
$nothing = __('None');
}
}
$output .= '>'.$nothing.'</option>';
$output .= '<option value="'.$nothing_value.'"';
if ($nothing_value == $selected) {
$output .= ' selected="selected"';
} else if (is_array($selected)) {
if (in_array($nothing_value, $selected)) {
$output .= ' selected="selected"';
}
}
$output .= '>'.$nothing.'</option>';
}
}
if (is_array($fields) && !empty($fields)) {
@ -702,6 +704,364 @@ function html_print_select(
}
/**
* Generates a multiselect component with filters.
*
* @param array $available Available.
* @param array $selected Selected.
* @param string $name Custom identifier (optional).
* @param string $class Custom class for main container (optional).
* @param boolean $return Dump to output or only return.
* @param array $group_filter Ajax information to reload content while
* using different group filter (if enabled). Uses:
* [
* page => 'your/controller/php',
* method => 'yourMethodName'
* ]
* Ensure you return data in json format as:
* {id:label,id2:label2...}
* Provided by caller.
* @param array $texts Texts.
* @param array $sections Enables or disables sub-components.
*
* @return string HTML code with component.
*/
function html_print_select_multiple_filtered(
array $available,
array $selected,
?string $name=null,
string $class='',
bool $return=true,
array $group_filter=[],
array $texts=[],
array $sections=[]
) {
ui_require_css_file('multiselect_filtered');
ui_require_javascript_file('multiselect_filtered');
if (empty($name) === true) {
$rid = uniqid();
} else {
$rid = $name;
}
if (empty($texts) === true) {
$texts = [];
}
if (empty($texts['filter-item']) === true) {
$texts['filter-item'] = 'Filter agent alias';
}
if (empty($texts['title-add']) === true) {
$texts['title-add'] = 'Add selected';
}
if (empty($texts['title-del']) === true) {
$texts['title-del'] = 'Remove selected';
}
if (empty($texts['title-left']) === true) {
$texts['title-left'] = 'Available items';
}
if (empty($texts['title-right']) === true) {
$texts['title-right'] = 'Selected items';
}
if (empty($sections) === true) {
$sections = [];
}
if (empty($sections['filters']) === true) {
$sections['filters'] = 1;
}
if (empty($sections['group-filter']) === true) {
$sections['group-filter'] = 1;
}
if (empty($sections['item-available-filter']) === true) {
$sections['item-available-filter'] = 1;
}
if (empty($sections['item-selected-filter']) === true) {
$sections['item-selected-filter'] = 1;
}
if (empty($group_filter) === true) {
$sections['group-filter'] = 0;
}
// Main container.
$output .= '<div class="multi-select flex-row-vcenter '.$class.'">';
// Left box.
$output .= '<div class="multi-select-container flex-column">';
$disable_filters = '';
// Filtering.
if (isset($sections['filters']) === true
&& $sections['filters'] === 1
) {
// Filtering.
if (isset($sections['group-filter']) === true
&& $sections['group-filter'] === 1
) {
$output .= '<div class="filter">';
$output .= '<div class="group-filter flex-row-vcenter">';
$reload_content = "reloadContent('".$rid."'";
$reload_content .= ", '".ui_get_full_url('ajax.php')."'";
$reload_content .= ", '".base64_encode(
json_encode($group_filter)
)."'";
$reload_content .= ", 'left'";
$reload_content .= ", '".__('None')."')";
$output .= html_print_input(
[
'label' => __('Filter group'),
'name' => 'id-group-available-select-'.$rid,
'returnAllGroup' => true,
'privilege' => 'AR',
'type' => 'select_groups',
'return' => true,
'script' => $reload_content,
]
);
$output .= html_print_input(
[
'label' => __('Group recursion'),
'name' => 'id-group-recursion-available-select-'.$rid,
'type' => 'checkbox',
'script' => $reload_content,
'return' => true,
]
);
$output .= '</div>';
$output .= '</div>';
$disable_filters = "disableFilters('".$rid."')";
}
if (isset($sections['item-available-filter']) === true
&& $sections['item-available-filter'] === 1
) {
$output .= '<div class="item-filter flex-row-vcenter">';
$output .= html_print_input(
[
'style' => 'display:none;',
'name' => 'tmp-available-select-'.$rid,
'type' => 'select',
'nothing' => false,
'return' => true,
]
);
$f = "filterAvailableItems(this.value,'".$rid."','".__('None')."')";
$output .= html_print_input(
[
'label' => __($texts['filter-item']),
'name' => 'filter-item-available-'.$rid,
'onKeyUp' => $f,
'input_class' => 'filter w100p',
'size' => 20,
'type' => 'text',
'return' => true,
]
);
$output .= '</div>';
}
}
$output .= '<span class="title">'.$texts['title-left'].'</span>';
// Selector boxes.
$output .= html_print_input(
[
'type' => 'select',
'fields' => $available,
'name' => 'available-select-'.$rid.'[]',
'selected' => '',
'script' => $disable_filters,
'nothing' => '',
'nothing_value' => 0,
'return' => true,
'multiple' => true,
'sort' => true,
'class' => 'select-multiple',
'disabled' => false,
'style' => false,
'option_style' => false,
'size' => false,
'modal' => false,
'message' => '',
'select_all' => false,
'simple_multiple_options' => false,
]
);
$output .= '</div>';
// Middle buttons actions.
$add = "addItems('".$rid."','".__('None')."'); return false";
$del = "removeItems('".$rid."','".__('None')."'); return false";
$output .= '<div class="arrows-container flex-column">';
$output .= html_print_input(
[
'type' => 'image',
'src' => 'images/darrowright.png',
'return' => true,
'options' => [
'title' => $texts['title-add'],
'onclick' => $add,
],
]
);
$output .= html_print_input(
[
'type' => 'image',
'src' => 'images/darrowleft.png',
'return' => true,
'options' => [
'title' => $texts['title-del'],
'onclick' => $del,
],
]
);
$output .= '</div>';
// Left box.
$output .= '<div class="multi-select-container flex-column">';
// Filtering.
if (isset($sections['filters']) === true
&& $sections['filters'] === 1
) {
if (isset($sections['group-filter']) === true
&& $sections['group-filter'] === 1
) {
$output .= '<div class="filter">';
$output .= '<div class="group-filter flex-row-vcenter">';
$reload_content = "reloadContent('".$rid."'";
$reload_content .= ", '".ui_get_full_url('ajax.php')."'";
$reload_content .= ", '".base64_encode(
json_encode($group_filter)
)."'";
$reload_content .= ", 'right'";
$reload_content .= ", '".__('None')."')";
$output .= html_print_input(
[
'label' => __('Filter group'),
'name' => 'id-group-selected-select-'.$rid,
'returnAllGroup' => true,
'privilege' => 'AR',
'type' => 'select_groups',
'return' => true,
'script' => $reload_content,
]
);
$output .= html_print_input(
[
'label' => __('Group recursion'),
'name' => 'id-group-recursion-selected-select-'.$rid,
'type' => 'checkbox',
'script' => $reload_content,
'return' => true,
]
);
$output .= '</div>';
$output .= '</div>';
}
// Filtering.
if (isset($sections['item-selected-filter']) === true
&& $sections['item-selected-filter'] === 1
) {
$output .= '<div class="item-filter flex-row-vcenter">';
$output .= html_print_input(
[
'style' => 'display:none;',
'name' => 'tmp-selected-select-'.$rid,
'type' => 'select',
'nothing' => false,
'return' => true,
]
);
$f = "filterSelectedItems(this.value,'".$rid."','".__('None')."')";
$output .= html_print_input(
[
'label' => __($texts['filter-item']),
'name' => 'filter-item-selected-'.$rid,
'onKeyUp' => $f,
'input_class' => 'filter w100p',
'size' => 20,
'type' => 'text',
'return' => true,
]
);
$output .= '</div>';
}
}
$output .= '<span class="title">'.$texts['title-right'].'</span>';
$output .= html_print_input(
[
'type' => 'select',
'fields' => $selected,
'name' => 'selected-select-'.$rid.'[]',
'selected' => '',
'script' => '',
'nothing' => '',
'nothing_value' => 0,
'return' => true,
'multiple' => true,
'sort' => true,
'class' => 'select-multiple',
'disabled' => false,
'style' => false,
'option_style' => false,
'size' => false,
'modal' => false,
'message' => '',
'select_all' => true,
'simple_multiple_options' => false,
]
);
$output .= '</div>';
// Close main.
$output .= '</div>';
if ($return === false) {
echo $output;
}
return $output;
}
/**
* Prints an array of fields in a popup menu of a form based on a SQL query.
* The first and second columns of the query will be used.
@ -1555,7 +1915,8 @@ function html_print_input_text(
$autocomplete='',
$autofocus=false,
$onKeyDown='',
$formTo=''
$formTo='',
$onKeyUp=''
) {
if ($maxlength == 0) {
$maxlength = 255;
@ -1584,6 +1945,10 @@ function html_print_input_text(
$attr['onkeydown'] = $onKeyDown;
}
if ($onKeyUp != '') {
$attr['onkeyup'] = $onKeyUp;
}
if ($autocomplete !== '') {
$attr['autocomplete'] = $autocomplete;
}
@ -3477,9 +3842,10 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['class']) === true) ? $data['class'] : ''),
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : ''),
false,
((isset($data['autofocus']) === true) ? $data['autofocus'] : false),
((isset($data['onKeyDown']) === true) ? $data['onKeyDown'] : ''),
((isset($data['form']) === true) ? $data['form'] : '')
((isset($data['form']) === true) ? $data['form'] : ''),
((isset($data['onKeyUp']) === true) ? $data['onKeyUp'] : '')
);
break;
@ -3901,6 +4267,19 @@ function html_print_input($data, $wrapper='div', $input_only=false)
);
break;
case 'select_multiple_filtered':
$output .= html_print_select_multiple_filtered(
$data['available'],
$data['selected'],
((isset($data['name']) === true) ? $data['name'] : null),
((isset($data['class']) === true) ? $data['class'] : ''),
((isset($data['return']) === true) ? $data['return'] : true),
((isset($data['group_filter']) === true) ? $data['group_filter'] : []),
((isset($data['texts']) === true) ? $data['texts'] : []),
((isset($data['sections']) === true) ? $data['sections'] : [])
);
break;
default:
// Ignore.
break;

View File

@ -2427,16 +2427,45 @@ function modules_get_modulegroup_name($modulegroup_id)
/**
* Returns target color to be used based on the status received.
*
* @param integer $status Source information.
* @param integer $status Source information.
* @param boolean $force_module Use module constants only.
*
* @return string HTML tag for color.
*/
function modules_get_color_status($status)
function modules_get_color_status($status, $force_module=false)
{
if (isset($status) === false) {
return COL_UNKNOWN;
}
if ($force_module === true) {
switch ($status) {
case AGENT_MODULE_STATUS_CRITICAL_BAD:
case AGENT_MODULE_STATUS_NOT_NORMAL:
return COL_CRITICAL;
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_NORMAL_ALERT:
return COL_ALERTFIRED;
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_NOT_INIT:
return COL_NOTINIT;
case AGENT_MODULE_STATUS_NORMAL:
return COL_NORMAL;
case AGENT_MODULE_STATUS_WARNING:
return COL_WARNING;
case AGENT_MODULE_STATUS_ALL:
case AGENT_MODULE_STATUS_UNKNOWN:
default:
return COL_UNKNOWN;
}
}
switch ((string) $status) {
case (string) AGENT_MODULE_STATUS_NORMAL:
case (string) AGENT_STATUS_NORMAL:

View File

@ -667,13 +667,22 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
if ($user_access_node && check_acl($config['id_user'], $agent['id_grupo'], 'AW')) {
$go_to_agent = '<div style="text-align: right;">';
if ($agent['id_os'] != 100) {
if ($agent['id_os'] == CLUSTER_OS_ID) {
if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id()
);
$go_to_agent .= '<a target="_blank" href="'.$url.'">';
$go_to_agent .= html_print_submit_button(__('Edit cluster'), 'upd_button', false, 'class="sub config"', true);
}
} else {
$go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
$go_to_agent .= html_print_submit_button(__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
} else {
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$id_agente);
$go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1='.$id_agente.'">';
$go_to_agent .= html_print_submit_button(__('Edit cluster'), 'upd_button', false, 'class="sub config"', true);
}
$go_to_agent .= '</a>';

View File

@ -2698,6 +2698,35 @@ function ui_print_status_image(
}
/**
* Returns html code to print a shape for a module.
*
* @param integer $status Module status.
* @param boolean $return True or false.
* @param string $class Custom class or use defined.
*
* @return string HTML code for shape.
*/
function ui_print_module_status(
$status,
$return=false,
$class='status_rounded_rectangles'
) {
$color = modules_get_color_status($status, true);
$title = modules_get_modules_status($status);
$output = '<div style="background: '.$color;
$output .= '" class="'.$class;
$output .= '" title="'.$title.'"></div>';
if ($return === false) {
echo $output;
}
return $output;
}
/**
* Get the shape of an image by assigning it a CSS class. Prints an image with CSS representing a status.
*
@ -3157,6 +3186,13 @@ function ui_print_datatable(array $parameters)
throw new Exception('[ui_print_datatable]: You must define columns for datatable');
}
if (isset($parameters['column_names'])
&& is_array($parameters['column_names'])
&& count($parameters['columns']) != count($parameters['column_names'])
) {
throw new Exception('[ui_print_datatable]: Columns and columns names must have same length');
}
if (!isset($parameters['ajax_url'])) {
throw new Exception('[ui_print_datatable]: Parameter ajax_url is required');
}

View File

@ -0,0 +1,157 @@
/* global $ */
/**
* Add modules from available to selected.
*/
function addItems(id, noneStr) {
$("#available-select-" + id + " :selected")
.toArray()
.forEach(function(item) {
$("#selected-select-" + id).append(item);
});
keepSelectClean("available-select-" + id, noneStr);
keepSelectClean("selected-select-" + id, noneStr);
}
/**
* Mark all options for given id.
*/
function markAll(id) {
$("#" + id + " option").prop("selected", true);
}
/**
* Remove modules from selected back to available.
*/
function removeItems(id, noneStr) {
$("#selected-select-" + id + " :selected")
.toArray()
.forEach(function(item) {
$("#available-select-" + id).append(item);
});
keepSelectClean("available-select-" + id, noneStr);
keepSelectClean("selected-select-" + id, noneStr);
}
/**
* 'None' option, if needed.
*/
function keepSelectClean(id, noneStr) {
$("#" + id + " option[value=0]").remove();
if ($("#" + id + " option").length == 0) {
$("#" + id).append(new Option(noneStr, 0));
}
$("#" + id + " option").each(function() {
$(this).prop("selected", false);
});
}
function filterItems(id, str) {
// Remove option 0 - None.
$("#" + id + " option[value=0]").remove();
// Move not matching elements filtered to tmp-id.
var tmp = $("#" + id + " option:not(:contains(" + str + "))").toArray();
tmp.forEach(function(item) {
$("#tmp-" + id).append(item);
$(this).remove();
});
// Move matching filter back to id.
tmp = $("#tmp-" + id + " option:contains(" + str + ")").toArray();
tmp.forEach(function(item) {
$("#" + id).append(item);
$(this).remove();
});
}
function filterAvailableItems(txt, id, noneStr) {
filterItems("available-select-" + id, txt);
keepSelectClean("available-select-" + id, noneStr);
}
function filterSelectedItems(txt, id, noneStr) {
filterItems("selected-select-" + id, txt);
keepSelectClean("selected-select-" + id, noneStr);
}
function disableFilters(id) {
$("#id-group-selected-select-" + id).prop("disabled", true);
$("#checkbox-id-group-recursion-selected-select-" + id).prop(
"disabled",
true
);
}
function reloadContent(id, url, options, side, noneStr) {
var current;
var opposite;
if (side == "right") {
current = "selected-select-" + id;
opposite = "available-select-" + id;
} else if (side == "left") {
current = "available-select-" + id;
opposite = "selected-select-" + id;
} else {
console.error("reloadContent bad usage.");
return;
}
var data = JSON.parse(atob(options));
data.side = side;
data.group_recursion = $("#checkbox-id-group-recursion-" + current).prop(
"checked"
);
data.group_id = $("#id-group-" + current).val();
$.ajax({
method: "post",
url: url,
dataType: "json",
data: data,
success: function(data) {
// Cleanup previous content.
$("#" + current).empty();
let items = Object.entries(data).sort(function(a, b) {
if (a[1] == b[1]) return 0;
var int_a = parseInt(a[1]);
var int_b = parseInt(b[1]);
if (!isNaN(int_a) && !isNaN(int_b)) {
return int_a > int_b ? 1 : -1;
}
return a[1] > b[1] ? 1 : -1;
});
for (var [value, label] of items) {
if (
$("#" + opposite + " option[value=" + value + "]").length == 0 &&
$("#tmp-" + current + " option[value=" + value + "]").length == 0
) {
// Does not exist in opposite box nor is filtered.
$("#" + current).append(new Option(label, value));
}
}
keepSelectClean(current, noneStr);
},
error: function(data) {
console.error(data.responseText);
}
});
}
$(document).submit(function() {
// Force select all 'selected' items to send them on submit.
$("[id*=text-filter-item-selected-")
.val("")
.keyup();
$("[id^=selected-select-] option").prop("selected", true);
});

View File

@ -0,0 +1,286 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Agent entity class.
*
* @category Class
* @package Pandora FMS
* @subpackage OpenSource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
namespace PandoraFMS;
/**
* PandoraFMS agent entity.
*/
class Agent extends Entity
{
/**
* Agent's modules.
*
* @var array
*/
private $modules = [];
/**
* Flag to verify if modules has been loaded.
*
* @var boolean
*/
private $modulesLoaded = false;
/**
* Builds a PandoraFMS\Agent object from a agent id.
*
* @param integer $id_agent Agent Id.
* @param boolean $load_modules Load all modules of this agent. Be careful.
*/
public function __construct(?int $id_agent=null, ?bool $load_modules=false)
{
if (is_numeric($id_agent) === true) {
parent::__construct('tagente', ['id_agente' => $id_agent]);
if ($load_modules === true) {
$rows = \db_get_all_rows_filter(
'tagente_modulo',
['id_agente' => $id_agent]
);
if (is_array($rows) === true) {
foreach ($rows as $row) {
$this->modules[] = Module::build($row);
}
}
$this->modulesLoaded = true;
}
} else {
// Create empty skel.
parent::__construct('tagente');
// New agent has no modules.
$this->modulesLoaded = true;
}
// Customize certain fields.
$this->fields['group'] = new Group($this->fields['id_grupo']);
}
/**
* Overrides Entity method.
*
* @param integer $id_group Target group Id.
*
* @return integer|null Group Id or null.
*/
public function id_grupo(?int $id_group=null)
{
if ($id_group === null) {
return $this->fields['id_grupo'];
} else {
$this->fields['id_grupo'] = $id_group;
$this->fields['group'] = new Group($this->fields['id_grupo']);
}
}
/**
* Saves current definition to database.
*
* @param boolean $alias_as_name Use alias as agent name.
*
* @return mixed Affected rows of false in case of error.
* @throws \Exception On error.
*/
public function save(bool $alias_as_name=false)
{
if (empty($this->fields['nombre']) === true) {
if ($alias_as_name === true
&& (empty($this->fields['alias']) === true)
) {
throw new \Exception(
get_class($this).' error, nor "alias" nor "nombre" are set'
);
} else {
// Use alias instead.
$this->fields['nombre'] = $this->fields['alias'];
}
}
if ($this->fields['id_agente'] > 0) {
// Agent update.
$updates = $this->fields;
// Remove shortcuts from values.
unset($updates['group']);
$rs = \db_process_sql_update(
'tagente',
$updates,
['id_agente' => $this->fields['id_agente']]
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
} else {
// Agent creation.
$updates = $this->fields;
// Remove shortcuts from values.
unset($updates['group']);
// Clean null fields.
foreach ($updates as $k => $v) {
if ($v === null) {
unset($updates[$k]);
}
}
$rs = \agents_create_agent(
$updates['nombre'],
$updates['id_grupo'],
$updates['intervalo'],
$updates['direccion'],
$updates,
$alias_as_name
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
$this->fields['id_agente'] = $rs;
}
if ($this->fields['group']->id_grupo() === null) {
// Customize certain fields.
$this->fields['group'] = new Group($this->fields['id_grupo']);
}
return true;
}
/**
* Creates a module in current agent.
*
* @param array $params Module definition (each db field).
*
* @return integer Id of new module.
* @throws \Exception On error.
*/
public function addModule(array $params)
{
$err = __METHOD__.' error: ';
if (empty($params['nombre']) === true) {
throw new \Exception(
$err.' module name is mandatory'
);
}
$params['id_agente'] = $this->fields['id_agente'];
$id_module = modules_create_agent_module(
$this->fields['id_agente'],
$params['nombre'],
$params
);
if ($id_module === false) {
global $config;
throw new \Exception(
$err.$config['dbconnection']->error
);
}
return $id_module;
}
/**
* Search for modules into this agent.
*
* @param array $filter Filters.
*
* @return PandoraFMS\Module Module found.
*/
public function searchModules(array $filter)
{
$filter['id_agente'] = $this->id_agente();
if ($this->modulesLoaded === true) {
// Search in $this->modules.
$results = [];
foreach ($this->modules as $module) {
$found = true;
foreach ($filter as $field => $value) {
if ($module->{$field}() !== $value) {
$found = false;
break;
}
}
if ($found === true) {
$results[] = $module;
}
}
return $results;
} else {
// Search in db.
return Module::search($filter);
}
}
/**
* Delete agent from db.
*
* @return void
*/
public function delete()
{
// This function also mark modules for deletion.
\agents_delete_agent(
$this->fields['id_agente']
);
unset($this->fields);
unset($this->modules);
}
}

View File

@ -0,0 +1,153 @@
<?php
/**
* Entity class.
*
* @category Abstract class
* @package Pandora FMS
* @subpackage OpenSource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
namespace PandoraFMS;
/**
* Defines common methods for all PandoraFMS entity objects.
*/
abstract class Entity
{
/**
* Entity fields (from table).
*
* @var array
*/
protected $fields = [];
/**
* Target table.
*
* @var string
*/
protected $table = '';
/**
* Defines a generic constructor to extract information of the object.
*
* @param string $table Table.
* @param array $filters Filters, for instance ['id' => $id].
*
* @throws \Exception On error.
*/
public function __construct(string $table, ?array $filters=null)
{
if (empty($table) === true) {
throw new \Exception(
get_class($this).' error, table name is not defined'
);
}
$this->table = $table;
if (is_array($filters) === true) {
// New one.
$data = \db_get_row_filter($this->table, $filters);
if ($data === false) {
throw new \Exception(
get_class($this).' error, entity not found'
);
}
// Map fields.
foreach ($data as $k => $v) {
$this->fields[$k] = $v;
}
} else {
// Empty one.
$data = \db_get_all_rows_sql(
sprintf(
'SHOW COLUMNS FROM %s',
$this->table
)
);
foreach ($data as $row) {
$this->fields[$row['Field']] = null;
}
}
}
/**
* Dynamically call methods in this object.
*
* @param string $methodName Name of target method or attribute.
* @param array $params Arguments for target method.
*
* @return mixed Return of method.
* @throws \Exception On error.
*/
public function __call(string $methodName, ?array $params=null)
{
// Prioritize written methods over dynamic ones.
if (method_exists($this, $methodName) === true) {
return $this->{$methodName}($params);
}
if (array_key_exists($methodName, $this->fields) === true) {
if (empty($params) === true) {
return $this->fields[$methodName];
} else {
$this->fields[$methodName] = $params[0];
}
return null;
}
throw new \Exception(
get_class($this).' error, method '.$methodName.' does not exist'
);
}
/**
* Returns current object as array.
*
* @return array Of fields.
*/
public function toArray()
{
return $this->fields;
}
/**
* Saves current object definition to database.
*
* @return boolean Success or not.
*/
public abstract function save();
}

View File

@ -0,0 +1,100 @@
<?php
/**
* Group entity class.
*
* @category Class
* @package Pandora FMS
* @subpackage OpenSource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
namespace PandoraFMS;
/**
* PandoraFMS Group entity.
*/
class Group extends Entity
{
/**
* Builds a PandoraFMS\Group object from a group id.
*
* @param integer $id_group Group Id.
* @param boolean $recursive Create parents as objects.
*/
public function __construct(?int $id_group=null, bool $recursive=false)
{
if ($id_group === 0) {
parent::__construct('tgrupo');
$this->fields['id'] = 0;
$this->fields['nombre'] = 'All';
} else if (is_numeric($id_group) === true) {
parent::__construct('tgrupo', ['id_grupo' => $id_group]);
if ($recursive === true) {
// Customize certain fields.
$this->fields['parent'] = new Group($this->fields['parent']);
}
} else {
// Empty skel.
parent::__construct('tgrupo');
}
}
/**
* Saves current group definition to database.
*
* @return mixed Affected rows of false in case of error.
*/
public function save()
{
global $config;
if (isset($config['centralized_management'])
&& $config['centralized_management'] > 0
) {
throw new \Exception(
get_class($this).' error, cannot be modified in a centralized management environment.'
);
}
if ($this->fields['id_grupo'] > 0) {
$updates = $this->fields;
if (is_numeric($updates['parent']) === false) {
$updates['parent'] = $this->parent()->id_grupo();
}
return db_process_sql_update(
'tgrupo',
$this->fields,
['id_grupo' => $this->fields['id_grupo']]
);
}
return false;
}
}

View File

@ -0,0 +1,253 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Module entity class.
*
* @category Class
* @package Pandora FMS
* @subpackage OpenSource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
namespace PandoraFMS;
/**
* PandoraFMS agent entity.
*/
class Module extends Entity
{
/**
* Module status (From tagente_estado).
*
* @var PandoraFMS\ModuleStatus
*/
private $status;
/**
* Search a module in db.
*
* @param array $params Search parameters (fields from tagente_modulo).
* @param integer $limit Limit results to N rows.
*
* @return PandoraFMS\Module found or null if not found.
* @throws \Exception On error.
*/
public static function search(array $params, ?int $limit=0)
{
if (empty($params) === true) {
return null;
}
$rs = \db_get_all_rows_filter(
'tagente_modulo',
$params
);
if ($rs === false) {
return null;
}
if (empty($rs) === true) {
return null;
}
if ($limit !== 1) {
$modules = [];
$i = 0;
foreach ($rs as $row) {
if ($limit > 1 && (++$i) > $limit) {
break;
}
$modules[] = self::build($row);
}
return $modules;
} else {
return self::build($rs[0]);
}
}
/**
* Returns current object as array.
*
* @return array Of fields.
*/
public function toArray()
{
return $this->fields;
}
/**
* Creates a module object from given data. Avoid query duplication.
*
* @param array $data Module information.
*
* @return PandoraFMS\Module Object.
*/
public static function build(array $data=[])
{
$obj = new Module();
// Set values.
foreach ($data as $k => $v) {
$obj->{$k}($v);
}
if ($obj->nombre() === 'delete_pending') {
return null;
}
// Customize certain fields.
$obj->status = new ModuleStatus($obj->id_agente_modulo());
return $obj;
}
/**
* Builds a PandoraFMS\Module object from given id.
*
* @param integer $id_agent_module Module id.
*/
public function __construct(?int $id_agent_module=null)
{
if (is_numeric($id_agent_module) === true
&& $id_agent_module > 0
) {
parent::__construct(
'tagente_modulo',
['id_agente_modulo' => $id_agent_module]
);
} else {
// Create empty skel.
parent::__construct('tagente_modulo');
}
if ($this->nombre() === 'delete_pending') {
return null;
}
// Customize certain fields.
$this->status = new ModuleStatus($this->fields['id_agente_modulo']);
}
/**
* Returns current status.
*
* @return PandoraFMS\ModuleStatus Status of the module.
*/
public function getStatus()
{
return $this->status;
}
/**
* Saves current definition to database.
*
* @return mixed Affected rows of false in case of error.
* @throws \Exception On error.
*/
public function save()
{
if (empty($this->fields['nombre']) === true) {
throw new \Exception(
get_class($this).' error, "nombre" is not set'
);
}
if (empty($this->fields['id_agente']) === true) {
throw new \Exception(
get_class($this).' error, "id_agente" is not set'
);
}
if ($this->fields['id_agente_modulo'] > 0) {
// Update.
$updates = $this->fields;
$rs = \db_process_sql_update(
'tagente_modulo',
$updates,
['id_agente_modulo' => $this->fields['id_agente_modulo']]
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
} else {
// Creation.
$updates = $this->fields;
// Clean null fields.
foreach ($updates as $k => $v) {
if ($v === null) {
unset($updates[$k]);
}
}
$rs = \modules_create_agent_module(
$this->fields['id_agente'],
$updates['nombre'],
$updates
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
$this->fields['id_agente_modulo'] = $rs;
}
return true;
}
/**
* Erases this module.
*
* @return void
*/
public function delete()
{
\modules_delete_agent_module(
$this->id_agente_modulo()
);
unset($this->fields);
unset($this->status);
}
}

View File

@ -0,0 +1,123 @@
<?php
/**
* ModuleStatus entity class.
*
* @category Class
* @package Pandora FMS
* @subpackage OpenSource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
namespace PandoraFMS;
/**
* PandoraFMS agent entity.
*/
class ModuleStatus extends Entity
{
/**
* Builds a PandoraFMS\Module object from given id.
*
* @param integer $id_agent_module Module id.
*
* @throws \Exception On error.
*/
public function __construct(?int $id_agent_module=null)
{
if (is_numeric($id_agent_module) === true
&& $id_agent_module > 0
) {
try {
parent::__construct(
'tagente_estado',
['id_agente_modulo' => $id_agent_module]
);
} catch (\Exception $e) {
throw new \Exception(
__METHOD__.' error: Status not found for module '.$id_agent_module
);
}
} else {
// Create empty skel.
parent::__construct('tagente_estado');
}
}
/**
* Saves current definition to database.
*
* @return mixed Affected rows of false in case of error.
* @throws \Exception On error.
*/
public function save()
{
if ($this->fields['id_agente_modulo'] > 0) {
// Update.
$updates = $this->fields;
$rs = \db_process_sql_update(
'tagente_estado',
$updates,
['id_agente_modulo' => $this->fields['id_agente_modulo']]
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
} else {
// Creation.
$updates = $this->fields;
// Clean null fields.
foreach ($updates as $k => $v) {
if ($v === null) {
unset($updates[$k]);
}
}
$rs = \db_process_sql_insert(
'tagente_estado',
$updates
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
$this->fields['id_agente_modulo'] = $rs;
}
return true;
}
}

View File

@ -1,8 +1,39 @@
<?php
/**
* Loader for views.
*
* @category Loader
* @package Pandora FMS
* @subpackage Enterprise
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
namespace PandoraFMS;
global $config;
require_once $config['homedir'].'/include/class/HTML.class.php';
use \HTML as HTML;
/**
* View class.
*/
@ -26,11 +57,15 @@ class View
extract($data);
}
if (file_exists($config['homedir'].'/views/'.$page.'.php') === true) {
include $config['homedir'].'/views/'.$page.'.php';
$open = $config['homedir'].'/views/'.$page.'.php';
$ent = $config['homedir'].'/'.ENTERPRISE_DIR.'/views/'.$page.'.php';
if (file_exists($ent) === true) {
include $ent;
} else if (file_exists($open) === true) {
include $open;
} else {
// TODO: XXX SHOW MESSAGE;
echo '???';
ui_print_error_message(__('View %s not found', $page), true);
}
}

View File

@ -1,144 +1,25 @@
/*
* ---------------------------------------------------------------------
* - CLUSTER VIEW -
* ---------------------------------------------------------------------
*/
#main_cluster {
max-width: 1770px;
margin: 0 auto;
.agent_details_col {
max-height: 340px;
overflow: hidden;
margin: 0.5em 0.5em;
}
.sub_cluster_1 {
width: 400px;
float: left;
margin-left: 30px;
margin-bottom: 25px;
vertical-align: top;
border: 1px solid #e7e9ea;
height: 150px;
.agent_details_col_left {
min-width: 370px;
flex: 1 1 370px;
}
.sub_cluster_2 {
width: 833px;
float: left;
margin-left: 30px;
margin-bottom: 25px;
vertical-align: top;
border: 1px solid #e7e9ea;
height: 150px;
.agent_details_col_right {
align-self: flex-end;
min-width: 500px;
flex: 3 3 500px;
}
.sub_cluster_header {
.agent_details_col_right .cluster-map {
width: 100%;
height: 30px;
background-color: #373737;
color: white;
text-align: center;
font-size: 9pt;
display: flex;
justify-content: center;
align-content: center;
flex-direction: column;
}
.sub_cluster_body {
width: 100%;
height: 120px;
background-color: #f9faf9;
display: flex;
justify-content: center;
align-content: center;
flex-direction: column;
}
.sub_cluster_body_3 {
width: 100%;
height: 120px;
background-color: #f9faf9;
overflow-y: scroll;
}
#simple_map {
border: 1px solid lightgray;
width: 900px;
height: 500px;
float: left;
margin-bottom: 30px;
}
#cluster_status_content {
width: 90%;
height: 30px;
margin: 0px auto;
}
#cluster_status_bar {
width: 85%;
height: 100%;
float: left;
}
.status_animation {
width: 1%;
height: 100%;
left: 0%;
background-color: red;
position: relative;
}
#cluster_status_button {
float: left;
width: 10%;
margin-left: 5%;
}
#last_contact_content {
width: 90%;
height: 60px;
margin: 0px auto;
}
#last_contact_clock {
width: 15%;
height: 100%;
float: left;
}
#last_contact_date {
float: left;
height: 60px;
width: 80%;
margin-left: 5%;
text-align: center;
display: flex;
justify-content: center;
align-content: center;
flex-direction: column;
}
#last_contact_date_text {
font-size: 14pt;
}
.balanced_module_item {
float: left;
margin-top: 11.5px;
margin-left: 5%;
height: 25px;
width: 90%;
}
.module_icon {
float: left;
width: 10%;
}
.modal_module_list {
float: left;
width: 90%;
height: 100%;
display: flex;
justify-content: center;
align-content: center;
flex-direction: column;
.w100p.modules {
min-width: 985px;
}

View File

@ -0,0 +1,29 @@
.wizard select {
min-width: 16em;
}
.wizard .multi-select.flex-row-vcenter.w80p.mw600px {
margin-top: 2em;
}
.flex-row.line.w100p {
flex-wrap: nowrap;
justify-content: flex-start;
align-items: baseline;
}
.wizard .flex-row.line.w100p > label:not(.p-switch) {
width: auto;
margin: 0 0.2em;
font-weight: normal;
}
.wizard .flex-row.line.w100p > input {
max-width: 100px;
margin: 0 1em;
}
b.state {
font-weight: bolder;
font-size: 1.1em;
}

View File

@ -0,0 +1,54 @@
.multi-select .multi-select-container {
flex: 1 1 200px;
min-width: 200px;
}
.multi-select-container * {
flex: 1 1 auto;
}
.multi-select.flex-column {
justify-content: space-between;
}
.multi-select-container.flex-column * {
margin: 0.2em 0;
}
.multi-select-container.flex-column {
flex-wrap: nowrap;
}
.arrows-container {
width: 50px;
}
.multi-select-container .filter input,
.multi-select-container .filter select {
float: right;
width: 50%;
text-align: left;
}
.multi-select-container .filter input[type="checkbox"] {
width: auto;
}
.group-filter.flex-row-vcenter div,
.item-filter.flex-row-vcenter div {
flex: 1 1 auto;
width: 100%;
}
.multi-select-container .title {
text-align: center;
font-style: italic;
margin-top: 1em;
color: #424242;
}
.multi-select-container.flex-column div {
text-align: left;
}
.multi-select-container.flex-column div input {
margin-left: 1em;
}

View File

@ -462,29 +462,45 @@ select:-internal-list-box {
.mw250px {
min-width: 250px;
}
.mw500px {
min-width: 500px;
}
.mw600px {
min-width: 600px;
}
.mw800px {
min-width: 800px;
}
.w20px {
width: 20px;
}
.w10p {
width: 10%;
}
.w20p {
width: 20%;
}
.w30p {
width: 30%;
}
.w40p {
width: 40%;
}
.w50p {
width: 50%;
}
.w60p {
width: 60%;
}
.w70p {
width: 70%;
}
.w80p {
width: 80%;
}
.w90p {
width: 90%;
}
.w100p {
width: 100%;
}

View File

@ -798,8 +798,18 @@ foreach ($agents as $agent) {
$data[0] .= '<div class="agentleft_'.$agent['id_agente'].'" style="visibility: hidden; clear: left;">';
if ($agent['id_os'] == 100) {
$data[0] .= '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id='.$cluster['id'].'">'.__('View').'</a>';
if ($agent['id_os'] == CLUSTER_OS_ID) {
if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=view&id='.$cluster->id()
);
$data[0] .= '<a href="'.$url.'">'.__('View').'</a>';
}
} else {
$data[0] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'">'.__('View').'</a>';
}
@ -807,8 +817,18 @@ foreach ($agents as $agent) {
if (check_acl($config['id_user'], $agent['id_grupo'], 'AW')) {
$data[0] .= ' | ';
if ($agent['id_os'] == 100) {
$data[0] .= '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.__('Edit').'</a>';
if ($agent['id_os'] == CLUSTER_OS_ID) {
if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id()
);
$data[0] .= '<a href="'.$url.'">'.__('Edit').'</a>';
}
} else {
$data[0] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$agent['id_agente'].'">'.__('Edit').'</a>';
}

View File

@ -148,8 +148,10 @@ $sort = get_parameter('sort', 'up');
$modules_not_init = agents_monitor_notinit($id_agente);
if (!empty($modules_not_init)) {
$help_not_init = clippy_context_help('modules_not_init');
if (empty($modules_not_init) === false) {
$help_not_init = ui_print_warning_message(
__('No initialized modules found.')
);
} else {
$help_not_init = '';
}

View File

@ -463,7 +463,7 @@ $autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console';
$autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map';
$autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console';
$autorefresh_list_out['operation/events/events'] = 'Events';
$autorefresh_list_out['enterprise/godmode/reporting/cluster_view'] = 'Cluster view';
$autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view';
if (enterprise_installed()) {
$autorefresh_list_out['general/sap_view'] = 'SAP view';
}

View File

@ -1,4 +1,3 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -18,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -308,9 +308,44 @@ return array(
'Mpdf\\Utils\\NumericString' => $vendorDir . '/mpdf/mpdf/src/Utils/NumericString.php',
'Mpdf\\Utils\\PdfDate' => $vendorDir . '/mpdf/mpdf/src/Utils/PdfDate.php',
'Mpdf\\Utils\\UtfString' => $vendorDir . '/mpdf/mpdf/src/Utils/UtfString.php',
'PandoraFMS\\Agent' => $baseDir . '/include/lib/Agent.php',
'PandoraFMS\\Dashboard\\AgentModuleWidget' => $baseDir . '/include/lib/Dashboard/Widgets/agent_module.php',
'PandoraFMS\\Dashboard\\AlertsFiredWidget' => $baseDir . '/include/lib/Dashboard/Widgets/alerts_fired.php',
'PandoraFMS\\Dashboard\\Cell' => $baseDir . '/include/lib/Dashboard/Cell.php',
'PandoraFMS\\Dashboard\\ClockWidget' => $baseDir . '/include/lib/Dashboard/Widgets/clock.php',
'PandoraFMS\\Dashboard\\CustomGraphWidget' => $baseDir . '/include/lib/Dashboard/Widgets/custom_graph.php',
'PandoraFMS\\Dashboard\\EventsListWidget' => $baseDir . '/include/lib/Dashboard/Widgets/events_list.php',
'PandoraFMS\\Dashboard\\GraphModuleHistogramWidget' => $baseDir . '/include/lib/Dashboard/Widgets/graph_module_histogram.php',
'PandoraFMS\\Dashboard\\GroupsStatusWidget' => $baseDir . '/include/lib/Dashboard/Widgets/groups_status.php',
'PandoraFMS\\Dashboard\\Manager' => $baseDir . '/include/lib/Dashboard/Manager.php',
'PandoraFMS\\Dashboard\\MapsMadeByUser' => $baseDir . '/include/lib/Dashboard/Widgets/maps_made_by_user.php',
'PandoraFMS\\Dashboard\\MapsStatusWidget' => $baseDir . '/include/lib/Dashboard/Widgets/maps_status.php',
'PandoraFMS\\Dashboard\\ModuleIconWidget' => $baseDir . '/include/lib/Dashboard/Widgets/module_icon.php',
'PandoraFMS\\Dashboard\\ModuleStatusWidget' => $baseDir . '/include/lib/Dashboard/Widgets/module_status.php',
'PandoraFMS\\Dashboard\\ModuleTableValueWidget' => $baseDir . '/include/lib/Dashboard/Widgets/module_table_value.php',
'PandoraFMS\\Dashboard\\ModuleValueWidget' => $baseDir . '/include/lib/Dashboard/Widgets/module_value.php',
'PandoraFMS\\Dashboard\\MonitorHealthWidget' => $baseDir . '/include/lib/Dashboard/Widgets/monitor_health.php',
'PandoraFMS\\Dashboard\\NetworkMapWidget' => $baseDir . '/include/lib/Dashboard/Widgets/network_map.php',
'PandoraFMS\\Dashboard\\PostWidget' => $baseDir . '/include/lib/Dashboard/Widgets/post.php',
'PandoraFMS\\Dashboard\\ReportsWidget' => $baseDir . '/include/lib/Dashboard/Widgets/reports.php',
'PandoraFMS\\Dashboard\\SLAPercentWidget' => $baseDir . '/include/lib/Dashboard/Widgets/sla_percent.php',
'PandoraFMS\\Dashboard\\ServiceMapWidget' => $baseDir . '/include/lib/Dashboard/Widgets/service_map.php',
'PandoraFMS\\Dashboard\\SingleGraphWidget' => $baseDir . '/include/lib/Dashboard/Widgets/single_graph.php',
'PandoraFMS\\Dashboard\\SystemGroupStatusWidget' => $baseDir . '/include/lib/Dashboard/Widgets/system_group_status.php',
'PandoraFMS\\Dashboard\\TacticalWidget' => $baseDir . '/include/lib/Dashboard/Widgets/tactical.php',
'PandoraFMS\\Dashboard\\TopNEventByGroupWidget' => $baseDir . '/include/lib/Dashboard/Widgets/top_n_events_by_group.php',
'PandoraFMS\\Dashboard\\TopNEventByModuleWidget' => $baseDir . '/include/lib/Dashboard/Widgets/top_n_events_by_module.php',
'PandoraFMS\\Dashboard\\TopNWidget' => $baseDir . '/include/lib/Dashboard/Widgets/top_n.php',
'PandoraFMS\\Dashboard\\TreeViewWidget' => $baseDir . '/include/lib/Dashboard/Widgets/tree_view.php',
'PandoraFMS\\Dashboard\\UrlWidget' => $baseDir . '/include/lib/Dashboard/Widgets/url.php',
'PandoraFMS\\Dashboard\\WelcomeWidget' => $baseDir . '/include/lib/Dashboard/Widgets/example.php',
'PandoraFMS\\Dashboard\\Widget' => $baseDir . '/include/lib/Dashboard/Widget.php',
'PandoraFMS\\Dashboard\\WuxStatsWidget' => $baseDir . '/include/lib/Dashboard/Widgets/wux_transaction_stats.php',
'PandoraFMS\\Dashboard\\WuxWidget' => $baseDir . '/include/lib/Dashboard/Widgets/wux_transaction.php',
'PandoraFMS\\Entity' => $baseDir . '/include/lib/Entity.php',
'PandoraFMS\\Group' => $baseDir . '/include/lib/Group.php',
'PandoraFMS\\User' => $baseDir . '/include/lib/User.php',
'PandoraFMS\\View' => $baseDir . '/include/lib/View.php',
'PandoraFMS\\WebSockets\\WSManager' => $baseDir . '/include/lib/WSManager.php',
'PandoraFMS\\Websockets\\WebSocketServer' => $baseDir . '/include/lib/WebSocketServer.php',
'PandoraFMS\\Websockets\\WebSocketUser' => $baseDir . '/include/lib/WebSocketUser.php',

View File

@ -13,6 +13,9 @@ class ComposerAutoloaderInitfdecadadce22e6dde51e9535fe4ad7aa
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {

View File

@ -390,9 +390,44 @@ class ComposerStaticInitfdecadadce22e6dde51e9535fe4ad7aa
'Mpdf\\Utils\\NumericString' => __DIR__ . '/..' . '/mpdf/mpdf/src/Utils/NumericString.php',
'Mpdf\\Utils\\PdfDate' => __DIR__ . '/..' . '/mpdf/mpdf/src/Utils/PdfDate.php',
'Mpdf\\Utils\\UtfString' => __DIR__ . '/..' . '/mpdf/mpdf/src/Utils/UtfString.php',
'PandoraFMS\\Agent' => __DIR__ . '/../..' . '/include/lib/Agent.php',
'PandoraFMS\\Dashboard\\AgentModuleWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/agent_module.php',
'PandoraFMS\\Dashboard\\AlertsFiredWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/alerts_fired.php',
'PandoraFMS\\Dashboard\\Cell' => __DIR__ . '/../..' . '/include/lib/Dashboard/Cell.php',
'PandoraFMS\\Dashboard\\ClockWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/clock.php',
'PandoraFMS\\Dashboard\\CustomGraphWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/custom_graph.php',
'PandoraFMS\\Dashboard\\EventsListWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/events_list.php',
'PandoraFMS\\Dashboard\\GraphModuleHistogramWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/graph_module_histogram.php',
'PandoraFMS\\Dashboard\\GroupsStatusWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/groups_status.php',
'PandoraFMS\\Dashboard\\Manager' => __DIR__ . '/../..' . '/include/lib/Dashboard/Manager.php',
'PandoraFMS\\Dashboard\\MapsMadeByUser' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/maps_made_by_user.php',
'PandoraFMS\\Dashboard\\MapsStatusWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/maps_status.php',
'PandoraFMS\\Dashboard\\ModuleIconWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/module_icon.php',
'PandoraFMS\\Dashboard\\ModuleStatusWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/module_status.php',
'PandoraFMS\\Dashboard\\ModuleTableValueWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/module_table_value.php',
'PandoraFMS\\Dashboard\\ModuleValueWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/module_value.php',
'PandoraFMS\\Dashboard\\MonitorHealthWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/monitor_health.php',
'PandoraFMS\\Dashboard\\NetworkMapWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/network_map.php',
'PandoraFMS\\Dashboard\\PostWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/post.php',
'PandoraFMS\\Dashboard\\ReportsWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/reports.php',
'PandoraFMS\\Dashboard\\SLAPercentWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/sla_percent.php',
'PandoraFMS\\Dashboard\\ServiceMapWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/service_map.php',
'PandoraFMS\\Dashboard\\SingleGraphWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/single_graph.php',
'PandoraFMS\\Dashboard\\SystemGroupStatusWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/system_group_status.php',
'PandoraFMS\\Dashboard\\TacticalWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/tactical.php',
'PandoraFMS\\Dashboard\\TopNEventByGroupWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/top_n_events_by_group.php',
'PandoraFMS\\Dashboard\\TopNEventByModuleWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/top_n_events_by_module.php',
'PandoraFMS\\Dashboard\\TopNWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/top_n.php',
'PandoraFMS\\Dashboard\\TreeViewWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/tree_view.php',
'PandoraFMS\\Dashboard\\UrlWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/url.php',
'PandoraFMS\\Dashboard\\WelcomeWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/example.php',
'PandoraFMS\\Dashboard\\Widget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widget.php',
'PandoraFMS\\Dashboard\\WuxStatsWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/wux_transaction_stats.php',
'PandoraFMS\\Dashboard\\WuxWidget' => __DIR__ . '/../..' . '/include/lib/Dashboard/Widgets/wux_transaction.php',
'PandoraFMS\\Entity' => __DIR__ . '/../..' . '/include/lib/Entity.php',
'PandoraFMS\\Group' => __DIR__ . '/../..' . '/include/lib/Group.php',
'PandoraFMS\\User' => __DIR__ . '/../..' . '/include/lib/User.php',
'PandoraFMS\\View' => __DIR__ . '/../..' . '/include/lib/View.php',
'PandoraFMS\\WebSockets\\WSManager' => __DIR__ . '/../..' . '/include/lib/WSManager.php',
'PandoraFMS\\Websockets\\WebSocketServer' => __DIR__ . '/../..' . '/include/lib/WebSocketServer.php',
'PandoraFMS\\Websockets\\WebSocketUser' => __DIR__ . '/../..' . '/include/lib/WebSocketUser.php',

View File

@ -47,8 +47,7 @@ $form = [
'extra' => 'novalidate',
];
$html = new HTML();
$html->printForm(
HTML::printForm(
[
'form' => $form,
'inputs' => $htmlInputs,

View File

@ -120,8 +120,7 @@ $inputs = [
],
];
$html = new HTML();
$html->printForm(
HTML::printForm(
[
'form' => $form,
'inputs' => $inputs,

View File

@ -84,8 +84,7 @@ $inputs[] = [
],
];
$html = new HTML();
$html->printForm(
HTML::printForm(
[
'form' => $form,
'inputs' => $inputs,

View File

@ -52,8 +52,7 @@ $inputs = [
],
];
$html = new HTML();
$html->printForm(
HTML::printForm(
[
'form' => $form,
'inputs' => $inputs,

View File

@ -1404,63 +1404,64 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
$self->call('message', "Storing results", 6);
my @hosts = keys %{$self->{'agents_found'}};
$self->{'step'} = STEP_PROCESSING;
my ($progress, $step) = (90, 10.0 / scalar(@hosts)); # From 90% to 100%.
if ((scalar (@hosts)) > 0) {
my ($progress, $step) = (90, 10.0 / scalar(@hosts)); # From 90% to 100%.
foreach my $addr (keys %{$self->{'agents_found'}}) {
my $label = $self->{'agents_found'}->{$addr}{'agent'}{'nombre'};
foreach my $addr (keys %{$self->{'agents_found'}}) {
my $label = $self->{'agents_found'}->{$addr}{'agent'}{'nombre'};
next if is_empty($label);
next if is_empty($label);
# Retrieve target agent OS version.
$self->{'agents_found'}->{$addr}{'agent'}{'id_os'} = $self->guess_os($addr);
# Retrieve target agent OS version.
$self->{'agents_found'}->{$addr}{'agent'}{'id_os'} = $self->guess_os($addr);
$self->call('update_progress', $progress);
$progress += $step;
# Store temporally. Wait user approval.
my $encoded;
$self->call('update_progress', $progress);
$progress += $step;
# Store temporally. Wait user approval.
my $encoded;
eval {
local $SIG{__DIE__};
$encoded = encode_base64(
p_encode_json($self->{'pa_config'}, $self->{'agents_found'}->{$addr})
);
};
eval {
local $SIG{__DIE__};
$encoded = encode_base64(
p_encode_json($self->{'pa_config'}, $self->{'agents_found'}->{$addr})
);
};
my $id = get_db_value(
$self->{'dbh'},
'SELECT id FROM tdiscovery_tmp_agents WHERE id_rt = ? AND label = ?',
$self->{'task_data'}{'id_rt'},
safe_input($label)
);
if (defined($id)) {
# Already defined.
$self->{'agents_found'}{$addr}{'id'} = $id;
db_do(
my $id = get_db_value(
$self->{'dbh'},
'UPDATE tdiscovery_tmp_agents SET `data` = ? '
.'WHERE `id_rt` = ? AND `label` = ?',
$encoded,
'SELECT id FROM tdiscovery_tmp_agents WHERE id_rt = ? AND label = ?',
$self->{'task_data'}{'id_rt'},
safe_input($label)
);
next;
if (defined($id)) {
# Already defined.
$self->{'agents_found'}{$addr}{'id'} = $id;
db_do(
$self->{'dbh'},
'UPDATE tdiscovery_tmp_agents SET `data` = ? '
.'WHERE `id_rt` = ? AND `label` = ?',
$encoded,
$self->{'task_data'}{'id_rt'},
safe_input($label)
);
next;
}
# Insert.
$self->{'agents_found'}{$addr}{'id'} = db_insert(
$self->{'dbh'},
'id',
'INSERT INTO tdiscovery_tmp_agents (`id_rt`,`label`,`data`,`created`) '
.'VALUES (?, ?, ?, now())',
$self->{'task_data'}{'id_rt'},
safe_input($label),
$encoded
);
}
# Insert.
$self->{'agents_found'}{$addr}{'id'} = db_insert(
$self->{'dbh'},
'id',
'INSERT INTO tdiscovery_tmp_agents (`id_rt`,`label`,`data`,`created`) '
.'VALUES (?, ?, ?, now())',
$self->{'task_data'}{'id_rt'},
safe_input($label),
$encoded
);
}
if(defined($self->{'task_data'}{'review_mode'})
&& $self->{'task_data'}{'review_mode'} == DISCOVERY_REVIEW
) {

View File

@ -1,4 +1,4 @@
FROM pandorafms/pandorafms-base
FROM pandorafms/pandorafms-base:centos7
MAINTAINER Pandora FMS Team <info@pandorafms.com>
# Pandora FMS Server dependencies