diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 184c0331ab..93a6a9957d 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150108 +Version: 6.0dev-150116 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 9af643fa25..d0c5229392 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150108" +pandora_version="6.0dev-150116" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 7a8ba1da27..ba0373c691 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150108'; +use constant AGENT_BUILD => '150116'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index f0081211c1..8c47bbcc93 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150108 +%define release 150116 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index a95dd515a0..5a181aa1e6 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150108 +%define release 150116 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 1874ed38df..23677b4197 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150108} +{150116} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 2904d25753..0ce398b87b 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("6.0dev(Build 150108)") +#define PANDORA_VERSION ("6.0dev(Build 150116)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index db5e0b231e..9aa744c80b 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(6.0dev(Build 150108))" + VALUE "ProductVersion", "(6.0dev(Build 150116))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 563a8d176f..c2fd004d71 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150108 +Version: 6.0dev-150116 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 166a037f56..a5934b288c 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150108" +pandora_version="6.0dev-150116" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/net_tools.php b/pandora_console/extensions/net_tools.php index 4c5f77a2f7..4da4d88fad 100644 --- a/pandora_console/extensions/net_tools.php +++ b/pandora_console/extensions/net_tools.php @@ -83,37 +83,75 @@ function whereis_the_command ($command) { function main_net_tools () { $id_agente = get_parameter ("id_agente"); - $ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente"); - if ($ip == "") { + $principal_ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente"); + + $list_address = db_get_all_rows_sql ("select id_a from taddress_agent where id_agent = " . $id_agente); + foreach ($list_address as $address){ + $ids []= join(",",$address); + } + $ids_address = implode(",",$ids); + $ips = db_get_all_rows_sql ("select ip from taddress where id_a in (" . $ids_address . ")"); + + if ($ips == "") { echo "
" . __('The agent hasn\'t got IP') . "
"; return; } + echo " + "; + echo "
"; echo "
"; - echo ""; + echo "
"; echo ""; echo ""; + echo ""; echo "
"; echo __("Operation"); ui_print_help_tip(__('You can set the command path in the menu Administration -> Extensions -> Config Network Tools')); - echo ""; - echo ""; + echo ""; + echo ""; - echo __("SNMP Community"); - echo ""; + echo __("IP address"); + echo ""; + echo ""; + echo ""; + echo __("SNMP Community") . " "; echo ""; - echo ""; + echo ""; echo ""; + echo "
"; echo "
"; $operation = get_parameter ("operation", 0); $community = get_parameter ("community", "public"); + $ip = get_parameter("select_ips"); switch($operation) { case 1: diff --git a/pandora_console/extensions/resource_registration.php b/pandora_console/extensions/resource_registration.php index 1afe93e611..56efebe67b 100755 --- a/pandora_console/extensions/resource_registration.php +++ b/pandora_console/extensions/resource_registration.php @@ -654,7 +654,7 @@ function process_upload_xml_component($xml) { $tcp_send = $snmp_version; $plugin_user = $auth_user; $plugin_pass = $auth_password; - $plugin_parameter = $auth_method; + $plugin_parameters = $auth_method; $custom_string_1 = $privacy_method; $custom_string_2 = $privacy_pass; $custom_string_3 = $security_level; diff --git a/pandora_console/extensions/vnc_view.php b/pandora_console/extensions/vnc_view.php index 130d422344..36c027583e 100644 --- a/pandora_console/extensions/vnc_view.php +++ b/pandora_console/extensions/vnc_view.php @@ -20,10 +20,14 @@ function vnc_view() { $display = get_parameter("display", 0); echo "
"; - echo __("VNC Display (:0 by default)"); + echo ""; + echo ""; + echo "
"; + echo __("VNC Display (:0 by default)") . " "; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo "
"; $port = 5800 + $display; echo ""; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql index 0f2d7a21f8..cf63cd06b5 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql @@ -40,4 +40,4 @@ INSERT INTO ttipo_modulo VALUES (5,'generic_data_inc_abs',0,'Generic numeric inc -- --------------------------------------------------------------------- -- Table `tusuario` -- --------------------------------------------------------------------- -ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5,0) DEFAULT 0; +ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5, 0) DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql index f6fd488be9..25b7e250b3 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql @@ -38,4 +38,4 @@ INSERT INTO "ttipo_modulo" VALUES (5,'generic_data_inc_abs',0,'Generic numeric i -- --------------------------------------------------------------------- -- Table `tusuario` -- --------------------------------------------------------------------- -ALTER TABLE "tusuario" ADD COLUMN "strict_acl" SMALLINT NOT NULL default 0; +ALTER TABLE "tusuario" ADD COLUMN "strict_acl" SMALLINT DEFAULT 0; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 09c3f0fbdc..fdcf57a1e4 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -208,7 +208,9 @@ if ($create_agent) { array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value)); } // Create address for this agent in taddress - agents_add_address ($id_agente, $direccion_agente); + if ( $direccion_agente != ''){ + agents_add_address ($id_agente, $direccion_agente); + } $agent_created_ok = true; diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index bd460fea7f..e79a653d6b 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -23,6 +23,7 @@ $ag_group = get_parameter ("ag_group_refresh", -1); $sortField = get_parameter('sort_field'); $sort = get_parameter('sort', 'none'); $recursion = get_parameter('recursion'); +$disabled = get_parameter('disabled'); if ($ag_group == -1 ) $ag_group = (int) get_parameter ("ag_group", -1); @@ -138,6 +139,16 @@ if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "PM")) else $return_all_group = true; html_print_select_groups(false, "AR", $return_all_group, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false, 'width:100px;'); +echo ""; +echo __('Show Agents') . ' '; +$fields = array( + 2 => __('Everyone'), + 1 => __('Only disabled'), + 0 => __('Only enabled'), + ); +html_print_select($fields,"disabled",$disabled,'this.form.submit()'); + +echo ""; echo ""; echo __('Recursion') . ' '; @@ -247,6 +258,16 @@ if ($search != "") { LIKE '%$search%' OR direccion LIKE '%$search%') "; } +if ($disabled==1) +{ + $search_sql = " AND disabled = ". $disabled . $search_sql; +} +else{ + if ($disabled==0){ + $search_sql = " AND disabled = 0" . $search_sql; + } +} + // Show only selected groups if ($ag_group > 0) { $sql = sprintf ('SELECT COUNT(*) @@ -395,23 +416,23 @@ if (($config['dbtype'] == 'oracle') && ($agents !== false)) { } // Prepare pagination -ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort", $offset); +ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled", $offset); if ($agents !== false) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; @@ -529,18 +550,18 @@ if ($agents !== false) { if ($agent['disabled']) { echo "". + enable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled''>". html_print_image('images/lightbulb_off.png', true, array('alt' => __('Enable agent'), 'title' => __('Enable agent'))) .""; } else { echo "". + disable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'>". html_print_image('images/lightbulb.png', true, array('alt' => __('Disable agent'), 'title' => __('Disable agent'))) .""; } if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { echo "  '; echo html_print_image('images/cross.png', true, array("border" => '0')) . ""; } @@ -548,7 +569,7 @@ if ($agents !== false) { echo ""; } echo "
".__('Agent name') . ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; echo "".__('R')."".__('OS'). ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . ''; echo "".__('Group'). ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . ''; echo "" . __('Description') . "" . __('Actions') . "
"; - ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset); + ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled", $offset); echo "
"; } else { diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 015a22ac70..021afe527e 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -462,7 +462,7 @@ html_print_table ($table_simple); ui_toggle(html_print_table ($table_advanced, true), __('Advanced options')); ui_toggle(html_print_table ($table_macros, true), - __('Module macros') . ui_print_help_icon ('module_macros', true)); + __('Custom macros') . ui_print_help_icon ('module_macros', true)); ui_toggle(html_print_table ($table_new_relations, true) . html_print_table ($table_relations, true), __('Module relations')); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 412e194349..f68d410fe8 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -574,7 +574,7 @@ if (isset($module_macros)) { } } } -$table_macros->data[$macro_count][0] = ''.__('Add module macro').' '.html_print_image('images/add.png',true).''; +$table_macros->data[$macro_count][0] = ''.__('Custom macros').' '.html_print_image('images/add.png',true).''; $table_macros->colspan[$macro_count][0] = 5; $macro_count++; diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index bde687bcdf..43306e109b 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -448,7 +448,7 @@ else { } // Hash for auto-auth in public link -$hash = md5($config["dbpass"] . $id_layout . $config["id_user"]); +$hash = md5($config["dbpass"] . $idVisualConsole . $config["id_user"]); $buttons = array(); @@ -456,7 +456,7 @@ $buttons['consoles_list'] = array('active' => false, 'text' => '' . html_print_image ("images/visual_console.png", true, array ("title" => __('Visual consoles list'))) .''); $buttons['public_link'] = array('active' => false, - 'text' => ''. + 'text' => ''. html_print_image ("images/camera_mc.png", true, array ("title" => __('Show link to public Visual Console'))).''); $buttons['data'] = array('active' => false, 'text' => '' . diff --git a/pandora_console/godmode/snmpconsole/snmp_filters.php b/pandora_console/godmode/snmpconsole/snmp_filters.php index 42f378c9b6..d81a2a23c3 100644 --- a/pandora_console/godmode/snmpconsole/snmp_filters.php +++ b/pandora_console/godmode/snmpconsole/snmp_filters.php @@ -94,7 +94,8 @@ if ($edit_filter > -2) { $table->data[0][1] = html_print_input_text ('description', $description, '', 60, 100, true); $table->data[1][0] = __('Filter'); $table->data[1][1] = html_print_input_text ('filter', $filter, '', 60, 100, true); - + $table->data[1][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true); + echo '
'; html_print_input_hidden ('update_filter', $edit_filter); html_print_table ($table); diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 9558f40003..ae00525814 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -450,7 +450,7 @@ if ($config['admin_can_make_admin']) { if ($own_info['is_admin'] || $user_info['is_admin']) { $table->data[6][1] = html_print_radio_button ('is_admin', 1, '', $user_info['is_admin'], true); $table->data[6][1] .= __('Administrator'); - $table->data[6][1] .= ui_print_help_tip (__("This user has permissions to manage all. This is admin user and overwrites all permissions given in profiles/groups"), true); + $table->data[6][1] .= ui_print_help_tip (__("This user has permissions to manage all. An admin user should not requiere additional group permissions, except for using Enterprise ACL."), true); $table->data[6][1] .= '
'; } $table->data[6][1] .= html_print_radio_button ('is_admin', 0, '', $user_info['is_admin'], true); @@ -601,6 +601,7 @@ if (!empty ($id) && !$new_user) { */ $result = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id); + if ($result === false) { $result = array (); } diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 3720cf25e6..2ff6afe878 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -79,7 +79,8 @@ if ($get_module_detail) { if (defined ('METACONSOLE')) { $server = metaconsole_get_connection ($server_name); - $conexion = mysql_connect ($server['dbhost'], $server['dbuser'], $server['dbpass']); + $conexion = mysql_connect ($server['dbhost'], $server['dbuser'], + $server['dbpass']); $select_db = mysql_select_db ($server['dbname'], $conexion); } else { @@ -112,25 +113,33 @@ if ($get_module_detail) { SECONDS_2YEARS =>__('2 years'), SECONDS_3YEARS =>__('3 years')); - $formtable->data[0][0] = html_print_radio_button_extended ("selection_mode", 'fromnow', '', $selection_mode, false, '', 'style="margin-right: 15px;"', true) . __("Choose a time from now"); + $formtable->data[0][0] = html_print_radio_button_extended ( + "selection_mode", 'fromnow', '', $selection_mode, false, '', + 'style="margin-right: 15px;"', true) . __("Choose a time from now"); $formtable->data[0][1] = html_print_select ($periods, 'period', $period, '', '', 0, true, false, false); $formtable->data[0][2] = ''; $formtable->data[0][3] = "
". html_print_image ("images/refresh.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . ""; $formtable->rowspan[0][3] = 2; $formtable->cellstyle[0][3] = 'vertical-align: middle;'; - $formtable->data[1][0] = html_print_radio_button_extended ("selection_mode", 'range','', $selection_mode, false, '', 'style="margin-right: 15px;"', true) . __("Specify time range"); + $formtable->data[1][0] = html_print_radio_button_extended( + "selection_mode", 'range','', $selection_mode, false, '', + 'style="margin-right: 15px;"', true) . __("Specify time range"); $formtable->data[1][1] = __('Timestamp from:'); - $formtable->data[1][2] = html_print_input_text ('date_from', $date_from, '', 10, 10, true); - $formtable->data[1][2] .= html_print_input_text ('time_from', $time_from, '', 9, 7, true); + $formtable->data[1][2] = html_print_input_text('date_from', + $date_from, '', 10, 10, true); + $formtable->data[1][2] .= html_print_input_text('time_from', + $time_from, '', 9, 7, true); $formtable->data[1][1] .= '
'; $formtable->data[1][1] .= __('Timestamp to:'); $formtable->data[1][2] .= '
'; - $formtable->data[1][2] .= html_print_input_text ('date_to', $date_to, '', 10, 10, true); - $formtable->data[1][2] .= html_print_input_text ('time_to', $time_to, '', 9, 7, true); + $formtable->data[1][2] .= html_print_input_text('date_to', $date_to, + '', 10, 10, true); + $formtable->data[1][2] .= html_print_input_text('time_to', $time_to, + '', 9, 7, true); html_print_table($formtable); @@ -145,136 +154,43 @@ if ($get_module_detail) { $datetime_from = strtotime ($date_from . ' ' . $time_from); $datetime_to = strtotime ($date_to . ' ' . $time_to); - if ($moduletype_name == "log4x") { - $table->width = "100%"; - - if ($selection_mode == "fromnow") { - $sql_body = sprintf ("FROM tagente_datos_log4x - WHERE id_agente_modulo = %d AND utimestamp > %d - ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); - } - else { - $sql_body = sprintf ("FROM tagente_datos_log4x - WHERE id_agente_modulo = %d AND utimestamp >= %d - AND utimestamp <= %d - ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to); - } - $columns = array( - "Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "center" ), - "Sev" => array("severity", "modules_format_data", "align" => "center", "width" => "70px"), - "Message"=> array("message", "modules_format_verbatim", "align" => "left", "width" => "45%"), - "StackTrace" => array("stacktrace", "modules_format_verbatim", "align" => "left", "width" => "50%") - ); - } - else if (preg_match ("/string/", $moduletype_name)) { - - if ($selection_mode == "fromnow") { - $sql_body = sprintf (" FROM tagente_datos_string - WHERE id_agente_modulo = %d AND utimestamp > %d - ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); - } - else { - $sql_body = sprintf (" FROM tagente_datos_string - WHERE id_agente_modulo = %d AND utimestamp >= %d - AND utimestamp <= %d - ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to); - } - - $columns = array( - "Timestamp" => array( - "utimestamp", - "modules_format_timestamp", - "align" => "left"), - "Data" => array( - "datos", - "modules_format_data", - "align" => "left"), - "Time" => array( - "utimestamp", - "modules_format_time", - "align" => "center") - ); + $columns = array( + "Timestamp" => array( + "utimestamp", + "modules_format_timestamp", + "align" => "left"), + "Data" => array( + "datos", + "modules_format_data", + "align" => "left"), + "Time" => array( + "utimestamp", + "modules_format_time", + "align" => "center") + ); + + if ($selection_mode == "fromnow") { + $date = get_system_time(); + $period = $period; } else { - if ($selection_mode == "fromnow") { - $sql_body = sprintf (" FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp > %d - ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); - } - else { - $sql_body = sprintf (" FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp >= %d AND utimestamp <= %d - ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to); - } - - $columns = array( - "Timestamp" => array( - "utimestamp", - "modules_format_timestamp", - "align" => "left"), - "Data" => array( - "datos", - "modules_format_data", - "align" => "left"), - "Time" => array( - "utimestamp", - "modules_format_time", - "align" => "center") - ); + $date = $datetime_from; + $period = $datetime_to - $datetime_from; } + $count = modules_get_agentmodule_data ($module_id, $period, + $date, true, $conexion); - $sql_body = io_safe_output($sql_body); - // Clean all codification characters + $module_data = modules_get_agentmodule_data ($module_id, $period, + $date, false, $conexion, 'DESC'); - $sql = "SELECT * " . $sql_body; - - switch ($config['dbtype']) { - case "mysql": - $sql_count = "SELECT count(*) " . $sql_body; - break; - case "postgresql": - $sql_body = str_replace("ORDER BY utimestamp DESC", - "GROUP BY utimestamp ORDER BY utimestamp DESC", - $sql_body); - $sql_count = "SELECT count(DISTINCT utimestamp) " . $sql_body; - break; - case "oracle": - $sql_count = "SELECT count(*) " . $sql_body; - break; + if (empty($module_data)) { + $result = array(); } - - $count = db_get_value_sql ($sql_count, $conexion); - - - switch ($config["dbtype"]) { - case "mysql": - $sql .= " LIMIT " . $offset . "," . $block_size; - break; - case "postgresql": - $sql .= " LIMIT " . $block_size . " OFFSET " . $offset; - break; - case "oracle": - $set = array(); - $set['limit'] = $block_size; - $set['offset'] = $offset; - $sql = oracle_recode_query ($sql, $set); - break; - } - - $result = db_get_all_rows_sql ($sql, false, true, $conexion); - - if ($result === false) { - $result = array (); - } - - if (($config['dbtype'] == 'oracle') && ($result !== false)) { - for ($i=0; $i < count($result); $i++) { - unset($result[$i]['rnum']); - } + else { + // Paginate the result + $result = array_slice($module_data, $offset, $block_size); } $table->width = '98%'; @@ -293,8 +209,8 @@ if ($get_module_detail) { $index++; } - $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', - 'nombre', 'web_content_string'); + $id_type_web_content_string = db_get_value('id_tipo', + 'ttipo_modulo', 'nombre', 'web_content_string'); foreach ($result as $row) { $data = array (); diff --git a/pandora_console/include/ajax/template_wizard.ajax.php b/pandora_console/include/ajax/template_wizard.ajax.php deleted file mode 100644 index 46e4da34f0..0000000000 --- a/pandora_console/include/ajax/template_wizard.ajax.php +++ /dev/null @@ -1,65 +0,0 @@ - $v) { - $agents_aux[$keys_prefix . $k] = $v; - //unset($agents[$k]); - } - } - $agents = $agents_aux; - } - - echo json_encode ($agents); - return; -} -?> diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index d4d85a1626..31b74fb55f 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150108'; +$build_version = 'PC150116'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index da7cbc39aa..22e1da590d 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -159,7 +159,6 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f if (($id_agent !== false) && ($idGroup !== false)) { $groups = users_get_groups($config["id_user"]); - //$where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); if ($idGroup != 0) { //All group $subQuery = 'SELECT id_agente_modulo FROM tagente_modulo @@ -215,7 +214,6 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f $selectText = 'COUNT(talert_template_modules.id) AS count'; } - $sql = sprintf ("SELECT %s FROM talert_template_modules INNER JOIN tagente_modulo t2 @@ -227,7 +225,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f WHERE id_agent_module in (%s) %s %s %s", $selectText, $subQuery, $where, $filter, $orderbyText); $alerts = db_get_all_rows_sql ($sql); - + if ($alerts === false) return array (); @@ -1183,8 +1181,6 @@ function agents_get_modules ($id_agent = null, $details = false, break; } - //html_debug_print($sql); - $result = db_get_all_rows_sql ($sql); if (empty ($result)) { diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 44feff82a0..47ba471751 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1573,8 +1573,6 @@ function get_group_alerts($id_group, $filter = '', $options = false, if ($id_group !== false) { $groups = users_get_groups($config["id_user"], "AR"); - //$where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); - if ($id_group != 0) { if (is_array($id_group)) { if (in_array(0, $id_group)) { @@ -1596,6 +1594,7 @@ function get_group_alerts($id_group, $filter = '', $options = false, FROM tagente WHERE id_grupo IN (' . implode(',', $id_group) . '))'; + } } else { @@ -1666,7 +1665,7 @@ function get_group_alerts($id_group, $filter = '', $options = false, WHERE id_agent_module in (%s) %s %s %s", $selectText, $subQuery, $where, $filter, $orderbyText); $alerts = db_get_all_rows_sql ($sql); - + if ($alerts === false) return array (); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 1506d1c262..5abbf7e7d2 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2369,7 +2369,9 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = } // Add tags condition to filter - $tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); + $user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); + $acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict); + $tags_condition = " AND (".tags_get_acl_tags_event_condition($acltags, false, $user_strict).")"; //This will give the distinct id_agente, give the id_grupo that goes //with it and then the number of times it occured. GROUP BY statement @@ -2463,7 +2465,9 @@ function grafico_eventos_total($filter = "", $width = 320, $height = 200) { $filter = str_replace ( "\\" , "", $filter); // Add tags condition to filter - $tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); + $user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); + $acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict); + $tags_condition = " AND (".tags_get_acl_tags_event_condition($acltags, false, $user_strict).")"; $filter .= $tags_condition; $data = array (); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index ab2e190ce6..b49c293957 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1218,14 +1218,12 @@ function groups_agent_total($group_array, $strict_user = false, $id_group_strict $group_clause = "(" . $group_clause . ")"; if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled = 0 AND id_grupo = ".$id_group_strict . $tags_clause; - $count = db_get_sql($sql); } else { @@ -1397,7 +1395,6 @@ function groups_monitor_ok ($group_array, $strict_user = false, $id_group_strict if ($strict_user) { $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_estado.estado = 0 @@ -1432,7 +1429,6 @@ function groups_monitor_critical ($group_array, $strict_user = false, $id_group_ if ($strict_user) { - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo @@ -1467,7 +1463,6 @@ function groups_monitor_warning ($group_array, $strict_user = false, $id_group_s $group_clause = "(" . $group_clause . ")"; if ($strict_user) { - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo @@ -1537,7 +1532,6 @@ function groups_monitor_alerts ($group_array, $strict_user = false, $id_group_st $group_clause = "(" . $group_clause . ")"; if ($strict_user) { - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $sql = "SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente @@ -1549,9 +1543,7 @@ function groups_monitor_alerts ($group_array, $strict_user = false, $id_group_st $tags_clause"; $count = db_get_sql ($sql); return $count; - } else { - //TODO REVIEW ORACLE AND POSTGRES return db_get_sql ("SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente @@ -1581,7 +1573,6 @@ function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_gr $group_clause = "(" . $group_clause . ")"; if ($strict_user) { - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $sql = "SELECT COUNT(talert_template_modules.id) @@ -1805,6 +1796,8 @@ function groups_get_tree(&$groups, $parent = false) { return $return; } + + function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { global $config; @@ -1819,10 +1812,12 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { $propagate = db_get_value('propagate','tgrupo','id_grupo',$parent); if ($propagate == 1) { + //$childrens_ids_parent = array($parent); $hierarchy[] = $parent; $childrens = groups_get_childrens($parent); if (!empty($childrens)) { foreach ($childrens as $child) { + //$childrens_ids_parent[] = (int)$child['id_grupo']; $hierarchy[] = (int)$child['id_grupo']; } } @@ -1900,6 +1895,23 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $i = 1; $list[0]['_id_'] = 0; $list[0]['_name_'] = __('All'); + + $list[0]['_agents_unknown_'] = 0; + $list[0]['_monitors_alerts_fired_'] = 0; + $list[0]['_total_agents_'] = 0; + $list[0]['_monitors_ok_'] = 0; + $list[0]['_monitors_critical_'] = 0; + $list[0]['_monitors_warning_'] = 0; + $list[0]['_monitors_unknown_'] = 0; + $list[0]['_monitors_not_init_'] = 0; + $list[0]['_agents_not_init_'] = 0; + + if ($mode == 'tactical') { + $list[0]['_agents_ok_'] = 0; + $list[0]['_agents_warning_'] = 0; + $list[0]['_agents_critical_'] = 0; + $list[0]['_monitors_alerts_'] = 0; + } } else { $i = 0; } @@ -1924,13 +1936,6 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"]; $list[$i]['_total_agents_'] = $group_stat[0]["agents"]; - if ($mode == 'tactical' || $mode == 'tree') { - $list[$i]['_agents_ok_'] = $group_stat[0]["normal"]; - $list[$i]['_agents_warning_'] = $group_stat[0]["warning"]; - $list[$i]['_agents_critical_'] = $group_stat[0]["critical"]; - $list[$i]['_monitors_alerts_'] = $group_stat[0]["alerts"]; - } - // This fields are not in database $list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id); $list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id); @@ -1939,6 +1944,62 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id); $list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id); + if ($mode == 'tactical' || $mode == 'tree') { + $list[$i]['_agents_ok_'] = $group_stat[0]["normal"]; + $list[$i]['_agents_warning_'] = $group_stat[0]["warning"]; + $list[$i]['_agents_critical_'] = $group_stat[0]["critical"]; + $list[$i]['_monitors_alerts_'] = $group_stat[0]["alerts"]; + + $list[$i]["_monitor_alerts_fire_count_"] = $group_stat[0]["alerts_fired"]; + $list[$i]["_total_checks_"] = $group_stat[0]["modules"]; + $list[$i]["_total_alerts_"] = $group_stat[0]["alerts"]; + } + if ($mode == 'tactical') { + // Get total count of monitors for this group, except disabled. + $list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"]; + + // Calculate not_normal monitors + $list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"]; + + if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_monitor_health_"] = 100; + } + + if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_module_sanity_"] = 100; + } + + if (isset($list[$i]["_alerts_"])) { + if ($list[$i]["_monitors_alerts_fired_"] > 0 && $list[$i]["_alerts_"] > 0) { + $list[$i]["_alert_level_"] = format_numeric (100 - ($list[$i]["_monitors_alerts_fired_"] / ($list[$i]["_alerts_"] / 100)), 1); + } + else { + $list[$i]["_alert_level_"] = 100; + } + } + else { + $list[$i]["_alert_level_"] = 100; + $list[$i]["_alerts_"] = 0; + } + + $list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"]; + + if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_global_health_"] = 100; + } + + $list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1); + } + if ($returnAllGroup) { $list[0]['_agents_unknown_'] += $group_stat[0]["unknown"]; $list[0]['_monitors_alerts_fired_'] += $group_stat[0]["alerts_fired"]; @@ -1948,7 +2009,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; $list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_']; - $list[0]['_agents_not_init'] += $list[$i]['_agents_not_init']; + $list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_']; if ($mode == 'tactical' || $mode == 'tree') { $list[0]['_agents_ok_'] += $group_stat[0]["normal"]; @@ -1993,6 +2054,54 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $list[$i]['_agents_warning_'] = groups_agent_warning ($id, $user_strict, $id); $list[$i]['_agents_critical_'] = groups_agent_critical ($id, $user_strict, $id); $list[$i]['_monitors_alerts_'] = groups_monitor_alerts ($id, $user_strict, $id); + + // TODO + //~ $list[$i]["_total_checks_"] + //~ $list[$i]["_total_alerts_"] + + // Get total count of monitors for this group, except disabled. + $list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"]; + + // Calculate not_normal monitors + $list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"]; + + if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_monitor_health_"] = 100; + } + + if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_module_sanity_"] = 100; + } + + if (isset($list[$i]["_alerts_"])) { + if ($list[$i]["_monitors_alerts_fired_"] > 0 && $list[$i]["_alerts_"] > 0) { + $list[$i]["_alert_level_"] = format_numeric (100 - ($list[$i]["_monitors_alerts_fired_"] / ($list[$i]["_alerts_"] / 100)), 1); + } + else { + $list[$i]["_alert_level_"] = 100; + } + } + else { + $list[$i]["_alert_level_"] = 100; + $list[$i]["_alerts_"] = 0; + } + + $list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"]; + + if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_global_health_"] = 100; + } + + $list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1); } if ($returnAllGroup) { @@ -2004,7 +2113,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; $list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_']; - $list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init']; + $list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_']; if ($mode == 'tactical' || $mode == 'tree') { $list[0]['_agents_ok_'] += $list[$i]['_agents_ok_']; @@ -2095,7 +2204,7 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access = if ($id_user == false) { $id_user = $config['id_user']; } - + $acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict); if (! defined ('METACONSOLE')) { @@ -2113,6 +2222,7 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access = $result_list = array (); foreach ($servers as $server) { + if (metaconsole_connect($server) != NOERR) { continue; } @@ -2120,6 +2230,7 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access = foreach ($server_list as $server_item) { if (! isset ($result_list[$server_item['_name_']])) { + $result_list[$server_item['_name_']] = $server_item; } else { @@ -2135,6 +2246,19 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access = $result_list[$server_item['_name_']]['_agents_critical_'] += $server_item['_agents_critical_']; $result_list[$server_item['_name_']]['_agents_warning_'] += $server_item['_agents_warning_']; $result_list[$server_item['_name_']]['_monitors_alerts_'] += $server_item['_monitors_alerts_']; + + $result_list[$server_item['_name_']]["_monitor_checks_"] += $server_item["_monitor_checks_"]; + $result_list[$server_item['_name_']]["_monitor_not_normal_"] += $server_item["_monitor_not_normal_"]; + $result_list[$server_item['_name_']]["_monitor_health_"] += $server_item["_monitor_health_"]; + $result_list[$server_item['_name_']]["_module_sanity_"] += $server_item["_module_sanity_"]; + $result_list[$server_item['_name_']]["_alerts_"] += $server_item["_alerts_"]; + $result_list[$server_item['_name_']]["_alert_level_"] += $server_item["_alert_level_"]; + $result_list[$server_item['_name_']]["_monitor_bad_"] += $server_item["_monitor_bad_"]; + $result_list[$server_item['_name_']]["_global_health_"] += $server_item["_global_health_"]; + $result_list[$server_item['_name_']]["_server_sanity_"] += $server_item["_server_sanity_"]; + $result_list[$server_item['_name_']]["_monitor_alerts_fire_count_"] += $server_item["_monitor_alerts_fire_count_"]; + $result_list[$server_item['_name_']]["_total_checks_"] += $server_item["_total_checks_"]; + $result_list[$server_item['_name_']]["_total_alerts_"] += $server_item["_total_alerts_"]; } } } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 7e48edfe79..0086ff0c8a 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -371,7 +371,7 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $keys_field = 'id_grupo', $strict_user = false) { global $config; - + $fields = users_get_groups_for_select($id_user, $privilege, $returnAllGroup, true, $id_group, $keys_field); diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 2844fdd3df..f4e084fba2 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -333,16 +333,6 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $node_ref[$agent['id_agente']] = $node_count; - // Save node parent information to define edges later - if ($agent['id_parent'] != "0" && - array_key_exists($agent['id_parent'], $node_ref)) { - - $parents[$node_count] = $node_ref[$agent['id_parent']]; - } - else { - $orphans[$node_count] = 1; - } - $agent['id_node'] = $node_count; $agent['type'] = 'agent'; @@ -389,6 +379,19 @@ function networkmap_generate_dot ($pandora_name, $group = 0, } } + // Addded the relationship of parents of agents + foreach ($agents as $agent) { + if ($agent['id_parent'] != "0" && + array_key_exists($agent['id_parent'], $node_ref)) { + + + $parents[$node_ref[$agent['id_agente']]] = $node_ref[$agent['id_parent']]; + } + else { + $orphans[$node_ref[$agent['id_agente']]] = 1; + } + } + // Drop the modules without a partner if l2_network is true // and the snmp interfaces token is false if ($l2_network) { @@ -1554,6 +1557,27 @@ function networkmap_delete_networkmap ($id_networkmap) { return @db_process_sql_delete ('tnetwork_map', array ('id_networkmap' => $id_networkmap)); } +/** + * Deletes a network map if the property is that user. + * + * @param string User id that call this funtion. + * @param int Map id to be deleted. + * + * @return bool True if the map was deleted, false the map is not yours. + */ +function networkmap_delete_user_networkmap ($id_user = '', $id_networkmap) { + if ($id_user == '') { + $id_user = $config['id_user']; + } + $id_networkmap = safe_int ($id_networkmap); + if (empty ($id_networkmap)) + return false; + $networkmap = networkmap_get_networkmap ($id_networkmap); + if ($networkmap === false) + return false; + return @db_process_sql_delete ('tnetwork_map', array ('id_networkmap' => $id_networkmap, 'id_user' => $id_user)); +} + /** * Updates a network map. * diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 1665fe1999..8d58420a16 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1563,7 +1563,7 @@ function reporting_get_stats_summary($data, $graph_width, $graph_height) { return $output; } -function reporting_get_stats_alerts($data) { +function reporting_get_stats_alerts($data, $links = false) { global $config; // Link URLS @@ -1581,8 +1581,13 @@ function reporting_get_stats_alerts($data) { } else { $urls = array(); - $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; - $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired"; + if ($links) { + $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&pure=" . $config['pure']; + $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&filter=fired&pure=" . $config['pure']; + } else { + $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; + $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired"; + } } // Alerts table @@ -8045,4 +8050,262 @@ function reporting_network_interfaces_table ($content, $report, $mini, $item_tit } } } -?> \ No newline at end of file + +function reporting_get_agents_by_status ($data, $graph_width = 250, $graph_height = 150, $links = false) { + global $config; + + if ($links == false) { + $links = array(); + } + + $table_agent = html_get_predefined_table(); + + $agent_data = array(); + $agent_data[0] = html_print_image('images/agent_critical.png', true, array('title' => __('Agents critical'))); + $agent_data[1] = "".format_numeric($data['agent_critical']).""; + $agent_data[2] = html_print_image('images/agent_warning.png', true, array('title' => __('Agents warning'))); + $agent_data[3] = "".format_numeric($data['agent_warning']).""; + + $table_agent->data[] = $agent_data; + + $agent_data = array(); + $agent_data[0] = html_print_image('images/agent_ok.png', true, array('title' => __('Agents ok'))); + $agent_data[1] = "".format_numeric($data['agent_ok']).""; + $agent_data[2] = html_print_image('images/agent_unknown.png', true, array('title' => __('Agents unknown'))); + $agent_data[3] = "".format_numeric($data['agent_unknown']).""; + $table_agent->data[] = $agent_data; + + $agent_data = array(); + $agent_data[0] = html_print_image('images/agent_notinit.png', true, array('title' => __('Agents not init'))); + $agent_data[1] = "".format_numeric($data['agent_not_init']).""; + $table_agent->data[] = $agent_data; + + $agents_data = '
+ ' . + __('Agents by status') . + '' . + html_print_table($table_agent, true) . '
'; + + return $agents_data; +} + +function reporting_get_total_agents_and_monitors ($data, $graph_width = 250, $graph_height = 150) { + global $config; + + $total_agent = $data['agent_ok'] + $data['agent_warning'] + $data['agent_critical'] + $data['gent_unknown'] + $data['agent_not_init']; + $total_module = $data['monitor_ok'] + $data['monitor_warning'] + $data['monitor_critical'] + $data['monitor_unknown'] + $data['monitor_not_init']; + + $table_total = html_get_predefined_table(); + + $total_data = array(); + $total_data[0] = html_print_image('images/agent.png', true, array('title' => __('Total agents'))); + $total_data[1] = $total_agent <= 0 ? '-' : $total_agent; + $total_data[2] = html_print_image('images/module.png', true, array('title' => __('Monitor checks'))); + $total_data[3] = $total_module <= 0 ? '-' : $total_module; + $table_total->data[] = $total_data; + $total_agent_module = '
+ ' . + __('Total agents and monitors') . + '' . + html_print_table($table_total, true) . '
'; + + return $total_agent_module; +} + +function reporting_get_total_servers ($num_servers) { + global $config; + + $table_node = html_get_predefined_table(); + + $node_data = array(); + $node_data[0] = html_print_image('images/server_export.png', true, array('title' => __('Nodes'))); + $node_data[1] = "".format_numeric($num_servers).""; + $table_node->data[] = $node_data; + $node_overview = '
+ ' . + __('Node overview') . + '' . + html_print_table($table_node, true) . '
'; + return $node_overview; +} + +function reporting_get_events ($data, $links = false) { + global $config; + + $table_events->width = "100%"; + + $table_events->data[0][0] = html_print_image('images/agent_critical.png', true, array('title' => __('Critical events'))); + $table_events->data[0][0] .= "   "."".format_numeric($data['critical']).""; + + $table_events->data[0][1] = html_print_image('images/agent_warning.png', true, array('title' => __('Warning events'))); + $table_events->data[0][1] .= "   "."".format_numeric($data['warning']).""; + $table_events->data[0][2] = html_print_image('images/agent_ok.png', true, array('title' => __('OK events'))); + $table_events->data[0][2] .= "   "."".format_numeric($data['normal']).""; + $table_events->data[0][3] = html_print_image('images/agent_unknown.png', true, array('title' => __('Unknown events'))); + $table_events->data[0][3] .= "   "."".format_numeric($data['unknown']).""; + $table_events->data[0][4] = html_print_image('images/agent_notinit.png', true, array('title' => __('Not init events'))); + $table_events->data[0][4] .= "   "."".format_numeric($data['not_init']).""; + + $event_view = '
+ ' . + __('Events by criticity') . + '' . + html_print_table($table_events, true) . '
'; + + return $event_view; +} + +function reporting_get_last_activity() { + global $config; + + // Show last activity from this user + + $table->width = '100%'; + $table->data = array (); + $table->size = array (); + $table->size[2] = '150px'; + $table->size[3] = '130px'; + $table->size[5] = '200px'; + $table->head = array (); + $table->head[0] = __('User'); + $table->head[1] = ''; + $table->head[2] = __('Action'); + $table->head[3] = __('Date'); + $table->head[4] = __('Source IP'); + $table->head[5] = __('Comments'); + $table->title = '' . __('Last activity in Pandora FMS console') . ''; + + switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf ("SELECT id_usuario,accion,fecha,ip_origen,descripcion,utimestamp + FROM tsesion + WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - " . SECONDS_1WEEK . ") + AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 5", $config["id_user"]); + break; + case "postgresql": + $sql = sprintf ("SELECT \"id_usuario\", accion, fecha, \"ip_origen\", descripcion, utimestamp + FROM tsesion + WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - " . SECONDS_1WEEK . ") + AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 5", $config["id_user"]); + break; + case "oracle": + $sql = sprintf ("SELECT id_usuario, accion, fecha, ip_origen, descripcion, utimestamp + FROM tsesion + WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - " . SECONDS_1WEEK . ") + AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config["id_user"]); + break; + } + + $sessions = db_get_all_rows_sql ($sql); + + if ($sessions === false) + $sessions = array (); + + foreach ($sessions as $session) { + $data = array (); + + switch ($config["dbtype"]) { + case "mysql": + case "oracle": + $session_id_usuario = $session['id_usuario']; + $session_ip_origen = $session['ip_origen']; + break; + case "postgresql": + $session_id_usuario = $session['id_usuario']; + $session_ip_origen = $session['ip_origen']; + break; + } + + + $data[0] = '' . $session_id_usuario . ''; + $data[1] = ui_print_session_action_icon ($session['accion'], true); + $data[2] = $session['accion']; + $data[3] = ui_print_help_tip($session['fecha'], true) . human_time_comparation($session['utimestamp'], 'tiny'); + $data[4] = $session_ip_origen; + $data[5] = io_safe_output ($session['descripcion']); + + array_push ($table->data, $data); + } + + return html_print_table ($table, true); + +} + +function reporting_get_event_histogram ($events) { + global $config; + include_once ('../../include/graphs/functions_gd.php'); + $max_value = count($events); + + $ttl = 1; + $urlImage = ui_get_full_url(false, true, false, false); + + $colors = array( + EVENT_CRIT_MAINTENANCE => COL_MAINTENANCE, + EVENT_CRIT_INFORMATIONAL => COL_INFORMATIONAL, + EVENT_CRIT_NORMAL => COL_MINOR, + EVENT_CRIT_MINOR => COL_NORMAL, + EVENT_CRIT_WARNING => COL_WARNING, + EVENT_CRIT_MAJOR => COL_MAJOR, + EVENT_CRIT_CRITICAL => COL_CRITICAL + ); + + foreach ($events as $data) { + + switch ($data['criticity']) { + case 0: + $color = EVENT_CRIT_MAINTENANCE; + break; + case 1: + $color = EVENT_CRIT_INFORMATIONAL; + break; + case 2: + $color = EVENT_CRIT_NORMAL; + break; + case 3: + $color = EVENT_CRIT_WARNING; + break; + case 4: + $color = EVENT_CRIT_CRITICAL; + break; + case 5: + $color = EVENT_CRIT_MINOR; + break; + case 6: + $color = EVENT_CRIT_MAJOR; + break; + case 20: + $color = EVENT_CRIT_NOT_NORMAL; + break; + case 34: + $color = EVENT_CRIT_WARNING_OR_CRITICAL; + break; + } + $graph_data[] = array( + 'data' => $color, + 'utimestamp' => 1 + ); + } + + $table->width = '100%'; + $table->data = array (); + $table->size = array (); + $table->head = array (); + $table->title = '' . __('Events info (1hr.)') . ''; + $table->data[0][0] = "" ; + + if (!empty($graph_data)) { + $slicebar = slicesbar_graph($graph_data, $max_value, 700, 25, $colors, $config['fontpath'], $config['round_corner'], $urlImage, $ttl); + $table->data[0][0] = $slicebar; + } else { + $table->data[0][0] = __('No events'); + } + + $event_graph = '
+ ' . + __('Events info (1hr)') . + '' . + html_print_table($table, true) . '
'; + + return $event_graph; +} +?> diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index ba74a5f6cc..809f366a1f 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -107,7 +107,7 @@ function tags_total_agents ($id_tag, $groups_and_tags = array()) { * @return mixed Returns count of agents in normal status or false if they aren't. */ function tags_agent_ok ($id_tag, $groups_and_tags = array()) { - + $groups_clause = ""; if (!empty($groups_and_tags)) { $i = 0; @@ -556,12 +556,18 @@ function tags_update_policy_module_tag ($id_policy_module, $tags, $autocommit = * * @return mixed Array with module tags or false if something goes wrong. */ -function tags_get_module_tags ($id_agent_module) { - if (empty($id_agent_module)) +function tags_get_module_tags ($id, $policy = false) { + if (empty($id)) return false; - $tags = db_get_all_rows_filter('ttag_module', - array('id_agente_modulo' => $id_agent_module), false); + if ($policy) { + $tags = db_get_all_rows_filter('ttag_policy_module', + array('id_policy_module' => $id), false); + } + else { + $tags = db_get_all_rows_filter('ttag_module', + array('id_agente_modulo' => $id), false); + } if ($tags === false) return array(); @@ -859,7 +865,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { // Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression) if ($i == 0) - $condition .= ' ( '; + $condition .= ' ( '; // Group condition (The module belongs to an agent of the group X) // Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition @@ -886,7 +892,8 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query); $condition .= "($group_condition AND \n$tags_condition)\n"; - } + } + $i++; } @@ -1058,7 +1065,7 @@ function tags_get_user_tags($id_user = false, $access = 'AR') { if(empty($acl_column)) { return array(); } - + $query = sprintf("SELECT count(*) FROM tusuario_perfil, tperfil WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND @@ -1067,7 +1074,7 @@ function tags_get_user_tags($id_user = false, $access = 'AR') { $id_user, $acl_column); $profiles_without_tags = db_get_value_sql($query); - + if ($profiles_without_tags == 0) { return $all_tags; } @@ -1095,7 +1102,8 @@ function tags_get_user_tags($id_user = false, $access = 'AR') { } $user_tags[$id] = $all_tags[$id]; } - + + return $user_tags; } @@ -1608,7 +1616,6 @@ function tags_monitors_fired_alerts ($id_tag, $groups_and_tags = array()) { /* Return array with groups and their tags */ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $strict_user = false) { - global $config; if ($id_user == false) { @@ -1756,7 +1763,7 @@ function tags_get_monitors_alerts ($id_tag, $groups_and_tags = array()) { function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = array(), $filter = false, $fields = false, $meta = true, $strict_user = true) { global $config; - + // Avoid mysql error if (empty($id_tag)) return; @@ -1775,7 +1782,7 @@ function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = $groups_clause = ""; if ($strict_user) { if (!empty($groups_and_tags)) { - $groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo"); + $groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo"); } } else { $groups_clause = " AND tagente.id_grupo IN (".implode(',',$groups_and_tags).")"; @@ -1795,7 +1802,7 @@ function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = } } } - + $user_agents_sql = "SELECT ".$select_fields ." FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente @@ -1803,9 +1810,10 @@ function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = AND ttag_module.id_tag = " . $id_tag . $groups_clause . $search_sql . $void_agents . " ORDER BY tagente.nombre ASC"; - + + //return db_get_sql ($user_agents); $user_agents = db_get_all_rows_sql($user_agents_sql); - + if (!$meta){ $user_agents_aux = array(); if ($user_agents === false) { diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 19aee51f0f..bb41341d0d 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -551,23 +551,24 @@ function treeview_printTree($type) { $first = true; foreach ($list as $item) { $lessBranchs = 0; + $tree_img_id = "tree_image_" . $type . "__" . $item['_id_']; if ($first) { if ($item != end($list)) { - $img = html_print_image ("operation/tree/first_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image_" . $type . "_" . $item['_id_'], "pos_tree" => "0")); + $img = html_print_image ("operation/tree/first_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "0")); $first = false; } else { $lessBranchs = 1; - $img = html_print_image ("operation/tree/one_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image_" . $type . "_" . $item['_id_'], "pos_tree" => "1")); + $img = html_print_image ("operation/tree/one_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "1")); } } else { if ($item != end($list)) - $img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image_" . $type . "_" . $item['_id_'], "pos_tree" => "2")); + $img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "2")); else { $lessBranchs = 1; - $img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image_" . $type . "_" . $item['_id_'], "pos_tree" => "3")); + $img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "3")); } } @@ -604,7 +605,7 @@ function treeview_printTree($type) { echo ') '. ""; - echo "
"; + echo "
"; echo "\n"; } echo "\n"; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 87e3211a85..5d5b23d768 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1243,7 +1243,7 @@ function ui_process_page_head ($string, $bitfield) { $_GET['sec2'] == 'operation/snmpconsole/snmp_view' || $_GET['sec2'] == 'enterprise/dashboard/main_dashboard') { - $query = ui_get_url_refresh (false); + $query = ui_get_url_refresh (false, false); $output .= ''; @@ -1256,8 +1256,8 @@ function ui_process_page_head ($string, $bitfield) { - - + + @@ -2141,8 +2141,13 @@ function ui_toggle($code, $name, $title = '', $hidden_default = true, $return = function ui_get_url_refresh ($params = false, $relative = true, $add_post = true) { // Agent selection filters and refresh global $config; - $url = ''; - + + // slerena, 8/Ene/2015 - Need to put index.php on URL which have it. + if (strpos($_SERVER['REQUEST_URI'], 'index.php') === false) + $url = ''; + else + $url = 'index.php'; + if (sizeof ($_REQUEST)) { //Some (old) browsers don't like the ?&key=var $url .= '?'; @@ -2221,6 +2226,7 @@ function ui_get_url_refresh ($params = false, $relative = true, $add_post = true } $url = htmlspecialchars ($url); + if (! $relative) { return ui_get_full_url ($url); } diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 8e0efcc478..79f578268f 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -335,10 +335,10 @@ function visual_map_print_item($mode = "read", $layoutData, } else if ($is_a_link_to_other_visualconsole) { if (empty($layout_data['id_metaconsole'])) { - $url_vc = $config['homeurl'] . "index.php?sec=reporting&sec2=operation/visual_console/render_view&pure=" . $config["pure"] . "&id=" . $layout_data["id_layout_linked"]; + $url = $config['homeurl'] . "index.php?sec=reporting&sec2=operation/visual_console/render_view&pure=" . $config["pure"] . "&id=" . $layoutData["id_layout_linked"]; } else { - $url_vc = "index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=1&id_visualmap=" . $layout_data["id_layout_linked"] . "&refr=0"; + $url = "index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=1&id_visualmap=" . $layoutData["id_layout_linked"] . "&refr=0"; } } else { @@ -371,9 +371,24 @@ function visual_map_print_item($mode = "read", $layoutData, break; case GROUP_ITEM: - $url = $config['homeurl'] . - 'index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' . - $layoutData['id_group']; + $is_a_link_to_other_visualconsole = false; + if ($layoutData['id_layout_linked'] != 0) { + $is_a_link_to_other_visualconsole = true; + } + + if ($is_a_link_to_other_visualconsole) { + if (empty($layout_data['id_metaconsole'])) { + $url = $config['homeurl'] . "index.php?sec=reporting&sec2=operation/visual_console/render_view&pure=" . $config["pure"] . "&id=" . $layoutData["id_layout_linked"]; + } + else { + $url = "index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=1&id_visualmap=" . $layoutData["id_layout_linked"] . "&refr=0"; + } + } + else { + $url = $config['homeurl'] . + 'index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' . + $layoutData['id_group']; + } break; case LABEL: if ($layoutData['id_layout_linked'] != 0) { @@ -1916,34 +1931,78 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { $id_layout = (int) $id_layout; - $result = db_get_all_rows_filter ('tlayout_data', array ('id_layout' => $id_layout), - array ('id_agente_modulo', 'parent_item', 'id_layout_linked', 'id_agent', 'type')); + $result = db_get_all_rows_filter ('tlayout_data', + array ('id_layout' => $id_layout), + array ( + 'id_agente_modulo', + 'id_group', + 'parent_item', + 'id_layout_linked', + 'id_agent', + 'type')); if ($result === false) return VISUAL_MAP_STATUS_NORMAL; - foreach ($result as $rownum => $data) { - if (($data["id_layout_linked"] == 0 && $data["id_agente_modulo"] == 0 && $data["id_agent"] == 0) || $data['type'] != 0) - continue; - // Other Layout (Recursive!) - if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) { - $status = visual_map_get_layout_status ($data["id_layout_linked"], $depth); + foreach ($result as $data) { + switch ($data['type']) { + case GROUP_ITEM: + if ($data["id_layout_linked"] == 0) { + $group_status = groups_get_status($data['id_group']); + switch ($group_status) { + case AGENT_STATUS_ALERT_FIRED: + $status = VISUAL_MAP_STATUS_CRITICAL_ALERT; + break; + case AGENT_STATUS_CRITICAL: + $status = VISUAL_MAP_STATUS_CRITICAL_BAD; + break; + case AGENT_STATUS_WARNING: + $status = VISUAL_MAP_STATUS_WARNING; + break; + case AGENT_STATUS_UNKNOWN: + $status = VISUAL_MAP_STATUS_UNKNOWN; + break; + case AGENT_STATUS_NORMAL: + default: + $status = VISUAL_MAP_STATUS_NORMAL; + break; + } + } + else { + $status = visual_map_get_layout_status( + $data["id_layout_linked"], $depth); + } + break; + default: + if (($data["id_layout_linked"] == 0 && + $data["id_agente_modulo"] == 0 && + $data["id_agent"] == 0) || + $data['type'] != 0) + continue; + + // Other Layout (Recursive!) + if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) { + $status = visual_map_get_layout_status($data["id_layout_linked"], $depth); + } + // Module + elseif ($data["id_agente_modulo"] != 0) { + $status = modules_get_agentmodule_status($data["id_agente_modulo"]); + + } + // Agent + else { + //-------------------------------------------------- + // ADDED NO CHECK ACL FOR AVOID CHECK TAGS THAT + // MAKE VERY SLOW THE VISUALMAPS WITH ACL TAGS + //-------------------------------------------------- + + $status = agents_get_status($data["id_agent"], true); + } + break; } - // Module - elseif ($data["id_agente_modulo"] != 0) { - $status = modules_get_agentmodule_status ($data["id_agente_modulo"]); - } - // Agent - else { - //-------------------------------------------------- - // ADDED NO CHECK ACL FOR AVOID CHECK TAGS THAT - // MAKE VERY SLOW THE VISUALMAPS WITH ACL TAGS - //-------------------------------------------------- - - $status = agents_get_status ($data["id_agent"], true); - } if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) return VISUAL_MAP_STATUS_CRITICAL_BAD; + if ($status > $temp_total) $temp_total = $status; } diff --git a/pandora_console/include/help/en/help_inventory_tab.php b/pandora_console/include/help/en/help_inventory_tab.php index 7980773254..83150650ea 100644 --- a/pandora_console/include/help/en/help_inventory_tab.php +++ b/pandora_console/include/help/en/help_inventory_tab.php @@ -9,7 +9,7 @@ Next are described the fields that you should complete to add an Inventory Modul
    Module: Combo where you can choose the Inventory Module that you want to add. It will only show the modules which Operative System will match up with that from the agent.
    Target: IP or servername from you want to get the inventory.
    Interval: Combo where you choose the time interval in which the Inventory Module will ve executed.
-
    Username: User that will ve used to execute the Inventory Module.
+
    Username: User that will be used to execute the Inventory Module.
    Password: User Password that will be used to execute the Inventory Module.

You can apply changes in all modules clicking in "Update all" when update any module. diff --git a/pandora_console/index.php b/pandora_console/index.php index 335b283dc9..a92726bb30 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -372,6 +372,9 @@ if (! isset ($config['id_user'])) { case 'Dashboard': $_GET["sec"] = "dashboard"; $_GET["sec2"] = ENTERPRISE_DIR.'/dashboard/main_dashboard'; + $id_dashboard_select = + db_get_value('id', 'tdashboard', 'name', $home_url); + $_GET['id_dashboard_select'] = $id_dashboard_select; break; case 'Visual console': $_GET["sec"] = "visualc"; diff --git a/pandora_console/install.php b/pandora_console/install.php index 54948ec47e..491acc5e32 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@

"; + $updated_time .= __('Last update'). " : ". ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); + $updated_time .= ""; } else { $updated_time = __("Updated at realtime"); } // Header -ui_print_page_header (__("Group view"), "images/group.png", false, "", false, $updated_time ); +ui_print_page_header (__("Group view"), "images/group.png", false, "", false, $updated_time); -if (tags_has_user_acl_tags()) { - ui_print_tags_warning(); + +$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); +//Groups and tags +$result_groups = group_get_groups_list($config['id_user'], $strict_user, 'AR', true, true); + +$count = count($result_groups); + +if ($count == 1) { + if ($result_groups[0]['_id_'] == 0) { + unset($result_groups[0]); + } } +ui_pagination($count); -// Init vars -$groups_info = array (); -$counter = 1; +if (!empty($result_groups)) { -$agents = agents_get_group_agents(array_keys($groups)); - -$offset = (int)get_parameter('offset', 0); - -if (count($agents) > 0) { - $groups_get_groups_with_agent = groups_get_groups_with_agent($config['id_user'], "AR", true, true); - ui_pagination(count($groups_get_groups_with_agent)); - echo ''; - echo ""; - echo ""; - //echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - $printed_groups = array(); - - // For each valid group for this user, take data from agent and modules - $table_rows = array(); - foreach ($groups as $id_group => $group) { - $rows = groups_get_group_row($id_group, $groups, $group, $printed_groups); - if (!is_array_empty($rows)) { - $table_rows += $rows; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + foreach ($result_groups as $data) { + + // Calculate entire row color + if ($data["_monitors_alerts_fired_"] > 0){ + $color_class = 'group_view_alrm'; + $status_image = ui_print_status_image ('agent_alertsfired_ball.png', "", true); + } + elseif ($data["_monitors_critical_"] > 0) { + $color_class = 'group_view_crit'; + $status_image = ui_print_status_image ('agent_critical_ball.png', "", true); + } + elseif ($data["_monitors_warning_"] > 0) { + $color_class = 'group_view_warn'; + $status_image = ui_print_status_image ('agent_warning_ball.png', "", true); + } + elseif (($data["_monitors_unknown_"] > 0) || ($data["_agents_unknown_"] > 0)) { + $color_class = 'group_view_unk'; + $status_image = ui_print_status_image ('agent_no_monitors_ball.png', "", true); + } + elseif ($data["_monitors_ok_"] > 0) { + $color_class = 'group_view_ok'; + $status_image = ui_print_status_image ('agent_ok_ball.png', "", true); + } + else { + $color_class = ''; + $status_image = ui_print_status_image ('agent_no_data_ball.png', "", true); + } + + echo ""; + + // Force + echo ""; + + $prefix = ""; + if (!isset($data['_is_tag_'])) { + if ($data['_id_'] != 0) { + $prefix = '    '; + } + } + + // Groupname + echo ""; + + // Total agents + echo ""; + + // Agents unknown + echo ""; + + // Agents not init + echo ""; + + // Monitors unknown + echo ""; + + // Monitors not init + echo ""; + + // Monitors OK + echo ""; + + // Monitors Warning + echo ""; + + // Monitors Critical + echo ""; + + // Alerts fired + echo "'; + + echo ""; } - } - - $table_rows = array_slice($table_rows, $offset, $config['block_size']); - foreach ($table_rows as $row) { - echo $row; - } - - echo "
" . __("Force") . "" . __("Status") . "" . __("Group") . "" . __("Agents") . "" . __("Agent unknown") . "" . __("Agents not init") . "" . __("Unknown") . "" . __("Not Init") . "" . __("Normal") . "" . __("Warning") . "" . __("Critical") . "" . __("Alert fired") . "
" . __("Force") . "" . __("Group") . "" . __("Agents") . "" . __("Agent unknown") . "" . __("Agents not init") . "" . __("Unknown") . "" . __("Not Init") . "" . __("Normal") . "" . __("Warning") . "" . __("Critical") . "" . __("Alert fired") . "
"; + if (!isset($data['_is_tag_']) && check_acl ($config['id_user'], $data['_id_'], "AW")) { + echo '' . + html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'))) . ''; + } + echo ""; + if (isset($data['_is_tag_'])) { + $deep = ""; + $link = ""; + } else { + $deep = groups_get_group_deep ($data['_id_']); + $link = ""; + } + + $group_name = "" . ui_print_truncate_text($data['_name_'], 50) . ""; + + $item_icon = ''; + if (isset($data['_iconImg_']) && !empty($data['_iconImg_'])) + $item_icon = $data['_iconImg_']; + + echo $link . $deep . $item_icon ." " . $group_name . ""; + + echo ""; + if (isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_total_agents_"] > 0) { + echo $link . $data["_total_agents_"] . ""; + } + echo ""; + if (isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_agents_unknown_"] > 0) { + echo $link . $data["_agents_unknown_"] . ""; + } + echo ""; + if (isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_agents_not_init_"] > 0) { + echo $link . $data["_agents_not_init_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_unknown_"] > 0) { + echo $link . $data["_monitors_unknown_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_not_init_"] > 0) { + echo $link . $data["_monitors_not_init_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_ok_"] > 0) { + echo $link . $data["_monitors_ok_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_warning_"] > 0) { + echo $link . $data["_monitors_warning_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_critical_"] > 0) { + echo $link . $data["_monitors_critical_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_alerts_fired_"] > 0){ + echo $link . $data["_monitors_alerts_fired_"] . ""; + } + echo '
"; - - ui_pagination(count($groups_get_groups_with_agent)); -} -else { + echo '
'; +} else { echo "
" . __('There are no defined agents') . "
"; } - -?> - +?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index 19ac0d15a1..0c05bd98b0 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -229,7 +229,7 @@ $combolist .= ''; $buttons['combolist'] = $combolist; -if (check_acl ($config['id_user'], 0, "AW")) { +if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $buttons['addmap'] = array('active' => $activeTab == false, 'text' => '' . html_print_image("images/add_mc.png", true, array ("title" => __('Add map'))) .''); diff --git a/pandora_console/operation/agentes/networkmap_list.php b/pandora_console/operation/agentes/networkmap_list.php index b6073eb656..5c716e38d6 100644 --- a/pandora_console/operation/agentes/networkmap_list.php +++ b/pandora_console/operation/agentes/networkmap_list.php @@ -38,23 +38,36 @@ if (is_ajax()) { $delete_networkmaps = (bool) get_parameter('delete_networkmaps'); if ($delete_networkmaps) { - if (! check_acl ($config['id_user'], 0, "AW")) { - db_pandora_audit("ACL Violation", + if ( check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM") ) { + if (check_acl ($config['id_user'], 0, "RW")) { + $result = false; + $results = array(); + $ids_networkmap = (array) get_parameter ('ids_networkmap'); + + foreach ($ids_networkmap as $id) { + $results[$id] = (bool) networkmap_delete_user_networkmap($config['id_user'], $id); + } + echo json_encode($results); + return; + }else{ + if (check_acl ($config['id_user'], 0, "RM")) { + $result = false; + $results = array(); + $ids_networkmap = (array) get_parameter ('ids_networkmap'); + + foreach ($ids_networkmap as $id) { + $results[$id] = (bool) networkmap_delete_networkmap($id); + } + echo json_encode($results); + return; + } + } + }else{ + db_pandora_audit("ACL Violation", "Trying to access Networkmap deletion"); echo json_encode(-1); return; } - - $result = false; - $results = array(); - $ids_networkmap = (array) get_parameter ('ids_networkmap'); - - foreach ($ids_networkmap as $id) { - $results[$id] = (bool) networkmap_delete_networkmap($id); - } - - echo json_encode($results); - return; } return; @@ -67,7 +80,13 @@ $id_networkmap = get_parameter ('id_networkmap', 0); $delete_networkmap = get_parameter ('delete_networkmap', 0); if ($delete_networkmap) { - $result = networkmap_delete_networkmap($id_networkmap); + if (check_acl ($config['id_user'], 0, "RW")) { + $result = networkmap_delete_user_networkmap($config['id_user'], $id_networkmap); + }else{ + if (check_acl ($config['id_user'], 0, "RM")) { + $result = networkmap_delete_networkmap($id_networkmap); + } + } $message = ui_print_result_message ($result, __('Network map deleted successfully'), __('Could not delete network map'), '', true); @@ -132,7 +151,7 @@ $table->size[0] = '80%'; $table->size[1] = '60px'; $table->size[2] = '30px'; -if (check_acl ($config["id_user"], 0, "AW")) { +if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $table->size[3] = '30px'; $table->size[4] = '30px'; } @@ -141,7 +160,7 @@ $table->head = array(); $table->head[0] = __('Name'); $table->head[1] = __('Type'); $table->head[2] = __('Group'); -if (check_acl ($config["id_user"], 0, "AW")) { +if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $table->head[3] = __('Edit'); $table->head[4] = __('Delete'); // Checkbox to select all the another checkboxes @@ -187,7 +206,7 @@ else { $data[1] = $network_map['type']; $data[2] = ui_print_group_icon ($network_map['id_group'], true); - if (check_acl ($config["id_user"], 0, "AW")) { + if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $data[3] = '' . html_print_image("images/config.png", true) . ''; $data[4] = '' . html_print_image('images/cross.png', true) . ''; // The value of the checkbox will be the networkmap id to recover it in js to perform the massive deletion @@ -201,7 +220,7 @@ else { } // Create networkmap form -if (check_acl ($config['id_user'], 0, "AW")) { +if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $table_manage = new StdClass(); $table_manage->width = "100%"; $table_manage->style = array(); @@ -349,4 +368,4 @@ if (check_acl ($config['id_user'], 0, "AW")) { } } - \ No newline at end of file + diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 755ee8e2a3..03d1e855c1 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -907,6 +907,10 @@ if (! defined ('METACONSOLE')) { '' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleNameDown, "alt" => "down")) . ''; } +/* +$table->head[4] = __('Tags'); +*/ + $table->head[5] = __('Interval'); if (! defined ('METACONSOLE')) { $table->head[5] .= ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '' . diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index 44e19ca3a1..b0dacdf8ed 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -32,6 +32,7 @@ if (! check_acl ($config['id_user'], 0, "AR")) { } $is_admin = check_acl ($config['id_user'], 0, "PM"); +$user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); $force_refresh = get_parameter ("force_refresh", ""); if ($force_refresh == 1) { @@ -49,10 +50,69 @@ else { // Header ui_print_page_header (__("Tactical view"), "images/op_monitoring.png", false, "", false, $updated_time); -$data = reporting_get_group_stats(); -if (tags_has_user_acl_tags()) { - ui_print_tags_warning(); +$all_data = group_get_groups_list($config['id_user'], $user_strict, 'AR', true, false, 'tactical'); + +$data = array(); +$data['monitor_checks'] = 0; +$data['monitor_not_init'] = 0; +$data['monitor_unknown'] = 0; +$data['monitor_ok'] = 0; +$data['monitor_bad'] = 0; +$data['monitor_warning'] = 0; +$data['monitor_critical'] = 0; +$data['monitor_not_normal'] = 0; +$data['monitor_alerts'] = 0; +$data['monitor_alerts_fired'] = 0; +$data['monitor_alerts_fire_count'] = 0; +$data['total_agents'] = 0; +$data['total_alerts'] = 0; +$data['total_checks'] = 0; +$data['alerts'] = 0; +$data['agents_unknown'] = 0; +$data['monitor_health'] = 0; +$data['alert_level'] = 0; +$data['module_sanity'] = 0; +$data['server_sanity'] = 0; +$data['agent_ok'] = 0; +$data['agent_warning'] = 0; +$data['agent_critical'] = 0; +$data['agent_unknown'] = 0; +$data['agent_not_init'] = 0; +$data['global_health'] = 0; +foreach ($all_data as $item) { + $data['monitor_checks'] += $item['_monitor_checks_']; + $data['monitor_not_init'] += $item['_monitors_not_init_']; + $data['monitor_unknown'] += $item['_monitors_unknown_']; + $data['monitor_ok'] += $item['_monitors_ok_']; + $data['monitor_bad'] += $item['_monitor_bad_']; + $data['monitor_warning'] += $item['_monitors_warning_']; + $data['monitor_critical'] += $item['_monitors_critical_']; + $data['monitor_not_normal'] += $item['_monitor_not_normal_']; + $data['monitor_alerts'] += $item['_monitors_alerts_']; + $data['monitor_alerts_fired'] += $item['_monitors_alerts_fired_']; + + if (isset($item['_total_agents_'])) + $data['total_agents'] += $item['_total_agents_']; + + if (isset($item['_total_alerts_'])) + $data['total_alerts'] += $item['_total_alerts_']; + + if (isset($item['_total_checks_'])) + $data['total_checks'] += $item['_total_checks_']; + + $data['alerts'] += $item['_alerts_']; + $data['agents_unknown'] += $item['_agents_unknown_']; + $data['monitor_health'] += $item['_monitor_health_']; + $data['alert_level'] += $item['_alert_level_']; + $data['module_sanity'] += $item['_module_sanity_']; + $data['server_sanity'] += $item['_server_sanity_']; + $data['agent_ok'] += $item['_agents_ok_']; + $data['agent_warning'] += $item['_agents_warning_']; + $data['agent_critical'] += $item['_agents_critical_']; + $data['agent_unknown'] += $item['_agents_unknown_']; + $data['agent_not_init'] += $item['_agents_not_init_']; + $data['global_health'] += $item['_global_health_']; } echo ''; @@ -123,9 +183,11 @@ echo ''; echo '
1 $tags_condition", 10, "100%"); +$acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict); +$tags_condition = tags_get_acl_tags_event_condition($acltags, false, $user_strict); + +events_print_event_table ("estado<>1 AND ($tags_condition)", 10, "100%"); // --------------------------------------------------------------------- // Server information @@ -138,4 +200,4 @@ if ($is_admin) { echo '
'; -?> +?> \ No newline at end of file diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index 3772123afa..2daade52aa 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -230,11 +230,12 @@ if (is_ajax ()) { } $less = $lessBranchs; + $tree_img_id = "tree_image" . $id . "_agent_" . $type . "_" . $row["server_name"] . "_" . $row["id_agente"]; if ($count != $countRows) - $img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image" . $id . "_agent_" . $type . "_" . $row["id_agente"], "pos_tree" => "2")); + $img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "2")); else { $less = $less + 2; // $less = $less or 0b10 - $img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image" . $id . "_agent_" . $type . "_" . $row["id_agente"], "pos_tree" => "3")); + $img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "3")); } echo "
  • "; echo " '0', "title" => __('Quiet'), "alt" => "")); } echo ""; - echo "
    "; + echo "
    "; echo "
  • "; } @@ -708,13 +709,11 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri * id_father int use in js and ajax php, its useful when you have a two subtrees with same agent for diferent each one */ function loadSubTree(type, div_id, less_branchs, id_father, server_name) { - hiddenDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id) - .attr('hiddenDiv'); - loadDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id) - .attr('loadDiv'); + var id = id_father + '_' + type + '_' + server_name + '_' + div_id; + var hiddenDiv = $('#tree_div' + id).attr('hiddenDiv'); + var loadDiv = $('#tree_div' + id).attr('loadDiv'); - pos = parseInt($('#tree_image' + id_father + '_' + type + '_' + div_id) - .attr('pos_tree')); + var pos = parseInt($('#tree_image' + id).attr('pos_tree')); //If has yet ajax request running if (loadDiv == 2) @@ -723,12 +722,12 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri if (loadDiv == 0) { //Put an spinner to simulate loading process - $('#tree_div' + id_father + '_' + type + '_' + div_id) + $('#tree_div' + id) .html(""); - $('#tree_div' + id_father + '_' + type + '_' + div_id) + $('#tree_div' + id) .show('normal'); - $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 2); + $('#tree_div'+id).attr('loadDiv', 2); $.ajax({ type: "POST", url: , @@ -745,9 +744,9 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri }, success: function(msg) { if (msg.length != 0) { - $('#tree_div'+id_father+'_'+type+'_'+div_id).hide(); - $('#tree_div'+id_father+'_'+type+'_'+div_id).html(msg); - $('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal'); + $('#tree_div'+id).hide(); + $('#tree_div'+id).html(msg); + $('#tree_div'+id).show('normal'); //change image of tree [+] to [-] switch (pos) { case 0: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/first_expanded.png'); + $('#tree_image'+id).attr('src',icon_path+'/first_expanded.png'); break; case 1: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/one_expanded.png'); + $('#tree_image'+id).attr('src',icon_path+'/one_expanded.png'); break; case 2: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/expanded.png'); + $('#tree_image'+id).attr('src',icon_path+'/expanded.png'); break; case 3: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/last_expanded.png'); + $('#tree_image'+id).attr('src',icon_path+'/last_expanded.png'); break; } - $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddendiv',0); - $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 1); + $('#tree_div'+id).attr('hiddendiv',0); + $('#tree_div'+id).attr('loadDiv', 1); } // Refresh forced title callback to work with html code created dinamicly @@ -790,22 +789,22 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri } ?> if (hiddenDiv == 0) { - $('#tree_div'+id_father+'_'+type+'_'+div_id).hide('normal'); - $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv',1); + $('#tree_div'+id).hide('normal'); + $('#tree_div'+id).attr('hiddenDiv',1); //change image of tree [-] to [+] switch (pos) { case 0: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/first_closed.png'); + $('#tree_image'+id).attr('src',icon_path+'/first_closed.png'); break; case 1: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/one_closed.png'); + $('#tree_image'+id).attr('src',icon_path+'/one_closed.png'); break; case 2: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/closed.png'); + $('#tree_image'+id).attr('src',icon_path+'/closed.png'); break; case 3: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/last_closed.png'); + $('#tree_image'+id).attr('src',icon_path+'/last_closed.png'); break; } } @@ -813,21 +812,21 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri //change image of tree [+] to [-] switch (pos) { case 0: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/first_expanded.png'); + $('#tree_image'+id).attr('src',icon_path+'/first_expanded.png'); break; case 1: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/one_expanded.png'); + $('#tree_image'+id).attr('src',icon_path+'/one_expanded.png'); break; case 2: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/expanded.png'); + $('#tree_image'+id).attr('src',icon_path+'/expanded.png'); break; case 3: - $('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/last_expanded.png'); + $('#tree_image'+id).attr('src',icon_path+'/last_expanded.png'); break; } - $('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal'); - $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv',0); + $('#tree_div'+id).show('normal'); + $('#tree_div'+id).attr('hiddenDiv',0); } } } diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index f785d33163..baaa0c9cb0 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 6.0dev -%define release 150108 +%define release 150116 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 37271cb263..d53bba045f 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 6.0dev -%define release 150108 +%define release 150116 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 73a746f383..b8438d6a83 100755 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -1029,7 +1029,7 @@ CREATE TABLE tusuario ( metaconsole_agents_manager NUMBER(10, 0) default 0 NOT NULL, metaconsole_assigned_server NUMBER(10, 0) default 0 NOT NULL, metaconsole_access_node NUMBER(10, 0) default 0 NOT NULL, - strict_acl NUMBER(5,0) unsigned NOT NULL DEFAULT 0, + strict_acl NUMBER(5,0) NOT NULL DEFAULT 0, CONSTRAINT t_usuario_metaconsole_access_cons CHECK (metaconsole_access IN ('basic','advanced')) ); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index 824293eb45..a78404a135 100755 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -911,7 +911,7 @@ CREATE TABLE "tusuario" ( "metaconsole_assigned_server" INTEGER NOT NULL default 0, "metaconsole_access_node" SMALLINT DEFAULT 0, "metaconsole_access" type_tusuario_metaconsole_access default 'basic', - "strict_acl" SMALLINT NOT NULL default 0 + "strict_acl" SMALLINT DEFAULT 0 ); -- ----------------------------------------------------- diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index b384adfa99..e7d41acd3b 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -38,7 +38,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('graph_res','5'), ('step_compact','1'), ('db_scheme_version','6.0dev'), -('db_scheme_build','PD150108'), +('db_scheme_build','PD150116'), ('show_unknown','0'), ('show_lastalerts','1'), ('style','pandora'), diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 1c04e147cf..c4f70d8332 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 6.0dev-150108 +Version: 6.0dev-150116 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index fe72c00055..ea3fc02b5a 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150108" +pandora_version="6.0dev-150116" package_cpan=0 package_pandora=1 diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 14e38f51a8..d542295d01 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -264,88 +264,95 @@ sub pandora_server_tasks ($) { my $counter = 0; while ($RUN == 1) { eval{ - # TASKS EXECUTED EVERY 5 SECONDS (Low latency tasks) - # -------------------------------------------------- - if (($counter % 5) == 0) { - - # Update forced alerts - pandora_exec_forced_alerts ($pa_config, $dbh); + if (pandora_is_master($pa_config) == 1) { - # Rotate Log File - pandora_rotate_logfile($pa_config); - } - - # TASKS EXECUTED EVERY 30 SECONDS (Mid latency tasks) - # --------------------------------------------------- - if (($counter % 30) == 0) { + # TASKS EXECUTED EVERY 5 SECONDS (Low latency tasks) + # -------------------------------------------------- + if (($counter % 5) == 0) { + + # Update forced alerts + pandora_exec_forced_alerts ($pa_config, $dbh); - # Update module status and fired alert counts - my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1)'); - foreach my $agent (@agents) { - logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10); - - if ($agent->{'update_module_count'} == 1) { - pandora_update_agent_module_count ($dbh, $agent->{'id_agente'}); - } - - if ($agent->{'update_alert_count'} == 1) { - pandora_update_agent_alert_count ($dbh, $agent->{'id_agente'}); - } - } - - # Keepalive module control.(very DB intensive, not run frecuently - pandora_module_keep_alive_nd ($pa_config, $dbh); - - # Set the status of unknown modules - pandora_module_unknown ($pa_config, $dbh); - - # Set event storm protection - pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0)); - } - - # TASKS EXECUTED EVERY 60 SECONDS (High latency tasks) - # ---------------------------------------------------- - if (($counter % 60) == 0) { - # Downtimes are executed only 30 x Server Threshold secs - pandora_planned_downtime ($pa_config, $dbh); - - # Realtime stats (Only master server!) - ( VERY HEAVY !) - # Realtimestats == 1, generated by WEB Console, not by server! - if (defined($pa_config->{"realtimestats"}) && $pa_config->{"realtimestats"} == 0){ - - # Check if I need to refresh stats - my $last_execution_stats = get_db_value ($dbh, "SELECT MAX(utimestamp) FROM tgroup_stat"); - if (!defined($last_execution_stats) || $last_execution_stats < (time() - $pa_config->{"stats_interval"})){ - pandora_group_statistics ($pa_config, $dbh); - pandora_server_statistics ($pa_config, $dbh); - } + # Rotate Log File + pandora_rotate_logfile($pa_config); } - # Event auto-expiry - my $expiry_time = $pa_config->{"event_expiry_time"}; - my $expiry_window = $pa_config->{"event_expiry_window"}; - if ($expiry_time > 0 && $expiry_window > 0 && $expiry_window > $expiry_time) { - my $time_ref = time (); - my $expiry_limit = $time_ref - $expiry_time; - my $expiry_window = $time_ref - $expiry_window; - db_do ($dbh, 'UPDATE tevento SET estado=1, ack_utimestamp=? WHERE estado=0 AND utimestamp < ? AND utimestamp > ?', $time_ref, $expiry_limit, $expiry_window); - } - } - - # Pandora self monitoring - if (defined($pa_config->{"self_monitoring"}) - && $pa_config->{"self_monitoring"} == 1 - && $counter % $pa_config->{'self_monitoring_interval'} == 0) { - pandora_self_monitoring ($pa_config, $dbh); - } - + # TASKS EXECUTED EVERY 30 SECONDS (Mid latency tasks) + # --------------------------------------------------- + if (($counter % 30) == 0) { - # Avoid counter overflow - if ($counter > 10000){ - $counter = 0; + # Update module status and fired alert counts + my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1)'); + foreach my $agent (@agents) { + logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10); + + if ($agent->{'update_module_count'} == 1) { + pandora_update_agent_module_count ($dbh, $agent->{'id_agente'}); + } + + if ($agent->{'update_alert_count'} == 1) { + pandora_update_agent_alert_count ($dbh, $agent->{'id_agente'}); + } + } + + # Keepalive module control.(very DB intensive, not run frecuently + pandora_module_keep_alive_nd ($pa_config, $dbh); + + # Set the status of unknown modules + pandora_module_unknown ($pa_config, $dbh); + + # Set event storm protection + pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0)); + } + + # TASKS EXECUTED EVERY 60 SECONDS (High latency tasks) + # ---------------------------------------------------- + if (($counter % 60) == 0) { + # Downtimes are executed only 30 x Server Threshold secs + pandora_planned_downtime ($pa_config, $dbh); + + # Realtime stats (Only master server!) - ( VERY HEAVY !) + # Realtimestats == 1, generated by WEB Console, not by server! + if (defined($pa_config->{"realtimestats"}) && $pa_config->{"realtimestats"} == 0){ + + # Check if I need to refresh stats + my $last_execution_stats = get_db_value ($dbh, "SELECT MAX(utimestamp) FROM tgroup_stat"); + if (!defined($last_execution_stats) || $last_execution_stats < (time() - $pa_config->{"stats_interval"})){ + pandora_group_statistics ($pa_config, $dbh); + pandora_server_statistics ($pa_config, $dbh); + } + } + + # Event auto-expiry + my $expiry_time = $pa_config->{"event_expiry_time"}; + my $expiry_window = $pa_config->{"event_expiry_window"}; + if ($expiry_time > 0 && $expiry_window > 0 && $expiry_window > $expiry_time) { + my $time_ref = time (); + my $expiry_limit = $time_ref - $expiry_time; + my $expiry_window = $time_ref - $expiry_window; + db_do ($dbh, 'UPDATE tevento SET estado=1, ack_utimestamp=? WHERE estado=0 AND utimestamp < ? AND utimestamp > ?', $time_ref, $expiry_limit, $expiry_window); + } + } + + # Pandora self monitoring + if (defined($pa_config->{"self_monitoring"}) + && $pa_config->{"self_monitoring"} == 1 + && $counter % $pa_config->{'self_monitoring_interval'} == 0) { + pandora_self_monitoring ($pa_config, $dbh); + } + + + # Avoid counter overflow + if ($counter > 10000){ + $counter = 0; + } + else { + $counter++; + } } else { - $counter++; + # Do an additional sleep if we are not the master server + sleep ($pa_config->{'server_threshold'}); } }; @@ -518,7 +525,7 @@ sub main() { pandora_startup (); # Start thread to execute server tasks on the master server - threads->create('pandora_server_tasks', (\%Config))->detach() if ($Config{"pandora_master"} == 1); + threads->create('pandora_server_tasks', (\%Config))->detach(); # Generate 'going up' events foreach my $server (@Servers) { @@ -568,9 +575,11 @@ sub main() { $server->update(); } - # Not needed. The console assumes a server is down if it has not updated its status in the last 15 minutes. - ## Update fallen servers - #db_do ($DBH, "UPDATE tserver SET status = 0 WHERE keepalive < ?", strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - $Config{'keepalive'}))); + # Update fallen servers + db_do ($DBH, "UPDATE tserver SET status = 0 WHERE keepalive < ?", strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - $Config{'keepalive'}))); + + # Set the master server + pandora_set_master(\%Config, $DBH); }; # Restart on error or auto restart diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 9673646fcd..7aacaa11d6 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -78,8 +78,9 @@ dbhost 127.0.0.1 verbosity 3 -# Master Server, 1 if master server (normal mode), 0 for slave mode (slave in multi-server setup) - +# Master Server priority. The running server with the highest master value will +# be the master. Ties are broken at random. If set to 0, this server will +# never become master. master 1 # Activate Pandora SNMP console (depending on snmptrapd) @@ -249,7 +250,7 @@ xprobe2 /usr/bin/xprobe2 nmap /usr/bin/nmap # Path to the fping binary. Used by the Enterprise ICMP Server. -fping /usr/bin/fping +fping /usr/sbin/fping # A value that specifies how aggressive nmap should be from 1 to 5. 1 means slower but more reliable, 5 means faster but less reliable. 2 by default. nmap_timing_template 2 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index a423814343..043411c163 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -43,7 +43,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "6.0dev"; -my $pandora_build = "150108"; +my $pandora_build = "150116"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -850,8 +850,8 @@ sub pandora_load_config { if ($pa_config->{"pandora_check"} == 1) { print " [*] MD5 Security enabled.\n"; } - if ($pa_config->{"pandora_master"} == 1) { - print " [*] This server is running in MASTER mode.\n"; + if ($pa_config->{"pandora_master"} != 0) { + print " [*] This server is running with MASTER priority " . $pa_config->{"pandora_master"} . "\n"; } } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 131270e4ed..d3587caf2d 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -165,6 +165,7 @@ our @EXPORT = qw( pandora_get_module_phone_tags pandora_get_module_email_tags pandora_get_os + pandora_is_master pandora_mark_agent_for_alert_update pandora_mark_agent_for_module_update pandora_module_keep_alive @@ -189,6 +190,7 @@ our @EXPORT = qw( pandora_reset_server pandora_server_keep_alive pandora_set_event_storm_protection + pandora_set_master pandora_update_agent pandora_update_agent_address pandora_update_agent_alert_count @@ -225,6 +227,9 @@ our @AlertStatus = ('Execute the alert', 'Do not execute the alert', 'Do not exe # Event storm protection (no alerts or events) our $EventStormProtection :shared = 0; +# Current master server +my $Master :shared = 0; + ########################################################################## # Return the agent given the IP address. ########################################################################## @@ -4221,6 +4226,43 @@ sub pandora_self_monitoring ($$) { close (XMLFILE); } +########################################################################## +=head2 C<< set_master (I<$pa_config>, I<$dbh>) >> + +Set the current master server. + +=cut +########################################################################## +sub pandora_set_master ($$) { + my ($pa_config, $dbh) = @_; + + my $current_master = get_db_value ($dbh, 'SELECT name FROM tserver + WHERE master <> 0 AND status = 1 + ORDER BY master DESC LIMIT 1'); + return unless defined($current_master) and ($current_master ne $Master); + + logger($pa_config, "Server $current_master is the current master.", 1); + $Master = $current_master; +} + +########################################################################## +=head2 C<< is_master (I<$pa_config>) >> + +Returns 1 if this server is the current master, 0 otherwise. + +=cut +########################################################################## +sub pandora_is_master ($) { + my ($pa_config) = @_; + + if ($Master eq $pa_config->{'servername'}) { + return 1; + } + + return 0; +} + + ########################################################################## =head2 C<< pandora_module_unknown (I<$pa_config>, I<$dbh>) >> diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index c3544ac76d..86b1f05025 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -96,7 +96,7 @@ sub data_producer ($) { my @rows; my $network_filter = enterprise_hook ('get_network_filter', [$pa_config]); - if ($pa_config->{'pandora_master'} == 0) { + if (pandora_is_master($pa_config) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index dfc75519d3..e8144f4dfb 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -96,7 +96,7 @@ sub data_producer ($) { my @tasks; my @rows; - if ($pa_config->{'pandora_master'} != 1) { + if (pandora_is_master($pa_config) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index 3c07c11baf..1818f68b55 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -92,7 +92,7 @@ sub data_producer ($) { my @tasks; my @rows; - if ($pa_config->{'pandora_master'} != 1) { + if (pandora_is_master($pa_config) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, last_execution_try FROM tagente, tagente_modulo, tagente_estado diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index fd400225fe..77f0394f52 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -94,7 +94,7 @@ sub data_producer ($) { my @tasks; my @rows; - if ($pa_config->{'pandora_master'} != 1) { + if (pandora_is_master($pa_config) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index ab1ae8f1d0..8408e27897 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 6.0dev -%define release 150108 +%define release 150116 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 2299fbdf7b..77ac1f797a 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 6.0dev -%define release 150108 +%define release 150116 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index e3ad9112bd..37c48d5fe3 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -33,7 +33,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; # version: define current version -my $version = "6.0dev PS150108"; +my $version = "6.0dev PS150116"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 41485fb6e3..37f21d67bc 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -34,7 +34,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "6.0dev PS150108"; +my $version = "6.0dev PS150116"; # save program name for logging my $progname = basename($0); @@ -2997,7 +2997,7 @@ sub cli_get_agent_modules() { exist_check($id_agent,'agent',$agent_name); my $modules = pandora_get_agent_modules ($dbh, $id_agent); - + if(scalar(@{$modules}) == 0) { print_log "[INFO] The agent '$agent_name' have not modules\n\n"; } @@ -3008,49 +3008,56 @@ sub cli_get_agent_modules() { } } -############################################################################## +######################################################################## # Show all the modules of a policy # Related option: --get_policy_modules -############################################################################## +######################################################################## sub cli_get_policy_modules() { my $policy_name = @ARGV[2]; - my $policy_id = enterprise_hook('get_policy_id',[$dbh, safe_input($policy_name)]); - exist_check($policy_id,'policy',$policy_name); + my $policy_id = enterprise_hook('get_policy_id', + [$dbh, safe_input($policy_name)]); + exist_check($policy_id, 'policy', $policy_name); - my $policy_modules = enterprise_hook('get_policy_modules',[$dbh, $policy_id]); - exist_check(scalar(@{$policy_modules})-1,'modules in policy',$policy_name); + my $policy_modules = enterprise_hook( + 'get_policy_modules', [$dbh, $policy_id]); + + if (defined($policy_modules)) { + exist_check(scalar(@{$policy_modules}) - 1, 'modules in policy', + $policy_name); + } print "id_policy_module, module_name\n"; foreach my $module (@{$policy_modules}) { - print $module->{'id'}.",".safe_output($module->{'name'})."\n"; + print $module->{'id'} . "," . safe_output($module->{'name'}) . "\n"; } } -############################################################################## -# Show all the policies (without parameters) or the policies of given agent +######################################################################## +# Show all the policies (without parameters) or the policies of given +# agent. # Related option: --get_policies -############################################################################## +######################################################################## sub cli_get_policies() { my $agent_name = @ARGV[2]; my $policies; - - if(defined($agent_name)) { + + if (defined($agent_name)) { my $id_agent = get_agent_id($dbh,$agent_name); exist_check($id_agent,'agent',$agent_name); - $policies = enterprise_hook('get_agent_policies',[$dbh,$id_agent]); - - if(scalar(@{$policies}) == 0) { + $policies = enterprise_hook('get_agent_policies', [$dbh,$id_agent]); + + if (scalar(@{$policies}) == 0) { print_log "[INFO] No policies found on agent '$agent_name'\n\n"; exit; } } else { - $policies = enterprise_hook('get_policies',[$dbh]); - if(scalar(@{$policies}) == 0) { + $policies = enterprise_hook('get_policies', [$dbh]); + if (scalar(@{$policies}) == 0) { print_log "[INFO] No policies found\n\n"; exit; } diff --git a/pandora_server/util/snmptrap_gen.sh b/pandora_server/util/snmptrap_gen.sh index e412cfebc2..6a2dde631f 100755 --- a/pandora_server/util/snmptrap_gen.sh +++ b/pandora_server/util/snmptrap_gen.sh @@ -14,7 +14,7 @@ if [ $# -lt 2 ] then echo " " echo "Syntax error: " - echo "SNMP Trap generator <# traps> []" + echo "SNMP Trap generator use: ./snmptrap_gen.sh <# No traps> []" echo "If is not provided, it will forge fake IP's" echo " " exit -1