diff --git a/pandora_agents/Dockerfile b/pandora_agents/Dockerfile index 0ee2515a75..79257b955c 100644 --- a/pandora_agents/Dockerfile +++ b/pandora_agents/Dockerfile @@ -1,15 +1,15 @@ -FROM centos:centos8 -MAINTAINER Pandora FMS Team +FROM centos:7 +LABEL maintainer="Pandora FMS Team " # Add Pandora FMS agent installer ADD unix /opt/pandora/pandora_agent/unix RUN export LC_ALL=C -RUN dnf install -y dnf-plugins-core; dnf config-manager --set-enabled PowerTools +RUN yum -y update # Install dependencies -RUN dnf -y install \ +RUN yum -y install \ epel-release \ unzip \ perl \ @@ -17,7 +17,7 @@ RUN dnf -y install \ sed \ perl-YAML-Tiny \ "perl(Sys::Syslog)" \ - && dnf clean all + && yum clean all # Install Pandora FMS agent diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 53f6c71331..284f2d7c7a 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.752-210311 +Version: 7.0NG.752-210318 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 c7ac46ab2a..ef723e092b 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="7.0NG.752-210311" +pandora_version="7.0NG.752-210318" 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 efbc6bcaea..15d09b10a8 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1016,7 +1016,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.752'; -use constant AGENT_BUILD => '210311'; +use constant AGENT_BUILD => '210318'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -4143,7 +4143,7 @@ while (1) { @address_list = `ip addr show 2>$DevNull | sed -e '/127.0.0/d' -e '/\\([0-9][0-9]*\\.\\)\\{3\\}[0-9][0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/\\/.*//'`; } else { - @address_list = `ifconfig -a 2>$DevNull | sed -e '/127.0.0/d' -e '/\\([0-9][0-9]*\\.\\)\\{3\\}[0-9][0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/.*://'`; + @address_list = `ifconfig -a 2>$DevNull | grep -i inet | grep -v 'inet6' | grep -v '0.0.0.0' | grep -v '::/0' | awk '{print \$2}' | grep -v '127.0.0.1'`; } for (my $i = 0; $i <= $#address_list; $i++) { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index cd6f5c5345..d809aed77d 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 7.0NG.752 -%define release 210311 +%define release 210318 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 6bc45c43ab..c535b0b973 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 7.0NG.752 -%define release 210311 +%define release 210318 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index c29decfbca..fe011c76e6 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210311" +PI_BUILD="210318" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 3676db6f23..0f62b05a6d 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{210311} +{210318} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 6085898f74..de6d4ba9ed 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 ("7.0NG.752(Build 210311)") +#define PANDORA_VERSION ("7.0NG.752(Build 210318)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 9d7c3a7d12..01e30be83e 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", "(7.0NG.752(Build 210311))" + VALUE "ProductVersion", "(7.0NG.752(Build 210318))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 1dfc8565d5..cfa7abf43a 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.752-210311 +Version: 7.0NG.752-210318 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 e3fc7561d9..3fb7248a48 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="7.0NG.752-210311" +pandora_version="7.0NG.752-210318" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/net_tools.php b/pandora_console/extensions/net_tools.php deleted file mode 100644 index 47874f78f5..0000000000 --- a/pandora_console/extensions/net_tools.php +++ /dev/null @@ -1,506 +0,0 @@ -'.__('Traceroute to ').$ip.''; - echo '
';
-                    echo system($traceroute.' '.$ip);
-                    echo '
'; - } - break; - - case 2: - $ping = whereis_the_command('ping'); - if (empty($ping)) { - ui_print_error_message(__('Ping executable does not exist.')); - } else { - echo '

'.__('Ping to %s', $ip).'

'; - echo '
';
-                    echo system($ping.' -c 5 '.$ip);
-                    echo '
'; - } - break; - - case 4: - $nmap = whereis_the_command('nmap'); - if (empty($nmap)) { - ui_print_error_message(__('Nmap executable does not exist.')); - } else { - echo '

'.__('Basic TCP Scan on ').$ip.'

'; - echo '
';
-                    echo system($nmap.' -F '.$ip);
-                    echo '
'; - } - break; - - case 5: - echo '

'.__('Domain and IP information for ').$ip.'

'; - - $dig = whereis_the_command('dig'); - if (empty($dig)) { - ui_print_error_message(__('Dig executable does not exist.')); - } else { - echo '
';
-                    echo system('dig '.$ip);
-                    echo '
'; - } - - $whois = whereis_the_command('whois'); - if (empty($whois)) { - ui_print_error_message(__('Whois executable does not exist.')); - } else { - echo '
';
-                    echo system('whois '.$ip);
-                    echo '
'; - } - break; - - case 3: - $snmp_obj = [ - 'ip_target' => $ip, - 'snmp_version' => $snmp_version, - 'snmp_community' => $community, - 'format' => '-Oqn', - ]; - - $snmp_obj['base_oid'] = '.1.3.6.1.2.1.1.3.0'; - $result = get_h_snmpwalk($snmp_obj); - echo '

'.__('SNMP information for ').$ip.'

'; - echo '

'.__('Uptime').'

'; - echo '
';
-                if (empty($result)) {
-                    ui_print_error_message(__('Target unreachable.'));
-                    break;
-                } else {
-                    echo array_pop($result);
-                }
-
-                echo '
'; - echo '

'.__('Device info').'

'; - echo '
';
-                $snmp_obj['base_oid'] = '.1.3.6.1.2.1.1.1.0';
-                $result = get_h_snmpwalk($snmp_obj);
-                if (empty($result)) {
-                    ui_print_error_message(__('Target unreachable.'));
-                    break;
-                } else {
-                    echo array_pop($result);
-                }
-
-                echo '
'; - - echo '

Interface Information

