Merge remote-tracking branch 'origin/develop' into ent-6753-consistencia-en-el-selector-de-grupos

This commit is contained in:
fbsanchez 2021-03-18 10:04:18 +01:00
commit a3069fdf76
84 changed files with 2650 additions and 2589 deletions

View File

@ -1,15 +1,15 @@
FROM centos:centos8
MAINTAINER Pandora FMS Team <info@pandorafms.com>
FROM centos:7
LABEL maintainer="Pandora FMS Team <info@pandorafms.com>"
# 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

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.752-210311
Version: 7.0NG.752-210318
Architecture: all
Priority: optional
Section: admin

View File

@ -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

View File

@ -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++) {

View File

@ -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}

View File

@ -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}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.752"
PI_BUILD="210311"
PI_BUILD="210318"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{210311}
{210318}
ViewReadme
{Yes}

View File

@ -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;

View File

@ -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

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.752-210311
Version: 7.0NG.752-210318
Architecture: all
Priority: optional
Section: admin

View File

@ -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

View File

@ -1,506 +0,0 @@
<?php
/**
* Net tools utils.
*
* @category Extensions
* @package Pandora FMS
* @subpackage NetTools
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
// Requires.
require_once $config['homedir'].'/include/functions.php';
// This extension is usefull only if the agent has associated IP.
$id_agente = get_parameter('id_agente');
$address = agents_get_address($id_agente);
if (!empty($address) || empty($id_agente)) {
extensions_add_opemode_tab_agent(
'network_tools',
'Network Tools',
'extensions/net_tools/nettool.png',
'main_net_tools',
'v1r1',
'AW'
);
}
/**
* Searchs for command.
*
* @param string $command Command.
*
* @return string Path.
*/
function whereis_the_command($command)
{
global $config;
if (isset($config['network_tools_config'])) {
$network_tools_config = json_decode($config['network_tools_config'], 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'];
switch ($command) {
case 'traceroute':
if (!empty($traceroute_path)) {
return $traceroute_path;
}
break;
case 'ping':
if (!empty($ping_path)) {
return $ping_path;
}
break;
case 'nmap':
if (!empty($nmap_path)) {
return $nmap_path;
}
break;
case 'dig':
if (!empty($dig_path)) {
return $dig_path;
}
break;
case 'snmpget':
if (!empty($snmpget_path)) {
return $snmpget_path;
}
break;
default:
return null;
}
}
ob_start();
system('whereis '.$command);
$output = ob_get_clean();
$result = explode(':', $output);
$result = trim($result[1]);
if (empty($result)) {
return null;
}
$result = explode(' ', $result);
$fullpath = trim($result[0]);
if (! file_exists($fullpath)) {
return null;
}
return $fullpath;
}
/**
* Execute net tools action.
*
* @param integer $operation Operation.
* @param string $ip Ip.
* @param string $community Community.
* @param string $snmp_version SNMP version.
*
* @return void
*/
function net_tools_execute($operation, $ip, $community, $snmp_version)
{
if (!validate_address($ip)) {
ui_print_error_message(__('The ip or dns name entered cannot be resolved'));
} else {
switch ($operation) {
case 1:
$traceroute = whereis_the_command('traceroute');
if (empty($traceroute)) {
ui_print_error_message(__('Traceroute executable does not exist.'));
} else {
echo '<h3>'.__('Traceroute to ').$ip.'</h3>';
echo '<pre>';
echo system($traceroute.' '.$ip);
echo '</pre>';
}
break;
case 2:
$ping = whereis_the_command('ping');
if (empty($ping)) {
ui_print_error_message(__('Ping executable does not exist.'));
} else {
echo '<h3>'.__('Ping to %s', $ip).'</h3>';
echo '<pre>';
echo system($ping.' -c 5 '.$ip);
echo '</pre>';
}
break;
case 4:
$nmap = whereis_the_command('nmap');
if (empty($nmap)) {
ui_print_error_message(__('Nmap executable does not exist.'));
} else {
echo '<h3>'.__('Basic TCP Scan on ').$ip.'</h3>';
echo '<pre>';
echo system($nmap.' -F '.$ip);
echo '</pre>';
}
break;
case 5:
echo '<h3>'.__('Domain and IP information for ').$ip.'</h3>';
$dig = whereis_the_command('dig');
if (empty($dig)) {
ui_print_error_message(__('Dig executable does not exist.'));
} else {
echo '<pre>';
echo system('dig '.$ip);
echo '</pre>';
}
$whois = whereis_the_command('whois');
if (empty($whois)) {
ui_print_error_message(__('Whois executable does not exist.'));
} else {
echo '<pre>';
echo system('whois '.$ip);
echo '</pre>';
}
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 '<h3>'.__('SNMP information for ').$ip.'</h3>';
echo '<h4>'.__('Uptime').'</h4>';
echo '<pre>';
if (empty($result)) {
ui_print_error_message(__('Target unreachable.'));
break;
} else {
echo array_pop($result);
}
echo '</pre>';
echo '<h4>'.__('Device info').'</h4>';
echo '<pre>';
$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 '</pre>';
echo '<h4>Interface Information</h4>';
$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 "<div class='error mrgn_top_5'>".__('The agent hasn\'t got IP').'</div>';
return;
}
// Javascript.
?>
<script type='text/javascript'>
$(document).ready(function(){
mostrarColumns($('#operation :selected').val());
});
function mostrarColumns(value) {
if (value == 3) {
$('.snmpcolumn').show();
}
else {
$('.snmpcolumn').hide();
}
}
</script>
<?php
echo '<div>';
echo "<form name='actionbox' method='post'>";
echo "<table class='databox filters' width=100% id=netToolTable>";
echo '<tr><td>';
echo __('Operation');
echo '</td><td>';
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 '</td>';
echo '<td>';
echo __('IP address');
echo '</td><td>';
$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 '</td>';
echo "<td class='snmpcolumn'>";
echo __('SNMP Version');
html_print_select(
[
'1' => 'v1',
'2c' => 'v2c',
],
'select_version',
$snmp_version
);
echo '</td><td class="snmpcolumn">';
echo __('SNMP Community').'&nbsp;';
html_print_input_text('community', $community);
echo '</td><td>';
echo "<input name=submit type=submit class='sub next mrgn_0px' value='".__('Execute')."'>";
echo '</td>';
echo '</tr></table>';
echo '</form>';
if ($operation) {
// Execute form.
net_tools_execute($operation, $ip, $community, $snmp_version);
}
echo '</div>';
}
/**
* 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 '<form id="form_setup" method="post" >';
echo '<fieldset>';
echo '<legend>'.__('Options').'</legend>';
html_print_input_hidden('update_traceroute', 1);
html_print_table($table);
echo '</fieldset>';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
echo '</div>';
echo '</form>';
}
extensions_add_godmode_menu_option(__('Config Network Tools'), 'PM');
extensions_add_godmode_function('godmode_net_tools');

View File

@ -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

View File

@ -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;

View File

@ -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`
-- ---------------------------------------------------------------------

View File

@ -234,8 +234,8 @@ if (!$double_auth_enabled && $config['2FA_all_users'] != ''
}
});
$("div#doble_auth_window").dialog({
<?php config_update_value('2Fa_auth', ''); ?>
$("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) {
<?php
if (!$double_auth_enabled) {
config_update_value('2Fa_auth', '1');
}
?>
// 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(); </script>
.show();
// Don't allow close the dialog with X button
$('.ui-dialog-titlebar-close').css('display', 'none');
</script>
<?php
echo '</div>';
}

View File

@ -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] = '<a href="index.php?sec=incidencias&amp;sec2=operation/incidents/incident_detail&amp;id='.$row['id_incidencia'].'">'.$row['id_incidencia'].'</a>';
$data[0] = '<a href="index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$row['id_incidencia'].'">'.$row['id_incidencia'].'</a>';
$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] = '<a href="index.php?sec=incidencias&amp;sec2=operation/incidents/incident_detail&amp;id='.$row['id_incidencia'].'">'.substr(io_safe_output($row['titulo']), 0, 45).'</a>';
$data[2] = '<a href="index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$row['id_incidencia'].'">'.substr(io_safe_output($row['titulo']), 0, 45).'</a>';
$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);
}

View File

@ -367,7 +367,7 @@ $img_style = [
if ($id_agente) {
// View tab.
$viewtab['text'] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">'.html_print_image(
'images/operation.png',
'images/eye.png',
true,
[
'title' => __('View'),

View File

@ -754,7 +754,7 @@ if ($agents !== false) {
echo '</em>';
}
echo '</span><div class="left actions clear_left">';
echo '</span><div class="left actions clear_left" style=" visibility: hidden">';
if ($check_aw) {
if ($agent['id_os'] == CLUSTER_OS_ID) {
if (enterprise_installed()) {

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,7 @@ if (is_ajax()) {
$command = alerts_get_alert_command($id);
// If is setted a description, we change the carriage return by <br> tags
// If a description is set, change the carriage return by <br> tags.
if (isset($command['description'])) {
$command['description'] = str_replace(
[
@ -277,6 +277,76 @@ if (is_ajax()) {
$editor_type_chkbx .= '</small></b></div>';
$rfield = $editor_type_chkbx;
// Select type.
} else if (preg_match('/^_integria_type_custom_field_$/i', $field_value)) {
$ffield = '';
$rfield = '';
$ffield .= '<div name="field'.$i.'_value_container">'.html_print_switch(
[
'name' => 'field'.$i.'_value[]',
'value' => '',
]
).'</div>';
$rfield .= '<div name="field'.$i.'_recovery_value_container">'.html_print_switch(
[
'name' => 'field'.$i.'_recovery_value[]',
'value' => '',
]
).'</div>';
$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,

View File

@ -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&#x20;IMS&#x20;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);
}

View File

@ -551,7 +551,7 @@ for ($month = 1; $month <= 12; $month++) {
$cal_table->data[$cal_line][$week] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_special_days&create_special_day=1&date='.$date.'" title=';
$cal_table->data[$cal_line][$week] .= __('Create');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image(
'images/add.png',
'images/add_mc.png',
true,
['class' => 'invert_filter']
).'</a>';

View File

@ -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] = '<div class="w250px inline">'.html_print_select_groups(
).'</div>';
$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 = <?php echo $config['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 = <?php echo $config['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('<br>')[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($('<option>', {
value: value,
text: value
}));
combo_input_recovery.append($('<option>', {
value: value,
text: value
}));
});
if (typeof values[key] !== "undefined") {
combo_input.val(values[key]);
}
if (typeof recovery_values[key] !== "undefined") {
combo_input_recovery.val(recovery_values[key]);
}
combo_input.show();
combo_input_recovery.show();
break;
case 'date':
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').removeClass("hasDatepicker");
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').removeClass("hasDatepicker");
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').datepicker("destroy");
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').datepicker("destroy");
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').show();
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').show();
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
if (typeof values[key] !== "undefined") {
$('input.datepicker[type="text"][name=field'+custom_field_key+'_value\\[\\]]').val(values[key]);
}
if (typeof recovery_values[key] !== "undefined") {
$('input.datepicker[type="text"][name=field'+custom_field_key+'_recovery_value\\[\\]]').val(recovery_values[key]);
}
break;
case 'text':
case 'textarea':
case 'numeric':
if (typeof values[key] !== "undefined") {
$('textarea[name=field'+custom_field_key+'_value\\[\\]]').val(values[key]);
}
if (typeof recovery_values[key] !== "undefined") {
$('textarea[name=field'+custom_field_key+'_recovery_value\\[\\]]').val(recovery_values[key]);
}
$('textarea[name=field'+custom_field_key+'_value\\[\\]]').show();
$('textarea[name=field'+custom_field_key+'_recovery_value\\[\\]]').show();
break;
}
});
},
"json"
);
}
$("#id_command").change (function () {
values = Array ();
values.push({
@ -406,6 +602,9 @@ $(document).ready (function () {
$("#group").val(0);
}
var integria_custom_fields_values = [];
var integria_custom_fields_rvalues = [];
for (i = 1; i <= max_fields; i++) {
var old_value = '';
var old_recovery_value = '';
@ -474,6 +673,12 @@ $(document).ready (function () {
.val());
}
}
if ($("#id_command option:selected").text() === "Integria IMS Ticket" && i > 7) {
integria_custom_fields_values.push(old_value);
integria_custom_fields_rvalues.push(old_recovery_value);
}
// Add help hint only in first field
if (i == 1) {
var td_content = $table_macros_field.find('td').eq(0);
@ -486,7 +691,30 @@ $(document).ready (function () {
$table_macros_field.show();
}
// Ad-hoc solution for Integria IMS command: get Integia IMS Ticket custom fields only when this command is selected and we selected a ticket type to retrieve fields from.
// Check command by name since it is unvariable in any case, unlike its ID.
if ($("#id_command option:selected").text() === "Integria IMS Ticket") {
var max_macro_fields = <?php echo $config['max_macro_fields']; ?>;
// At start hide all 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();
}
if ($('#field5_value').val() !== '') {
ajax_get_integria_custom_fields($('#field5_value').val(), integria_custom_fields_values, integria_custom_fields_rvalues);
}
$('#field5_value').on('change', function() {
ajax_get_integria_custom_fields($(this).val());
});
}
var added_config = {
"selector": "textarea.tiny-mce-editor",
"plugins": "preview, print, table, searchreplace, nonbreaking, xhtmlxtras, noneditable",

View File

@ -803,11 +803,11 @@ $table->data['edit1'][1] = '<table width="100%">';
true
);
$table->data['edit36'][2] = __('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
$table->data['edit36'][3] = html_print_input_text('plugin_pass_snmp', '', '', 15, 60, true);
$table->data['edit36'][3] = html_print_input_password('plugin_pass_snmp', '', '', 15, 60, true);
$table->data['edit37'][0] = __('Privacy method');
$table->data['edit37'][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'custom_string_1', '', '', __('No change'), '', true);
$table->data['edit37'][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_privacy_method', '', '', __('No change'), '', true);
$table->data['edit37'][2] = __('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
$table->data['edit37'][3] = html_print_input_text('custom_string_2', '', '', 15, 60, true);
$table->data['edit37'][3] = html_print_input_password('snmp3_privacy_pass', '', '', 15, 60, true);
$table->data['edit38'][0] = __('Auth method');
$table->data['edit38'][1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'plugin_parameter', '', '', __('No change'), '', true);
$table->data['edit38'][2] = __('Security level');
@ -1670,7 +1670,7 @@ $(document).ready (function () {
}
});
$('#tcp_send').change(function() {
$('#snmp_version').change(function() {
if($(this).val() == 3) {
$("tr#delete_table-edit36, tr#delete_table-edit37, tr#delete_table-edit38").show();
}
@ -2096,7 +2096,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
}
// Specific snmp reused fields
if (get_parameter('tcp_send', '') == 3) {
if (get_parameter('snmp_version', '') == 3) {
$plugin_user_snmp = get_parameter('plugin_user_snmp', '');
if ($plugin_user_snmp != '') {
$values['plugin_user'] = $plugin_user_snmp;
@ -2107,7 +2107,12 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
$values['plugin_pass'] = io_input_password($plugin_pass_snmp);
}
$snmp3_privacy_pass = get_parameter('custom_string_2', '');
$snmp3_privacy_method = get_parameter('snmp3_privacy_method', '');
if ($snmp3_privacy_method != '') {
$values['custom_string_1'] = io_input_password($snmp3_privacy_method);
}
$snmp3_privacy_pass = get_parameter('snmp3_privacy_pass', '');
if ($snmp3_privacy_pass != '') {
$values['custom_string_2'] = io_input_password($snmp3_privacy_pass);
}
@ -2209,7 +2214,11 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
}
// Set tcp_send value according to module type since the purpose of this field in database varies in case of SNMP modules.
if ($module['id_tipo_modulo'] >= 15 && $module['id_tipo_modulo'] <= 18) {
if ($module['id_tipo_modulo'] == MODULE_TYPE_REMOTE_SNMP
|| $module['id_tipo_modulo'] == MODULE_TYPE_REMOTE_SNMP_INC
|| $module['id_tipo_modulo'] == MODULE_TYPE_REMOTE_SNMP_STRING
|| $module['id_tipo_modulo'] <= MODULE_TYPE_REMOTE_SNMP_PROC
) {
if ($snmp_version != '') {
$values['tcp_send'] = $snmp_version;
} else {

View File

@ -351,6 +351,9 @@ if (check_acl($config['id_user'], 0, 'PM')) {
$sub2['godmode/setup/setup&amp;section=websocket_engine']['text'] = __('Websocket Engine');
$sub2['godmode/setup/setup&amp;section=websocket_engine']['refr'] = 0;
$sub2['godmode/setup/setup&amp;section=external_tools']['text'] = __('External Tools');
$sub2['godmode/setup/setup&amp;section=external_tools']['refr'] = 0;
if ($config['activate_gis']) {
$sub2['godmode/setup/setup&amp;section=gis']['text'] = __('Map conections GIS');
}

View File

@ -918,7 +918,7 @@ if (isset($data)) {
);
}
echo '<form method="post" action="'.$url.'">';
echo '<form method="post" action="'.$url.'" class="float-right">';
echo '<div class="right">';
html_print_input_hidden('new_component', 1);
html_print_select(

View File

@ -293,11 +293,11 @@ $output .= '</table>';
if ($edit_graph) {
$output .= "<div class='w100p'>";
$output .= "<input class='right' type=submit name='store' class='sub upd' value='".__('Update')."'>";
$output .= "<input type=submit name='store' class='sub upd right' value='".__('Update')."'>";
$output .= '</div>';
} else {
$output .= "<div class='w100p'>";
$output .= "<input class='right' type=submit name='store' class='sub next' value='".__('Create')."'>";
$output .= "<input type=submit name='store' class='sub next right' value='".__('Create')."'>";
$output .= '</div>';
}

View File

@ -349,7 +349,6 @@ $table_aux = new stdClass();
ui_pagination(count($graphs), false, 0, 0, false, 'offset', true, 'pagination-bottom');
echo "<div class='right'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo '</div>';
echo '</form>';
}
@ -361,6 +360,8 @@ $table_aux = new stdClass();
echo '</form>';
}
echo '</div>';
echo '</div>';
} else {
include_once $config['homedir'].'/general/first_task/custom_graphs.php';

View File

@ -2763,17 +2763,13 @@ $class = 'databox filters';
</td>
</tr>
<<<<<<< HEAD
<tr id="row_filter_search" class="datos">
<td class="bolder"><?php echo __('Free search'); ?></td>
=======
<tr id="row_summary" style="" class="datos">
<td style="font-weight:bold;">
<tr id="row_summary"class="datos">
<td class="bolder">
<?php
echo __('Summary');
?>
</td>
<td style="">
<td>
<?php
html_print_checkbox_switch(
'summary',
@ -2788,9 +2784,8 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_filter_search" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Include filter'); ?></td>
>>>>>>> origin/develop
<tr id="row_filter_search" class="datos">
<td class="bolder"><?php echo __('Include filter'); ?></td>
<td>
<?php
html_print_input_text('filter_search', $filter_search);

View File

@ -664,7 +664,7 @@ if (defined('METACONSOLE')) {
if (check_acl($config['id_user'], 0, 'RM')) {
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"');
}
echo '</div>';
@ -687,7 +687,7 @@ if (defined('METACONSOLE')) {
echo "<div class='pdd_b_20px right; w100p'>";
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 '</div>';
echo '</form>';
}

View File

@ -216,6 +216,11 @@ $buttons['websocket_engine'] = [
).'</a>',
];
$buttons['external_tools'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=external_tools').'">'.html_print_image('images/nettool.png', true, ['title' => __('External Tools'), 'class' => 'invert_filter']).'</a>',
];
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 = ' &raquo '.__('External Tools');
$help_header = 'External_Tools';
break;
case 'enterprise':
$buttons['enterprise']['active'] = true;
$subpage = ' &raquo '.__('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;

View File

@ -0,0 +1,48 @@
<?php
/**
* External Tools Setup Tab.
*
* @category Operations
* @package Pandora FMS
* @subpackage Opensource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
// Requires.
require_once $config['homedir'].'/include/functions.php';
// Require needed class.
require_once $config['homedir'].'/include/class/ExternalTools.class.php';
// Control call flow for debug window.
try {
// User access and validation is being processed on class constructor.
$obj = new ExternalTools('setup');
} catch (Exception $e) {
echo '[ExternalTools]'.$e->getMessage();
// Stop this execution, but continue 'globally'.
return;
}
$obj->run();

View File

@ -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] .= '&nbsp;&nbsp;'.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] .= ' <a href="javascript: toggleButton(\'alert\');">'.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',
]
).'</a>';
$table->data[$i++][1] .= '<div id="layer_sound_alert"></div>';
$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] .= ' <a href="javascript: toggleButton(\'critical\');">'.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',
]
).'</a>';
$table->data[$i++][1] .= '<div id="layer_sound_critical"></div>';
$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] .= ' <a href="javascript: toggleButton(\'warning\');">'.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',
]
).'</a>';
$table->data[$i++][1] .= '<div id="layer_sound_warning"></div>';
$table->data[$i][0] = __('Public URL');
$table->data[$i++][1] = html_print_input_text(
'public_url',
@ -773,24 +677,6 @@ echo '<legend>'.__('Mail configuration').'</legend>';
?>
<script type="text/javascript">
function toggleButton(type) {
if ($("#button_sound_" + type).attr('src') == 'images/control_pause_col.png') {
$("#button_sound_" + type).attr('src', 'images/control_play_col.png');
$('#layer_sound_' + type).html("");
}
else {
$("#button_sound_" + type).attr('src', 'images/control_pause_col.png');
$('#layer_sound_' + type).html("<audio src='" + $("#sound_" + type).val() + "' autoplay='true' hidden='true' loop='true'>");
}
}
function replaySound(type) {
if ($("#button_sound_" + type).attr('src') == 'images/control_pause_col.png') {
$('#layer_sound_' + type).html("");
$('#layer_sound_' + type).html("<audio src='" + $("#sound_" + type).val() + "' autoplay='true' hidden='true' loop='true'>");
}
}
function show_timezone () {
zone = $("#zone").val();
$.ajax({

View File

@ -31,6 +31,12 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user
require_once $config['homedir'].'/include/functions_integriaims.php';
if (is_ajax()) {
$operation = (string) get_parameter('operation', '');
if ($operation === 'check_api_access') {
} else if ($operation === 'sync_inventory') {
}
$integria_user = get_parameter('integria_user', '');
$integria_pass = get_parameter('integria_pass', '');
$integria_api_hostname = get_parameter('api_hostname', '');
@ -80,6 +86,16 @@ if (get_parameter('update_config', 0) == 1) {
);
}
$ticket_types = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', '', false, 'json');
$types_string = '';
if ($ticket_types !== '') {
foreach (json_decode($ticket_types, true) as $key => $value) {
$types_string .= $value['id'].','.$value['name'].';';
}
}
if ($command_exists === false) {
// Create 'Integria IMS Ticket' command only when user enables IntegriaIMS integration and it does not exist in database.
$id_command_inserted = db_process_sql_insert(
@ -89,7 +105,8 @@ if (get_parameter('update_config', 0) == 1) {
'command' => io_safe_input('Internal type'),
'internal' => 1,
'description' => io_safe_input('Create a ticket in Integria IMS'),
'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'","'.io_safe_input('Ticket status').'","'.io_safe_input('Ticket description').'"]',
'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'","'.io_safe_input('Ticket status').'","'.io_safe_input('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_"]',
'fields_values' => '["", "", "","","'.$types_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_"]',
]
);
@ -115,41 +132,80 @@ if (get_parameter('update_config', 0) == 1) {
alerts_create_alert_action(io_safe_input('Create Integria IMS ticket'), $id_command_inserted, $action_values);
} else {
// Update 'Create Integria IMS Ticket' action when setup data is updated, user enables IntegriaIMS integration and command does exist in database.
db_process_sql_update(
'talert_actions',
[
'field1' => io_safe_input($config['incident_title']),
'field1_recovery' => io_safe_input($config['incident_title']),
'field2' => io_safe_input($config['default_group']),
'field2_recovery' => io_safe_input($config['default_group']),
'field3' => io_safe_input($config['default_criticity']),
'field3_recovery' => io_safe_input($config['default_criticity']),
'field4' => io_safe_input($config['default_owner']),
'field4_recovery' => io_safe_input($config['default_owner']),
'field5' => io_safe_input($config['incident_type']),
'field5_recovery' => io_safe_input($config['incident_type']),
'field6' => io_safe_input($config['incident_status']),
'field6_recovery' => io_safe_input($config['incident_status']),
'field7' => io_safe_input($config['incident_content']),
'field7_recovery' => io_safe_input($config['incident_content']),
],
['name' => io_safe_input('Create Integria IMS ticket')]
// Update 'Integria IMS Ticket' command with ticket types retrieved from Integria IMS.
$sql_update_command_values = sprintf(
'
UPDATE talert_commands
SET fields_values = \'["","","","","%s","","","_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="%s"',
$types_string,
io_safe_input('Integria IMS Ticket')
);
db_process_sql($sql_update_command_values);
// Update those actions that make use of 'Integria IMS Ticket' command when setup default fields are updated. Empty fields in actions will be filled in with default values.
$update_action_values = [
$config['incident_title'],
$config['default_group'],
$config['default_criticity'],
$config['default_owner'],
$config['incident_type'],
$config['incident_status'],
$config['incident_content'],
];
foreach ($update_action_values as $key => $value) {
$field_key = ($key + 1);
$sql_update_action_field = sprintf(
'
UPDATE talert_actions taa
INNER JOIN talert_commands tac
ON taa.id_alert_command=tac.id
SET field%s= "%s"
WHERE tac.name="Integria&#x20;IMS&#x20;Ticket"
AND (
taa.field%s IS NULL OR taa.field%s=""
)',
$field_key,
$value,
$field_key,
$field_key,
$field_key
);
db_process_sql($sql_update_action_field);
}
foreach ($update_action_values as $key => $value) {
$field_key = ($key + 1);
$sql_update_action_recovery_field = sprintf(
'
UPDATE talert_actions taa
INNER JOIN talert_commands tac
ON taa.id_alert_command=tac.id
SET field%s_recovery = "%s"
WHERE tac.name="Integria&#x20;IMS&#x20;Ticket"
AND (
taa.field%s_recovery IS NULL OR taa.field%s_recovery=""
)',
$field_key,
$value,
$field_key,
$field_key,
$field_key
);
db_process_sql($sql_update_action_recovery_field);
}
}
} else {
if ($event_response_exists != false) {
if ($event_response_exists !== false) {
// Delete 'Create incident in IntegriaIMS from event' event response if it does exist and IntegriaIMS integration is disabled.
db_process_sql_delete('tevent_response', ['name' => io_safe_input('Create ticket in IntegriaIMS from event')]);
}
if ($command_exists != false) {
// Delete 'Integria IMS Ticket' command if it does exist and IntegriaIMS integration is disabled.
db_process_sql_delete('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]);
// Delete 'Create Integria IMS Ticket' action if command exists and IntegriaIMS integration is disabled.
db_process_sql_delete('talert_actions', ['name' => io_safe_input('Create Integria IMS ticket')]);
}
}
}
@ -243,6 +299,14 @@ $row['name'] = __('Request timeout');
$row['control'] = html_print_input_text('integria_req_timeout', $config['integria_req_timeout'], '', 3, 10, true);
$table_remote->data['integria_req_timeout'] = $row;
$row = [];
$row['name'] = __('Inventory');
$row['control'] = html_print_button(__('Sync inventory'), 'sync-inventory', false, '', 'class="sub next"', true);
$row['control'] .= '<span id="test-integria-spinner-sync" style="display:none;">&nbsp;'.html_print_image('images/spinner.gif', true).'</span>';
$row['control'] .= '<span id="test-integria-success-sync" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
$row['control'] .= '<span id="test-integria-failure-sync" style="display:none;">&nbsp;'.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
$table_remote->data['integria_sync_inventory'] = $row;
// Alert settings.
$table_alert_settings = new StdClass();
$table_alert_settings->data = [];
@ -661,8 +725,8 @@ echo '</form>';
var api_pass = $('input[name=integria_api_pass]').val();
var data = {
page: "godmode/setup/setup_integria",
check_api_access: 1,
page: 'godmode/setup/setup_integria',
operation: 'check_api_access',
integria_user: integria_user,
integria_pass: integria_pass,
api_hostname: api_hostname,
@ -694,7 +758,100 @@ echo '</form>';
hideLoadingImage();
});
}
var handleInventorySync = function (event) {
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
var notFoundMessage = '<?php echo __('User not found'); ?>';
var invalidPassMessage = '<?php echo __('Invalid password'); ?>';
var hideLoadingImage = function () {
$('span#test-integria-spinner-sync').hide();
}
var showLoadingImage = function () {
$('span#test-integria-spinner-sync').show();
}
var hideSuccessImage = function () {
$('span#test-integria-success-sync').hide();
}
var showSuccessImage = function () {
$('span#test-integria-success-sync').show();
}
var hideFailureImage = function () {
$('span#test-integria-failure-sync').hide();
}
var showFailureImage = function () {
$('span#test-integria-failure-sync').show();
}
hideSuccessImage();
hideFailureImage();
showLoadingImage();
var integria_user = $('input[name=integria_user]').val();
var integria_pass = $('input[name=integria_pass]').val();
var api_hostname = $('input[name=integria_hostname]').val();
var api_pass = $('input[name=integria_api_pass]').val();
if (!api_hostname.match(/^[a-zA-Z]+:\/\//))
{
api_hostname = 'http://' + api_hostname;
}
var url = api_hostname + '/integria/include/api.php';
<?php
// Retrieve all agents and codify string in the format that will be sent over in Ajax call.
$agent_fields = [
'nombre',
'alias',
'id_os',
'direccion',
'id_agente',
'id_grupo',
];
$agents = agents_get_agents(false, $agent_fields);
$agents_query_string_array = [];
foreach ($agents as $agent_data) {
$agents_query_string_array[] = implode('|;|', $agent_data);
}
?>
var agents_query_string_array = <?php echo json_encode($agents_query_string_array); ?>;
var data = {
op: 'sync_pandora_agents_inventory',
user: integria_user,
user_pass: integria_pass,
pass: api_pass,
params: agents_query_string_array,
token: '|;|'
}
// AJAX call to check API connection.
$.ajax({
type: "GET",
url: url,
dataType: "json",
data: data
})
.done(function(data, textStatus, xhr) {
showSuccessImage();
})
.fail(function(xhr, textStatus, errorThrown) {
showFailureImage();
})
.always(function(xhr, textStatus) {
hideLoadingImage();
});
}
$('input#button-test-integria').click(handleTest);
$('input#button-sync-inventory').click(handleInventorySync);

View File

@ -131,6 +131,20 @@ $table_styles->style[0] = 'font-weight: bold;';
$table_styles->size[0] = '50%';
$table_styles->data = [];
$table_styles->data[$row][0] = __('Style template');
$table_styles->data[$row][1] = html_print_select(
themes_get_css(),
'style',
$config['style'].'.css',
'',
'',
'',
true
);
$row++;
$table_styles->data[$row][0] = __('Status icon set');
$iconsets['default'] = __('Colors');
$iconsets['faces'] = __('Faces');
@ -1289,16 +1303,6 @@ $row++;
$table_other->size[3] = '12%';
$table_other->data = [];
$table_other->data[$row][0] = __('Custom graphviz directory');
$table_other->data[$row][1] = html_print_input_text(
'graphviz_bin_dir',
$config['graphviz_bin_dir'],
'',
25,
255,
true
);
$row++;
$table_other->data[$row][0] = __('Networkmap max width');

View File

@ -667,57 +667,9 @@ class DiscoveryTaskList extends HTML
$data[4] = '-';
}
$can_be_reviewed = false;
if (empty($task['summary']) === false
&& $task['summary'] == 'cancelled'
) {
$data[5] = __('Cancelled').ui_print_help_tip(
__('Server has been restarted while executing this task, please retry.'),
true
);
} else if ($task['review_mode'] == DISCOVERY_STANDARD) {
if ($task['type'] == DISCOVERY_APP_VMWARE) {
if ($task['status'] <= 0 && $task['utimestamp'] != 0) {
$data[5] = __('Done');
} else if ($task['status'] > 0) {
$data[5] = __('Pending');
} else {
$data[5] = __('Not started');
}
} else {
if ($task['status'] <= 0
&& empty($task['summary']) === false
) {
$data[5] = __('Done');
} else if ($task['utimestamp'] == 0
&& empty($task['summary'])
) {
$data[5] = __('Not started');
} else {
$data[5] = __('Pending');
}
}
} else {
if ($task['status'] <= 0
&& empty($task['summary']) === false
&& (int) $task['type'] === DISCOVERY_HOSTDEVICES
) {
$can_be_reviewed = true;
$data[5] = '<span class="link review" onclick="show_review('.$task['id_rt'].',\''.$task['name'].'\')">';
$data[5] .= __('Review');
$data[5] .= '</span>';
} else if ($task['utimestamp'] == 0
&& empty($task['summary'])
) {
$data[5] = __('Not started');
} else {
if ($task['review_mode'] == DISCOVERY_RESULTS) {
$data[5] = __('Processing');
} else {
$data[5] = __('Searching');
}
}
}
$_rs = $this->getStatusMessage($task);
$can_be_reviewed = $_rs['can_be_reviewed'];
$data[5] = $_rs['message'];
switch ($task['type']) {
case DISCOVERY_CLOUD_AZURE_COMPUTE:
@ -1763,4 +1715,65 @@ class DiscoveryTaskList extends HTML
}
/**
* Generates task status string for given task.
*
* @param array $task Discovery task (retrieved from DB).
*
* @return array Message to be displayed and review status.
*/
public function getStatusMessage(array $task)
{
$status = '';
$can_be_reviewed = false;
if (empty($task['summary']) === false
&& $task['summary'] == 'cancelled'
) {
$status = __('Cancelled').ui_print_help_tip(
__('Server has been restarted while executing this task, please retry.'),
true
);
} else if ($task['review_mode'] == DISCOVERY_STANDARD) {
if ($task['status'] <= 0
&& empty($task['summary']) === false
) {
$status = __('Done');
} else if ($task['utimestamp'] == 0
&& empty($task['summary'])
) {
$status = __('Not started');
} else if ($task['utimestamp'] > 0) {
$status = __('Done');
} else {
$status = __('Pending');
}
} else {
if ($task['status'] <= 0
&& empty($task['summary']) === false
) {
$can_be_reviewed = true;
$status = '<span class="link review" onclick="show_review('.$task['id_rt'].',\''.$task['name'].'\')">';
$status .= __('Review');
$status .= '</span>';
} else if ($task['utimestamp'] == 0
&& empty($task['summary'])
) {
$status = __('Not started');
} else {
if ($task['review_mode'] == DISCOVERY_RESULTS) {
$status = __('Processing');
} else {
$status = __('Searching');
}
}
}
return [
'message' => $status,
'can_be_reviewed' => $can_be_reviewed,
];
}
}

View File

@ -1356,12 +1356,10 @@ class AgentWizard extends HTML
$generalInterface = false;
// Lets catch all values.
foreach ($data as $key => $value) {
if (empty(preg_match('/module-active/', $key)) === false
if (empty(preg_match('/module-active-(.*)/m', $key, $tmpModules)) === false
&& (int) $value === 1
) {
$tmpModules = explode('-', $key);
$keyData = $tmpModules[2].'-'.$tmpModules[3];
$keyData = $tmpModules[1];
$modulesActivated[] = $keyData;
} else if (empty(preg_match('/interfaz_select_/', $key)) === false) {
@ -1435,8 +1433,8 @@ class AgentWizard extends HTML
$result[$value]['value'] = $data['module-value-'.$key];
}
preg_match('/^(.*)-.*?_(\d+-\d+)$/', $k, $matches);
$k = $matches[1].'-0_'.$matches[2];
preg_match('/^(.*).*?_(\d+)-+(\d+)$/', $k, $matches);
$k = $matches[1].'_'.$matches[2].'-'.$matches[3];
} else {
if (empty(preg_match('/module-value/', $k)) === false) {
$result[$value]['value'] = $data[$k];

View File

@ -246,7 +246,7 @@ class ConfigPEN extends HTML
$tmp->options .= $tmp->pen;
$tmp->options .= '\')" >';
$tmp->options .= html_print_image(
'images/eye.png',
'images/operation.png',
true,
[
'title' => __('Show'),

File diff suppressed because it is too large Load Diff

View File

@ -704,9 +704,9 @@ class Tree
if ((bool) $module['alerts']) {
// Module has alerts triggered.
if ($module_alert_triggered === true) {
$module['alertsImageHTML'] = html_print_image('images/bell_orange.png', true, ['title' => __('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']);
}
}
}

View File

@ -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.

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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) {

View File

@ -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';
}

View File

@ -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'.

View File

@ -144,7 +144,7 @@ function snmp_browser_get_html_tree(
// Branch or leave with branches!
if (isset($sub_level['__OID__'])) {
$output .= "<a onfocus='javascript: this.blur();' href='javascript: snmpGet(\"".addslashes($sub_level['__OID__'])."\");'>";
$output .= '<img src="'.$url.'/../../images/eye.png" class="vertical_middle">';
$output .= '<img src="'.$url.'/../../images/operation.png" class="vertical_middle">';
$output .= '</a>';
}
@ -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 .= '<div id="snmp3_browser_options">';
} else {
$output .= '<div id="snmp3_browser_options" class="invisible">';
$output .= '<div id="snmp3_browser_options" style="display: none;">';
}
$output .= ui_toggle(
@ -1068,7 +1068,7 @@ function snmp_browser_print_container(
$output .= '<div id="spinner" class="spinner_none_padding">'.html_print_image('images/spinner.gif', true).'</div>';
$output .= '<div id="snmp_browser">';
$output .= '</div>';
$output .= '<div class="databox invisible mrgn_5px" id="snmp_data"></div>';
$output .= '<div class="databox mrgn_5px" id="snmp_data"></div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';

View File

@ -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;
}

View File

@ -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';

View File

@ -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");
}
});

View File

@ -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;

View File

@ -129,7 +129,7 @@
<div style='height: 10px'>
<?php
$version = '7.0NG.752';
$build = '210311';
$build = '210318';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -709,7 +709,7 @@ $table->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%';

View File

@ -0,0 +1,48 @@
<?php
/**
* External Tools view for agents.
*
* @category External tools for agents.
* @package Pandora FMS
* @subpackage Classic agent management view.
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
require_once 'include/functions_agents.php';
// Require needed class.
require_once $config['homedir'].'/include/class/ExternalTools.class.php';
// Control call flow for debug window.
try {
// User access and validation is being processed on class constructor.
$obj = new ExternalTools('agent');
} catch (Exception $e) {
echo '[ExternalTools]'.$e->getMessage();
// Stop this execution, but continue 'globally'.
return;
}
$obj->run();

View File

@ -190,7 +190,7 @@ if (!empty($result_groups)) {
echo '<tr>';
echo "<th class='w26px'>".__('Force').'</th>';
echo "<th width='30%' class='mw60px'>".__('Group').'/'.__('Tags').'</th>';
echo "<th width='30%' class='mw60px' style='text-align: justify'>".__('Group').'/'.__('Tags').'</th>';
echo "<th width='10%' class='mw60px center'>".__('Total').'</th>';
echo "<th width='10%' class='mw60px center'>".__('Unknown').'</th>';
echo "<th width='10%' class='mw60px center'>".__('Not init').'</th>';
@ -319,7 +319,7 @@ if (!empty($result_groups)) {
$link = "<a class='group_view_data $color_class bolder font_18px center'
href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_UNKNOWN."'>";
} else {
$link = "<a class='group_view_data $color_class bolder font_18x center'
$link = "<a class='group_view_data $color_class bolder font_18px center'
href='index.php?sec=view&sec2=operation/agentes/estado_agente&group_id=".$data['_id_'].'&status='.AGENT_STATUS_UNKNOWN."'>";
}
@ -336,7 +336,7 @@ if (!empty($result_groups)) {
// Agents not init
echo "<td class='group_view_data group_view_data_unk $color_class bolder font_18px center'>";
if (isset($data['_is_tag_'])) {
$link = "<a class='group_view_data $color_class bolder ont_18px center'
$link = "<a class='group_view_data $color_class bolder font_18px center'
href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NOT_INIT."'>";
} else {
$link = "<a class='group_view_data $color_class bolder font_18px center'
@ -359,7 +359,7 @@ if (!empty($result_groups)) {
$link = "<a class='group_view_data $color_class bolder font_18px center'
href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NORMAL."'>";
} else {
$link = "<a class='group_view_data $color_class bolder ont_18px center'
$link = "<a class='group_view_data $color_class bolder font_18px center'
href='index.php?sec=view&sec2=operation/agentes/estado_agente&group_id=".$data['_id_'].'&status='.AGENT_STATUS_NORMAL."'>";
}

View File

@ -1500,6 +1500,13 @@ if ($is_sap) {
$saptab = '';
}
// External Tools tab.
$external_tools['text'] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=external_tools&id_agente='.$id_agente.'">'.html_print_image('images/nettool.png', true, ['title' => __('External Tools')]).'</a>';
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) {

View File

@ -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);

View File

@ -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] .= '<div class="w100p right">'.html_print_submit_button(__('Upload'), 'accion', false, 'class="sub wand"', true).'</div>';
$upload_file_form = '<div>';
$upload_file_form = '<div class="w100p">';
if (check_acl($config['id_user'], 0, 'IW')) {
$upload_file_form .= '<form method="post" id="file_control" enctype="multipart/form-data">'.'<h4>'.__('Add attachment').'</h4>'.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 = '<div>';
$upload_comment_form = '<div class="w100p">';
if (check_acl($config['id_user'], 0, 'IW')) {
$upload_comment_form .= '<form method="post" id="comment_form" enctype="multipart/form-data"><h4>'.__('Add comment').'</h4>'.html_print_table($table_comments_section, true).html_print_input_hidden('upload_comment', 1, true).'</form>';

View File

@ -1,503 +0,0 @@
<script type="text/javascript">
$( document ).ready(function() {
$('[id^=checkbox-id_inc]').change(function(){
if($(this).parent().parent().hasClass('checkselected')){
$(this).parent().parent().removeClass('checkselected');
}
else{
$(this).parent().parent().addClass('checkselected');
}
});
$('[id^=checkbox-all_action]').change(function(){
if ($("#checkbox-all_action").prop("checked")) {
$('[id^=checkbox-id_inc]').parent().parent().addClass('checkselected');
$('[name^=id_inc]').prop("checked", true);
}
else{
$('[id^=checkbox-id_inc]').parent().parent().removeClass('checkselected');
$('[name^=id_inc]').prop("checked", false);
}
});
});
</script>
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
require_once 'include/functions_incidents.php';
check_login();
$incident_r = check_acl($config['id_user'], 0, 'IR');
$incident_w = check_acl($config['id_user'], 0, 'IW');
$incident_m = check_acl($config['id_user'], 0, 'IM');
$access = ($incident_r == true) ? 'IR' : (($incident_w == true) ? 'IW' : (($incident_m == true) ? 'IM' : 'IR'));
if (!$incident_r && !$incident_w && !$incident_m) {
db_pandora_audit('ACL Violation', 'Trying to access incident viewer');
include 'general/noaccess.php';
exit;
}
// Header
ui_print_page_header(
__('Incident management'),
'images/book_edit.png',
false,
'',
false,
''
);
// Take input parameters
// Offset adjustment
if (isset($_GET['offset'])) {
$offset = get_parameter('offset');
} else {
$offset = 0;
}
// Check action. Try to get author and group
$action = get_parameter('action');
if ($action == 'mass') {
$id_inc = get_parameter('id_inc', []);
$delete_btn = get_parameter('delete_btn', -1);
$own_btn = get_parameter('own_btn', -1);
foreach ($id_inc as $incident) {
if (check_acl($config['id_user'], incidents_get_group($incident), 'IM') || incidents_get_author($incident) == $config['id_user'] || incidents_get_owner($incident) == $config['id_user']) {
continue;
}
db_pandora_audit('ACL Forbidden', 'Mass-update or deletion of incident');
include 'general/noaccess.php';
exit;
}
if ($delete_btn != -1) {
$result = incidents_delete_incident($id_inc);
ui_print_result_message(
$result,
__('Successfully deleted'),
__('Could not be deleted')
);
}
if ($own_btn != -1) {
$result = incidents_process_chown($id_inc, $config['id_user']);
ui_print_result_message(
$result,
__('Successfully reclaimed ownership'),
__('Could not reclame ownership')
);
}
} else if ($action == 'update') {
$id_inc = get_parameter('id_inc', 0);
$author = incidents_get_author($id_inc);
$owner = incidents_get_owner($id_inc);
$grupo = incidents_get_group($id_inc);
if ($author != $config['id_user'] && $owner != $config['id_user'] && !check_acl($config['id_user'], $grupo, 'IM')) {
// Only admins (manage incident) or owners/creators can modify incidents
db_pandora_audit('ACL Forbidden', 'Update incident #'.$id_inc, $author);
include 'general/noaccess.php';
exit;
}
$titulo = get_parameter('titulo');
$titulo = io_safe_input(strip_tags(io_safe_output($titulo)));
$descripcion = get_parameter('descripcion');
$origen = get_parameter('origen_form');
$prioridad = get_parameter('prioridad_form', 0);
$estado = get_parameter('estado_form', 0);
$grupo = get_parameter('grupo_form', 1);
$usuario = get_parameter('usuario_form', $config['id_user']);
$id_agent = get_parameter('id_agent');
$sql = sprintf(
"UPDATE tincidencia
SET titulo = '%s', origen = '%s', estado = %d, id_grupo = %d, id_usuario = '%s', prioridad = %d, descripcion = '%s', id_lastupdate = '%s', id_agent = %d
WHERE id_incidencia = %d",
$titulo,
$origen,
$estado,
$grupo,
$usuario,
$prioridad,
$descripcion,
$config['id_user'],
$id_agent,
$id_inc
);
$result = db_process_sql($sql);
if ($result !== false) {
db_pandora_audit('Incident updated', 'User '.$config['id_user'].' updated incident #'.$id_inc);
}
ui_print_result_message(
$result,
__('Successfully updated'),
__('Could not be updated')
);
} else if ($action == 'insert') {
// Create incident
$grupo = get_parameter('grupo_form', 1);
if (!check_acl($config['id_user'], $grupo, 'IW')) {
db_pandora_audit('ACL Forbidden', 'User '.$config['id_user'].' tried to update incident');
include 'general/noaccess.php';
exit;
}
// Read input variables
$titulo = get_parameter('titulo');
$titulo = io_safe_input(strip_tags(io_safe_output($titulo)));
$descripcion = get_parameter('descripcion');
$origen = get_parameter('origen_form');
$prioridad = get_parameter('prioridad_form');
$id_creator = $config['id_user'];
$estado = get_parameter('estado_form');
$usuario = get_parameter('usuario_form', '');
$id_agent = get_parameter('id_agent');
$sql = sprintf(
"INSERT INTO tincidencia
(inicio, actualizacion, titulo, descripcion, id_usuario, origen, estado, prioridad, id_grupo, id_creator, id_agent, id_agente_modulo)
VALUES
(NOW(), NOW(), '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0)",
$titulo,
$descripcion,
$usuario,
$origen,
$estado,
$prioridad,
$grupo,
$config['id_user'],
$id_agent
);
$id_inc = db_process_sql($sql, 'insert_id');
if ($id_inc === false) {
ui_print_error_message(__('Error creating incident'));
} else {
ui_print_success_message(__('Incident created'));
db_pandora_audit('Incident created', 'User '.$config['id_user'].' created incident #'.$id_inc);
}
}
// Search
$filter = '';
$texto = (string) get_parameter('texto', '');
if ($texto != '') {
$filter .= sprintf(" AND (titulo LIKE '%%%s%%' OR descripcion LIKE '%%%s%%')", $texto, $texto);
}
$usuario = (string) get_parameter('usuario', '');
if ($usuario != '') {
$filter .= sprintf(" AND id_usuario = '%s'", $usuario);
}
$estado = (int) get_parameter('estado', -1);
if ($estado >= 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 '<form name="visualizacion" method="post" action="index.php?sec=workspace&amp;sec2=operation/incidents/incident">';
echo '<table class="databox filters" cellpadding="4" cellspacing="4" width="100%"><tr>
<td valign="middle"><h3>'.__('Filter').'</h3>';
$fields = incidents_get_status();
echo '<b>'.__('Incidents:').'</b>'.'&nbsp;&nbsp;';
html_print_select($fields, 'estado', $estado, 'javascript:this.form.submit();', __('All incidents'), -1, false, false, false, 'w155');
// Legend
echo '</td><td valign="middle"><noscript>';
html_print_submit_button(__('Show'), 'submit-estado', false, ['class' => 'sub']);
echo '</noscript></td><td rowspan="7" class="f9" class="pdd_l_30px align-top"><h3>'.__('Status').'</h3>';
foreach (incidents_get_status() as $id => $str) {
incidents_print_status_img($id);
echo ' - '.$str.'<br />';
}
echo '</td><td rowspan="7" class="f9" class="pdd_l_30px align-top"><h3>'.__('Priority').'</h3>';
foreach (incidents_get_priorities() as $id => $str) {
incidents_print_priority_img($id);
echo ' - '.$str.'<br />';
}
echo '</td></tr><tr><td>';
$fields = incidents_get_priorities();
echo '<b>'.__('Priorities:').'</b>'.'&nbsp;&nbsp;';
html_print_select($fields, 'prioridad', $prioridad, 'javascript:this.form.submit();', __('All priorities'), -1, false, false, false, 'w155');
echo '</td></tr><tr><td>';
echo '<b>'.__('Users:').'</b>'.'&nbsp;&nbsp;';
html_print_select(users_get_info(), 'usuario', $usuario, 'javascript:this.form.submit();', __('All users'), '', false, false, false, 'w155');
echo '</td></tr><tr><td>';
$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 '<b>'.__('Agents:').'</b>'.'&nbsp;&nbsp;';
html_print_select(
$result_agent_incidents,
'agent_search',
$agent_search,
'javascript:this.form.submit();',
__('All agents'),
'',
false,
false,
false,
'w155'
);
echo '</td></tr><tr><td colspan=3>';
echo '<b>'.__('Groups:').'</b>'.'&nbsp;&nbsp;';
echo '<div class="w250px inline">';
html_print_select_groups($config['id_user'], 'IR', true, 'grupo', $grupo, 'javascript:this.form.submit();', '', '', false, false, false, 'w155');
echo '</div>';
// echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo '</td></tr><tr><td colspan=3>';
echo '<b>'.__('Free text:').'</b>'.ui_print_help_tip(
__('Search by incident name or description, list matches.'),
true
).'&nbsp;&nbsp;';
html_print_input_text('texto', $texto, '', 45);
echo '&nbsp;';
html_print_input_image('submit', 'images/zoom.png', __('Search'), 'padding:0;', false, ['alt' => __('Search')]);
echo '</td></tr></table>';
echo '</form>';
}
if ($count_total < 1) {
include_once $config['homedir'].'/general/first_task/incidents.php';
} else {
// TOTAL incidents
$url = 'index.php?sec=workspace&amp;sec2=operation/incidents/incident';
$estado = -1;
// add form filter values for group, priority, state, and search fields: user and text
if ($grupo != -1) {
$url .= '&amp;grupo='.$grupo;
}
if ($prioridad != -1) {
$url .= '&amp;prioridad='.$prioridad;
}
if ($estado != -1) {
$url .= '&amp;estado='.$estado;
}
if ($usuario != '') {
$url .= '&amp;usuario='.$usuario;
}
if ($texto != '') {
$url .= '&amp;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 '<br />';
// 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] = '<a href="index.php?sec=workspace&amp;sec2=operation/incidents/incident_detail&amp;id='.$row['id_incidencia'].'">'.$row['id_incidencia'].'</a>';
$attach = incidents_get_attach($row['id_incidencia']);
if (!empty($attach)) {
$data[1] .= '&nbsp;&nbsp;'.html_print_image('images/attachment.png', true, ['style' => 'align:middle;']);
}
$data[2] = incidents_print_status_img($row['estado'], true);
$data[3] = '<a href="index.php?sec=workspace&amp;sec2=operation/incidents/incident_detail&amp;id='.$row['id_incidencia'].'">'.ui_print_truncate_text(io_safe_output($row['titulo']), 'item_title').'</a>';
$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 '<form method="post" action="'.$url.'&amp;action=mass" class="mrgn_btn_0px">';
html_print_table($table);
echo '<div class="right float-right">';
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 '</div>';
echo '</form>';
unset($table);
if (check_acl($config['id_user'], 0, 'IW')) {
echo '<div class="right float-right pdd_r_5px">';
echo '<form method="post" action="index.php?sec=workspace&amp;sec2=operation/incidents/incident_detail&amp;insert_form=1">';
html_print_submit_button(__('Create incident'), 'crt', false, 'class="sub next"');
echo '</form>';
echo '</div>';
}
}
echo '<div id="both">&nbsp;</div>';

View File

@ -1,532 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
require_once 'include/functions_incidents.php';
require_once 'include/functions_events.php';
// To get events group information
check_login();
if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) {
// Doesn't have access to this page
db_pandora_audit('ACL Violation', 'Trying to access incident details');
include 'general/noaccess.php';
exit;
}
$inicio = get_system_time();
// Just inits the variable
$actualizacion = get_system_time();
// EDITION MODE
if (isset($_GET['id'])) {
$id_inc = (int) get_parameter('id', 0);
// Obtain group of this incident
$row = db_get_row('tincidencia', 'id_incidencia', $id_inc);
// Get values
$titulo = $row['titulo'];
$texto = $row['descripcion'];
$inicio = time_w_fixed_tz($row['inicio']);
$actualizacion = time_w_fixed_tz($row['actualizacion']);
$estado = $row['estado'];
$prioridad = $row['prioridad'];
$origen = $row['origen'];
$usuario = $row['id_usuario'];
// owner
$id_grupo = $row['id_grupo'];
$id_creator = $row['id_creator'];
// creator
$id_lastupdate = $row['id_lastupdate'];
// last updater
$id_agent = $row['id_agent'];
// Agent
// Note add - everybody that can read incidents, can add notes
if (isset($_GET['insertar_nota'])) {
$nota = get_parameter('nota');
$sql = sprintf(
"INSERT INTO tnota (id_usuario, id_incident, nota)
VALUES ('%s', %d, '%s')",
$config['id_user'],
$id_inc,
$nota
);
$id_nota = db_process_sql($sql, 'insert_id');
if ($id_nota !== false) {
incidents_process_touch($id_inc);
}
ui_print_result_message(
$id_nota,
__('Successfully added'),
__('Could not be added')
);
}
// Delete note
if (isset($_POST['delete_nota'])) {
$id_nota = get_parameter('delete_nota', 0);
$note_user = incidents_get_notes_author($id_nota);
if (((check_acl($config['id_user'], $id_grupo, 'IM') == 1) or ($note_user == $config['id_user'])) or ($id_owner == $config['id_user'])) {
// Only admins (manage incident) or owners can modify
// incidents notes. note authors are
// able to delete their own notes
$result = incidents_delete_note($id_nota);
if (!empty($result)) {
incidents_process_touch($id_inc);
}
ui_print_result_message(
$id_nota,
__('Successfully deleted'),
__('Could not be deleted')
);
}
}
// Delete file
if (((check_acl($config['id_user'], $id_grupo, 'IM') == 1)
or ($id_owner == $config['id_user'])) and isset($_POST['delete_file'])
) {
$file_id = (int) get_parameter('delete_file', 0);
$filename = db_get_value('filename', 'tattachment', 'id_attachment', $file_id);
$sql = sprintf(
'
DELETE
FROM tattachment
WHERE id_attachment = %d',
$file_id
);
$result = db_process_sql($sql);
if (!empty($result)) {
if (file_exists($config['homedir'].'/attachment/pand'.$row['id_attachment'].'_'.$row['filename'].'.zip')) {
unlink(
$config['attachment_store'].'/pand'.$file_id.'_'.io_safe_output($filename).'.zip'
);
} else {
unlink(
$config['attachment_store'].'/pand'.$file_id.'_'.io_safe_output($filename)
);
}
incidents_process_touch($id_inc);
}
ui_print_result_message(
$result,
__('Successfully deleted'),
__('Could not be deleted')
);
}
// Upload file
if ((check_acl($config['id_user'], $id_grupo, 'IW') == 1) && isset($_GET['upload_file']) && ($_FILES['userfile']['name'] != '')) {
$description = get_parameter('file_description', __('No description available'));
// Insert into database
$filename = strip_tags(io_safe_input($_FILES['userfile']['name']), '<br>');
$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.'<br>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 "<script type=\"text/javascript\">
$(document).ready(function() {
$('#file_control').hide();
$('#add_note').hide();
$('a.attachment').click(function() {
$('a.attachment').fadeOut('fast');
$('#file_control').slideDown('slow');
return false;
});
$('a.note_control').click(function() {
$('a.note_control').fadeOut('fast');
$('#add_note').slideDown('slow');
return false;
});
});
</script>";
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 '<form name="accion_form" method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident&action=update">';
echo '<input type="hidden" name="id_inc" value="'.$id_inc.'">';
} else {
ui_print_page_header(__('Create incident'), 'images/book_edit.png', false, '', false, '');
echo '<form name="accion_form" method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident&action=insert">';
}
echo '<table cellpadding="4" cellspacing="4" class="databox filters" width="100%">';
echo '<tr>
<td class="datos"><b>'.__('Incident').'</b></td>
<td colspan="3" class="datos">';
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 '</td>
</tr>';
echo '<tr>
<td class="datos2"><b>'.__('Opened at').'</b></td>
<td class="datos2"><i>'.date($config['date_format'], $inicio).'</i></td>
<td class="datos2"><b>'.__('Updated at').'</b></td>
<td class="datos2"><i>'.date($config['date_format'], $actualizacion).'</i></td>
</tr>';
echo '<tr>
<td class="datos"><b>'.__('Owner').'</b></td>
<td class="datos">';
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 '</td>
<td class="datos"><b>'.__('Status').'</b></td>
<td class="datos">';
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 '</td>
</tr>';
echo '<tr>
<td class="datos2"><b>'.__('Source').'</b></td>
<td class="datos2">';
$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 '</td><td class="datos2"><b>'.__('Group').'</b></td><td class="datos2">';
// Group combo
echo '<div class="w250px">';
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 '</div>';
echo '</td></tr><tr><td class="datos"><b>'.__('Priority').'</b></td><td class="datos">';
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 '</td><td class="datos"><b>'.__('Creator').'</b></td><td class="datos">';
if (empty($id_creator)) {
echo 'SYSTEM';
} else {
echo $id_creator.' (<i>'.get_user_fullname($id_creator).'</i>)';
}
$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 '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="datos"><b>'.__('Agent').'</b></td>';
echo '<td class="datos">';
$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 '</td>';
echo '</tr>';
echo '<tr><td class="datos2" colspan="4">';
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 '</td></tr></table><div class="w100p right">';
// 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 '</div></form>';
// If we're actually working on an incident
if (isset($id_inc)) {
// ******************************************************************
// Notes
// ******************************************************************
echo '<div>';
echo '<a class="note_control" href="#">';
echo html_print_image('images/add.png', true);
echo __('Add note');
echo '</a>';
echo '</div><div>';
echo '<form id="add_note" name="nota" method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident_detail&insertar_nota=1&id='.$id_inc.'"><h4>'.__('Add note').'</h4>';
echo '<table cellpadding="4" cellspacing="4" class="databox" width="100%">
<tr><td class="datos2"><textarea name="nota" rows="5" cols="70" class="height_100px"></textarea></td>
<td valign="bottom"><input name="addnote" type="submit" class="sub wand" value="'.__('Add').'"></td></tr>
</table></form></div><div>';
$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 '<h4>'.__('Notes attached to incident').'</h4>';
echo '<form method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident_detail&id='.$id_inc.'">';
html_print_table($table);
echo '</form>';
}
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']).'&nbsp;&nbsp;<a target="_new" href="'.$url.'"><b>'.$row['filename'].'</b></a>';
$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 '<h4>'.__('Attached files').'</h4>';
echo '<form method="POST" action="index.php?sec=workspace&sec2=operation/incidents/incident_detail&id='.$id_inc.'">';
html_print_table($table);
echo '</form>';
}
unset($table);
// ******************************************************************
// Upload control
// ******************************************************************
// Upload control
if ((check_acl($config['id_user'], $id_grupo, 'IW') == 1)) {
echo '<div>';
echo '<a class="attachment" href="#">';
echo html_print_image('images/add.png', true);
echo __('Add attachment');
echo '</a>';
echo '</div>';
echo '<div><form method="post" id="file_control" action="index.php?sec=workspace&sec2=operation/incidents/incident_detail&id='.$id_inc.'&upload_file=1" enctype="multipart/form-data"><h4>'.__('Add attachment').'</h4>';
echo '<table cellpadding="4" cellspacing="3" class="databox" width="98%">
<tr><td class="datos">'.__('Filename').'</td><td class="datos"><input type="file" name="userfile" value="userfile" class="sub" size="40" /></td></tr>
<tr><td class="datos2">'.__('Description').'</td><td class="datos2" colspan="3"><input type="text" name="file_description" size="47"></td></tr>
<tr><td colspan="2" class="right"> <input type="submit" name="upload" value="'.__('Upload').'" class="sub wand"></td></tr>
</table></form></div>';
}
}

View File

@ -26,6 +26,11 @@ if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'],
ui_print_page_header(__('Incidents').' &raquo; '.__('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 '<table width="90%">
<tr><td valign="top"><h3>'.__('Incidents by status').'</h3>';
echo graph_incidents_status();
@ -39,7 +44,4 @@ echo graphic_incident_group();
echo '<td><h3>'.__('Incidents by user').'</h3>';
echo graphic_incident_user();
echo '<tr><td><h3>'.__('Incidents by source').'</h3>';
echo graphic_incident_source();
echo '</table>';

View File

@ -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;
}

View File

@ -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;

View File

@ -82,10 +82,10 @@ ui_print_page_header(
// SNMP tree container.
snmp_browser_print_container(false, '100%', '60%', '', true);
// Div for modal
echo '<div id="modal" class="invisible"></div>';
// Div for modal.
echo '<div id="modal" style="display:none"></div>';
// Div for loading modal.
echo '<div id="loading_modal" class="invisible"></div>';
echo '<div id="loading_modal" style="display:none"></div>';
?>

View File

@ -565,7 +565,7 @@ $table_ichanges = '<div class="autorefresh_select">
<p class="autorefresh_select_text">'.__('Full list of pages').': </p>
<div>'.$select_out.'</div>
</div>
<div class="autorefresh_select_arrows">
<div class="autorefresh_select_arrows" style="display:grid">
<a href="javascript:">'.html_print_image(
'images/darrowright_green.png',
true,

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -43,10 +43,10 @@
$output = '';
// Div for modal update dashboard.
$output .= '<div id="modal-update-dashboard" class=""></div>';
$output .= '<div id="modal-add-widget" class=""></div>';
$output .= '<div id="modal-config-widget" class=""></div>';
$output .= '<div id="modal-slides-dialog" class=""></div>';
$output .= '<div id="modal-update-dashboard" style="display:none;"></div>';
$output .= '<div id="modal-add-widget" style="display:none;"></div>';
$output .= '<div id="modal-config-widget" style="display:none;"></div>';
$output .= '<div id="modal-slides-dialog" style="display:none;"></div>';
// Layout.
$output .= '<div class="container-fluid">';

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.752-210311
Version: 7.0NG.752-210318
Architecture: all
Priority: optional
Section: admin

View File

@ -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

View File

@ -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 <file> : Store PID to file.\n";
print " -q : Quiet startup \n";
print " -S <install|uninstall|run>: 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);

View File

@ -44,8 +44,6 @@ Exported Functions:
=item * C<pandora_create_group>
=item * C<pandora_create_incident>
=item * C<pandora_create_module>
=item * C<pandora_disable_autodisable_agents>
@ -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>) >>

View File

@ -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() ] );

View File

@ -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}

View File

@ -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}

View File

@ -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"

View File

@ -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&#x20;title\",\"Ticket&#x20;group&#x20;ID\",\"Ticket&#x20;priority\",\"Ticket&#x20;owner\",\"Ticket&#x20;type\",\"Ticket&#x20;status\",\"Ticket&#x20;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&#x20;IMS&#x20;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&#x20;IMS&#x20;Ticket\"");
}
# Release the lock
if ($lock == 1) {
db_release_lock ($dbh, $lock_name);

View File

@ -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', '<event_id>', 'Validate event given a event id');
help_screen_line('--get_event_info', '<event_id>[<csv_separator>]', 'Show info about a event given a event id');
help_screen_line('--add_event_comment', '<event_id> <user_name> <comment>', 'Add event\'s comment');
print "\nINCIDENTS:\n\n" unless $param ne '';
help_screen_line('--create_incident', "<title> <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);

View File

@ -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);