';
// Get Groups and profiles from user
$user_groups = implode (",", array_keys (users_get_groups ()));
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$profiles = db_get_all_rows_sql('SELECT id_grupo
FROM tusuario_perfil AS t1
INNER JOIN tperfil AS t2 ON t1.id_perfil = t2.id_perfil
WHERE t2.agent_view = 1 AND t1.id_usuario = \'' . $config['id_user'] . '\';');
if ($profiles === false)
$profiles = array();
$id_groups = array();
$flag_all_group = false;
foreach ($profiles as $profile) {
if ($profile['id_grupo'] == 0) {
$flag_all_group = true;
}
$id_groups[] = $profile['id_grupo'];
}
//The check of is_admin
$flag_is_admin = (bool)db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']);
$sql = ' SELECT distinct(nombre)
FROM tagente_modulo
WHERE nombre <> \'delete_pending\' AND id_agente IN
(
SELECT id_agente
FROM tagente
WHERE';
$sql .= $extra_sql.'(';
if ($flag_is_admin || $flag_all_group) {
$sql .= ' 1 = 1 ';
}
else {
if (empty($id_groups)) {
$sql .= ' 1 = 0 ';
}
else {
$sql .= ' id_grupo IN (' . implode(',', $id_groups) . ') ';
}
}
$sql .= '))';
break;
case "oracle":
$profiles = db_get_all_rows_sql('SELECT id_grupo
FROM tusuario_perfil t1
INNER JOIN tperfil t2 ON t1.id_perfil = t2.id_perfil
WHERE t2.agent_view = 1 AND t1.id_usuario = \'' . $config['id_user'] . '\';');
if ($profiles === false)
$profiles = array();
$id_groups = array();
$flag_all_group = false;
foreach ($profiles as $profile) {
if ($profile['id_grupo'] == 0) {
$flag_all_group = true;
}
$id_groups[] = $profile['id_grupo'];
}
//The check of is_admin
$flag_is_admin = (bool)db_get_value('is_admin', 'tusuario',
'id_user', $config['id_user']);
$sql = ' SELECT DISTINCT dbms_lob.substr(nombre,4000,1) AS nombre
FROM tagente_modulo
WHERE dbms_lob.substr(nombre,4000,1) <> \'delete_pending\'
AND id_agente IN
(
SELECT id_agente
FROM tagente
WHERE';
$sql .= $extra_sql . '(';
if ($flag_is_admin || $flag_all_group) {
$sql .= ' 1 = 1 ';
}
else {
if (empty($id_groups)) {
$sql .= ' 1 = 0 ';
}
else {
$sql .= ' id_grupo IN (' . implode(',', $id_groups) . ') ';
}
}
$sql .= '))';
break;
}
$modules = array();
$tags = array();
$rows_select = array();
$rows_temp_processed = array();
$groups_select = array();
if ($flag_is_admin)
$groups_select[0] = __('All');
if (defined('METACONSOLE')) {
// For each server defined and not disabled:
$servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup WHERE disabled = 0");
if ($servers === false)
$servers = array();
$result = array();
foreach($servers as $server) {
// If connection was good then retrieve all data server
if (metaconsole_connect($server) == NOERR){
$connection = true;
}
else{
$connection = false;
}
// Get all info for filters of all nodes
$modules_temp = db_get_all_rows_sql($sql);
$tags_temp = db_get_all_rows_sql('SELECT name, name
FROM ttag
WHERE id_tag IN (SELECT ttag_module.id_tag
FROM ttag_module)');
$rows_temp = db_get_all_rows_sql("SELECT distinct name
FROM tmodule_group ORDER BY name");
$rows_temp = io_safe_output($rows_temp);
if (!empty($rows_temp)) {
foreach ($rows_temp as $module_group_key => $modules_group_val)
$rows_temp_processed[$modules_group_val['name']] = $modules_group_val['name'];
$rows_select = array_unique(array_merge($rows_select, $rows_temp_processed));
}
$groups_temp = users_get_groups_for_select(false, "AR", true, true, false);
$groups_temp_processed = array();
foreach ($groups_temp as $group_temp_key => $group_temp_val) {
$new_key = str_replace(' ','',$group_temp_val);
$groups_temp_processed[$new_key] = $group_temp_val;
}
if (!empty($groups_temp_processed)) {
$groups_select = array_unique(array_merge($groups_select, $groups_temp_processed));
}
if (!empty($modules_temp))
$modules = array_merge($modules, $modules_temp);
if (!empty($tags_temp))
$tags = array_merge($tags, $tags_temp);
metaconsole_restore_db();
}
unset($groups_select[__('All')]);
}
if (!defined('METACONSOLE')) {
echo '
' . __('Group') . ' |
' .
html_print_select_groups(false, "AR", true, "ag_group",
$ag_group, '', '', '0', true, false, false, 'w130',
false, 'width:150px;') . '
| ';
}
else {
echo '
' . __('Group') . ' |
' .
html_print_select($groups_select, "ag_group",
io_safe_output($ag_group), '', '', '0', true, false, false, 'w130',
false, 'width:150px;') . '
| ';
}
echo '' . __('Monitor status') . " | ";
echo "";
$fields = array ();
$fields[0] = __('Normal');
$fields[1] = __('Warning');
$fields[2] = __('Critical');
$fields[3] = __('Unknown');
$fields[4] = __('Not normal'); //default
$fields[5] = __('Not init');
html_print_select ($fields, "status", $status, '', __('All'), -1,
false, false, true, '', false, 'width: 125px;');
echo ' | ';
echo '' . __('Module group') . ' | ';
echo '';
if (!defined('METACONSOLE')) {
$rows = db_get_all_rows_sql("SELECT *
FROM tmodule_group ORDER BY name");
$rows = io_safe_output($rows);
$rows_select = array();
if (!empty($rows))
foreach ($rows as $module_group)
$rows_select[$module_group['id_mg']] = $module_group['name'];
}
$rows_select[0] = __('Not assigned');
html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'), -1);
echo ' | ';
echo '
';
echo '';
echo '' . __('Module name') . ' | ';
echo '';
if (!defined('METACONSOLE'))
$modules = db_get_all_rows_sql($sql);
html_print_select (index_array ($modules, 'nombre', 'nombre'), "ag_modulename",
$ag_modulename, '', __('All'), '', false, false, true, '', false, 'width: 150px;');
echo ' | ';
echo '' .
__('Tags') .
ui_print_help_tip(__('Only it is show tags in use.'), true) .
' | ';
echo '';
if (!defined('METACONSOLE'))
$tags = db_get_all_rows_sql('SELECT id_tag, name
FROM ttag
WHERE id_tag IN (SELECT ttag_module.id_tag
FROM ttag_module)');
if (empty($tags)) {
echo __('None tag');
}
else {
if (!defined('METACONSOLE'))
html_print_select (index_array($tags, 'id_tag', 'name'), "tag_filter",
$tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;');
else
html_print_select (index_array($tags, 'name', 'name'), "tag_filter",
$tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;');
}
echo ' | ';
echo '' .
__('Search') .
' | ';
echo '';
html_print_input_text ("ag_freestring", $ag_freestring, '', 20,30, false);
echo ' | ';
echo '';
html_print_submit_button (__('Show'), "uptbutton", false, 'class="sub search"');
echo " | ";
echo "