'; - - $table = new StdClass(); - $table->class = 'databox'; - $table->head = []; - $table->head[] = __('Interface'); - $table->head[] = __('Status'); - - $i = 0; - - $base_oid = '.1.3.6.1.2.1.2.2.1'; - $idx_oids = '.1'; - $names_oids = '.2'; - $status_oids = '.8'; - - $snmp_obj['base_oid'] = $base_oid.$idx_oids; - $idx = get_h_snmpwalk($snmp_obj); - - $snmp_obj['base_oid'] = $base_oid.$names_oids; - $names = get_h_snmpwalk($snmp_obj); - - $snmp_obj['base_oid'] = $base_oid.$status_oids; - $statuses = get_h_snmpwalk($snmp_obj); - - foreach ($idx as $k => $v) { - $index = str_replace($base_oid.$idx_oids, '', $k); - $name = $names[$base_oid.$names_oids.$index]; - - $status = $statuses[$base_oid.$status_oids.$index]; - - $table->data[$i][0] = $name; - $table->data[$i++][1] = $status; - } - - html_print_table($table); - break; - - default: - // Ignore. - break; - } - } - -} - - -/** - * Main function. - * - * @return void - */ -function main_net_tools() -{ - $operation = get_parameter('operation', 0); - $community = get_parameter('community', 'public'); - $ip = get_parameter('select_ips'); - $snmp_version = get_parameter('select_version'); - - // Show form. - $id_agente = get_parameter('id_agente', 0); - $principal_ip = db_get_sql( - sprintf( - 'SELECT direccion FROM tagente WHERE id_agente = %d', - $id_agente - ) - ); - - $list_address = db_get_all_rows_sql( - sprintf( - 'SELECT id_a FROM taddress_agent WHERE id_agent = %d', - $id_agente - ) - ); - foreach ($list_address as $address) { - $ids[] = join(',', $address); - } - - $ips = db_get_all_rows_sql( - sprintf( - 'SELECT ip FROM taddress WHERE id_a IN (%s)', - join(',', $ids) - ) - ); - - if ($ips == '') { - echo "
".__('The agent hasn\'t got IP').'
'; - return; - } - - // Javascript. - ?> - - '; - echo "
"; - echo ""; - echo ''; - echo ''; - echo "'; - echo '
'; - echo __('Operation'); - echo ''; - - html_print_select( - [ - 1 => __('Traceroute'), - 2 => __('Ping host & Latency'), - 3 => __('SNMP Interface status'), - 4 => __('Basic TCP Port Scan'), - 5 => __('DiG/Whois Lookup'), - ], - 'operation', - $operation, - 'mostrarColumns(this.value)', - __('Please select') - ); - - echo ''; - echo __('IP address'); - echo ''; - - $ips_for_select = array_reduce( - $ips, - function ($carry, $item) { - $carry[$item['ip']] = $item['ip']; - return $carry; - } - ); - - html_print_select( - $ips_for_select, - 'select_ips', - $principal_ip - ); - echo '"; - echo __('SNMP Version'); - html_print_select( - [ - '1' => 'v1', - '2c' => 'v2c', - ], - 'select_version', - $snmp_version - ); - echo ''; - echo __('SNMP Community').' '; - html_print_input_text('community', $community); - echo ''; - echo ""; - echo '
'; - echo '
'; - - if ($operation) { - // Execute form. - net_tools_execute($operation, $ip, $community, $snmp_version); - } - - echo ''; -} - - -/** - * Add option. - * - * @return void - */ -function godmode_net_tools() -{ - global $config; - - check_login(); - - if (! check_acl($config['id_user'], 0, 'PM')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access Profile Management' - ); - include 'general/noaccess.php'; - return; - } - - ui_print_page_header( - __('Config Network Tools'), - '', - false, - 'network_tools_tab' - ); - - $update_traceroute = (bool) get_parameter('update_traceroute', 0); - - $traceroute_path = (string) get_parameter('traceroute_path', ''); - $ping_path = (string) get_parameter('ping_path', ''); - $nmap_path = (string) get_parameter('nmap_path', ''); - $dig_path = (string) get_parameter('dig_path', ''); - $snmpget_path = (string) get_parameter('snmpget_path', ''); - - if ($update_traceroute) { - $network_tools_config = []; - $network_tools_config['traceroute_path'] = $traceroute_path; - $network_tools_config['ping_path'] = $ping_path; - $network_tools_config['nmap_path'] = $nmap_path; - $network_tools_config['dig_path'] = $dig_path; - $network_tools_config['snmpget_path'] = $snmpget_path; - - $result = config_update_value('network_tools_config', json_encode($network_tools_config)); - - ui_print_result_message( - $result, - __('Set the paths.'), - __('Set the paths.') - ); - } else { - if (isset($config['network_tools_config'])) { - $network_tools_config_output = io_safe_output($config['network_tools_config']); - $network_tools_config = json_decode($network_tools_config_output, true); - $traceroute_path = $network_tools_config['traceroute_path']; - $ping_path = $network_tools_config['ping_path']; - $nmap_path = $network_tools_config['nmap_path']; - $dig_path = $network_tools_config['dig_path']; - $snmpget_path = $network_tools_config['snmpget_path']; - } - } - - $table = null; - $table->width = '100%'; - - $table->data = []; - - $table->data[0][0] = __('Traceroute path'); - $table->data[0][1] = html_print_input_text('traceroute_path', $traceroute_path, '', 40, 255, true); - - $table->data[1][0] = __('Ping path'); - $table->data[1][1] = html_print_input_text('ping_path', $ping_path, '', 40, 255, true); - - $table->data[2][0] = __('Nmap path'); - $table->data[2][1] = html_print_input_text('nmap_path', $nmap_path, '', 40, 255, true); - - $table->data[3][0] = __('Dig path'); - $table->data[3][1] = html_print_input_text('dig_path', $dig_path, '', 40, 255, true); - - $table->data[4][0] = __('Snmpget path'); - $table->data[4][1] = html_print_input_text('snmpget_path', $snmpget_path, '', 40, 255, true); - - echo '
'; - echo '
'; - echo ''.__('Options').''; - html_print_input_hidden('update_traceroute', 1); - html_print_table($table); - echo '
'; - - echo '
'; - html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"'); - echo '
'; - echo '
'; -} - - -extensions_add_godmode_menu_option(__('Config Network Tools'), 'PM'); -extensions_add_godmode_function('godmode_net_tools'); diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index 51b2e7a8c8..f21a69a040 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -73,3 +73,4 @@ enterprise/extensions/ipam.php enterprise/extensions/ipam enterprise/extensions/disabled/visual_console_manager.php enterprise/extensions/visual_console_manager.php +pandora_console/extensions/net_tools.php \ No newline at end of file diff --git a/pandora_console/extras/mr/45.sql b/pandora_console/extras/mr/45.sql index 90f821dae5..c51ff4a248 100644 --- a/pandora_console/extras/mr/45.sql +++ b/pandora_console/extras/mr/45.sql @@ -1,5 +1,8 @@ START TRANSACTION; + +ALTER TABLE `talert_actions` ADD COLUMN `create_wu_integria` TINYINT(1) default NULL; + ALTER TABLE `treport_content` ADD COLUMN `summary` tinyint(1) DEFAULT 0; ALTER TABLE `treport_content_template` ADD COLUMN `summary` tinyint(1) DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 2742e7e197..16142456fe 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1380,6 +1380,8 @@ ALTER TABLE `talert_actions` MODIFY COLUMN `field11` text NOT NULL, MODIFY COLUMN `field14` text NOT NULL, MODIFY COLUMN `field15` text NOT NULL; +ALTER TABLE `talert_actions` ADD COLUMN `create_wu_integria` TINYINT(1) default NULL; + -- --------------------------------------------------------------------- -- Table `talert_commands` -- --------------------------------------------------------------------- diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index 9a71a97631..b28ba53db1 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -234,8 +234,8 @@ if (!$double_auth_enabled && $config['2FA_all_users'] != '' } }); - $("div#doble_auth_window").dialog({ + $("div#doble_auth_window").dialog({ resizable: true, draggable: true, modal: true, @@ -247,12 +247,6 @@ if (!$double_auth_enabled && $config['2FA_all_users'] != '' width: 500, height: 400, close: function (event, ui) { - - // Abort the ajax request if (typeof request != 'undefined'){ request.abort(); @@ -263,7 +257,11 @@ if (!$double_auth_enabled && $config['2FA_all_users'] != '' //document.location.reload(); } }) - .show(); + .show(); + // Don't allow close the dialog with X button + $('.ui-dialog-titlebar-close').css('display', 'none'); + + '; } diff --git a/pandora_console/godmode/agentes/agent_incidents.php b/pandora_console/godmode/agentes/agent_incidents.php index 1cd03ca41f..16cdd9370c 100644 --- a/pandora_console/godmode/agentes/agent_incidents.php +++ b/pandora_console/godmode/agentes/agent_incidents.php @@ -18,6 +18,11 @@ require_once 'include/functions_incidents.php'; check_login(); +if (!$config['integria_enabled']) { + ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured')); + return; +} + $group = $id_grupo; if (! check_acl($config['id_user'], $group, 'AW', $id_agente)) { @@ -38,30 +43,25 @@ $groups = users_get_groups($config['id_user'], 'IR'); $filter = ' AND id_agent = '.$id_agent; $url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=incident&id_agente='.$id_agent; -// Select incidencts where the user has access to ($groups from -// get_user_groups), array_keys for the id, implode to pass to SQL -switch ($config['dbtype']) { - case 'mysql': - $sql = 'SELECT * FROM tincidencia WHERE - id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.' - ORDER BY actualizacion DESC LIMIT '.$offset.','.$config['block_size']; - break; +$params = [ + '', + '-10', + '1', + '-1', + '0', + '', + '', + '', + agents_get_name($id_agent), +]; - case 'oracle': - $sql = 'SELECT * FROM tincidencia WHERE - id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.' - AND rownum <= '.$offset.','.$config['block_size'].' - ORDER BY actualizacion DESC'; - break; -} +$result = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents', $params, false, 'json', ','); -$result = db_get_all_rows_sql($sql); +$result = json_decode($result, true); -$count_sql = 'SELECT count(*) FROM tincidencia WHERE - id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.' - ORDER BY actualizacion DESC'; +$count = count($result); -$count = db_get_value_sql($count_sql); +$result = array_slice($result, $offset, $config['block_size']); if (empty($result)) { $result = []; @@ -91,8 +91,6 @@ $table->head[2] = __('Incident'); $table->head[3] = __('Priority'); $table->head[4] = __('Group'); $table->head[5] = __('Updated'); -$table->head[6] = __('Source'); -$table->head[7] = __('Owner'); $table->size[0] = 43; $table->size[7] = 50; @@ -115,7 +113,7 @@ foreach ($result as $row) { $data = []; - $data[0] = ''.$row['id_incidencia'].''; + $data[0] = ''.$row['id_incidencia'].''; $attach = incidents_get_attach($row['id_incidencia']); if (!empty($attach)) { @@ -123,12 +121,10 @@ foreach ($result as $row) { } $data[1] = incidents_print_status_img($row['estado'], true); - $data[2] = ''.substr(io_safe_output($row['titulo']), 0, 45).''; + $data[2] = ''.substr(io_safe_output($row['titulo']), 0, 45).''; $data[3] = incidents_print_priority_img($row['prioridad'], true); - $data[4] = ui_print_group_icon($row['id_grupo'], true); + $data[4] = $row['id_grupo']; $data[5] = ui_print_timestamp($row['actualizacion'], true); - $data[6] = $row['origen']; - $data[7] = ui_print_username($row['id_usuario'], true); array_push($table->data, $data); } diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index d5de778514..f7ff804b50 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -367,7 +367,7 @@ $img_style = [ if ($id_agente) { // View tab. $viewtab['text'] = ''.html_print_image( - 'images/operation.png', + 'images/eye.png', true, [ 'title' => __('View'), diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 909930a4e0..6d9516bad7 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -754,7 +754,7 @@ if ($agents !== false) { echo ''; } - echo '
'; + echo '
'; if ($check_aw) { if ($agent['id_os'] == CLUSTER_OS_ID) { if (enterprise_installed()) { diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index e2c645a414..10f323ffab 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -75,6 +75,7 @@ ui_print_page_header( // Recursion group filter. $recursion = get_parameter('recursion', $_POST['recursion']); + // Initialize data. $id_group = (int) get_parameter('id_group'); $name = (string) get_parameter('name'); @@ -147,144 +148,9 @@ $user_groups_ad = array_keys( users_get_groups($config['id_user'], $access) ); -// Check AD permission on downtime. -$downtime_group = db_get_value( - 'id_group', - 'tplanned_downtime', - 'id', - $id_downtime -); - -if ($id_downtime > 0) { - if (!check_acl_restricted_all($config['id_user'], $downtime_group, 'AW') - && !check_acl_restricted_all($config['id_user'], $downtime_group, 'AD') - ) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access downtime scheduler' - ); - include 'general/noaccess.php'; - return; - } -} - // INSERT A NEW DOWNTIME_AGENT ASSOCIATION. if ($insert_downtime_agent === 1) { - if ($downtime_group === false - || !in_array($downtime_group, $user_groups_ad) - ) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access downtime scheduler' - ); - include 'general/noaccess.php'; - return; - } - - $agents = (array) get_parameter('id_agents'); - $module_names = (array) get_parameter('module'); - - $all_modules = ($modules_selection_mode === 'all' && (empty($module_names) || (int) $modules[0] === 0)); - $all_common_modules = ($modules_selection_mode === 'common' && (empty($module_names) || (int) $modules[0] === 0)); - - if ($all_common_modules === true) { - $module_names = explode(',', get_parameter('all_common_modules')); - } - - // 'Is running' check. - $is_running = (bool) db_get_value( - 'executed', - 'tplanned_downtime', - 'id', - $id_downtime - ); - if ($is_running) { - ui_print_error_message( - __('This elements cannot be modified while the downtime is being executed') - ); - } else { - // If is selected 'Any', get all the agents. - if (count($agents) === 1 && (int) $agents[0] === -2) { - $all_agents = get_parameter('all_agents'); - $agents = explode(',', $all_agents); - } - - foreach ($agents as $agent_id) { - // Check module belongs to the agent. - if ($modules_selection_mode == 'all' && $all_modules === false) { - $check = false; - foreach ($module_names as $module_name) { - $check_module = modules_get_agentmodule_id( - $module_name, - $agent_id - ); - if (!empty($check_module)) { - $check = true; - } - } - - if (!$check) { - continue; - } - } - - // Check AD permission on agent. - $agent_group = db_get_value( - 'id_grupo', - 'tagente', - 'id_agente', - $agent_id - ); - - if ($agent_group === false - || !in_array($agent_group, $user_groups_ad) - ) { - continue; - } - - $values = [ - 'id_downtime' => $id_downtime, - 'id_agent' => $agent_id, - 'all_modules' => $all_modules, - ]; - $result = db_process_sql_insert( - 'tplanned_downtime_agents', - $values - ); - - if ($result && !$all_modules) { - foreach ($module_names as $module_name) { - $module = modules_get_agentmodule_id( - $module_name, - $agent_id - ); - - if (empty($module)) { - continue; - } - - $values = [ - 'id_downtime' => $id_downtime, - 'id_agent' => $agent_id, - 'id_agent_module' => $module['id_agente_modulo'], - ]; - $result = db_process_sql_insert( - 'tplanned_downtime_modules', - $values - ); - - if ($result) { - $values = ['id_user' => $config['id_user']]; - $result = db_process_sql_update( - 'tplanned_downtime', - $values, - ['id' => $id_downtime] - ); - } - } - } - } - } + insert_downtime_agent($id_downtime, $user_groups_ad); } // DELETE A DOWNTIME_AGENT ASSOCIATION. @@ -490,10 +356,6 @@ if ($create_downtime || $update_downtime) { 'date_to' => $datetime_to, 'id_user' => $config['id_user'], ]; - } else if ($is_running) { - ui_print_error_message( - __('Cannot be modified while the downtime is being executed') - ); } else { $values = [ 'name' => $name, @@ -524,12 +386,16 @@ if ($create_downtime || $update_downtime) { } } - if (!empty($values)) { - $result = db_process_sql_update( - 'tplanned_downtime', - $values, - ['id' => $id_downtime] - ); + if ($is_running) { + $result = false; + } else { + if (!empty($values)) { + $result = db_process_sql_update( + 'tplanned_downtime', + $values, + ['id' => $id_downtime] + ); + } } } @@ -542,6 +408,9 @@ if ($create_downtime || $update_downtime) { } else { if ($create_downtime && $name && !$check) { $id_downtime = $result; + + insert_downtime_agent($id_downtime, $user_groups_ad); + ui_print_success_message(__('Successfully created')); } else if ($update_downtime && $name) { ui_print_success_message(__('Successfully updated')); @@ -584,8 +453,8 @@ if ($id_downtime > 0) { case 'postgresql': $columns_str = implode(',', $columns); $sql = "SELECT $columns_str - FROM tplanned_downtime - WHERE id = $id_downtime"; + FROM tplanned_downtime + WHERE id = $id_downtime"; break; case 'oracle': @@ -607,8 +476,8 @@ if ($id_downtime > 0) { $columns_str = implode(',', $columns); $sql = "SELECT $columns_str - FROM tplanned_downtime - WHERE id = $id_downtime"; + FROM tplanned_downtime + WHERE id = $id_downtime"; break; } @@ -672,20 +541,11 @@ $table->data[0][1] = html_print_input_text( true, $disabled_in_execution ); - -$return_all_group = false; - -if (users_can_manage_group_all('AW') === true - || users_can_manage_group_all('AD') === true -) { - $return_all_group = true; -} - $table->data[1][0] = __('Group'); $table->data[1][1] = '
'.html_print_select_groups( false, $access, - $return_all_group, + true, 'id_group', $id_group, '', @@ -750,23 +610,23 @@ $days = array_combine(range(1, 31), range(1, 31)); $table->data[5][0] = __('Configure the time').' '; ; $table->data[5][1] = " - - '; if ($id_downtime > 0) { - echo ''; - echo "
"; + echo ""; +} else { + echo ''; } // Editor form. html_print_table($table); +echo ""; + +$filter_group = (int) get_parameter('filter_group', 0); + +// User AD groups to str for the filter. +$id_groups_str = implode(',', $user_groups_ad); + +if (empty($id_groups_str)) { + // Restrictive filter on error. This will filter all the downtimes. + $id_groups_str = '-1'; +} + +$filter_cond = ''; +if ($filter_group > 0) { + if ($recursion) { + $rg = groups_get_children_ids($filter_group, true); + $filter_cond .= ' AND id_grupo IN ('; + + $i = 0; + $len = count($rg); + + foreach ($rg as $key) { + if ($i == ($len - 1)) { + $filter_cond .= $key.')'; + } else { + $i++; + $filter_cond .= $key.','; + } + } + } else { + $filter_cond = " AND id_grupo = $filter_group "; + } +} + +$agents = get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str); + +$disabled_add_button = false; +if (empty($agents) || $disabled_in_execution) { + $disabled_add_button = true; +} + +// Show available agents to include into downtime +$table = new StdClass(); +$table->class = 'databox filters'; +$table->width = '100%'; +$table->data = []; + +$table->data[0][0] = __('Group filter'); +$table->data[0][1] = html_print_select_groups(false, $access, true, 'filter_group', $filter_group, '', '', '', true, false, true, '', false, 'min-width:180px;margin-right:15px;'); +$table->data[0][2] = __('Recursion').'  '.html_print_checkbox('recursion', 1, $recursion, true, false, ''); + +$table->data[1][0] = __('Available agents'); +$table->data[1][1] = html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, true, true, true, '', false, 'width: 180px;'); + + +if ($type_downtime != 'quiet') { + echo '"; +// Start Overview of existing planned downtime. +echo '

'.__('Agents planned for this downtime').':

'; - $filter_group = (int) get_parameter('filter_group', 0); +// User the $id_groups_str built before. +$sql = sprintf( + 'SELECT ta.nombre, tpda.id, + ta.id_os, ta.id_agente, ta.id_grupo, + ta.ultimo_contacto, tpda.all_modules + FROM tagente ta + INNER JOIN tplanned_downtime_agents tpda + ON ta.id_agente = tpda.id_agent + AND tpda.id_downtime = %d + WHERE ta.id_grupo IN (%s)', + $id_downtime, + $id_groups_str +); +$downtimes_agents = db_get_all_rows_sql($sql); - // User AD groups to str for the filter. - $id_groups_str = implode(',', $user_groups_ad); +if (empty($downtimes_agents)) { + echo '
'.__('There are no agents').'
'; +} else { + $table = new stdClass(); + $table->id = 'list'; + $table->class = 'databox data'; + $table->width = '100%'; + $table->data = []; + $table->head = []; + $table->head[0] = __('Name'); + $table->head[1] = __('Group'); + $table->head[2] = __('OS'); + $table->head[3] = __('Last contact'); + $table->head['count_modules'] = __('Modules'); - if (empty($id_groups_str)) { - // Restrictive filter on error. This will filter all the downtimes. - $id_groups_str = '-1'; + if (!$running) { + $table->head[5] = __('Actions'); + $table->align[5] = 'center'; + $table->size[5] = '5%'; } - $filter_cond = ''; - if ($filter_group > 0) { - if ($recursion) { - $rg = groups_get_children_ids($filter_group, true); - $filter_cond .= ' AND id_grupo IN ('; + foreach ($downtimes_agents as $downtime_agent) { + $data = []; - $i = 0; - $len = count($rg); + $alias = db_get_value( + 'alias', + 'tagente', + 'id_agente', + $downtime_agent['id_agente'] + ); + $data[0] = $alias; - foreach ($rg as $key) { - if ($i == ($len - 1)) { - $filter_cond .= $key.')'; - } else { - $i++; - $filter_cond .= $key.','; - } - } + $data[1] = db_get_sql( + 'SELECT nombre + FROM tgrupo + WHERE id_grupo = '.$downtime_agent['id_grupo'] + ); + + $data[2] = ui_print_os_icon($downtime_agent['id_os'], true, true); + + $data[3] = $downtime_agent['ultimo_contacto']; + + if ($type_downtime == 'disable_agents_alerts') { + $data['count_modules'] = __('All alerts'); + } else if ($type_downtime == 'disable_agents') { + $data['count_modules'] = __('Entire agent'); } else { - $filter_cond = " AND id_grupo = $filter_group "; + if ($downtime_agent['all_modules']) { + $data['count_modules'] = __('All modules'); + } else { + $data['count_modules'] = __('Some modules'); + } } - } - - $agents = get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str); - - $disabled_add_button = false; - if (empty($agents) || $disabled_in_execution) { - $disabled_add_button = true; - } - - echo "
"; - html_print_select_groups(false, $access, true, 'filter_group', $filter_group, '', '', '', false, false, true, '', false, 'min-width:180px;margin-right:15px;'); - - html_print_checkbox('recursion', 1, $recursion, false, false, ''); - echo __('Recursion').' '; - echo '

'; - html_print_submit_button(__('Filter by group'), '', false, 'class="sub next"', false); - echo '
'; - // Show available agents to include into downtime - echo '

'.__('Available agents').':

'; - echo "
"; - html_print_input_hidden('all_agents', implode(',', array_keys($agents))); - echo html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, false, true, true, '', false, 'width: 180px;'); - - if ($type_downtime != 'quiet') { - echo '
'; - - // Start Overview of existing planned downtime. - echo '

'.__('Agents planned for this downtime').':

'; - - // User the $id_groups_str built before. - $sql = sprintf( - 'SELECT ta.nombre, tpda.id, - ta.id_os, ta.id_agente, ta.id_grupo, - ta.ultimo_contacto, tpda.all_modules - FROM tagente ta - INNER JOIN tplanned_downtime_agents tpda - ON ta.id_agente = tpda.id_agent - AND tpda.id_downtime = %d - WHERE ta.id_grupo IN (%s)', - $id_downtime, - $id_groups_str - ); - $downtimes_agents = db_get_all_rows_sql($sql); - - if (empty($downtimes_agents)) { - echo '
'.__('There are no agents').'
'; - } else { - $table = new stdClass(); - $table->id = 'list'; - $table->class = 'databox data'; - $table->width = '100%'; - $table->data = []; - $table->head = []; - $table->head[0] = __('Name'); - $table->head[1] = __('Group'); - $table->head[2] = __('OS'); - $table->head[3] = __('Last contact'); - $table->head['count_modules'] = __('Modules'); if (!$running) { - $table->head[5] = __('Actions'); - $table->align[5] = 'center'; - $table->size[5] = '5%'; - } - - foreach ($downtimes_agents as $downtime_agent) { - $data = []; - - $alias = db_get_value( - 'alias', - 'tagente', - 'id_agente', - $downtime_agent['id_agente'] - ); - $data[0] = $alias; - - $data[1] = db_get_sql( - 'SELECT nombre - FROM tgrupo - WHERE id_grupo = '.$downtime_agent['id_grupo'] - ); - - $data[2] = ui_print_os_icon($downtime_agent['id_os'], true, true); - - $data[3] = $downtime_agent['ultimo_contacto']; - - if ($type_downtime == 'disable_agents_alerts') { - $data['count_modules'] = __('All alerts'); - } else if ($type_downtime == 'disable_agents') { - $data['count_modules'] = __('Entire agent'); - } else { - if ($downtime_agent['all_modules']) { - $data['count_modules'] = __('All modules'); - } else { - $data['count_modules'] = __('Some modules'); - } + $data[5] = ''; + if ($type_downtime != 'disable_agents_alerts' + && $type_downtime != 'disable_agents' + ) { + $data[5] = '
'.html_print_image('images/config.png', true, ['border' => '0', 'alt' => __('Delete'), 'class' => 'invert_filter']).''; } - if (!$running) { - $data[5] = ''; - if ($type_downtime != 'disable_agents_alerts' - && $type_downtime != 'disable_agents' - ) { - $data[5] = ''.html_print_image( - 'images/config.png', - true, - [ - 'border' => '0', - 'alt' => __('Delete'), - ] - ).''; - } - - $data[5] .= ''.html_print_image( - 'images/cross.png', - true, - [ - 'border' => '0', - 'alt' => __('Delete'), - 'class' => 'invert_filter', - ] - ).''; - } - - $table->data['agent_'.$downtime_agent['id_agente']] = $data; + $data[5] .= ''.html_print_image('images/cross.png', true, ['border' => '0', 'alt' => __('Delete'), 'class' => 'invert_filter']).''; } - html_print_table($table); + $table->data['agent_'.$downtime_agent['id_agente']] = $data; } + + html_print_table($table); } $table = new stdClass(); @@ -1145,20 +984,20 @@ $table->data['module'][1] = '

'.__('Modules').'

'; // List of modules, empty, it is populated by javascript. $table->data['module'][1] = " - - - - - - - - - - - + +
".__('Module')."".__('Action')."
".''.html_print_image( + + + + + + + + + + + - - - + + - - -
".__('Module')."".__('Action')."
".__('Add Module:').' '.html_print_select( +
".__('Add Module:').' '.html_print_select( [], 'modules', '', @@ -1178,7 +1017,7 @@ $table->data['module'][1] = " 0, true )."".'".''."'.'
'; +).'
'."
'; echo "'; ui_include_time_picker(); ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/'); +// Auxiliary function for downtime agent creation. +function insert_downtime_agent($id_downtime, $user_groups_ad) +{ + // Check AD permission on downtime. + $downtime_group = db_get_value( + 'id_group', + 'tplanned_downtime', + 'id', + $id_downtime + ); + + if ($downtime_group === false + || !in_array($downtime_group, $user_groups_ad) + ) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access downtime scheduler' + ); + include 'general/noaccess.php'; + return; + } + + $agents = (array) get_parameter('id_agents'); + $module_names = (array) get_parameter('module'); + $modules_selection_mode = (string) get_parameter('modules_selection_mode'); + + $all_modules = ($modules_selection_mode === 'all' && (empty($module_names) || (string) $module_names[0] === '0')); + $all_common_modules = ($modules_selection_mode === 'common' && (empty($module_names) || (string) $module_names[0] === '0')); + + if ($all_common_modules === true) { + $module_names = explode(',', get_parameter('all_common_modules')); + } + + // 'Is running' check. + $is_running = (bool) db_get_value( + 'executed', + 'tplanned_downtime', + 'id', + $id_downtime + ); + if ($is_running) { + ui_print_error_message( + __('This elements cannot be modified while the downtime is being executed') + ); + } else { + // If is selected 'Any', get all the agents. + if (count($agents) === 1 && (int) $agents[0] === -2) { + $all_agents = get_parameter('all_agents'); + $agents = explode(',', $all_agents); + } + + foreach ($agents as $agent_id) { + // Check module belongs to the agent. + if ($modules_selection_mode == 'all' && $all_modules === false) { + $check = false; + foreach ($module_names as $module_name) { + $check_module = modules_get_agentmodule_id( + $module_name, + $agent_id + ); + if (!empty($check_module)) { + $check = true; + } + } + + if (!$check) { + continue; + } + } + + // Check AD permission on agent. + $agent_group = db_get_value( + 'id_grupo', + 'tagente', + 'id_agente', + $agent_id + ); + + if ($agent_group === false + || !in_array($agent_group, $user_groups_ad) + ) { + continue; + } + + $values = [ + 'id_downtime' => $id_downtime, + 'id_agent' => $agent_id, + 'all_modules' => $all_modules, + ]; + $result = db_process_sql_insert( + 'tplanned_downtime_agents', + $values + ); + + if ($result && !$all_modules) { + foreach ($module_names as $module_name) { + $module = modules_get_agentmodule_id( + $module_name, + $agent_id + ); + + if (empty($module)) { + continue; + } + + $values = [ + 'id_downtime' => $id_downtime, + 'id_agent' => $agent_id, + 'id_agent_module' => $module['id_agente_modulo'], + ]; + $result = db_process_sql_insert( + 'tplanned_downtime_modules', + $values + ); + + if ($result) { + $values = ['id_user' => $config['id_user']]; + $result = db_process_sql_update( + 'tplanned_downtime', + $values, + ['id' => $id_downtime] + ); + } + } + } + } + } +} + + ?> diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 0c53937dc5..8407a88f97 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -62,7 +62,7 @@ if (is_ajax()) { $command = alerts_get_alert_command($id); - // If is setted a description, we change the carriage return by
tags + // If a description is set, change the carriage return by
tags. if (isset($command['description'])) { $command['description'] = str_replace( [ @@ -277,6 +277,76 @@ if (is_ajax()) { $editor_type_chkbx .= '
'; $rfield = $editor_type_chkbx; // Select type. + } else if (preg_match('/^_integria_type_custom_field_$/i', $field_value)) { + $ffield = ''; + $rfield = ''; + + $ffield .= '
'.html_print_switch( + [ + 'name' => 'field'.$i.'_value[]', + 'value' => '', + ] + ).'
'; + $rfield .= '
'.html_print_switch( + [ + 'name' => 'field'.$i.'_recovery_value[]', + 'value' => '', + ] + ).'
'; + + $ffield .= html_print_select( + '', + 'field'.$i.'_value[]', + '', + '', + __('None'), + '', + true, + false, + false, + 'fields', + $is_central_policies_on_node + ); + + $rfield .= html_print_select( + '', + 'field'.$i.'_recovery_value[]', + '', + '', + __('None'), + '', + true, + false, + false, + 'fields', + $is_central_policies_on_node + ); + + $ffield .= html_print_input_text('field'.$i.'_value[]', '', '', 10, 10, true, false, false, '', 'datepicker'); + $rfield .= html_print_input_text('field'.$i.'_recovery_value[]', '', '', 10, 10, true, false, false, '', 'datepicker'); + + $ffield .= html_print_textarea( + 'field'.$i.'_value[]', + 1, + 1, + '', + 'style="min-height:40px; '.$style.'" class="fields"', + true, + '', + $is_central_policies_on_node + ); + + + $rfield .= html_print_textarea( + 'field'.$i.'_recovery_value[]', + 1, + 1, + '', + 'style="min-height:40px; '.$style.'" class="fields_recovery', + true, + '', + $is_central_policies_on_node + ); } else { $fields_value_select = []; $fv = explode(';', $field_value); @@ -316,7 +386,7 @@ if (is_ajax()) { 'field'.$i.'_recovery_value', '', '', - '', + __('None'), 0, true, false, diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index 73f22f8151..f6a60fffae 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -97,7 +97,14 @@ $table->data[1][0] = __('Actions'); $groups_user = users_get_groups($config['id_user']); if (!empty($groups_user)) { $groups = implode(',', array_keys($groups_user)); - $sql = "SELECT id, name FROM talert_actions WHERE id_group IN ($groups)"; + + if ($config['integria_enabled'] == 0) { + $integria_command = 'Integria IMS Ticket'; + $sql = sprintf('SELECT taa.id, taa.name FROM talert_actions taa INNER JOIN talert_commands tac ON taa.id_alert_command = tac.id WHERE tac.name <> "%s" AND taa.id_group IN (%s)', $integria_command, $groups); + } else { + $sql = "SELECT id, name FROM talert_actions WHERE id_group IN ($groups)"; + } + $actions = db_get_all_rows_sql($sql); } diff --git a/pandora_console/godmode/alerts/alert_special_days.php b/pandora_console/godmode/alerts/alert_special_days.php index 7a29f7758b..31f787f910 100644 --- a/pandora_console/godmode/alerts/alert_special_days.php +++ b/pandora_console/godmode/alerts/alert_special_days.php @@ -551,7 +551,7 @@ for ($month = 1; $month <= 12; $month++) { $cal_table->data[$cal_line][$week] .= 'data[$cal_line][$week] .= '>'.html_print_image( - 'images/add.png', + 'images/add_mc.png', true, ['class' => 'invert_filter'] ).''; diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 18454c86da..7d44ffd25b 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -16,6 +16,7 @@ global $config; require_once $config['homedir'].'/include/functions_alerts.php'; require_once $config['homedir'].'/include/functions_users.php'; +require_once $config['homedir'].'/include/functions_integriaims.php'; enterprise_include_once('meta/include/functions_alerts_meta.php'); check_login(); @@ -36,6 +37,19 @@ $id = (int) get_parameter('id'); $al_action = alerts_get_alert_action($id); $pure = get_parameter('pure', 0); +if (is_ajax()) { + $get_integria_ticket_custom_types = (bool) get_parameter('get_integria_ticket_custom_types'); + + if ($get_integria_ticket_custom_types) { + $ticket_type_id = get_parameter('ticket_type_id'); + + $api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_fields', $ticket_type_id, false, 'json'); + + echo $api_call; + return; + } +} + if (defined('METACONSOLE')) { $sec = 'advanced'; } else { @@ -101,6 +115,7 @@ if ($id) { $group = $action['id_group']; $action_threshold = $action['action_threshold']; + $create_wu_integria = $action['create_wu_integria']; if (!check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM')) { db_pandora_audit( @@ -200,10 +215,18 @@ $table->data[1][1] = '
'.html_print_select_groups( ).'
'; $table->colspan[1][1] = 2; +$create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Integria IMS Ticket')); + +$sql_exclude_command_id = ''; + +if ($config['integria_enabled'] == 0 && $create_ticket_command_id !== false) { + $sql_exclude_command_id = ' AND id <> '.$create_ticket_command_id; +} + $table->data[2][0] = __('Command'); $commands_sql = db_get_all_rows_filter( 'talert_commands', - ['id_group' => array_keys(users_get_groups(false, 'LW'))], + 'id_group IN ('.implode(',', array_keys(users_get_groups(false, 'LW'))).')'.$sql_exclude_command_id, [ 'id', 'name', @@ -281,6 +304,12 @@ $table->data[5][2] = html_print_textarea( true ); +$table->data[6][0] = __('Create workunit on recovery').ui_print_help_tip( + __('If closed status is set on recovery, a workunit will be added to the ticket in Integria IMS rather that closing the ticket.'), + true +); +$table->data[6][1] = html_print_checkbox_switch_extended('create_wu_integria', 1, $create_wu_integria, false, '', '', true); + for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $table->data['field'.$i][0] = html_print_image( 'images/spinner.gif', @@ -371,6 +400,173 @@ $(document).ready (function () { render_command_description(command_description); } + function ajax_get_integria_custom_fields(ticket_type_id, values, recovery_values) { + var values = values || []; + var recovery_values = recovery_values || []; + var max_macro_fields = ; + + if (ticket_type_id === null || ticket_type_id === '' || (Array.isArray(values) && values.length === 0 && Array.isArray(recovery_values) && recovery_values.length === 0)) { + for (var i=8; i <= max_macro_fields; i++) { + $('[name=field'+i+'_value\\[\\]').val(''); + $('[name=field'+i+'_recovery_value\\[\\]').val(''); + } + } + + // On ticket type change, hide all table rows and inputs corresponding to custom fields, regardless of what its type is. + for (var i=8; i <= max_macro_fields; i++) { + $('[name=field'+i+'_value\\[\\]').hide(); + $('[name=field'+i+'_recovery_value\\[\\]').hide(); + $('#table_macros-field'+i).hide(); + $('[name=field'+i+'_value_container').hide(); + $('[name=field'+i+'_recovery_value_container').hide(); + } + + jQuery.post( + "ajax.php", + { + page: "godmode/alerts/configure_alert_action", + get_integria_ticket_custom_types: 1, + ticket_type_id: ticket_type_id + }, + function(data) { + var max_macro_fields = ; + + data.forEach(function(custom_field, key) { + var custom_field_key = key+8; // Custom fields start from field 8. + + if (custom_field_key > max_macro_fields) { + return; + } + + // Display field row for current input. + var custom_field_row = $('#table_macros-field'+custom_field_key); + custom_field_row.show(); + + // Replace label text of field row for current input. + var label_html = $('#table_macros-field'+custom_field_key+' td').first().html(); + var label_name = label_html.split('
')[0]; + var new_html_content = custom_field_row.html().replace(label_name, custom_field.label); + custom_field_row.html(new_html_content); + + switch (custom_field.type) { + case 'checkbox': + var checkbox_selector = $('input:not(.datepicker)[name=field'+custom_field_key+'_value\\[\\]]'); + var checkbox_recovery_selector = $('input:not(.datepicker)[name=field'+custom_field_key+'_recovery_value\\[\\]]'); + + checkbox_selector.on('change', function() { + if (checkbox_selector.prop('checked')) { + checkbox_selector.attr('value', "1"); + } else { + checkbox_selector.attr('value', "0"); + } + }); + + checkbox_recovery_selector.on('change', function() { + if (checkbox_recovery_selector.prop('checked')) { + checkbox_recovery_selector.attr('value', "1"); + } else { + checkbox_recovery_selector.attr('value', "0"); + } + }); + + if (typeof values[key] !== "undefined") { + if (values[key] == 1) { + checkbox_selector.prop('checked', true); + checkbox_selector.attr('value', "1"); + } else { + checkbox_selector.prop('checked', false); + checkbox_selector.attr('value', "0"); + } + } + + if (typeof recovery_values[key] !== "undefined") { + if (recovery_values[key] == 1) { + checkbox_recovery_selector.prop('checked', true); + checkbox_recovery_selector.attr('value', "1"); + } else { + checkbox_recovery_selector.prop('checked', false); + checkbox_recovery_selector.attr('value', "0"); + } + } + + $('[name=field'+custom_field_key+'_value_container]').show(); + $('[name=field'+custom_field_key+'_recovery_value_container]').show(); + $('input:not(.datepicker)[name=field'+custom_field_key+'_value\\[\\]]').show(); + $('input:not(.datepicker)[name=field'+custom_field_key+'_recovery_value\\[\\]]').show(); + break; + case 'combo': + var combo_input = $('select[name=field'+custom_field_key+'_value\\[\\]]'); + var combo_input_recovery = $('select[name=field'+custom_field_key+'_recovery_value\\[\\]]'); + + combo_input.find('option').remove(); + combo_input_recovery.find('option').remove(); + + var combo_values_array = custom_field.combo_value.split(','); + + combo_values_array.forEach(function(value) { + combo_input.append($('
'; + echo '
'; } else { include_once $config['homedir'].'/general/first_task/custom_graphs.php'; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 298e36aa25..0a6c53d766 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -2763,17 +2763,13 @@ $class = 'databox filters'; -<<<<<<< HEAD - - -======= - - + + - + - - ->>>>>>> origin/develop + + '; @@ -687,7 +687,7 @@ if (defined('METACONSOLE')) { echo "
"; html_print_input_hidden('ids_items_to_delete', ''); - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete right mrgn_btn_15px"'); echo '
'; echo ''; } diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 1e3e5c79f0..3f1867591e 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -216,6 +216,11 @@ $buttons['websocket_engine'] = [ ).'', ]; +$buttons['external_tools'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/nettool.png', true, ['title' => __('External Tools'), 'class' => 'invert_filter']).'', +]; + if ($config['activate_gis']) { $buttons['gis'] = [ 'active' => false, @@ -298,6 +303,12 @@ switch ($section) { $help_header = 'quickshell_settings'; break; + case 'external_tools': + $buttons['external_tools']['active'] = true; + $subpage = ' » '.__('External Tools'); + $help_header = 'External_Tools'; + break; + case 'enterprise': $buttons['enterprise']['active'] = true; $subpage = ' » '.__('Enterprise'); @@ -370,6 +381,10 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_websocket_engine.php'; break; + case 'external_tools': + include_once $config['homedir'].'/godmode/setup/setup_external_tools.php'; + break; + default: enterprise_hook('setup_enterprise_select_tab', [$section]); break; diff --git a/pandora_console/godmode/setup/setup_external_tools.php b/pandora_console/godmode/setup/setup_external_tools.php new file mode 100644 index 0000000000..30bdd6b188 --- /dev/null +++ b/pandora_console/godmode/setup/setup_external_tools.php @@ -0,0 +1,48 @@ +getMessage(); + + // Stop this execution, but continue 'globally'. + return; +} + +$obj->run(); diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index ad8e88194e..6401cd2949 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -27,32 +27,6 @@ */ // File begin. - - -/** - * Return sounds path. - * - * @return string Path. - */ -function get_sounds() -{ - global $config; - - $return = []; - - $files = scandir($config['homedir'].'/include/sounds'); - - foreach ($files as $file) { - if (strstr($file, 'wav') !== false) { - $return['include/sounds/'.$file] = $file; - } - } - - return $return; -} - - -// Begin. global $config; @@ -348,76 +322,6 @@ $table->data[$i++][1] .= '  '.html_print_select( true ); -$sounds = get_sounds(); -$table->data[$i][0] = __('Sound for Alert fired'); -$table->data[$i][1] = html_print_select( - $sounds, - 'sound_alert', - $config['sound_alert'], - 'replaySound(\'alert\');', - '', - '', - true -); -$table->data[$i][1] .= ' '.html_print_image( - 'images/control_play_col.png', - true, - [ - 'id' => 'button_sound_alert', - 'style' => 'vertical-align: middle;', - 'width' => '16', - 'title' => __('Play sound'), - 'class' => 'invert_filter', - ] -).''; -$table->data[$i++][1] .= '
'; - -$table->data[$i][0] = __('Sound for Monitor critical'); -$table->data[$i][1] = html_print_select( - $sounds, - 'sound_critical', - $config['sound_critical'], - 'replaySound(\'critical\');', - '', - '', - true -); -$table->data[$i][1] .= ' '.html_print_image( - 'images/control_play_col.png', - true, - [ - 'id' => 'button_sound_critical', - 'style' => 'vertical-align: middle;', - 'width' => '16', - 'title' => __('Play sound'), - 'class' => 'invert_filter', - ] -).''; -$table->data[$i++][1] .= '
'; - -$table->data[$i][0] = __('Sound for Monitor warning'); -$table->data[$i][1] = html_print_select( - $sounds, - 'sound_warning', - $config['sound_warning'], - 'replaySound(\'warning\');', - '', - '', - true -); -$table->data[$i][1] .= ' '.html_print_image( - 'images/control_play_col.png', - true, - [ - 'id' => 'button_sound_warning', - 'style' => 'vertical-align: middle;', - 'width' => '16', - 'title' => __('Play sound'), - 'class' => 'invert_filter', - ] -).''; -$table->data[$i++][1] .= '
'; - $table->data[$i][0] = __('Public URL'); $table->data[$i++][1] = html_print_input_text( 'public_url', @@ -773,24 +677,6 @@ echo ''.__('Mail configuration').''; ?> + __('Module alerts')]); + $module['alertsImageHTML'] = html_print_image('images/bell_orange.png', true, ['title' => __('Module alerts'), 'style' => 'filter: initial']); } else { - $module['alertsImageHTML'] = html_print_image('images/bell_green.png', true, ['title' => __('Module alerts')]); + $module['alertsImageHTML'] = html_print_image('images/bell_green.png', true, ['title' => __('Module alerts'), 'style' => 'filter: initial']); } } } diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 45e58db6d9..d53ce18b66 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC210311'; +$build_version = 'PC210318'; $pandora_version = 'v7.0NG.752'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index f5600f4ef6..19520f9791 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -749,3 +749,10 @@ define('MODULE_TYPE_REMOTE_CMD_PROC', 35); define('MODULE_TYPE_REMOTE_CMD_STRING', 36); define('MODULE_TYPE_REMOTE_CMD_INC', 37); define('MODULE_TYPE_KEEP_ALIVE', 100); + +// Commands basics for external tools. +define('COMMAND_TRACEROUTE', 1); +define('COMMAND_PING', 2); +define('COMMAND_SNMP', 3); +define('COMMAND_NMAP', 4); +define('COMMAND_DIGWHOIS', 5); diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index df12801680..9e27001d15 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -2750,6 +2750,7 @@ function alerts_ui_update_or_create_actions($update=true) $id_alert_command = (int) get_parameter('id_command'); $group = get_parameter('group'); $action_threshold = (int) get_parameter('action_threshold'); + $create_wu_integria = (int) get_parameter('create_wu_integria'); // Validate some values if (!$id_alert_command) { @@ -2772,14 +2773,36 @@ function alerts_ui_update_or_create_actions($update=true) $info_fields = ''; $values = []; for ($i = 1; $i <= $config['max_macro_fields']; $i++) { - $values['field'.$i] = (string) get_parameter('field'.$i.'_value'); + $field_value = get_parameter('field'.$i.'_value'); + + if (is_array($field_value)) { + $field_value = reset(array_filter($field_value)); + + if ($field_value === false) { + $field_value = ''; + } + } + + $values['field'.$i] = (string) $field_value; $info_fields .= ' Field'.$i.': '.$values['field'.$i]; - $values['field'.$i.'_recovery'] = (string) get_parameter('field'.$i.'_recovery_value'); + + $field_recovery_value = get_parameter('field'.$i.'_recovery_value'); + + if (is_array($field_recovery_value)) { + $field_recovery_value = reset(array_filter($field_recovery_value)); + + if ($field_recovery_value === false) { + $field_recovery_value = ''; + } + } + + $values['field'.$i.'_recovery'] = (string) $field_recovery_value; $info_fields .= ' Field'.$i.'Recovery: '.$values['field'.$i.'_recovery']; } $values['id_group'] = $group; $values['action_threshold'] = $action_threshold; + $values['create_wu_integria'] = $create_wu_integria; if ($update) { $values['name'] = $name; $values['id_alert_command'] = $id_alert_command; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 906cfb5838..1a6a396ee3 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1564,7 +1564,13 @@ function config_update_config() $error_update[] = __('Integria password'); } - if (!config_update_value('integria_hostname', (string) get_parameter('integria_hostname', $config['integria_hostname']))) { + $integria_hostname = (string) get_parameter('integria_hostname', $config['integria_hostname']); + + if (parse_url($integria_hostname, PHP_URL_SCHEME) === null) { + $integria_hostname = 'http://'.$integria_hostname; + } + + if (!config_update_value('integria_hostname', $integria_hostname)) { $error_update[] = __('integria API hostname'); } @@ -1942,6 +1948,10 @@ function config_process_config() config_update_value('collection_max_size', 1000000); } + if (!isset($config['policy_add_max_agents'])) { + config_update_value('policy_add_max_agents', 200); + } + if (!isset($config['event_replication'])) { config_update_value('event_replication', 0); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c40b9fc49c..f3ff4c9821 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_reporting.php'; require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_users.php'; +require_once $config['homedir'].'/include/functions_integriaims.php'; /** @@ -2971,43 +2972,25 @@ function graph_sla_slicebar( function grafico_incidente_prioridad() { global $config; - global $graphic_type; - $data_tmp = [ - 0, - 0, - 0, - 0, - 0, - 0, - ]; - $sql = 'SELECT COUNT(id_incidencia) n_incidents, prioridad - FROM tincidencia - GROUP BY prioridad - ORDER BY 2 DESC'; - $incidents = db_get_all_rows_sql($sql); + $integria_ticket_count_by_priority_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['prioridad', 30], false, '', '|;|'); - if ($incidents == false) { - $incidents = []; + $integria_priorities_map_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', '', false, 'json'); + + $integria_ticket_count_by_priority = json_decode($integria_ticket_count_by_priority_json, true); + $integria_priorities_map = json_decode($integria_priorities_map_json, true); + + $integria_priorities_map_ids = array_column($integria_priorities_map, 'id'); + $integria_priorities_map_names = array_column($integria_priorities_map, 'name'); + $integria_priorities_map_indexed_by_id = array_combine($integria_priorities_map_ids, $integria_priorities_map_names); + + $data = []; + + foreach ($integria_ticket_count_by_priority as $item) { + $priority_name = $integria_priorities_map_indexed_by_id[$item['prioridad']]; + $data[__($priority_name)] = $item['n_incidents']; } - foreach ($incidents as $incident) { - if ($incident['prioridad'] < 5) { - $data_tmp[$incident['prioridad']] = $incident['n_incidents']; - } else { - $data_tmp[5] += $incident['n_incidents']; - } - } - - $data = [ - __('Informative') => $data_tmp[0], - __('Low') => $data_tmp[1], - __('Medium') => $data_tmp[2], - __('Serious') => $data_tmp[3], - __('Very serious') => $data_tmp[4], - __('Maintenance') => $data_tmp[5], - ]; - if ($config['fixed_graph'] == false) { $water_mark = [ 'file' => $config['homedir'].'/images/logo_vertical_water.png', @@ -3034,52 +3017,23 @@ function grafico_incidente_prioridad() function graph_incidents_status() { global $config; - global $graphic_type; - $data = [ - 0, - 0, - 0, - 0, - ]; + + $integria_ticket_count_by_status_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['estado', 30], false, '', '|;|'); + + $integria_status_map_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status', '', false, 'json'); + + $integria_ticket_count_by_status = json_decode($integria_ticket_count_by_status_json, true); + $integria_status_map = json_decode($integria_status_map_json, true); + + $integria_status_map_ids = array_column($integria_status_map, 'id'); + $integria_status_map_names = array_column($integria_status_map, 'name'); + $integria_status_map_indexed_by_id = array_combine($integria_status_map_ids, $integria_status_map_names); $data = []; - $data[__('Open incident')] = 0; - $data[__('Closed incident')] = 0; - $data[__('Outdated')] = 0; - $data[__('Invalid')] = 0; - $incidents = db_get_all_rows_filter( - 'tincidencia', - [ - 'estado' => [ - 0, - 2, - 3, - 13, - ], - ], - ['estado'] - ); - if ($incidents === false) { - $incidents = []; - } - - foreach ($incidents as $incident) { - if ($incident['estado'] == 0) { - $data[__('Open incident')]++; - } - - if ($incident['estado'] == 2) { - $data[__('Closed incident')]++; - } - - if ($incident['estado'] == 3) { - $data[__('Outdated')]++; - } - - if ($incident['estado'] == 13) { - $data[__('Invalid')]++; - } + foreach ($integria_ticket_count_by_status as $item) { + $status_name = $integria_status_map_indexed_by_id[$item['estado']]; + $data[__($status_name)] = $item['n_incidents']; } if ($config['fixed_graph'] == false) { @@ -3108,53 +3062,19 @@ function graph_incidents_status() function graphic_incident_group() { global $config; - global $graphic_type; + + $integria_ticket_count_by_group_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['id_grupo', 30], false, '', '|;|'); + + $integria_group_map_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', '', false, 'json'); + + $integria_ticket_count_by_group = json_decode($integria_ticket_count_by_group_json, true); + $integria_group_map = json_decode($integria_group_map_json, true); $data = []; - $max_items = 5; - switch ($config['dbtype']) { - case 'mysql': - $sql = sprintf( - 'SELECT COUNT(id_incidencia) n_incidents, nombre - FROM tincidencia,tgrupo - WHERE tgrupo.id_grupo = tincidencia.id_grupo - GROUP BY tgrupo.id_grupo, nombre ORDER BY 1 DESC LIMIT %d', - $max_items - ); - break; - case 'oracle': - $sql = sprintf( - 'SELECT COUNT(id_incidencia) n_incidents, nombre - FROM tincidencia,tgrupo - WHERE tgrupo.id_grupo = tincidencia.id_grupo - AND rownum <= %d - GROUP BY tgrupo.id_grupo, nombre ORDER BY 1 DESC', - $max_items - ); - break; - } - - $incidents = db_get_all_rows_sql($sql); - - $sql = sprintf( - 'SELECT COUNT(id_incidencia) n_incidents - FROM tincidencia - WHERE tincidencia.id_grupo = 0' - ); - - $incidents_all = db_get_value_sql($sql); - - if ($incidents == false) { - $incidents = []; - } - - foreach ($incidents as $incident) { - $data[$incident['nombre']] = $incident['n_incidents']; - } - - if ($incidents_all > 0) { - $data[__('All')] = $incidents_all; + foreach ($integria_ticket_count_by_group as $item) { + $group_name = $integria_group_map[$item['id_grupo']]; + $data[__($group_name)] = $item['n_incidents']; } if ($config['fixed_graph'] == false) { @@ -3188,47 +3108,15 @@ function graphic_incident_group() function graphic_incident_user() { global $config; - global $graphic_type; + + $integria_ticket_count_by_user_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['id_usuario', 30], false, '', '|;|'); + + $integria_ticket_count_by_user = json_decode($integria_ticket_count_by_user_json, true); $data = []; - $max_items = 5; - switch ($config['dbtype']) { - case 'mysql': - $sql = sprintf( - 'SELECT COUNT(id_incidencia) n_incidents, id_usuario - FROM tincidencia - GROUP BY id_usuario - ORDER BY 1 DESC LIMIT %d', - $max_items - ); - break; - case 'oracle': - $sql = sprintf( - 'SELECT COUNT(id_incidencia) n_incidents, id_usuario - FROM tincidencia - WHERE rownum <= %d - GROUP BY id_usuario - ORDER BY 1 DESC', - $max_items - ); - break; - } - - $incidents = db_get_all_rows_sql($sql); - - if ($incidents == false) { - $incidents = []; - } - - foreach ($incidents as $incident) { - if ($incident['id_usuario'] == false) { - $name = __('System'); - } else { - $name = $incident['id_usuario']; - } - - $data[$name] = $incident['n_incidents']; + foreach ($integria_ticket_count_by_user as $item) { + $data[__($item['id_usuario'])] = $item['n_incidents']; } if ($config['fixed_graph'] == false) { diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 2f0e7f501f..c2ec13be47 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -4048,7 +4048,7 @@ function html_print_autocomplete_modules( ob_start(); - $module_icon = 'images/module.png'; + $module_icon = 'images/search_module.png'; if ($config['style'] === 'pandora_black') { $module_icon = 'images/brick.menu.png'; } diff --git a/pandora_console/include/functions_integriaims.php b/pandora_console/include/functions_integriaims.php index 3edbce37f2..4c5f02c3ae 100644 --- a/pandora_console/include/functions_integriaims.php +++ b/pandora_console/include/functions_integriaims.php @@ -161,22 +161,32 @@ function integriaims_get_details($details, $detail_index=false) * @param string User password. * @param string API password. * @param string API Operation. - * @param array Array with parameters required by the API function. + * @param mixed String or array with parameters required by the API function. * * @return boolean True if API request succeeded, false if API request failed. */ -function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operation, $params_array=[], $show_credentials_error_msg=false) +function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operation, $params='', $show_credentials_error_msg=false, $return_type='', $token='') { - $params_string = implode(',', $params_array); + if (is_array($params)) { + $params = implode($token, $params); + } $url_data = [ 'user' => $user, 'user_pass' => $user_pass, 'pass' => $api_pass, 'op' => $operation, - 'params' => html_entity_decode($params_string), + 'params' => html_entity_decode($params), ]; + if ($return_type !== '') { + $url_data['return_type'] = $return_type; + } + + if ($token !== '') { + $url_data['token'] = $token; + } + // Build URL for API request. $url = $api_hostname.'/integria/include/api.php'; @@ -355,7 +365,10 @@ function get_tickets_integriaims($tickets_filters) '0', $incident_owner, $incident_creator, - ] + ], + false, + '', + ',' ); // Return array of api call 'get_incidents'. diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index ec31f20cc2..5c55dd4e69 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -144,7 +144,7 @@ function snmp_browser_get_html_tree( // Branch or leave with branches! if (isset($sub_level['__OID__'])) { $output .= ""; - $output .= ''; + $output .= ''; $output .= ''; } @@ -636,7 +636,7 @@ function snmp_browser_print_oid( __('Create network component'), 'create_network_component', false, - 'class="sub add"', + 'class="sub add float-left"', true ); @@ -1024,7 +1024,7 @@ function snmp_browser_print_container( if ($snmp_version == 3) { $output .= '
'; } else { - $output .= ''; $output .= '
'; diff --git a/pandora_console/include/functions_themes.php b/pandora_console/include/functions_themes.php index 456a2337cc..3fdead3998 100644 --- a/pandora_console/include/functions_themes.php +++ b/pandora_console/include/functions_themes.php @@ -43,7 +43,11 @@ function themes_get_css($path=false) $retval = []; foreach ($files as $file) { - // Skip '..' and '.' entries and files not ended in '.css' + if ($file === 'pandora_green_old.css') { + continue; + } + + // Skip '..' and '.' entries and files not ended in '.css'. if ($path && ($file == '.' || $file == '..' || strtolower(substr($file, (strlen($file) - 4))) !== '.css')) { continue; } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 8026bd12c2..267b5123c4 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -4689,7 +4689,7 @@ function ui_print_agent_autocomplete_input($parameters) } // Default value. - $icon_agent = 'images/agent.png'; + $icon_agent = 'images/search_agent.png'; if ($config['style'] === 'pandora_black') { $icon_agent = 'images/agent_mc.menu.png'; diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 6b05e0e680..d992a9d5fa 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -452,7 +452,7 @@ function initialiceLayout(data) { $(".add-widget").show(); $(".new-widget-message").hide(); $("#container-layout").addClass("container-layout"); - $("#add-widget").show(); + $("#add-widget").removeClass("invisible"); } else { grid.movable(".grid-stack-item", false); grid.resizable(".grid-stack-item", false); @@ -461,7 +461,7 @@ function initialiceLayout(data) { $(".add-widget").hide(); $(".new-widget-message").show(); $("#container-layout").removeClass("container-layout"); - $("#add-widget").hide(); + $("#add-widget").addClass("invisible"); } }); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 935520bc78..6827b19220 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -1775,7 +1775,7 @@ table.databox { padding: 9px 7px; font-weight: normal; color: #fff; - text-align: justify; + text-align: center; } .databox > th * { @@ -6261,6 +6261,13 @@ div.graph div.legend table { white-space: nowrap; } +/* NetTools */ +#add_button_custom_command { + float: left; + cursor: pointer; + margin: -3px 0 0 1em; +} + .sound_events { background-color: #494949; max-width: 550px; diff --git a/pandora_console/install.php b/pandora_console/install.php index 30f37720b7..8211415152 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
class = 'info_table'; $table->head = []; $table->head[0] = __('Agent').ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectNameUp, $selectNameDown); -$table->size[0] = '10%'; +$table->size[0] = '12%'; $table->head[1] = __('Description').ui_get_sorting_arrows($url_up_description, $url_down_description, $selectDescriptionUp, $selectDescriptionDown); $table->size[1] = '16%'; diff --git a/pandora_console/operation/agentes/external_tools.php b/pandora_console/operation/agentes/external_tools.php new file mode 100644 index 0000000000..1d57c06f81 --- /dev/null +++ b/pandora_console/operation/agentes/external_tools.php @@ -0,0 +1,48 @@ +getMessage(); + + // Stop this execution, but continue 'globally'. + return; +} + +$obj->run(); diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index befd7439fb..61dfda1a22 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -190,7 +190,7 @@ if (!empty($result_groups)) { echo ''; echo "".__('Force').''; - echo "".__('Group').'/'.__('Tags').''; + echo "".__('Group').'/'.__('Tags').''; echo "".__('Total').''; echo "".__('Unknown').''; echo "".__('Not init').''; @@ -319,7 +319,7 @@ if (!empty($result_groups)) { $link = ""; } else { - $link = ""; } @@ -336,7 +336,7 @@ if (!empty($result_groups)) { // Agents not init echo ""; if (isset($data['_is_tag_'])) { - $link = ""; } else { $link = ""; } else { - $link = ""; } diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 3de7ae4608..01a21bf19d 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -1500,6 +1500,13 @@ if ($is_sap) { $saptab = ''; } +// External Tools tab. +$external_tools['text'] = ''.html_print_image('images/nettool.png', true, ['title' => __('External Tools')]).''; +if ($tab == 'external_tools') { + $external_tools['active'] = true; +} else { + $external_tools['active'] = false; +} $onheader = [ 'manage' => $managetab, @@ -1515,14 +1522,12 @@ $onheader = [ 'wux_console' => $wux_console_tab, 'url_route_analyzer' => $url_route_analyzer_tab, 'sap_view' => $saptab, - + 'external_tools' => $external_tools, ]; -// Added after it exists -// If the agent has incidents associated. -if ($total_incidents) { - $onheader['incident'] = $incidenttab; -} + +$onheader['incident'] = $incidenttab; + if ($agent['url_address'] != '') { $onheader['url_address'] = $urladdresstab; @@ -1684,6 +1689,10 @@ switch ($tab) { $tab_name = 'SAP View'; break; + case 'external_tools': + $tab_name = 'External Tools'; + break; + default: $tab_name = ''; $help_header = ''; @@ -1804,6 +1813,10 @@ switch ($tab) { include 'general/sap_view.php'; break; + case 'external_tools': + include 'external_tools.php'; + break; + case 'extension': $found = false; foreach ($config['extensions'] as $extension) { diff --git a/pandora_console/operation/incidents/configure_integriaims_incident.php b/pandora_console/operation/incidents/configure_integriaims_incident.php index 8e07ca7eff..195ee7350f 100644 --- a/pandora_console/operation/incidents/configure_integriaims_incident.php +++ b/pandora_console/operation/incidents/configure_integriaims_incident.php @@ -37,12 +37,12 @@ if ($update) { // Check if Integria integration enabled. if ($config['integria_enabled'] == 0) { - ui_print_error_message(__('Integria integration must be enabled in Pandora setup')); + ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured')); return; } // Check connection to Integria IMS API. -$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []); +$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login'); if ($has_connection === false) { ui_print_error_message(__('Integria IMS API is not reachable')); @@ -59,19 +59,19 @@ $integria_users_values = []; $integria_types_values = []; $integria_status_values = []; -$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []); +$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups'); get_array_from_csv_data_pair($integria_groups_csv, $integria_group_values); -$integria_status_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status', []); +$integria_status_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status'); get_array_from_csv_data_pair($integria_status_csv, $integria_status_values); -$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []); +$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities'); get_array_from_csv_data_pair($integria_criticity_levels_csv, $integria_criticity_values); -$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []); +$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users'); $csv_array = explode("\n", $integria_users_csv); @@ -81,7 +81,7 @@ foreach ($csv_array as $csv_line) { } } -$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []); +$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types'); get_array_from_csv_data_pair($integria_types_csv, $integria_types_values); @@ -105,7 +105,7 @@ $incident_content = str_replace(',', ':::', $incident_content); // Perform action. if ($create_incident === true) { // Call Integria IMS API method to create an incident. - $result_api_call = integria_api_call($config['integria_hostname'], $incident_creator, $config['integria_pass'], $config['integria_api_pass'], 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status]); + $result_api_call = integria_api_call($config['integria_hostname'], $incident_creator, $config['integria_pass'], $config['integria_api_pass'], 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status], false, '', ','); // Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value. $incident_created_ok = ($result_api_call != false) ? true : false; @@ -117,7 +117,7 @@ if ($create_incident === true) { ); } else if ($update_incident === true) { // Call Integria IMS API method to update an incident. - $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, 0, $incident_status, $incident_owner, 0, $incident_type]); + $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, 0, $incident_status, $incident_owner, 0, $incident_type], false, '', ','); // Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value. $incident_updated_ok = ($result_api_call != false) ? true : false; @@ -132,7 +132,7 @@ if ($create_incident === true) { // If incident id is specified, retrieve incident values from api to populate combos with such values. if ($update) { // Call Integria IMS API method to get details of an incident given its id. - $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_details', [$incident_id_edit]); + $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_details', [$incident_id_edit], false, '', ','); // API call does not return indexes, therefore future modifications of API function in Integria IMS may lead to inconsistencies when accessing resulting array in this file. $incident_details_separator = explode(',', $result_api_call); diff --git a/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php b/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php index bb7050344c..9b195342cc 100644 --- a/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php +++ b/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php @@ -27,7 +27,7 @@ if (!check_acl($config['id_user'], 0, 'IR')) { // Check if Integria integration enabled. if ($config['integria_enabled'] == 0) { - ui_print_error_message(__('Integria integration must be enabled in Pandora setup')); + ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured')); return; } @@ -265,7 +265,7 @@ $table_files_section->data[1][0] .= html_print_textarea( $table_files_section->data[2][0] .= '
'.html_print_submit_button(__('Upload'), 'accion', false, 'class="sub wand"', true).'
'; -$upload_file_form = '
'; +$upload_file_form = '
'; if (check_acl($config['id_user'], 0, 'IW')) { $upload_file_form .= '
'.'

'.__('Add attachment').'

'.html_print_table($table_files_section, true).html_print_input_hidden('upload_file', 1, true); @@ -359,7 +359,7 @@ if (!empty($comments)) { $comment_table = __('No comments found'); } -$upload_comment_form = '
'; +$upload_comment_form = '
'; if (check_acl($config['id_user'], 0, 'IW')) { $upload_comment_form .= '

'.__('Add comment').'

'.html_print_table($table_comments_section, true).html_print_input_hidden('upload_comment', 1, true).''; diff --git a/pandora_console/operation/incidents/incident.php b/pandora_console/operation/incidents/incident.php deleted file mode 100755 index 52356b9262..0000000000 --- a/pandora_console/operation/incidents/incident.php +++ /dev/null @@ -1,503 +0,0 @@ - - -= 0) { - // -1 = All - $filter .= sprintf(' AND estado = %d', $estado); -} - -$grupo = (int) get_parameter('grupo', 0); -if ($grupo > 0) { - $filter .= sprintf(' AND id_grupo = %d', $grupo); - if (check_acl($config['id_user'], $grupo, 'IM') == 0) { - db_pandora_audit('ACL Forbidden', 'User tried to read incidents from group without access'); - include 'general/noaccess.php'; - exit; - } -} - -$prioridad = (int) get_parameter('prioridad', -1); -if ($prioridad != -1) { - // -1 = All - $filter .= sprintf(' AND prioridad = %d', $prioridad); -} - -$agent_search = (int) get_parameter('agent_search'); -if ($agent_search != 0) { - $filter .= sprintf(' AND id_agent = %d', $agent_search); -} - -$offset = (int) get_parameter('offset', 0); -$groups = users_get_groups($config['id_user'], 'IR'); - -// Select incidencts where the user has access to ($groups from -// get_user_groups), array_keys for the id, implode to pass to SQL -switch ($config['dbtype']) { - case 'mysql': - $sql = 'SELECT * FROM tincidencia WHERE - id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.' - ORDER BY actualizacion DESC LIMIT '.$offset.','.$config['block_size']; - $count_sql = 'SELECT count(*) FROM tincidencia WHERE - id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.' - ORDER BY actualizacion DESC'; - $total_sql = 'SELECT count(*) FROM tincidencia WHERE - id_grupo IN ('.implode(',', array_keys($groups)).') - ORDER BY actualizacion DESC'; - break; - - case 'postgresql': - case 'oracle': - $set = []; - $set['limit'] = $config['block_size']; - $set['offset'] = $offset; - $sql = 'SELECT * FROM tincidencia WHERE - id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter.' - ORDER BY actualizacion DESC'; - $sql = oracle_recode_query($sql, $set); - $count_sql = 'SELECT count(*) FROM tincidencia WHERE - id_grupo IN ('.implode(',', array_keys($groups)).')'.$filter; - $total_sql = 'SELECT count(*) FROM tincidencia WHERE - id_grupo IN ('.implode(',', array_keys($groups)).')'; - break; -} - -$result = db_get_all_rows_sql($sql); -$count = db_get_value_sql($count_sql); -$count_total = db_get_value_sql($total_sql); - -if (empty($result)) { - $result = []; - $count = 0; -} - -if ($count_total >= 1) { - echo '
'; - - echo ' -

'.__('Filter').'

'; - - $fields = incidents_get_status(); - echo ''.__('Incidents:').''.'  '; - html_print_select($fields, 'estado', $estado, 'javascript:this.form.submit();', __('All incidents'), -1, false, false, false, 'w155'); - - // Legend - echo '

'.__('Status').'

'; - foreach (incidents_get_status() as $id => $str) { - incidents_print_status_img($id); - echo ' - '.$str.'
'; - } - - echo '

'.__('Priority').'

'; - foreach (incidents_get_priorities() as $id => $str) { - incidents_print_priority_img($id); - echo ' - '.$str.'
'; - } - - echo '
'; - - $fields = incidents_get_priorities(); - - echo ''.__('Priorities:').''.'  '; - html_print_select($fields, 'prioridad', $prioridad, 'javascript:this.form.submit();', __('All priorities'), -1, false, false, false, 'w155'); - - echo '
'; - - echo ''.__('Users:').''.'  '; - html_print_select(users_get_info(), 'usuario', $usuario, 'javascript:this.form.submit();', __('All users'), '', false, false, false, 'w155'); - - echo '
'; - - $agents_incidents = agents_get_agents(false, ['id_agente', 'nombre']); - - if ($agents_incidents === false) { - $agents_incidents = []; - } - - $result_agent_incidents = []; - foreach ($agents_incidents as $agent_incident) { - $result_agent_incidents[$agent_incident['id_agente']] = $agent_incident['nombre']; - } - - echo ''.__('Agents:').''.'  '; - html_print_select( - $result_agent_incidents, - 'agent_search', - $agent_search, - 'javascript:this.form.submit();', - __('All agents'), - '', - false, - false, - false, - 'w155' - ); - - echo '
'; - - echo ''.__('Groups:').''.'  '; - echo '
'; - html_print_select_groups($config['id_user'], 'IR', true, 'grupo', $grupo, 'javascript:this.form.submit();', '', '', false, false, false, 'w155'); - echo '
'; - - // echo "    "; - echo '
'; - - echo ''.__('Free text:').''.ui_print_help_tip( - __('Search by incident name or description, list matches.'), - true - ).'  '; - html_print_input_text('texto', $texto, '', 45); - echo ' '; - html_print_input_image('submit', 'images/zoom.png', __('Search'), 'padding:0;', false, ['alt' => __('Search')]); - - echo '
'; - echo '
'; -} - -if ($count_total < 1) { - include_once $config['homedir'].'/general/first_task/incidents.php'; -} else { - // TOTAL incidents - $url = 'index.php?sec=workspace&sec2=operation/incidents/incident'; - - $estado = -1; - - // add form filter values for group, priority, state, and search fields: user and text - if ($grupo != -1) { - $url .= '&grupo='.$grupo; - } - - if ($prioridad != -1) { - $url .= '&prioridad='.$prioridad; - } - - if ($estado != -1) { - $url .= '&estado='.$estado; - } - - if ($usuario != '') { - $url .= '&usuario='.$usuario; - } - - if ($texto != '') { - $url .= '&texto='.$texto; - } - - // Show pagination - ui_pagination($count, $url, $offset, 0, false); - // ($count + $offset) it's real count of incidents because it's use LIMIT $offset in query. - echo '
'; - - // Show headers - $table->width = '100%'; - $table->class = 'info_table'; - $table->cellpadding = 0; - $table->cellspacing = 0; - $table->head = []; - $table->data = []; - $table->size = []; - $table->align = []; - - $table->head[0] = html_print_checkbox('all_action', 0, false, true, false); - $table->head[1] = __('ID'); - $table->head[2] = __('Status'); - $table->head[3] = __('Incident'); - $table->head[4] = __('Priority'); - $table->head[5] = __('Group'); - $table->head[6] = __('Updated'); - $table->head[7] = __('Source'); - $table->head[8] = __('Owner'); - - $table->size[0] = '20px'; - - $table->align[0] = 'left'; - $table->align[2] = 'left'; - $table->align[4] = 'left'; - $table->align[5] = 'left'; - - $rowPair = true; - $iterator = 0; - foreach ($result as $row) { - if ($rowPair) { - $table->rowclass[$iterator] = 'rowPair'; - } else { - $table->rowclass[$iterator] = 'rowOdd'; - } - - $rowPair = !$rowPair; - $iterator++; - - $data = []; - - if (check_acl($config['id_user'], $row['id_grupo'], 'IM') || $config['id_user'] == $row['id_usuario'] || $config['id_user'] == $row['id_creator']) { - $data[0] = html_print_checkbox('id_inc[]', $row['id_incidencia'], false, true); - } else { - $data[0] = ''; - } - - $data[1] = ''.$row['id_incidencia'].''; - $attach = incidents_get_attach($row['id_incidencia']); - - if (!empty($attach)) { - $data[1] .= '  '.html_print_image('images/attachment.png', true, ['style' => 'align:middle;']); - } - - $data[2] = incidents_print_status_img($row['estado'], true); - $data[3] = ''.ui_print_truncate_text(io_safe_output($row['titulo']), 'item_title').''; - $data[4] = incidents_print_priority_img($row['prioridad'], true); - $data[5] = ui_print_group_icon($row['id_grupo'], true); - $data[6] = ui_print_timestamp($row['actualizacion'], true); - $data[7] = $row['origen']; - if (empty($row['id_usuario'])) { - $data[8] = 'SYSTEM'; - } else { - $data[8] = ui_print_username($row['id_usuario'], true); - } - - array_push($table->data, $data); - } - - echo '
'; - html_print_table($table); - echo '
'; - if (check_acl($config['id_user'], 0, 'IW')) { - html_print_submit_button(__('Delete incidents'), 'delete_btn', false, 'class="sub delete" class="mrgn_right_5px"'); - } - - if (check_acl($config['id_user'], 0, 'IM')) { - html_print_submit_button(__('Become owner'), 'own_btn', false, 'class="sub upd"'); - } - - echo '
'; - echo '
'; - unset($table); - if (check_acl($config['id_user'], 0, 'IW')) { - echo '
'; - echo '
'; - html_print_submit_button(__('Create incident'), 'crt', false, 'class="sub next"'); - echo '
'; - echo '
'; - } -} - - -echo '
 
'; diff --git a/pandora_console/operation/incidents/incident_detail.php b/pandora_console/operation/incidents/incident_detail.php deleted file mode 100755 index b432a7d34a..0000000000 --- a/pandora_console/operation/incidents/incident_detail.php +++ /dev/null @@ -1,532 +0,0 @@ -'); - $filesize = io_safe_input($_FILES['userfile']['size']); - - // The following is if you have clamavlib installed - // (php5-clamavlib) and enabled in php.ini - // http://www.howtoforge.com/scan_viruses_with_php_clamavlib - if (extension_loaded('clamav')) { - cl_setlimits(5, 1000, 200, 0, 10485760); - $malware = cl_scanfile($_FILES['file']['tmp_name']); - if ($malware) { - $error = 'Malware detected: '.$malware.'
ClamAV version: '.clam_get_version(); - die($error); - // On malware, we die because it's not good to handle it - } - } - - $sql = sprintf( - "INSERT INTO tattachment (id_incidencia, id_usuario, filename, description, size) - VALUES (%d, '%s', '%s', '%s', %d)", - $id_inc, - $config['id_user'], - $filename, - $description, - $filesize - ); - - $id_attachment = db_process_sql($sql, 'insert_id'); - - // Copy file to directory and change name - if ($id_attachment !== false) { - $nombre_archivo = $config['attachment_store'].'/pand'.$id_attachment.'_'.$_FILES['userfile']['name']; - - - $zip = new ZipArchive; - - if ($zip->open($nombre_archivo.'.zip', ZIPARCHIVE::CREATE) === true) { - $zip->addFile($_FILES['userfile']['tmp_name'], io_safe_output($filename)); - $zip->close(); - } - - - // $result = copy ($_FILES['userfile']['tmp_name'], $nombre_archivo); - } else { - ui_print_error_message(__('File could not be saved due to database error')); - $result = false; - } - - if ($result !== false) { - unlink($_FILES['userfile']['tmp_name']); - incidents_process_touch($id_inc); - } else { - db_process_sql('DELETE FROM tattachment WHERE id_attachment = '.$id_attachment); - } - - ui_print_result_message( - $result, - __('File uploaded'), - __('File could not be uploaded') - ); - } -} //end if -// Create incident from event... read event data -else if (isset($_GET['insert_form'])) { - $titulo = ''; - $descripcion = ''; - $origen = ''; - $prioridad = 0; - $id_grupo = 0; - $estado = 0; - $texto = ''; - $usuario = $config['id_user']; - $id_creator = $config['id_user']; - $id_grupo = 0; - $id_agent = 0; - - if (isset($_GET['from_event'])) { - $event = get_parameter('from_event'); - $texto = io_safe_output(events_get_description($event)); - $titulo = ui_print_truncate_text(events_get_description($event), 'description', false, true, false); - $id_grupo = events_get_group($event); - $origen = 'Pandora FMS Event'; - $id_agent = db_get_value('id_agente', 'tevento', 'id_evento', $event); - unset($event); - } - - $prioridad = 0; -} else { - db_pandora_audit('HACK', 'Trying to get to incident details in an unusual way'); - include 'general/noaccess.php'; - exit; -} - - - -// ******************************************************************************************************** -// ******************************************************************************************************** -// Show the form -// ******************************************************************************************************** -// This is for the pretty slide down attachment form -echo ""; - -if (isset($id_inc)) { - // If $id_inc is set (when $_GET["id"] is set, not $_GET["insert_form"] - ui_print_page_header(__('Incident details').' #'.$id_inc, 'images/book_edit.png', false, '', false, ''); - echo '
'; - echo ''; -} else { - ui_print_page_header(__('Create incident'), 'images/book_edit.png', false, '', false, ''); - echo ''; -} - -echo ''; -echo ' - - - '; - -echo ' - - - - - '; - -echo ' - - - - - '; - -echo ' - - '; -echo ''; - -echo ''; -echo ''; -echo ''; -echo ''; -echo '
'.__('Incident').''; - -if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) - or ($usuario == $config['id_user']) -) { - html_print_input_text('titulo', $titulo, '', 70); -} else { - html_print_input_text_extended('titulo', $titulo, '', '', 70, '', false, '', 'readonly'); -} - -echo '
'.__('Opened at').''.date($config['date_format'], $inicio).''.__('Updated at').''.date($config['date_format'], $actualizacion).'
'.__('Owner').''; - -if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) { - html_print_select(users_get_info(), 'usuario_form', $usuario, '', 'SYSTEM', '', false, false, true, 'w135'); -} else { - html_print_select(users_get_info(), 'usuario_form', $usuario, '', 'SYSTEM', '', false, false, true, 'w135', true); -} - -echo ''.__('Status').''; - -if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) { - html_print_select(incidents_get_status(), 'estado_form', $estado, '', '', '', false, false, false, 'w135'); -} else { - html_print_select(incidents_get_status(), 'estado_form', $estado, '', '', '', false, false, false, 'w135', true); -} - -echo '
'.__('Source').''; - -$fields = []; -$return = db_get_all_rows_sql('SELECT origen FROM torigen ORDER BY origen'); -if ($return === false) { - $return[0] = $estado; - // Something must be displayed -} - -foreach ($return as $row) { - $fields[$row['origen']] = $row['origen']; -} - -// Only owner could change source or user with Incident management privileges -if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) { - html_print_select($fields, 'origen_form', $origen, '', '', '', false, false, false, 'w135'); -} else { - html_print_select($fields, 'origen_form', $origen, '', '', '', false, false, false, 'w135', true); -} - -echo ''.__('Group').''; - -// Group combo -echo '
'; -if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) { - html_print_select_groups($config['id_user'], 'IR', true, 'grupo_form', $id_grupo, '', '', '', false, false, false, 'w135'); -} else { - html_print_select_groups($config['id_user'], 'IR', true, 'grupo_form', $id_grupo, '', '', '', false, false, true, 'w135', true); -} - -echo '
'; -echo '
'.__('Priority').''; - -if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) { - html_print_select(incidents_get_priorities(), 'prioridad_form', $prioridad, '', '', '', false, false, false, 'w135'); -} else { - html_print_select(incidents_get_priorities(), 'prioridad_form', $prioridad, '', '', '', false, false, false, 'w135', true); -} - -echo ''.__('Creator').''; -if (empty($id_creator)) { - echo 'SYSTEM'; -} else { - echo $id_creator.' ('.get_user_fullname($id_creator).')'; -} - -$agents_incidents = agents_get_agents(false, ['id_agente', 'nombre']); - -if ($agents_incidents === false) { - $agents_incidents = []; -} - -foreach ($agents_incidents as $agent_incident) { - $result_agent_incidents[$agent_incident['id_agente']] = $agent_incident['nombre']; -} - -echo '
'.__('Agent').''; -$params = []; -$params['show_helptip'] = true; -$params['input_name'] = 'agent'; -$params['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_agent); -$params['print_hidden_input_idagent'] = true; -$params['hidden_input_idagent_value'] = $id_agent; -$params['hidden_input_idagent_name'] = 'id_agent'; -ui_print_agent_autocomplete_input($params); -echo '
'; - -if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) { - html_print_textarea('descripcion', 15, 80, $texto, 'class="height_200px"'); -} else { - html_print_textarea('descripcion', 15, 80, $texto, 'class="height:200px" disabled'); -} - -echo '
'; - -// Only if user is the used who opened incident or (s)he is admin -if (isset($id_inc) and ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user']))) { - html_print_submit_button(__('Update incident'), 'accion', false, 'class="sub upd"'); -} else if (check_acl($config['id_user'], $id_grupo, 'IW')) { - html_print_submit_button(__('Create'), 'accion', false, 'class="sub wand"'); -} else { - html_print_submit_button(__('Submit'), 'accion', true, 'class="sub upd"'); -} - -echo '
'; - -// If we're actually working on an incident -if (isset($id_inc)) { - // ****************************************************************** - // Notes - // ****************************************************************** - echo '
'; - echo '

'.__('Add note').'

'; - - echo ' - - -
'; - - $result = incidents_get_notes($id_inc); - - $table->cellpadding = 4; - $table->cellspacing = 4; - $table->class = 'databox'; - $table->width = '98%'; - $table->data = []; - $table->head = []; - - foreach ($result as $row) { - $data = []; - $data[0] = html_print_image('images/page_white_text.png', true, ['class' => 'invert_filter', 'border' => '0']); - $data[1] = __('Author').': '.ui_print_username($row['id_usuario'], true).' ('.ui_print_timestamp($row['timestamp'], true).')'; - array_push($table->data, $data); - - $data = []; - $data[0] = ''; - if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($row['id_usuario'] == $config['id_user'])) { - $data[0] .= html_print_input_image('delete_nota', 'images/cross.png', $row['id_nota'], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true); - } - - $data[1] = $row['nota']; - array_push($table->data, $data); - } - - if (!empty($table->data)) { - echo '

'.__('Notes attached to incident').'

'; - echo '
'; - html_print_table($table); - echo '
'; - } - - unset($table); - - - // ****************************************************************** - // Files attached to this incident - // ****************************************************************** - $result = incidents_get_attach($id_inc); - - $table->cellpadding = 4; - $table->cellspacing = 4; - $table->class = 'databox'; - $table->width = '98%'; - $table->head = []; - $table->data = []; - - $table->head[0] = __('Filename'); - $table->head[1] = __('Description'); - $table->head[2] = __('Size'); - $table->head[3] = __('Delete'); - - $table->align[2] = 'center'; - $table->align[3] = 'center'; - - foreach ($result as $row) { - if (file_exists($config['homedir'].'/attachment/pand'.$row['id_attachment'].'_'.io_safe_output($row['filename']).'.zip')) { - $url = 'attachment/pand'.$row['id_attachment'].'_'.io_safe_output($row['filename']).'.zip'; - } else { - $url = 'attachment/pand'.$row['id_attachment'].'_'.io_safe_output($row['filename']); - } - - $data[0] = html_print_image('images/disk.png', true, ['border' => '0', 'align' => 'top']).'  '.$row['filename'].''; - $data[1] = $row['description']; - $data[2] = format_for_graph($row['size']).'B'; - if ((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($usuario == $config['id_user'])) { - $data[3] = html_print_input_image('delete_file', 'images/cross.png', $row['id_attachment'], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true); - } else { - $data[3] = ''; - } - - array_push($table->data, $data); - } - - if (!empty($table->data)) { - echo '

'.__('Attached files').'

'; - echo '
'; - html_print_table($table); - echo '
'; - } - - unset($table); - - // ****************************************************************** - // Upload control - // ****************************************************************** - // Upload control - if ((check_acl($config['id_user'], $id_grupo, 'IW') == 1)) { - echo ''; - - echo '

'.__('Add attachment').'

'; - echo ' - - - -
'.__('Filename').'
'.__('Description').'
'; - } -} diff --git a/pandora_console/operation/incidents/incident_statistics.php b/pandora_console/operation/incidents/incident_statistics.php index 7cabe749d7..af1867264f 100755 --- a/pandora_console/operation/incidents/incident_statistics.php +++ b/pandora_console/operation/incidents/incident_statistics.php @@ -26,6 +26,11 @@ if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], ui_print_page_header(__('Incidents').' » '.__('Statistics'), 'images/book_edit.png', false, '', false, ''); +if (!$config['integria_enabled']) { + ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured')); + exit; +} + echo '

'.__('Incidents by status').'

'; echo graph_incidents_status(); @@ -39,7 +44,4 @@ echo graphic_incident_group(); echo '

'.__('Incidents by user').'

'; echo graphic_incident_user(); -echo '

'.__('Incidents by source').'

'; -echo graphic_incident_source(); - echo '
'; diff --git a/pandora_console/operation/incidents/list_integriaims_incidents.php b/pandora_console/operation/incidents/list_integriaims_incidents.php index 9da970d00d..a352300cd2 100644 --- a/pandora_console/operation/incidents/list_integriaims_incidents.php +++ b/pandora_console/operation/incidents/list_integriaims_incidents.php @@ -38,7 +38,7 @@ ui_print_page_header( // Check if Integria integration enabled. if ($config['integria_enabled'] == 0) { - ui_print_error_message(__('Integria integration must be enabled in Pandora setup')); + ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured')); return; } diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index fe769e1525..5c30612969 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -493,9 +493,8 @@ if (check_acl($config['id_user'], 0, 'IR') ]; $sub2 = []; - $sub2['operation/incidents/incident']['text'] = __('List of Incidents'); - $sub2[$sec2sub]['text'] = __('Statistics'); - $sub2['operation/incidents/list_integriaims_incidents']['text'] = __('Integria IMS Tickets'); + $sub2[$sec2sub]['text'] = __('Integria IMS statistics'); + $sub2['operation/incidents/list_integriaims_incidents']['text'] = __('Integria IMS ticket list'); $sub[$sec2]['sub2'] = $sub2; $sec2 = $temp_sec2; diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index a4839cce25..9b5a194410 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -82,10 +82,10 @@ ui_print_page_header( // SNMP tree container. snmp_browser_print_container(false, '100%', '60%', '', true); -// Div for modal -echo ''; +// Div for modal. +echo ''; // Div for loading modal. -echo ''; +echo ''; ?> diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 269ef69203..7f17cedb19 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -565,7 +565,7 @@ $table_ichanges = '

'.__('Full list of pages').':

'.$select_out.'
-
+
'.html_print_image( 'images/darrowright_green.png', true, diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 425b1b5bf5..2c72229d9b 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 7.0NG.752 -%define release 210311 +%define release 210318 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index 3b942ae95c..1e6aea79bc 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.752 -%define release 210311 +%define release 210318 # 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 a767f3821f..76d1a74c67 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.752 -%define release 210311 +%define release 210318 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index a4c3174889..02eac23def 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -441,6 +441,7 @@ CREATE TABLE IF NOT EXISTS `talert_actions` ( `field19_recovery` text NOT NULL, `field20_recovery` text NOT NULL, `previous_name` text, + `create_wu_integria` tinyint(1) default NULL, PRIMARY KEY (`id`), FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`) ON DELETE CASCADE ON UPDATE CASCADE diff --git a/pandora_console/views/dashboard/layout.php b/pandora_console/views/dashboard/layout.php index de0273c684..09a6d76c2a 100644 --- a/pandora_console/views/dashboard/layout.php +++ b/pandora_console/views/dashboard/layout.php @@ -43,10 +43,10 @@ $output = ''; // Div for modal update dashboard. -$output .= ''; -$output .= ''; -$output .= ''; -$output .= ''; +$output .= ''; +$output .= ''; +$output .= ''; +$output .= ''; // Layout. $output .= '
'; diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index ec1a4d6834..555a1a534d 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.752-210311 +Version: 7.0NG.752-210318 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 354acc4570..3627800caa 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="7.0NG.752-210311" +pandora_version="7.0NG.752-210318" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 3fdaa7baef..d1bf8a6fb0 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -45,7 +45,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.752"; -my $pandora_build = "210311"; +my $pandora_build = "210318"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -60,11 +60,9 @@ my %pa_config; sub help_screen { print "\nSyntax: \n\n pandora_server [ options ] < fullpathname to configuration file > \n\n"; print "Following options are optional : \n"; - print " -v : Verbose mode activated. Writes more information in the logfile \n"; print " -d : Debug mode activated. Writes extensive information in the logfile \n"; print " -D : Daemon mode (runs in background)\n"; print " -P : Store PID to file.\n"; - print " -q : Quiet startup \n"; print " -S : Manage the win32 service.\n"; print " -h : This screen. Shows a little help screen \n"; print " \n"; @@ -103,18 +101,12 @@ sub pandora_init { if (($parametro =~ m/-h\z/i ) || ($parametro =~ m/help\z/i )) { help_screen(); } - elsif ($parametro =~ m/-v\z/i) { - $pa_config->{"verbosity"}=5; - } elsif ($parametro =~ m/^-P\z/i) { $pa_config->{'PID'}= clean_blank($ARGV[$ax+1]); } elsif ($parametro =~ m/-d\z/) { $pa_config->{"verbosity"}=10; } - elsif ($parametro =~ m/-q\z/) { - $pa_config->{"quiet"}=1; - } elsif ($parametro =~ m/-D\z/) { $pa_config->{"daemon"}=1; } @@ -826,7 +818,9 @@ sub pandora_load_config { $pa_config->{"snmp_proc_deadresponse"} = clean_blank($1); } elsif ($parametro =~ m/^verbosity\s+([0-9]*)/i) { - $pa_config->{"verbosity"} = clean_blank($1); + if ($pa_config->{"verbosity"} == 0) { + $pa_config->{"verbosity"} = clean_blank($1); + } } elsif ($parametro =~ m/^server_threshold\s+([0-9]*)/i) { $pa_config->{"server_threshold"} = clean_blank($1); diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 24b89ce1f1..462baadf56 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -44,8 +44,6 @@ Exported Functions: =item * C -=item * C - =item * C =item * C @@ -161,6 +159,9 @@ use LWP::Simple; use IO::Socket::INET6; use LWP::UserAgent; use HTTP::Request::Common; +use URI::URL; +use LWP::UserAgent; +use JSON; # For IPv6 support in Net::HTTP. BEGIN { @@ -179,7 +180,6 @@ our @EXPORT = qw( pandora_create_agent pandora_create_alert_command pandora_create_group - pandora_create_incident pandora_create_module pandora_create_module_from_hash pandora_create_module_from_network_component @@ -254,6 +254,8 @@ our @EXPORT = qw( pandora_self_monitoring pandora_sample_agent pandora_process_policy_queue + pandora_sync_agents_integria + pandora_get_integria_ticket_types subst_alert_macros subst_column_macros locate_agent @@ -1564,6 +1566,12 @@ sub pandora_execute_action ($$$$$$$$$;$) { # Integria IMS Ticket } elsif ($clean_name eq "Integria IMS Ticket") { + my $config_integria_enabled = pandora_get_tconfig_token ($dbh, 'integria_enabled', ''); + + if (!$config_integria_enabled) { + return; + } + my $config_api_path = pandora_get_tconfig_token ($dbh, 'integria_hostname', ''); my $config_api_pass = pandora_get_tconfig_token ($dbh, 'integria_api_pass', ''); my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', ''); @@ -1575,6 +1583,19 @@ sub pandora_execute_action ($$$$$$$$$;$) { $field5 = subst_alert_macros ($field5, \%macros, $pa_config, $dbh, $agent, $module, $alert); $field6 = subst_alert_macros ($field6, \%macros, $pa_config, $dbh, $agent, $module, $alert); $field7 = subst_alert_macros ($field7, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field8 = subst_alert_macros ($field8, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field9 = subst_alert_macros ($field9, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field10 = subst_alert_macros ($field10, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field11 = subst_alert_macros ($field11, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field12 = subst_alert_macros ($field12, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field13 = subst_alert_macros ($field13, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field14 = subst_alert_macros ($field14, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field15 = subst_alert_macros ($field15, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field16 = subst_alert_macros ($field16, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field17 = subst_alert_macros ($field17, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field18 = subst_alert_macros ($field18, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field19 = subst_alert_macros ($field19, \%macros, $pa_config, $dbh, $agent, $module, $alert); + $field20 = subst_alert_macros ($field20, \%macros, $pa_config, $dbh, $agent, $module, $alert); # Field 1 (Integria IMS API path) my $api_path = $config_api_path . "/integria/include/api.php"; @@ -1627,7 +1648,28 @@ sub pandora_execute_action ($$$$$$$$$;$) { # Field 7 (Ticket description); my $ticket_description = safe_output($field7); - pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_owner, $ticket_type, $ticket_status, $ticket_description); + my $create_wu_on_close_recovery = 0; + + if ($alert_mode == RECOVERED_ALERT && $action->{'create_wu_integria'} == '1') { + $create_wu_on_close_recovery = 1; + } + + # Ticket type custom fields + my $ticket_custom_field1 = $field8; + my $ticket_custom_field2 = $field9; + my $ticket_custom_field3 = $field10; + my $ticket_custom_field4 = $field11; + my $ticket_custom_field5 = $field12; + my $ticket_custom_field6 = $field13; + my $ticket_custom_field7 = $field14; + my $ticket_custom_field8 = $field15; + my $ticket_custom_field9 = $field16; + my $ticket_custom_field10 = $field17; + my $ticket_custom_field11 = $field18; + my $ticket_custom_field12 = $field19; + my $ticket_custom_field13 = $field20; + + pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $agent->{'nombre'}, $agent->{'alias'}, $agent->{'id_os'}, $agent->{'direccion'}, $agent->{'id_agente'}, $agent->{'id_grupo'}, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_owner, $ticket_type, $ticket_status, $ticket_description, $create_wu_on_close_recovery, $ticket_custom_field1, $ticket_custom_field2, $ticket_custom_field3, $ticket_custom_field4, $ticket_custom_field5, $ticket_custom_field6, $ticket_custom_field7, $ticket_custom_field8, $ticket_custom_field9, $ticket_custom_field10, $ticket_custom_field11, $ticket_custom_field12, $ticket_custom_field13); # Generate notification } elsif ($clean_name eq "Generate Notification") { @@ -3040,27 +3082,6 @@ sub pandora_module_keep_alive ($$$$$) { } } -########################################################################## -=head2 C<< pandora_create_incident (I<$pa_config>, I<$dbh>, I<$title>, I<$text>, I<$priority>, I<$status>, I<$origin>, I<$id_group>) >> - -Create an internal Pandora incident. - -=cut -########################################################################## -sub pandora_create_incident ($$$$$$$$;$) { - my ($pa_config, $dbh, $title, $text, - $priority, $status, $origin, $id_group, $owner) = @_; - - logger($pa_config, "Creating incident '$text' source '$origin'.", 8); - - # Initialize default parameters - $owner = '' unless defined ($owner); - - db_do($dbh, 'INSERT INTO tincidencia (inicio, titulo, descripcion, origen, estado, prioridad, id_grupo, id_usuario) - VALUES (NOW(), ?, ?, ?, ?, ?, ?, ?)', $title, $text, $origin, $status, $priority, $id_group, $owner); -} - - ########################################################################## =head2 C<< pandora_audit (I<$pa_config>, I<$description>, I<$name>, I<$action>, I<$dbh>) >> @@ -6213,30 +6234,61 @@ sub pandora_edit_custom_graph ($$$$$$$$$$$) { return $res; } -sub pandora_create_integria_ticket ($$$$$$$$$$$) { - my ($pa_config,$api_path,$api_pass,$integria_user,$user_pass,$ticket_name,$ticket_group_id,$ticket_priority,$ticket_owner,$ticket_type,$ticket_status,$ticket_description) = @_; +sub pandora_create_integria_ticket ($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$) { + my ($pa_config,$api_path,$api_pass,$integria_user,$user_pass,$agent_name,$agent_alias,$agent_os,$agent_addr,$agent_id,$agent_group,$ticket_name,$ticket_group_id,$ticket_priority,$ticket_owner,$ticket_type,$ticket_status,$ticket_description, $create_wu_on_close_recovery, $ticket_custom_field1, $ticket_custom_field2, $ticket_custom_field3, $ticket_custom_field4, $ticket_custom_field5, $ticket_custom_field6, $ticket_custom_field7, $ticket_custom_field8, $ticket_custom_field9, $ticket_custom_field10, $ticket_custom_field11, $ticket_custom_field12, $ticket_custom_field13) = @_; + + use URI::URL; + use URI::Escape; + use HTML::Entities; my $data_ticket; my $call_api; - $data_ticket = $ticket_name . + my $uri = URI->new($api_path); + + if ($uri->scheme eq "") { + $api_path = "http://" . $api_path; + } + + my $ticket_create_wu = 0; + + if ($create_wu_on_close_recovery == 1 && $ticket_status eq '7') { + $ticket_create_wu = 1; + } + + $data_ticket = $agent_name . + "|;|" . uri_escape(decode_entities($agent_alias)) . + "|;|" . $agent_os . + "|;|" . $agent_addr . + "|;|" . $agent_id . + "|;|" . $agent_group . + "|;|" . $ticket_name . "|;|" . $ticket_group_id . "|;|" . $ticket_priority . "|;|" . $ticket_description . - "|;|" . "|;|" . $ticket_type . - "|;|" . "|;|" . $ticket_owner . - "|;|" . "|;|" . $ticket_status . - "|;|" . - "|;|"; - + "|;|" . $ticket_create_wu . + "|;|" . $ticket_custom_field1 . + "|;|" . $ticket_custom_field2 . + "|;|" . $ticket_custom_field3 . + "|;|" . $ticket_custom_field4 . + "|;|" . $ticket_custom_field5 . + "|;|" . $ticket_custom_field6 . + "|;|" . $ticket_custom_field7 . + "|;|" . $ticket_custom_field8 . + "|;|" . $ticket_custom_field9 . + "|;|" . $ticket_custom_field10 . + "|;|" . $ticket_custom_field11 . + "|;|" . $ticket_custom_field12 . + "|;|" . $ticket_custom_field13; + $call_api = $api_path . '?' . 'user=' . $integria_user . '&' . 'user_pass=' . $user_pass . '&' . 'pass=' . $api_pass . '&' . - 'op=create_incident&' . + 'op=create_pandora_ticket&' . 'params=' . $data_ticket .'&' . 'token=|;|'; @@ -6250,6 +6302,86 @@ sub pandora_create_integria_ticket ($$$$$$$$$$$) { } } +sub pandora_sync_agents_integria ($) { + my ($dbh) = @_; + + my $config_integria_enabled = pandora_get_tconfig_token ($dbh, 'integria_enabled', ''); + + if (!$config_integria_enabled) { + return; + } + + my $config_api_path = pandora_get_tconfig_token ($dbh, 'integria_hostname', ''); + my $config_api_pass = pandora_get_tconfig_token ($dbh, 'integria_api_pass', ''); + my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', ''); + my $config_integria_user_pass = pandora_get_tconfig_token ($dbh, 'integria_pass', ''); + + my $api_path = $config_api_path . "/integria/include/api.php"; + + my @agents_string = ''; + my @agents = get_db_rows ($dbh, 'SELECT * FROM tagente'); + + my @agents_array = (); + my $agents_string = ''; + + foreach my $agent (@agents) { + push @agents_array, $agent->{'nombre'} . + "|;|" . + $agent->{'alias'} . + "|;|" . + $agent->{'id_os'} . + "|;|" . + $agent->{'direccion'} . + "|;|" . + $agent->{'id_grupo'}; + } + + my $ua = LWP::UserAgent->new(); + my $response = $ua->post( $api_path, { + 'user' => $config_integria_user, + 'user_pass' => $config_integria_user_pass, + 'pass' => $config_api_pass, + 'op' => 'sync_pandora_agents_inventory', + 'params[]' => [@agents_array], + 'token' => '|;|' + }); + + my $content = $response->decoded_content(); + + if (defined $content && is_numeric($content) && $content ne "-1") { + return $content; + } + else { + return 0; + } +} + +sub pandora_get_integria_ticket_types($) { + my ($dbh) = @_; + + my $config_api_path = pandora_get_tconfig_token ($dbh, 'integria_hostname', ''); + my $config_api_pass = pandora_get_tconfig_token ($dbh, 'integria_api_pass', ''); + my $config_integria_user = pandora_get_tconfig_token ($dbh, 'integria_user', ''); + my $config_integria_user_pass = pandora_get_tconfig_token ($dbh, 'integria_pass', ''); + + my $api_path = $config_api_path . "/integria/include/api.php"; + + my $call_api = $api_path . '?' . + 'user=' . $config_integria_user . '&' . + 'user_pass=' . $config_integria_user_pass . '&' . + 'pass=' . $config_api_pass . '&' . + 'op=get_types&' . + 'return_type=json'; + + my $content = get($call_api); + + my @decoded_json; + @decoded_json = @{decode_json($content)} if (defined $content && $content ne ""); + + return @decoded_json; + +} + ########################################################################## =head2 C<< pandora_input_password (I<$pa_config>, I<$password>) >> diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 1b889a33b0..2f73404363 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.752"; -my $pandora_build = "210311"; +my $pandora_build = "210318"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index b67521022d..52d328d661 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 7.0NG.752 -%define release 210311 +%define release 210318 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c5db0e8c0a..030930ed18 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210311 +%define release 210318 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index bc2a62de7e..211bc4c441 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210311" +PI_BUILD="210318" MODE=$1 if [ $# -gt 1 ]; then @@ -313,7 +313,7 @@ install () { mkdir $DESTDIR$PANDORA_SPOOL/data_in/commands 2> /dev/null chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/commands mkdir -p $DESTDIR$PANDORA_LOG 2> /dev/null - chown -R pandora $DESTDIR$PANDORA_LOG 2> /dev/null + chown -R pandora:apache $DESTDIR$PANDORA_LOG 2> /dev/null chmod 2774 $DESTDIR$PANDORA_LOG 2> /dev/null echo "Giving proper permission to /var/spool/pandora" diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 4f03017475..476e56d29f 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.752 PS210311"; +my $version = "7.0NG.752 PS210318"; # Pandora server configuration my %conf; @@ -404,8 +404,10 @@ sub pandora_purgedb ($$) { } # Delete old tgraph_source data + log_message ('PURGE', 'Deleting old tgraph_source data.'); db_do ($dbh,"DELETE FROM tgraph_source WHERE id_graph NOT IN (SELECT id_graph FROM tgraph)"); + # Delete network traffic old data. log_message ('PURGE', 'Deleting old network matrix data.'); if ($conf->{'_delete_old_network_matrix'} > 0) { @@ -1169,6 +1171,24 @@ if (defined($history_dbh)) { } +# Keep integrity between PandoraFMS agents and IntegriaIMS inventory objects. +pandora_sync_agents_integria($dbh); + +# Get Integria IMS ticket types for alert commands. +my @types = pandora_get_integria_ticket_types($dbh); + +if (scalar(@types) != 0) { + my $query_string = ''; + foreach my $type (@types) { + $query_string .= $type->{'id'} . ',' . $type->{'name'} . ';'; + } + + $query_string = substr $query_string, 0, -1; + + db_do($dbh, "UPDATE talert_commands SET fields_descriptions='[\"Ticket title\",\"Ticket group ID\",\"Ticket priority\",\"Ticket owner\",\"Ticket type\",\"Ticket status\",\"Ticket description\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\"]' WHERE name=\"Integria IMS Ticket\""); + db_do($dbh, "UPDATE talert_commands SET fields_values='[\"\", \"\", \"\",\"\",\"" . $query_string . "\",\"\",\"\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\"]' WHERE name=\"Integria IMS Ticket\""); +} + # Release the lock if ($lock == 1) { db_release_lock ($dbh, $lock_name); diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 6fd7ae604d..991fe7f244 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.752 PS210311"; +my $version = "7.0NG.752 PS210318"; # save program name for logging my $progname = basename($0); @@ -202,8 +202,6 @@ sub help_screen{ help_screen_line('--validate_event_id', '', 'Validate event given a event id'); help_screen_line('--get_event_info', '[]', 'Show info about a event given a event id'); help_screen_line('--add_event_comment', ' ', 'Add event\'s comment'); - print "\nINCIDENTS:\n\n" unless $param ne ''; - help_screen_line('--create_incident', " <description> <origin> <status> <priority 0 for Informative, \n\t 1 for Low, 2 for Medium, 3 for Serious, 4 for Very serious or 5 for Maintenance>\n\t <group> [<owner>]", 'Create incidents'); print "\nPOLICIES:\n\n" unless $param ne ''; help_screen_line('--apply_policy', '<id_policy> [<id_agent> <name(boolean)> <id_server>]', 'Force apply a policy in an agent'); help_screen_line('--apply_all_policies', '', 'Force apply to all the policies'); @@ -4364,21 +4362,6 @@ sub cli_add_event_comment() { pandora_update_event_from_hash ($update, 'id_evento', $id_event, $dbh); } -############################################################################## -# Create incident. -# Related option: --create_incident -############################################################################## - -sub cli_create_incident() { - my ($title, $description, $origin, $status, $priority, $group_name, $owner) = @ARGV[2..8]; - - my $id_group = get_group_id($dbh,$group_name); - exist_check($id_group,'group',$group_name); - - pandora_create_incident ($conf, $dbh, $title, $description, $priority, $status, $origin, $id_group, $owner); - print_log "[INFO] Creating incident '$title'\n\n"; -} - ############################################################################## # Delete data. # Related option: --delete_data @@ -7392,10 +7375,6 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 3); cli_add_event_comment(); } - elsif ($param eq '--create_incident') { - param_check($ltotal, 7, 1); - cli_create_incident(); - } elsif ($param eq '--delete_data') { param_check($ltotal, 4, 2); cli_delete_data($ltotal); diff --git a/pandora_server/util/recon_scripts/wmi-recon.pl b/pandora_server/util/recon_scripts/wmi-recon.pl index 53bb697b0d..513a5ac08a 100755 --- a/pandora_server/util/recon_scripts/wmi-recon.pl +++ b/pandora_server/util/recon_scripts/wmi-recon.pl @@ -136,13 +136,6 @@ sub recon_scan($$) { # Mark the recon task as done. update_recon_task ($DBH, $task->{'id_rt'}, -1); - - # Create an incident. - if (defined($ADDED_HOSTS[0]) && $task->{'create_incident'} == 1) { - my $text = "At " . strftime ("%Y-%m-%d %H:%M:%S", localtime()) . " (". scalar(@ADDED_HOSTS) . ") new hosts were detected by Pandora FMS WMI Recon Script running on [" . $CONF{'servername'} . "_Recon]. This incident has been automatically created following instructions for this recon task [" . $task->{'id_group'} . "].\n\n"; - $text .= "\n\nThis is the list of IP addresses found: \n\n" . join(',', @ADDED_HOSTS); - pandora_create_incident (\%CONF, $DBH, "[RECON] New hosts detected", $text, 0, 0, 'Pandora FMS Recon Server', $task->{'id_group'}); - } } ########################################################################## @@ -369,6 +362,5 @@ die("Error retrieving recon task ID $TASK_ID\n") unless defined($task); # Scan! $task->{'subnet'} = $NETWORKS; $task->{'id_group'} = $GROUP_ID; -$task->{'create_incident'} = $CREATE_INCIDENT; recon_scan($task, \&wmi_scan);