Merge branch 'develop' into feature/report_SLA_new

This commit is contained in:
daniel 2016-12-14 15:42:18 +01:00
commit b28fe4cef4
71 changed files with 94933 additions and 87430 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0dev-161130 Version: 7.0dev-161214
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0dev-161130" pandora_version="7.0dev-161214"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -41,7 +41,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0dev'; use constant AGENT_VERSION => '7.0dev';
use constant AGENT_BUILD => '161130'; use constant AGENT_BUILD => '161214';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -131,10 +131,12 @@ my %DefaultConf = (
'temporal' => '/var/spool/pandora', 'temporal' => '/var/spool/pandora',
'interval' => 300, 'interval' => 300,
'debug' => 0, 'debug' => 0,
'ehorus_conf' => undef,
'agent_name' => hostname (), 'agent_name' => hostname (),
'agent_name_cmd' => '', 'agent_name_cmd' => '',
'description' => '', 'description' => '',
'group' => '', 'group' => '',
'group_id' => undef,
'group_password' => undef, 'group_password' => undef,
'encoding' => 'UTF-8', 'encoding' => 'UTF-8',
'server_port' => 41121, 'server_port' => 41121,
@ -2194,6 +2196,39 @@ sub init_module ($) {
$module->{'alert_template'} = undef; $module->{'alert_template'} = undef;
} }
################################################################################
# Get the eHorus key from the eHorus agent configuration file.
################################################################################
sub get_ehkey {
my $fh;
return '' unless defined($Conf{'ehorus_conf'});
# Open the eHorus configuration file.
if (!open($fh, '<', $Conf{'ehorus_conf'})) {
# Do not write to the log, since ehorus_conf points to the default eHorus configuration file by default.
return '';
}
# Look for the eHorus key.
while (my $line = <$fh>) {
# Skip comments.
next if ($line =~ m/^\s*#/);
if ($line =~ m/\s*eh_key\s+(\S+)/) {
my $eh_key = $1;
close($fh);
return $eh_key;
}
}
# Not found.
close($fh);
return '';
}
################################################################################ ################################################################################
# Main. # Main.
################################################################################ ################################################################################
@ -2373,11 +2408,14 @@ while (1) {
# Clear the XML # Clear the XML
$Xml = ""; $Xml = "";
# Custom fields # Get the eHorus key.
my $eh_key = get_ehkey();
# Custom fields
my @customfieldskeys = keys(%Customfields); my @customfieldskeys = keys(%Customfields);
if ($#customfieldskeys > -1) { if ($#customfieldskeys > -1 || $eh_key ne '') {
$Xml .= "<custom_fields>\n"; $Xml .= "<custom_fields>\n";
foreach my $customfieldkey (@customfieldskeys) { foreach my $customfieldkey (@customfieldskeys) {
if($customfieldkey =~ m/^(custom_field\d+_)name/) { if($customfieldkey =~ m/^(custom_field\d+_)name/) {
if(defined($Customfields{$1."value"})) { if(defined($Customfields{$1."value"})) {
@ -2388,6 +2426,15 @@ while (1) {
} }
} }
} }
# Add the eHorus key as a custom field.
if ($eh_key ne '') {
$Xml .= " <field>\n";
$Xml .= " <name>eHorusID</name>\n";
$Xml .= " <value><![CDATA[". $eh_key ."]]></value>\n";
$Xml .= " </field>\n";
}
$Xml .= "</custom_fields>\n"; $Xml .= "</custom_fields>\n";
} }
@ -2422,6 +2469,7 @@ while (1) {
my $xml_header = "<?xml version='1.0' encoding='" . $Conf{'encoding'} . "'?>\n" . my $xml_header = "<?xml version='1.0' encoding='" . $Conf{'encoding'} . "'?>\n" .
"<agent_data description='" . $Conf{'description'} . "' group='" . $Conf{'group'} . "<agent_data description='" . $Conf{'description'} . "' group='" . $Conf{'group'} .
(defined($Conf{'group_password'}) ? ("' group_password='" . $Conf{'group_password'}) : '') . (defined($Conf{'group_password'}) ? ("' group_password='" . $Conf{'group_password'}) : '') .
(defined($Conf{'group_id'}) ? ("' group_id='" . $Conf{'group_id'}) : '') .
"' os_name='$OS' os_version='$OS_VERSION' interval='" . $Conf{'interval'} . "' os_name='$OS' os_version='$OS_VERSION' interval='" . $Conf{'interval'} .
"' version='" . AGENT_VERSION . '(Build ' . AGENT_BUILD . ')' . ($Conf{'autotime'} eq '1' ? '' : "' timestamp='" . strftime ('%Y/%m/%d %H:%M:%S', localtime ())) . "' version='" . AGENT_VERSION . '(Build ' . AGENT_BUILD . ')' . ($Conf{'autotime'} eq '1' ? '' : "' timestamp='" . strftime ('%Y/%m/%d %H:%M:%S', localtime ())) .
"' agent_name='" . $Conf{'agent_name'} . "' timezone_offset='". $Conf{'timezone_offset'} . "' agent_name='" . $Conf{'agent_name'} . "' timezone_offset='". $Conf{'timezone_offset'} .
@ -2475,6 +2523,7 @@ while (1) {
$xml_header .= "' position_description='" .$Conf{'position_description'}; $xml_header .= "' position_description='" .$Conf{'position_description'};
} }
} }
$xml_header .= "'>\n"; $xml_header .= "'>\n";
$Xml = $xml_header . $Xml . "</agent_data>"; $Xml = $xml_header . $Xml . "</agent_data>";

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0dev %define version 7.0dev
%define release 161130 %define release 161214
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}
@ -24,7 +24,7 @@ Requires(preun): chkconfig /bin/rm /usr/sbin/userdel
Requires: fileutils textutils unzip Requires: fileutils textutils unzip
Requires: util-linux procps grep Requires: util-linux procps grep
Requires: /sbin/ip /bin/awk Requires: /sbin/ip /bin/awk
Requires: perl perl(Sys::Syslog) Requires: perl perl(Sys::Syslog) perl(IO::Socket::SSL)
# Required by plugins # Required by plugins
#Requires: sh-utils sed passwd net-tools rpm #Requires: sh-utils sed passwd net-tools rpm
AutoReq: 0 AutoReq: 0

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0dev %define version 7.0dev
%define release 161130 %define release 161214
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0dev" PI_VERSION="7.0dev"
PI_BUILD="161130" PI_BUILD="161214"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{161130} {161214}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0dev(Build 161130)") #define PANDORA_VERSION ("7.0dev(Build 161214)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -385,7 +385,7 @@ Pandora_Windows_Service::getXmlHeader () {
char timestamp[20]; char timestamp[20];
string agent_name, os_name, os_version, encoding, value, xml, address, parent_agent_name, agent_name_cmd; string agent_name, os_name, os_version, encoding, value, xml, address, parent_agent_name, agent_name_cmd;
string custom_id, url_address, latitude, longitude, altitude, position_description, gis_exec, gis_result, agent_mode; string custom_id, url_address, latitude, longitude, altitude, position_description, gis_exec, gis_result, agent_mode;
string group_password; string group_password, group_id, ehorus_conf;
time_t ctime; time_t ctime;
struct tm *ctime_tm = NULL; struct tm *ctime_tm = NULL;
int pos; int pos;
@ -479,13 +479,20 @@ Pandora_Windows_Service::getXmlHeader () {
xml += url_address; xml += url_address;
} }
// Get Url Address // Get group password
group_password = conf->getValue ("group_password"); group_password = conf->getValue ("group_password");
if (group_password != "") { if (group_password != "") {
xml += "\" group_password=\""; xml += "\" group_password=\"";
xml += group_password; xml += group_password;
} }
// Get Group ID
group_id = conf->getValue ("group_id");
if (group_id != "") {
xml += "\" group_id=\"";
xml += group_id;
}
// Get Coordinates // Get Coordinates
gis_exec = conf->getValue ("gis_exec"); gis_exec = conf->getValue ("gis_exec");
@ -1634,6 +1641,7 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
string xml_filename, random_integer; string xml_filename, random_integer;
string tmp_filename, tmp_filepath; string tmp_filename, tmp_filepath;
string encoding; string encoding;
string ehorus_conf, eh_key;
static HANDLE mutex = 0; static HANDLE mutex = 0;
ULARGE_INTEGER free_bytes; ULARGE_INTEGER free_bytes;
double min_free_bytes = 0; double min_free_bytes = 0;
@ -1653,6 +1661,12 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
data_xml = getXmlHeader (); data_xml = getXmlHeader ();
/* Get the eHorus key. */
ehorus_conf = conf->getValue ("ehorus_conf");
if (ehorus_conf != "") {
eh_key = getEHKey(ehorus_conf);
}
/* Write custom fields */ /* Write custom fields */
int c = 1; int c = 1;
@ -1663,7 +1677,7 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
string token_name = conf->getValue (token_name_token); string token_name = conf->getValue (token_name_token);
string token_value = conf->getValue (token_value_token); string token_value = conf->getValue (token_value_token);
if(token_name != "" && token_value != "") { if((token_name != "" && token_value != "") || eh_key != "") {
data_xml += "<custom_fields>\n"; data_xml += "<custom_fields>\n";
while(token_name != "" && token_value != "") { while(token_name != "" && token_value != "") {
data_xml += " <field>\n"; data_xml += " <field>\n";
@ -1677,6 +1691,15 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
token_name = conf->getValue (token_name_token); token_name = conf->getValue (token_name_token);
token_value = conf->getValue (token_value_token); token_value = conf->getValue (token_value_token);
} }
/* Add the eHorus key as a custom field. */
if (eh_key != "") {
data_xml += " <field>\n";
data_xml += " <name>eHorusID</name>\n";
data_xml += " <value><![CDATA["+ eh_key +"]]></value>\n";
data_xml += " </field>\n";
}
data_xml += "</custom_fields>\n"; data_xml += "</custom_fields>\n";
} }
@ -2034,6 +2057,37 @@ Pandora_Windows_Service::getConf () {
return this->conf; return this->conf;
} }
string
Pandora_Windows_Service::getEHKey (string ehorus_conf) {
string buffer, eh_key;
std::ifstream ifs(ehorus_conf.c_str());
int pos;
if (! ifs.is_open ()) {
pandoraDebug ("Error opening eHorus configuration file %s", ehorus_conf.c_str ());
return eh_key;
}
/* Look for the eHorus key. */
while (ifs.good ()) {
getline (ifs, buffer);
/* Skip comments. */
if (buffer.empty() || buffer.at(0) == '#') {
continue;
}
pos = buffer.find("eh_key");
if (pos != string::npos){
eh_key = buffer.substr(pos + 7); /* pos + strlen("eh_key ") */
eh_key = trim(eh_key);
return eh_key;
}
}
return eh_key;
}
long long
Pandora_Windows_Service::getInterval () { Pandora_Windows_Service::getInterval () {
return this->interval; return this->interval;

View File

@ -114,6 +114,7 @@ namespace Pandora {
int sendXml (Pandora_Module_List *modules); int sendXml (Pandora_Module_List *modules);
void sendBufferedXml (string path); void sendBufferedXml (string path);
Pandora_Agent_Conf *getConf (); Pandora_Agent_Conf *getConf ();
string getEHKey (string ehorus_conf);
long getInterval (); long getInterval ();
long getIntensiveInterval (); long getIntensiveInterval ();

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0dev(Build 161130))" VALUE "ProductVersion", "(7.0dev(Build 161214))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0dev-161130 Version: 7.0dev-161214
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0dev-161130" pandora_version="7.0dev-161214"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -365,7 +365,7 @@ function resource_exportation_extension_main() {
id = $("select#" + type + " option:selected").val(); id = $("select#" + type + " option:selected").val();
url = location.href.split('index'); url = location.href.split('index');
if (type == "policy") { if (type == "policy") {
include_agents = $("#checkbox-export_agents").prop("checked") var include_agents = $("#checkbox-export_agents").prop("checked")
url = url[0] + 'extensions/resource_exportation.php?get_ptr=1&type=' + type url = url[0] + 'extensions/resource_exportation.php?get_ptr=1&type=' + type
+ '&id=' + id + '&include_agents=' + include_agents; + '&id=' + id + '&include_agents=' + include_agents;

View File

@ -88,6 +88,7 @@ ALTER TABLE tusuario ADD CONSTRAINT fk_id_filter FOREIGN KEY (id_filter) REFEREN
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
ALTER TABLE tagente_modulo ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; ALTER TABLE tagente_modulo ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0';
ALTER TABLE tagente_modulo ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; ALTER TABLE tagente_modulo ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
ALTER TABLE tagente_modulo ADD COLUMN `parent_module_id` int(10) unsigned NOT NULL;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tagente_datos` -- Table `tagente_datos`
@ -123,3 +124,8 @@ ALTER TABLE tlayout ADD `background_color` varchar(50) NOT NULL default '#FFF';
-- Table `tlayout_data` -- Table `tlayout_data`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
ALTER TABLE tlayout_data ADD `type_graph` varchar(50) NOT NULL default 'area'; ALTER TABLE tlayout_data ADD `type_graph` varchar(50) NOT NULL default 'area';
-- ---------------------------------------------------------------------
-- Table `tagent_custom_fields`
-- ---------------------------------------------------------------------
INSERT INTO `tagent_custom_fields` (`name`) VALUES ('eHorusID');

View File

@ -76,6 +76,7 @@ ALTER TABLE tagente_modulo ADD COLUMN dynamic_max bigint(20) default '0';
ALTER TABLE tagente_modulo ADD COLUMN dynamic_min bigint(20) default '0'; ALTER TABLE tagente_modulo ADD COLUMN dynamic_min bigint(20) default '0';
ALTER TABLE tagente_modulo ADD COLUMN dynamic_next bigint(20) NOT NULL default '0'; ALTER TABLE tagente_modulo ADD COLUMN dynamic_next bigint(20) NOT NULL default '0';
ALTER TABLE tagente_modulo ADD COLUMN dynamic_two_tailed tinyint(1) unsigned default '0'; ALTER TABLE tagente_modulo ADD COLUMN dynamic_two_tailed tinyint(1) unsigned default '0';
ALTER TABLE tagente_modulo ADD COLUMN parent_module_id NUMBER(10, 0);
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tnetwork_component` -- Table `tnetwork_component`
@ -101,3 +102,8 @@ ALTER TABLE tlayout ADD COLUMN background_color varchar(50) NOT NULL default '#F
-- Table `tlayout_data` -- Table `tlayout_data`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
ALTER TABLE tlayout_data ADD COLUMN type_graph varchar(50) NOT NULL default 'area'; ALTER TABLE tlayout_data ADD COLUMN type_graph varchar(50) NOT NULL default 'area';
-- ---------------------------------------------------------------------
-- Table `tagent_custom_fields`
-- ---------------------------------------------------------------------
INSERT INTO tagent_custom_fields (name) VALUES ('eHorusID');

View File

@ -245,7 +245,7 @@ foreach ($result as $row) {
} }
$data[1] = ui_print_session_action_icon ($row['accion'], true); $data[1] = ui_print_session_action_icon ($row['accion'], true);
$data[1] .= $row["accion"]; $data[1] .= $row["accion"];
$data[2] = ui_print_help_tip($row['fecha'], true) . human_time_comparation($row['utimestamp']); $data[2] = ui_print_help_tip($row['fecha'], true) . ui_print_timestamp($row['utimestamp'], true);
switch ($config['dbtype']) { switch ($config['dbtype']) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
@ -299,7 +299,7 @@ html_print_table ($table);
echo '<div style="width: '.$table->width.'" class="action-buttons">'; echo '<div style="width: '.$table->width.'" class="action-buttons">';
echo '<a href="' . echo '<a href="' .
ui_get_full_url(false, false, false, false) . 'index.php?sec=gextensions&sec2=godmode/audit_log_csv&tipo_log='.$tipo_log.'&user_filter='.$user_filter.'&filter_text='.$filter_text.'&filter_hours_old='.$filter_hours_old.'&filter_ip='.$filter_ip.'"'. ui_get_full_url(false, false, false, false) . 'index.php?sec=gextensions&sec2=godmode/audit_log_csv&tipo_log='.$tipo_log.'&user_filter='.$user_filter.'&filter_text='.$filter_text.'&filter_hours_old='.$filter_hours_old.'&filter_ip='.$filter_ip.'"'.
'target="_new">' . '>' .
html_print_button (__('Export to CSV '), 'export_csv', false, '', 'class=sub upd', true, false). '</a>'; html_print_button (__('Export to CSV '), 'export_csv', false, '', 'class=sub upd', true, false). '</a>';
echo '</div>'; echo '</div>';

View File

@ -1022,7 +1022,7 @@ if ($update_module || $create_module) {
$throw_unknown_events = (bool)get_parameter('throw_unknown_events', false); $throw_unknown_events = (bool)get_parameter('throw_unknown_events', false);
//Set the event type that can show. //Set the event type that can show.
$disabled_types_event = array(EVENTS_GOING_UNKNOWN => (int)$throw_unknown_events); $disabled_types_event = array(EVENTS_GOING_UNKNOWN => (int)!$throw_unknown_events);
$disabled_types_event = io_json_mb_encode($disabled_types_event); $disabled_types_event = io_json_mb_encode($disabled_types_event);
$module_macro_names = (array) get_parameter('module_macro_names', array()); $module_macro_names = (array) get_parameter('module_macro_names', array());

View File

@ -427,7 +427,7 @@ else {
$throw_unknown_events_check = $throw_unknown_events_check =
policy_module_is_disable_type_event($__id_pol_mod, EVENTS_GOING_UNKNOWN); policy_module_is_disable_type_event($__id_pol_mod, EVENTS_GOING_UNKNOWN);
} }
$table_advanced->data[4][3] = __('Throw unknown events'); $table_advanced->data[4][3] = __('Discard unknown events');
$table_advanced->data[4][4] = html_print_checkbox('throw_unknown_events', $table_advanced->data[4][4] = html_print_checkbox('throw_unknown_events',
1, $throw_unknown_events_check, true, $disabledBecauseInPolicy); 1, $throw_unknown_events_check, true, $disabledBecauseInPolicy);
$table_advanced->colspan[4][4] = 3; $table_advanced->colspan[4][4] = 3;

View File

@ -570,7 +570,7 @@ if ($table->rowspan['edit10'][0] == 2) {
else { else {
$table->rowspan['edit10'][0] = $table->rowspan['edit10'][1] = 2; $table->rowspan['edit10'][0] = $table->rowspan['edit10'][1] = 2;
} }
$table->data['edit102'][2] = __('Throw unknown events'); $table->data['edit102'][2] = __('Discard unknown events');
$table->data['edit102'][3] = html_print_select( $table->data['edit102'][3] = html_print_select(
array('' => __('No change'), array('' => __('No change'),

View File

@ -168,9 +168,9 @@ $table->data[8][3] = html_print_input_text ('max', $max, '', 5, 15, true) . ' '
$table->data[9][0] = __('Unit'); $table->data[9][0] = __('Unit');
$table->data[9][1] = html_print_input_text ('unit', $unit, '', 12, 25, true); $table->data[9][1] = html_print_input_text ('unit', $unit, '', 12, 25, true);
$table->data[9][2] = __('Throw unknown events'); $table->data[9][2] = __('Discard unknown events');
$table->data[9][3] = html_print_checkbox('throw_unknown_events', 1, $table->data[9][3] = html_print_checkbox('throw_unknown_events', 1,
!network_components_is_disable_type_event($id, EVENTS_GOING_UNKNOWN), true); network_components_is_disable_type_event($id, EVENTS_GOING_UNKNOWN), true);
$table->data[10][0] = __('Critical instructions'). ui_print_help_tip(__("Instructions when the status is critical"), true); $table->data[10][0] = __('Critical instructions'). ui_print_help_tip(__("Instructions when the status is critical"), true);
$table->data[10][1] = html_print_textarea ('critical_instructions', 2, 65, $critical_instructions, '', true); $table->data[10][1] = html_print_textarea ('critical_instructions', 2, 65, $critical_instructions, '', true);

View File

@ -100,6 +100,8 @@ $filter_event_no_validated = false;
$filter_event_critical = false; $filter_event_critical = false;
$filter_event_warning = false; $filter_event_warning = false;
$filter_event_type = false;
$event_graph_by_agent = false; $event_graph_by_agent = false;
$event_graph_by_user_validator = false; $event_graph_by_user_validator = false;
$event_graph_by_criticity = false; $event_graph_by_criticity = false;
@ -425,6 +427,7 @@ switch ($action) {
$filter_event_validated = $style['filter_event_validated']; $filter_event_validated = $style['filter_event_validated'];
$filter_event_critical = $style['filter_event_critical']; $filter_event_critical = $style['filter_event_critical'];
$filter_event_warning = $style['filter_event_warning']; $filter_event_warning = $style['filter_event_warning'];
$filter_event_type = json_decode($style['filter_event_type'], true);
$event_graph_by_agent = $style['event_graph_by_agent']; $event_graph_by_agent = $style['event_graph_by_agent'];
$event_graph_by_user_validator = $style['event_graph_by_user_validator']; $event_graph_by_user_validator = $style['event_graph_by_user_validator'];
@ -441,6 +444,7 @@ switch ($action) {
$filter_event_validated = $style['filter_event_validated']; $filter_event_validated = $style['filter_event_validated'];
$filter_event_critical = $style['filter_event_critical']; $filter_event_critical = $style['filter_event_critical'];
$filter_event_warning = $style['filter_event_warning']; $filter_event_warning = $style['filter_event_warning'];
$filter_event_type = json_decode($style['filter_event_type'], true);
$event_graph_by_agent = $style['event_graph_by_agent']; $event_graph_by_agent = $style['event_graph_by_agent'];
$event_graph_by_user_validator = $style['event_graph_by_user_validator']; $event_graph_by_user_validator = $style['event_graph_by_user_validator'];
@ -1357,6 +1361,20 @@ You can of course remove the warnings, that's why we include the source and do n
</td> </td>
</tr> </tr>
<tr id="row_event_type" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Event type'); ?></td>
<td>
<?php
$event_types_select = get_event_types();
html_debug($filter_event_type);
html_print_select ($event_types_select, 'filter_event_type[]',
$filter_event_type, '', __('All'), 'all', false, true,
false, '', false, false, false, false, false, '');
?>
</td>
</tr>
<tr id="row_event_graphs" style="" class="datos"> <tr id="row_event_graphs" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Event graphs'); ?></td> <td style="font-weight:bold;"><?php echo __('Event graphs'); ?></td>
<td> <td>
@ -1956,6 +1974,7 @@ $(document).ready (function () {
}); });
}); });
}); });
function create_custom_graph() { function create_custom_graph() {
@ -2454,6 +2473,7 @@ function chooseType() {
$("#row_percentil").hide(); $("#row_percentil").hide();
$("#agents_row").hide(); $("#agents_row").hide();
$("#modules_row").hide(); $("#modules_row").hide();
$("#row_event_type").hide();
// SLA list default state // SLA list default state
$("#sla_list").hide(); $("#sla_list").hide();
@ -2482,6 +2502,7 @@ function chooseType() {
$("#row_event_graph_by_user").show(); $("#row_event_graph_by_user").show();
$("#row_event_graph_by_criticity").show(); $("#row_event_graph_by_criticity").show();
$("#row_event_graph_by_validated").show(); $("#row_event_graph_by_validated").show();
$("#row_event_type").show();
$("#row_filter_search").show(); $("#row_filter_search").show();
break; break;
@ -2751,6 +2772,7 @@ function chooseType() {
$("#row_event_graph_by_user").show(); $("#row_event_graph_by_user").show();
$("#row_event_graph_by_criticity").show(); $("#row_event_graph_by_criticity").show();
$("#row_event_graph_by_validated").show(); $("#row_event_graph_by_validated").show();
$("#row_event_type").show();
$('#agent_autocomplete').hide(); $('#agent_autocomplete').hide();
$('#agent_autocomplete_events').show(); $('#agent_autocomplete_events').show();

View File

@ -1065,6 +1065,7 @@ switch ($action) {
$filter_event_no_validated = get_parameter('filter_event_no_validated', 0); $filter_event_no_validated = get_parameter('filter_event_no_validated', 0);
$filter_event_critical = get_parameter('filter_event_critical', 0); $filter_event_critical = get_parameter('filter_event_critical', 0);
$filter_event_warning = get_parameter('filter_event_warning', 0); $filter_event_warning = get_parameter('filter_event_warning', 0);
$filter_event_type = get_parameter('filter_event_type', '');
$event_graph_by_agent = get_parameter('event_graph_by_agent', 0); $event_graph_by_agent = get_parameter('event_graph_by_agent', 0);
$event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0);
@ -1135,7 +1136,7 @@ switch ($action) {
$style['filter_event_validated'] = $filter_event_validated; $style['filter_event_validated'] = $filter_event_validated;
$style['filter_event_critical'] = $filter_event_critical; $style['filter_event_critical'] = $filter_event_critical;
$style['filter_event_warning'] = $filter_event_warning; $style['filter_event_warning'] = $filter_event_warning;
$style['filter_event_type'] = json_encode($filter_event_type);
$style['event_graph_by_agent'] = $event_graph_by_agent; $style['event_graph_by_agent'] = $event_graph_by_agent;
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_by_criticity'] = $event_graph_by_criticity;
@ -1450,6 +1451,7 @@ switch ($action) {
$event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0);
$event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0); $event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0);
$event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0); $event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0);
$filter_event_type = get_parameter('filter_event_type', '');
$event_filter_search = get_parameter('filter_search', ''); $event_filter_search = get_parameter('filter_search', '');
@ -1458,6 +1460,7 @@ switch ($action) {
$style['filter_event_validated'] = $filter_event_validated; $style['filter_event_validated'] = $filter_event_validated;
$style['filter_event_critical'] = $filter_event_critical; $style['filter_event_critical'] = $filter_event_critical;
$style['filter_event_warning'] = $filter_event_warning; $style['filter_event_warning'] = $filter_event_warning;
$style['filter_event_type'] = json_encode($filter_event_type);
$style['event_graph_by_agent'] = $event_graph_by_agent; $style['event_graph_by_agent'] = $event_graph_by_agent;
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_user_validator'] = $event_graph_by_user_validator;

View File

@ -76,6 +76,11 @@ $table->data[9][1] = html_print_input_text ('days_autodisable_deletion', $config
$table->data[10][0] = __('Retention period of past special days') . ui_print_help_tip(__('This number is days to keep past special days. 0 means never remove.'), true); $table->data[10][0] = __('Retention period of past special days') . ui_print_help_tip(__('This number is days to keep past special days. 0 means never remove.'), true);
$table->data[10][1] = html_print_input_text ('num_past_special_days', $config["num_past_special_days"], '', 5, 5, true); $table->data[10][1] = html_print_input_text ('num_past_special_days', $config["num_past_special_days"], '', 5, 5, true);
if (enterprise_installed ()) {
$table->data[11][0] = __('Max. days before delete inventory data');
$table->data[11][1] = html_print_input_text ('inventory_purge', $config["inventory_purge"], '', 5, 5, true);
}
$table_other = new stdClass(); $table_other = new stdClass();
$table_other->width = '100%'; $table_other->width = '100%';
$table_other->class = 'databox filters'; $table_other->class = 'databox filters';

View File

@ -447,6 +447,15 @@ $table_chars->data[$row][1] .= __('Line').'&nbsp;' .
$config["type_module_charts"] != 'area', true); $config["type_module_charts"] != 'area', true);
$row++; $row++;
$table_chars->data[$row][0] = __('Type of interface charts');
$table_chars->data[$row][1] = __('Area').'&nbsp;' .
html_print_radio_button ('type_interface_charts', 'area', '',
$config["type_interface_charts"] == 'area', true).'&nbsp;&nbsp;';
$table_chars->data[$row][1] .= __('Line').'&nbsp;' .
html_print_radio_button ('type_interface_charts', 'line', '',
$config["type_interface_charts"] != 'area', true);
$row++;
$table_chars->data[$row][0] = __('Show only average'); $table_chars->data[$row][0] = __('Show only average');
$table_chars->data[$row][0] .= ui_print_help_tip(__('Allows only show the average in graphs'), true); $table_chars->data[$row][0] .= ui_print_help_tip(__('Allows only show the average in graphs'), true);
$table_chars->data[$row][1] = __('Yes').'&nbsp;' . $table_chars->data[$row][1] = __('Yes').'&nbsp;' .

View File

@ -273,7 +273,7 @@ $table->head[2] = __('Last contact') . ' ' .
'<a href="?sec='.$sec.'&sec2=godmode/users/user_list&sort_field=last_connect&sort=up&pure='.$pure.'">' . html_print_image("images/sort_up.png", true, array("style" => $selectLastConnectUp )) . '</a>' . '<a href="?sec='.$sec.'&sec2=godmode/users/user_list&sort_field=last_connect&sort=up&pure='.$pure.'">' . html_print_image("images/sort_up.png", true, array("style" => $selectLastConnectUp )) . '</a>' .
'<a href="?sec='.$sec.'&sec2=godmode/users/user_list&sort_field=last_connect&sort=down&pure='.$pure.'">' . html_print_image("images/sort_down.png", true, array("style" => $selectLastConnectDown)) . '</a>'; '<a href="?sec='.$sec.'&sec2=godmode/users/user_list&sort_field=last_connect&sort=down&pure='.$pure.'">' . html_print_image("images/sort_down.png", true, array("style" => $selectLastConnectDown)) . '</a>';
$table->head[3] = __('Admin'); $table->head[3] = __('Admin');
$table->head[4] = __('Profile'); $table->head[4] = __('Profile / Group');
$table->head[5] = __('Description'); $table->head[5] = __('Description');
$table->head[6] = '<span title="Operations">' . __('Op.') . '</span>'; $table->head[6] = '<span title="Operations">' . __('Op.') . '</span>';
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
@ -445,8 +445,7 @@ foreach ($info as $user_id => $user_info) {
$data[4] .= "<tr>"; $data[4] .= "<tr>";
$data[4] .= "<td>"; $data[4] .= "<td>";
$data[4] .= profile_get_name ($row["id_perfil"]); $data[4] .= profile_get_name ($row["id_perfil"]);
$data[4] .= "</td>"; $data[4] .= " / ";
$data[4] .= "<td align='right'>";
$data[4] .= groups_get_name ($row["id_grupo"], true); $data[4] .= groups_get_name ($row["id_grupo"], true);
$data[4] .= "</td>"; $data[4] .= "</td>";
$data[4] .= "</tr>"; $data[4] .= "</tr>";

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1022 B

After

Width:  |  Height:  |  Size: 240 B

View File

@ -22,7 +22,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC161130'; $build_version = 'PC161214';
$pandora_version = 'v7.0dev'; $pandora_version = 'v7.0dev';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -28,8 +28,12 @@ function mysql_connect_db($host = null, $db = null, $user = null, $pass = null,
if ($port === null) if ($port === null)
$port = $config["dbport"]; $port = $config["dbport"];
if ($config["mysqli"] === null && extension_loaded(mysqli)) if ($config["mysqli"] === null && extension_loaded(mysqli)) {
$config["mysqli"] = true; $config["mysqli"] = true;
}
else {
$config["mysqli"] = false;
}
// Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems // Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems
// If you want persistent connections change it to mysql_pconnect(). // If you want persistent connections change it to mysql_pconnect().

View File

@ -2293,6 +2293,11 @@ function print_audit_csv ($data) {
global $config; global $config;
global $graphic_type; global $graphic_type;
if (!$data) {
echo __('No data found to export');
return 0;
}
$config['ignore_callback'] = true; $config['ignore_callback'] = true;
while (@ob_end_clean ()); while (@ob_end_clean ());
@ -2301,7 +2306,9 @@ function print_audit_csv ($data) {
header("Pragma: no-cache"); header("Pragma: no-cache");
header("Expires: 0"); header("Expires: 0");
if ($data) { // BOM
print pack('C*',0xEF,0xBB,0xBF);
echo __('User') . ';' . echo __('User') . ';' .
__('Action') . ';' . __('Action') . ';' .
__('Date') . ';' . __('Date') . ';' .
@ -2310,10 +2317,8 @@ function print_audit_csv ($data) {
foreach ($data as $line) { foreach ($data as $line) {
echo io_safe_output($line['id_usuario']) . ';' . io_safe_output($line['accion']) . ';' . $line['fecha'] . ';' . $line['ip_origen'] . ';'. io_safe_output($line['descripcion']). "\n"; echo io_safe_output($line['id_usuario']) . ';' . io_safe_output($line['accion']) . ';' . $line['fecha'] . ';' . $line['ip_origen'] . ';'. io_safe_output($line['descripcion']). "\n";
} }
}
else { exit;
echo __('No data found to export');
}
} }
/** /**
@ -2664,7 +2669,13 @@ function pandora_setlocale() {
} }
function remove_right_zeros ($value) { function remove_right_zeros ($value) {
$is_decimal = explode(".", $value);
if (isset($is_decimal[1])) {
$value_to_return = rtrim($value, "0"); $value_to_return = rtrim($value, "0");
return rtrim($value_to_return, "."); return rtrim($value_to_return, ".");
}
else {
return $value;
}
} }
?> ?>

View File

@ -132,7 +132,7 @@ function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $s
* *
* @return mixed Return id if the group have any alert is fired or false is not. * @return mixed Return id if the group have any alert is fired or false is not.
*/ */
function alerts_get_event_status_group($idGroup, $type = "alert_fired", $query = 'AND 1=1') { function alerts_get_event_status_group($idGroup, $type = "alert_fired", $query = 'AND 1=1', $agents = null) {
global $config; global $config;
$return = false; $return = false;
@ -151,9 +151,14 @@ function alerts_get_event_status_group($idGroup, $type = "alert_fired", $query =
$typeWhere = ' AND event_type IN (' . implode(',', $temp) . ')'; $typeWhere = ' AND event_type IN (' . implode(',', $temp) . ')';
} }
if ($agents == null) {
$agents = agents_get_group_agents($idGroup, false, "lower", false); $agents = agents_get_group_agents($idGroup, false, "lower", false);
$idAgents = array_keys($agents); $idAgents = array_keys($agents);
}
else {
$idAgents = array_values($agents);
}
$result = db_get_all_rows_sql('SELECT id_evento $result = db_get_all_rows_sql('SELECT id_evento
FROM tevento FROM tevento

View File

@ -1483,6 +1483,308 @@ function api_get_agent_modules($thrash1, $thrash2, $other, $thrash3) {
} }
} }
function api_get_db_uncompress_module_data ($id_agente_modulo,$tstart,$other){
global $config;
if (!isset($id_agente_modulo)) {
return false;
}
if ((!isset($tstart)) || ($tstart === false)) {
// Return data from the begining
//$tstart = 0;
$tstart = 0;
}
$tend = $other['data'];
if ((!isset($tend)) || ($tend === false)) {
// Return data until now
$tend = time();
}
if ($tstart > $tend) {
return false;
}
$search_historydb = false;
$table = "tagente_datos";
$module = modules_get_agentmodule($id_agente_modulo);
if ($module === false){
// module not exists
return false;
}
$module_type = $module['id_tipo_modulo'];
$module_type_str = modules_get_type_name ($module_type);
if (strstr ($module_type_str, 'string') !== false) {
$table = "tagente_datos_string";
}
// Get first available utimestamp in active DB
$query = " SELECT utimestamp, datos FROM $table ";
$query .= " WHERE id_agente_modulo=$id_agente_modulo AND utimestamp < $tstart";
$query .= " ORDER BY utimestamp DESC LIMIT 1";
$ret = db_get_all_rows_sql( $query , $search_historydb);
if ( ( $ret === false ) || (( isset($ret[0]["utimestamp"]) && ($ret[0]["utimestamp"] > $tstart )))) {
// Value older than first retrieved from active DB
$search_historydb = true;
$ret = db_get_all_rows_sql( $query , $search_historydb);
}
else {
$first_data["utimestamp"] = $ret[0]["utimestamp"];
$first_data["datos"] = $ret[0]["datos"];
}
if ( ( $ret === false ) || (( isset($ret[0]["utimestamp"]) && ($ret[0]["utimestamp"] > $tstart )))) {
// No previous data. -> not init
// Avoid false unknown status
$first_data["utimestamp"] = time();
$first_data["datos"] = false;
}
else {
$first_data["utimestamp"] = $ret[0]["utimestamp"];
$first_data["datos"] = $ret[0]["datos"];
}
$query = " SELECT utimestamp, datos FROM $table ";
$query .= " WHERE id_agente_modulo=$id_agente_modulo AND utimestamp >= $tstart AND utimestamp <= $tend";
$query .= " ORDER BY utimestamp ASC";
// Retrieve all data from module in given range
$raw_data = db_get_all_rows_sql($query, $search_historydb);
if (($raw_data === false) && ($ret === false)) {
// No data
return false;
}
// Retrieve going unknown events in range
$unknown_events = db_get_module_ranges_unknown($id_agente_modulo, $tstart, $tend);
// Retrieve module_interval to build the template
$module_interval = modules_get_interval ($id_agente_modulo);
$slice_size = $module_interval;
// We'll return a bidimensional array
// Structure returned: schema:
//
// uncompressed_data =>
// pool_id (int)
// utimestamp (start of current slice)
// data
// array
// utimestamp
// datos
$return = array();
// Point current_timestamp to begin of the set and initialize flags
$current_timestamp = $tstart;
$last_inserted_value = $first_data["datos"];
$last_timestamp = $first_data["utimestamp"];
$data_found = 0;
// Build template
$pool_id = 0;
$now = time();
$in_unknown_status = 0;
if (is_array($unknown_events)) {
$current_unknown = array_shift($unknown_events);
}
while ( $current_timestamp < $tend ) {
$expected_data_generated = 0;
$return[$pool_id]["data"] = array();
$tmp_data = array();
$data_found = 0;
if (is_array($unknown_events)) {
$i = 0;
while ($current_timestamp >= $unknown_events[$i]["time_to"] ) {
// Skip unknown events in past
array_splice($unknown_events, $i,1);
$i++;
if (!isset($unknown_events[$i])) {
break;
}
}
if (isset($current_unknown)) {
// check if recovered from unknown status
if(is_array($unknown_events) && isset($current_unknown)) {
if ( (($current_timestamp+$slice_size) > $current_unknown["time_to"])
&& ($current_timestamp < $current_unknown["time_to"])
&& ($in_unknown_status == 1) ) {
// Recovered from unknown
if ( ($current_unknown["time_to"] > $current_timestamp)
&& ($expected_data_generated == 0) ) {
// also add the "expected" data
$tmp_data["utimestamp"] = $current_timestamp;
if ($in_unknown_status == 1) {
$tmp_data["datos"] = null;
}
else {
$tmp_data["datos"] = $last_inserted_value;
}
$return[$pool_id]["utimestamp"] = $current_timestamp;
array_push($return[$pool_id]["data"], $tmp_data);
$expected_data_generated = 1;
}
$tmp_data["utimestamp"] = $current_unknown["time_to"];
$tmp_data["datos"] = $last_inserted_value;
// debug purpose
$tmp_data["obs"] = "event recovery data";
$return[$pool_id]["utimestamp"] = $current_timestamp;
array_push($return[$pool_id]["data"], $tmp_data);
$data_found = 1;
$in_unknown_status = 0;
}
if ( (($current_timestamp+$slice_size) > $current_unknown["time_from"])
&& (($current_timestamp+$slice_size) < $current_unknown["time_to"])
&& ($in_unknown_status == 0) ) {
// Add unknown state detected
if ( $current_unknown["time_from"] < ($current_timestamp+$slice_size)) {
if ( ($current_unknown["time_from"] > $current_timestamp)
&& ($expected_data_generated == 0) ) {
// also add the "expected" data
$tmp_data["utimestamp"] = $current_timestamp;
if ($in_unknown_status == 1) {
$tmp_data["datos"] = null;
}
else {
$tmp_data["datos"] = $last_inserted_value;
}
$return[$pool_id]["utimestamp"] = $current_timestamp;
array_push($return[$pool_id]["data"], $tmp_data);
$expected_data_generated = 1;
}
$tmp_data["utimestamp"] = $current_unknown["time_from"];
$tmp_data["datos"] = null;
// debug purpose
$tmp_data["obs"] = "event data";
$return[$pool_id]["utimestamp"] = $current_timestamp;
array_push($return[$pool_id]["data"], $tmp_data);
$data_found = 1;
}
$in_unknown_status = 1;
}
if ( ($in_unknown_status == 0) && ($current_timestamp >= $current_unknown["time_to"]) ) {
$current_unknown = array_shift($unknown_events);
}
}
} // unknown events handle
}
// Search for data
$i=0;
if (is_array($raw_data)) {
foreach ($raw_data as $data) {
if ( ($data["utimestamp"] >= $current_timestamp)
&& ($data["utimestamp"] < ($current_timestamp+$slice_size)) ) {
// Data in block, push in, and remove from $raw_data (processed)
if ( ($data["utimestamp"] > $current_timestamp)
&& ($expected_data_generated == 0) ) {
// also add the "expected" data
$tmp_data["utimestamp"] = $current_timestamp;
if ($in_unknown_status == 1) {
$tmp_data["datos"] = null;
}
else {
$tmp_data["datos"] = $last_inserted_value;
}
$tmp_data["obs"] = "expected data";
$return[$pool_id]["utimestamp"] = $current_timestamp;
array_push($return[$pool_id]["data"], $tmp_data);
$expected_data_generated = 1;
}
$tmp_data["utimestamp"] = intval($data["utimestamp"]);
$tmp_data["datos"] = $data["datos"];
// debug purpose
$tmp_data["obs"] = "real data";
$return[$pool_id]["utimestamp"] = $current_timestamp;
array_push($return[$pool_id]["data"], $tmp_data);
$last_inserted_value = $data["datos"];
$last_timestamp = intval($data["utimestamp"]);
unset($raw_data[$i]);
$data_found = 1;
$in_unknown_status = 0;
}
elseif ($data["utimestamp"] > ($current_timestamp+$slice_size)) {
// Data in future, stop searching new ones
break;
}
}
$i++;
}
if ($data_found == 0) {
// No data found, lug the last_value until SECONDS_1DAY + 2*modules_get_interval
// UNKNOWN!
if (($current_timestamp > $now) || (($current_timestamp - $last_timestamp) > (SECONDS_1DAY + 2*$module_interval))) {
if (isset($last_inserted_value)) {
// unhandled unknown status control
$unhandled_time_unknown = $current_timestamp - (SECONDS_1DAY + 2*$module_interval) - $last_timestamp;
if ($unhandled_time_unknown > 0) {
// unhandled unknown status detected. Add to previous pool
$tmp_data["utimestamp"] = intval($last_timestamp) + (SECONDS_1DAY + 2*$module_interval);
$tmp_data["datos"] = null;
// debug purpose
$tmp_data["obs"] = "unknown extra";
// add to previous pool if needed
if (isset($return[$pool_id-1])) {
array_push($return[$pool_id-1]["data"], $tmp_data);
}
}
}
$last_inserted_value = null;
}
$tmp_data["utimestamp"] = $current_timestamp;
if ($in_unknown_status == 1) {
$tmp_data["datos"] = null;
}
else {
$tmp_data["datos"] = $last_inserted_value;
}
// debug purpose
$tmp_data["obs"] = "virtual data";
$return[$pool_id]["utimestamp"] = $current_timestamp;
array_push($return[$pool_id]["data"], $tmp_data);
}
$pool_id++;
$current_timestamp += $slice_size;
}
$data = array('type' => 'array', 'data' => $return);
returnData('json', $return, ';');
}
/** /**
* Get modules id for an agent, and print the result like a csv. * Get modules id for an agent, and print the result like a csv.

View File

@ -407,6 +407,10 @@ function config_update_config () {
$error_update[] = __('Small Operation Step to purge old data'); $error_update[] = __('Small Operation Step to purge old data');
if (!config_update_value ('num_past_special_days', get_parameter ('num_past_special_days'))) if (!config_update_value ('num_past_special_days', get_parameter ('num_past_special_days')))
$error_update[] = __('Retention period of past special days'); $error_update[] = __('Retention period of past special days');
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
if (!config_update_value ('inventory_purge', get_parameter ('inventory_purge')))
$error_update[] = __('Max. days before delete inventory data');
}
///////////// /////////////
break; break;
@ -514,6 +518,8 @@ function config_update_config () {
$error_update[] = __('Default line thickness for the Custom Graph.'); $error_update[] = __('Default line thickness for the Custom Graph.');
if (!config_update_value ('type_module_charts', (string) get_parameter('type_module_charts', 'area'))) if (!config_update_value ('type_module_charts', (string) get_parameter('type_module_charts', 'area')))
$error_update[] = __('Default type of module charts.'); $error_update[] = __('Default type of module charts.');
if (!config_update_value ('type_interface_charts', (string) get_parameter('type_interface_charts', 'line')))
$error_update[] = __('Default type of interface charts.');
if (!config_update_value ('only_average', (bool) get_parameter('only_average', false))) if (!config_update_value ('only_average', (bool) get_parameter('only_average', false)))
$error_update[] = __('Default show only average or min and max'); $error_update[] = __('Default show only average or min and max');
if (!config_update_value ('render_proc', (bool) get_parameter('render_proc', false))) if (!config_update_value ('render_proc', (bool) get_parameter('render_proc', false)))
@ -853,6 +859,12 @@ function config_process_config () {
config_update_value ('num_past_special_days', 0); config_update_value ('num_past_special_days', 0);
} }
if (isset($config['enterprise_installed'])) {
if (!isset($config['inventory_purge'])) {
config_update_value ('inventory_purge', 21);
}
}
if (!isset ($config["event_purge"])) { if (!isset ($config["event_purge"])) {
config_update_value ('event_purge', 15); config_update_value ('event_purge', 15);
} }
@ -1516,6 +1528,10 @@ function config_process_config () {
config_update_value ('type_module_charts', 'area'); config_update_value ('type_module_charts', 'area');
} }
if (!isset($config['type_interface_charts'])) {
config_update_value ('type_interface_charts', 'line');
}
if (!isset($config['render_proc'])) { if (!isset($config['render_proc'])) {
config_update_value ('render_proc', 0); config_update_value ('render_proc', 0);
} }

View File

@ -168,12 +168,22 @@ function custom_graphs_print($id_graph, $height, $width, $period,
global $config; global $config;
if ($from_interface) {
if ($config["type_interface_charts"] == 'line') {
$graph_conf['stacked'] = CUSTOM_GRAPH_LINE;
}
else {
$graph_conf['stacked'] = CUSTOM_GRAPH_AREA;
}
}
else {
if ($id_graph == 0) { if ($id_graph == 0) {
$graph_conf['stacked'] = CUSTOM_GRAPH_LINE; $graph_conf['stacked'] = CUSTOM_GRAPH_LINE;
} }
else { else {
$graph_conf = db_get_row('tgraph', 'id_graph', $id_graph); $graph_conf = db_get_row('tgraph', 'id_graph', $id_graph);
} }
}
if ($stacked === null) { if ($stacked === null) {
$stacked = $graph_conf['stacked']; $stacked = $graph_conf['stacked'];

View File

@ -1187,7 +1187,8 @@ function events_print_type_description ($type, $return = false) {
function events_get_group_events ($id_group, $period, $date, function events_get_group_events ($id_group, $period, $date,
$filter_event_validated = false, $filter_event_critical = false, $filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false, $filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false, $meta = false, $history = false) { $filter_event_search = false, $meta = false, $history = false,
$filter_event_type = false) {
global $config; global $config;
@ -1223,6 +1224,28 @@ function events_get_group_events ($id_group, $period, $date,
' OR id_evento LIKE "%' . io_safe_input($filter_event_search) . '%")'; ' OR id_evento LIKE "%' . io_safe_input($filter_event_search) . '%")';
} }
if (!empty($filter_event_type)) {
$sql_where .= ' AND (';
$type = array();
foreach ($filter_event_type as $event_type) {
if ($event_type != "") {
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
$type[] = " event_type LIKE '%$event_type%' ";
}
else if ($event_type == "not_normal") {
$type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
}
else if ($event_type != "all") {
$type[] = " event_type = '" . $event_type."'";
}
}
}
$sql_where .= implode(' OR ', $type) . ')';
}
$sql_where .= sprintf(' $sql_where .= sprintf('
AND id_grupo IN (%s) AND id_grupo IN (%s)
AND utimestamp > %d AND utimestamp > %d
@ -1308,7 +1331,7 @@ function events_get_group_events_steps ($begin, &$result, $id_group, $period, $d
function events_get_agent ($id_agent, $period, $date = 0, function events_get_agent ($id_agent, $period, $date = 0,
$filter_event_validated = false, $filter_event_critical = false, $filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false, $filter_event_warning = false, $filter_event_no_validated = false,
$history = false) { $history = false, $filter_event_type = false) {
if (!is_numeric ($date)) { if (!is_numeric ($date)) {
$date = strtotime ($date); $date = strtotime ($date);
@ -1345,6 +1368,28 @@ function events_get_agent ($id_agent, $period, $date = 0,
} }
} }
if (!empty($filter_event_type)) {
$sql_where .= ' AND (';
$type = array();
foreach ($filter_event_type as $event_type) {
if ($event_type != "") {
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") {
$type[] = " event_type LIKE '%$event_type%' ";
}
else if ($event_type == "not_normal") {
$type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
}
else if ($event_type != "all") {
$type[] = " event_type = '" . $event_type."'";
}
}
}
$sql_where .= implode(' OR ', $type) . ')';
}
$sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d $sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d
AND utimestamp <= %d ', $id_agent, $datelimit, $date); AND utimestamp <= %d ', $id_agent, $datelimit, $date);

View File

@ -1877,7 +1877,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$height, $color, $module_name_list, $long_index, $height, $color, $module_name_list, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false), ui_get_full_url("images/image_problem.opaque.png", false, false, false),
$title, "", $homeurl, $water_mark, $config['fontpath'], $title, "", $homeurl, $water_mark, $config['fontpath'],
$fixed_font_size, $unit, $ttl, array(), array(), 0, 0, '', $fixed_font_size, $unit, $ttl, array(), array(), $yellow_threshold, $red_threshold, '',
false, '', true, $background_color,$dashboard, $vconsole); false, '', true, $background_color,$dashboard, $vconsole);
break; break;
default: default:

View File

@ -53,7 +53,7 @@ function modules_is_disable_type_event($id_agent_module = false, $type_event = f
if ($id_agent_module === false) { if ($id_agent_module === false) {
switch ($type_event) { switch ($type_event) {
case EVENTS_GOING_UNKNOWN: case EVENTS_GOING_UNKNOWN:
return true; return false;
break; break;
case EVENTS_UNKNOWN: case EVENTS_UNKNOWN:
return false; return false;
@ -118,7 +118,7 @@ function modules_is_disable_type_event($id_agent_module = false, $type_event = f
return false; return false;
} }
} }
return true; return false;
} }
/** /**

View File

@ -1262,24 +1262,26 @@ function reporting_event_report_group($report, $content,
$return["description"] = $content["description"]; $return["description"] = $content["description"];
$return["date"] = reporting_get_date_text($report, $content); $return["date"] = reporting_get_date_text($report, $content);
$event_filter = $content['style'];
$filter_event_no_validated = $content['style']['filter_event_no_validated']; $filter_event_no_validated = $event_filter['filter_event_no_validated'];
$filter_event_validated = $content['style']['filter_event_validated']; $filter_event_validated = $event_filter['filter_event_validated'];
$filter_event_critical = $content['style']['filter_event_critical']; $filter_event_critical = $event_filter['filter_event_critical'];
$filter_event_warning = $content['style']['filter_event_warning']; $filter_event_warning = $event_filter['filter_event_warning'];
$filter_event_filter_search = $content['style']['event_filter_search']; $filter_event_filter_search = $event_filter['event_filter_search'];
$filter_event_type = json_decode($event_filter['filter_event_type'],true);
$event_graph_by_agent = $content['style']['event_graph_by_agent']; $event_graph_by_agent = $event_filter['event_graph_by_agent'];
$event_graph_by_user_validator = $content['style']['event_graph_by_user_validator']; $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator'];
$event_graph_by_criticity = $content['style']['event_graph_by_criticity']; $event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $content['style']['event_graph_validated_vs_unvalidated']; $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated'];
$data = reporting_get_group_detailed_event( $data = reporting_get_group_detailed_event(
$content['id_group'], $content['period'], $report["datetime"], $content['id_group'], $content['period'], $report["datetime"],
true, true, $filter_event_validated, $filter_event_critical, true, true, $filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated, $filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search, 'hash', $history); $filter_event_filter_search, 'hash', $history, $filter_event_type);
if (empty($data)) { if (empty($data)) {
$return['failed'] = __('No events'); $return['failed'] = __('No events');
@ -1410,6 +1412,8 @@ function reporting_event_report_group($report, $content,
metaconsole_restore_db(); metaconsole_restore_db();
} }
$return['total_events'] = count($return['data']);
return reporting_check_structure_content($return); return reporting_check_structure_content($return);
} }
@ -1454,6 +1458,8 @@ function reporting_event_report_module($report, $content) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
$return['total_events'] = count($return['data']);
return reporting_check_structure_content($return); return reporting_check_structure_content($return);
} }
@ -2158,6 +2164,7 @@ function reporting_event_report_agent($report, $content,
$filter_event_validated = $style['filter_event_validated']; $filter_event_validated = $style['filter_event_validated'];
$filter_event_critical = $style['filter_event_critical']; $filter_event_critical = $style['filter_event_critical'];
$filter_event_warning = $style['filter_event_warning']; $filter_event_warning = $style['filter_event_warning'];
$filter_event_type = json_decode($style['filter_event_type'], true);
$event_graph_by_user_validator = $style['event_graph_by_user_validator']; $event_graph_by_user_validator = $style['event_graph_by_user_validator'];
$event_graph_by_criticity = $style['event_graph_by_criticity']; $event_graph_by_criticity = $style['event_graph_by_criticity'];
@ -2173,7 +2180,8 @@ function reporting_event_report_agent($report, $content,
$filter_event_warning, $filter_event_warning,
$filter_event_no_validated, $filter_event_no_validated,
true, true,
$history); $history,
$filter_event_type);
@ -2270,6 +2278,8 @@ function reporting_event_report_agent($report, $content,
metaconsole_restore_db(); metaconsole_restore_db();
} }
$return['total_events'] = count($return['data']);
return reporting_check_structure_content($return); return reporting_check_structure_content($return);
} }
@ -6042,7 +6052,8 @@ function reporting_get_group_detailed_event ($id_group, $period = 0,
$date = 0, $return = false, $html = true, $date = 0, $return = false, $html = true,
$filter_event_validated = false, $filter_event_critical = false, $filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false, $filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null, $return_type = false, $history = false) { $filter_event_filter_search = null, $return_type = false,
$history = false, $filter_event_type = false) {
global $config; global $config;
@ -6074,7 +6085,7 @@ function reporting_get_group_detailed_event ($id_group, $period = 0,
$events = events_get_group_events($id_group, $period, $date, $events = events_get_group_events($id_group, $period, $date,
$filter_event_validated, $filter_event_critical, $filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated, $filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search, false, $history); $filter_event_filter_search, false, $history, $filter_event_type);
if ($return_type === 'hash') { if ($return_type === 'hash') {
return $events; return $events;
@ -6270,7 +6281,8 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
function reporting_get_agents_detailed_event ($id_agents, $period = 0, function reporting_get_agents_detailed_event ($id_agents, $period = 0,
$date = 0, $return = false, $filter_event_validated = false, $date = 0, $return = false, $filter_event_validated = false,
$filter_event_critical = false, $filter_event_warning = false, $filter_event_critical = false, $filter_event_warning = false,
$filter_event_no_validated = false, $only_data = false, $history = false) { $filter_event_no_validated = false, $only_data = false,
$history = false, $filter_event_type = false) {
global $config; global $config;
@ -6297,7 +6309,7 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0,
(int)$date, (int)$date,
$filter_event_validated, $filter_event_critical, $filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated, $filter_event_warning, $filter_event_no_validated,
$history); $history, $filter_event_type);
if (empty($event)) { if (empty($event)) {
$event = array(); $event = array();

View File

@ -129,10 +129,8 @@ function reporting_html_print_report($report, $mini = false) {
$item['date']['to'], $item['date']['to'],
$label); $label);
if ($item["description"] != "") { $table->data['description_row']['description'] = $item["description"]." - Total events: ".$item["total_events"];
$table->data['description_row']['description'] = $item["description"];
$table->colspan['description_row']['description'] = 3; $table->colspan['description_row']['description'] = 3;
}
switch ($item['type']) { switch ($item['type']) {
case 'availability': case 'availability':

View File

@ -247,6 +247,42 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head =
$last_data_str .= "&nbsp;"; $last_data_str .= "&nbsp;";
$last_data_str .= html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px')); $last_data_str .= html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px'));
$is_snapshot = is_snapshot_data ( $last_data["datos"] );
if (($config['command_snapshot']) && ($is_snapshot)) {
$handle = 'snapshot_' . $module['id_agente_modulo'];
$url = 'include/procesos.php?agente=' . $row['id_agente_modulo'];
$win_handle = dechex(crc32($handle));
if (! defined ('METACONSOLE')) {
$link = "winopeng_var('operation/agentes/snapshot_view.php?" .
"id=" . $module['id_agente_modulo'] .
"&refr=" . $module['current_interval'] .
"&label=" . rawurlencode(urlencode(io_safe_output($module['module_name']))) . "','" . $win_handle . "', 700,480)";
}
else{
$link = "winopeng_var('$last_data[datos]','',700,480)";
}
if(!is_image_data($last_data["datos"])){
$salida = '<a href="javascript:' . $link . '">' .
html_print_image('images/default_list.png', true,
array('border' => '0',
'alt' => '',
'title' => __('Snapshot view'))) . '</a> &nbsp;&nbsp;';
}
else {
$salida = '<a href="javascript:' . $link . '">' .
html_print_image('images/photo.png', true,
array('border' => '0',
'alt' => '',
'title' => __('Snapshot view'))) . '</a> &nbsp;&nbsp;';
}
}
$last_data_str .= $salida;
} }
else { else {
$last_data_str = '<i>' . __('No data') . '</i>'; $last_data_str = '<i>' . __('No data') . '</i>';
@ -370,7 +406,7 @@ function treeview_printAlertsTable($id_module, $server_data = array(), $no_head
$row['times_fired'] = __('Times fired'); $row['times_fired'] = __('Times fired');
$row['last_fired'] = __('Last fired'); $row['last_fired'] = __('Last fired');
$table2->data['titles'] = $row; $table2->data['titles'] = $row;
html_debug($module_alerts, true);
foreach ($module_alerts as $module_alert) { foreach ($module_alerts as $module_alert) {
$template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']); $template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']);

BIN
pandora_console/include/languages/en.mo Normal file → Executable file

Binary file not shown.

57888
pandora_console/include/languages/en.po Normal file → Executable file

File diff suppressed because it is too large Load Diff

BIN
pandora_console/include/languages/en_GB.mo Normal file → Executable file

Binary file not shown.

62023
pandora_console/include/languages/en_GB.po Normal file → Executable file

File diff suppressed because it is too large Load Diff

BIN
pandora_console/include/languages/es.mo Normal file → Executable file

Binary file not shown.

61427
pandora_console/include/languages/es.po Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@ -3509,6 +3509,17 @@ div.simple_value > a > span.text p
font-size:13pt; font-size:13pt;
top:8px; top:8px;
} }
.modalheaderh1{
text-align:center;
width:100%;
height:37px;
left:0px;
background-color:#82b92e;
color:white;
position:relative;
font-family:Nunito;
font-size:13pt;
}
.modalclosex{ .modalclosex{
cursor:pointer; cursor:pointer;
display:inline; display:inline;

View File

@ -71,7 +71,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0dev'; $version = '7.0dev';
$build = '161130'; $build = '161214';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -349,7 +349,15 @@ echo "</div>";
var $container = $(element); var $container = $(element);
var $errorMessage = $('div#graph-error-message'); var $errorMessage = $('div#graph-error-message');
var period = $container.data('period'); var period = $container.data('period');
var stacked = $container.data('stacked'); var conf_stacked = '<?php echo $config['type_module_charts']; ?>';
switch (conf_stacked) {
case 'area':
var stacked = 0;
break;
case 'line':
var stacked = 2;
break;
}
var date = $container.data('date'); var date = $container.data('date');
var height = $container.data('height'); var height = $container.data('height');

View File

@ -62,14 +62,14 @@ $label = get_parameter ("label");
FROM tagente_estado FROM tagente_estado
WHERE id_agente_modulo = $id"); WHERE id_agente_modulo = $id");
echo "<h2 id='title_snapshot_view'>"; echo "<h2 style='text-align:center;' id='title_snapshot_view'>";
echo __("Current data at"); echo __("Current data at");
echo " "; echo " ";
echo $row["timestamp"]; echo $row["timestamp"];
echo "</h2>"; echo "</h2>";
$datos = io_safe_output($row["datos"]); $datos = io_safe_output($row["datos"]);
if (is_image_data($datos)) { if (is_image_data($datos)) {
echo '<img src="' . $datos . '" alt="image"/>'; echo '<center><img src="' . $datos . '" alt="image"/></center>';
} }
else { else {
$datos = preg_replace ('/</', '&lt;', $datos); $datos = preg_replace ('/</', '&lt;', $datos);

View File

@ -133,6 +133,7 @@ if (is_ajax ()) {
$id = get_parameter('id_row'); $id = get_parameter('id_row');
$idGroup = get_parameter('id_group'); $idGroup = get_parameter('id_group');
$agents = get_parameter('agents', null);
$query = ' AND id_evento > ' . $id; $query = ' AND id_evento > ' . $id;
@ -140,17 +141,22 @@ if (is_ajax ()) {
$alert = get_parameter('alert_fired'); $alert = get_parameter('alert_fired');
if ($alert == 'true') { if ($alert == 'true') {
$resultAlert = alerts_get_event_status_group($idGroup, $resultAlert = alerts_get_event_status_group($idGroup,
'alert_fired', $query); 'alert_fired', $query, $agents);
} }
$critical = get_parameter('critical'); $critical = get_parameter('critical');
if ($critical == 'true') { if ($critical == 'true') {
$resultCritical = alerts_get_event_status_group($idGroup, $resultCritical = alerts_get_event_status_group($idGroup,
'going_up_critical', $query); 'going_up_critical', $query, $agents);
} }
$warning = get_parameter('warning'); $warning = get_parameter('warning');
if ($warning == 'true') { if ($warning == 'true') {
$resultWarning = alerts_get_event_status_group($idGroup, $resultWarning = alerts_get_event_status_group($idGroup,
'going_up_warning', $query); 'going_up_warning', $query, $agents);
}
$unknown = get_parameter('unknown');
if ($unknown == 'true') {
$resultUnknown = alerts_get_event_status_group($idGroup,
'going_unknown', $query, $agents);
} }
if ($resultAlert) { if ($resultAlert) {
@ -165,6 +171,10 @@ if (is_ajax ()) {
$return = array('fired' => $resultWarning, $return = array('fired' => $resultWarning,
'sound' => $config['sound_warning']); 'sound' => $config['sound_warning']);
} }
else if ($resultUnknown) {
$return = array('fired' => $resultWarning,
'sound' => $config['sound_alert']);
}
else { else {
$return = array('fired' => 0); $return = array('fired' => 0);
} }
@ -427,7 +437,7 @@ if ($config["pure"] == 0 || $meta) {
echo ui_get_full_url('operation/events/sound_events.php'); echo ui_get_full_url('operation/events/sound_events.php');
?>'; ?>';
window.open(url, '<?php __('Sound Alerts'); ?>','width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes'); window.open(url, '<?php __('Sound Alerts'); ?>','width=400, height=380, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no');
} }
</script> </script>
<?php <?php

View File

@ -819,33 +819,18 @@ if ($group_rep == 0) {
$sql = "SELECT COUNT(id_evento) $sql = "SELECT COUNT(id_evento)
FROM $event_table FROM $event_table
WHERE 1=1 $sql_post"; WHERE 1=1 $sql_post";
$total_events = (int) db_get_sql ($sql);
} }
elseif ($group_rep == 1) { elseif ($group_rep == 1) {
switch ($config["dbtype"]) { $total_events = events_get_events_grouped($sql_post, false,
case "mysql": false, $meta, $history, true, false);
case "postgresql":
$sql = "SELECT COUNT(1)
FROM (SELECT 1
FROM $event_table
WHERE 1=1 $sql_post
GROUP BY evento, id_agentmodule) t";
break;
case "oracle":
$sql = "SELECT COUNT(1)
FROM (SELECT 1
FROM $event_table
WHERE 1=1 $sql_post
GROUP BY to_char(evento), id_agentmodule) t";
break;
}
} }
elseif ($group_rep == 2) { elseif ($group_rep == 2) {
$sql = "SELECT COUNT(*) FROM (select id_agente as total from $event_table WHERE id_agente > 0 $sql = "SELECT COUNT(*) FROM (select id_agente as total from $event_table WHERE id_agente > 0
$sql_post GROUP BY id_agente ORDER BY id_agente ) AS t"; $sql_post GROUP BY id_agente ORDER BY id_agente ) AS t";
$total_events = (int) db_get_sql ($sql);
} }
$total_events = (int) db_get_sql ($sql);
if (empty ($result)) { if (empty ($result)) {
$result = array (); $result = array ();
} }

View File

@ -44,6 +44,8 @@ if (! check_acl ($config['id_user'], 0, "ER") && ! check_acl ($config['id_user']
return; return;
} }
$agents = agents_get_group_agents(0, false, "none", false, true);
echo "<html>"; echo "<html>";
echo "<head>"; echo "<head>";
echo "<title>" . __("Sound Events") . "</title>"; echo "<title>" . __("Sound Events") . "</title>";
@ -62,32 +64,40 @@ echo "<title>" . __("Sound Events") . "</title>";
echo '<link rel="icon" href="../../images/pandora.ico" type="image/ico" />'; echo '<link rel="icon" href="../../images/pandora.ico" type="image/ico" />';
echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/css" />'; echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/css" />';
echo "</head>"; echo "</head>";
echo "<body>"; echo "<body style='max-width: 400px; max-height: 400px;'>";
echo html_print_image('images/pandora_logo_head.png', true); echo "<h1 class='modalheaderh1'>" . __("Sound console"). "</h1>";
echo "<h1 style='background: #66AA44; color: #fff;'>" . __("Sound console"). "</h1>";
$table = null; $table = null;
$table->width = '100%'; $table->width = '100%';
$table->size[0] = '10%'; $table->size[0] = '10%';
$table->size[1] = '90%';
$table->style[0] = 'font-weight: bold; vertical-align: top;'; $table->style[0] = 'font-weight: bold; vertical-align: top;';
$table->style[1] = 'font-weight: bold; vertical-align: top;';
$table->data[0][0] = __('Group'); $table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(false, $access, true, 'group', '', 'changeGroup();', '', 0, true); $table->data[0][0] .= html_print_select_groups(false, $access, true, 'group', '', 'changeGroup();', '', 0, true) . '<br />' . '<br />';
$table->data[1][0] = __('Type'); $table->data[0][0] .= __('Agent');
$table->data[1][1] = html_print_checkbox('alert_fired', 'alert_fired', true, true, false, 'changeType();') . __('Alert fired') . '<br />' . $table->data[0][0] .= html_print_select($agents, 'id_agents[]', true, false, '', '', true, true);
$table->data[0][1] = __('Type');
$table->data[0][1] .= '<br />' . html_print_checkbox('alert_fired', 'alert_fired', true, true, false, 'changeType();') . __('Alert fired') . '<br />' .
html_print_checkbox('critical', 'critical', true, true, false, 'changeType();') . __('Monitor critical') . '<br />' . html_print_checkbox('critical', 'critical', true, true, false, 'changeType();') . __('Monitor critical') . '<br />' .
html_print_checkbox('warning', 'warning', true, true, false, 'changeType();') . __('Monitor warning') . '<br />' . html_print_checkbox('unknown', 'unknown', true, true, false, 'changeType();') . __('Monitor unknown') . '<br />' .
$table->data[2][0] = ''; html_print_checkbox('warning', 'warning', true, true, false, 'changeType();') . __('Monitor warning') . '<br />';
$table->data[2][1] = '<a href="javascript: toggleButton();">' .
html_print_image("images/play.button.png", true, array("id" => "button")) .
'</a>';
$table->data[2][1] .= '<a href="javascript: ok();">' .
html_print_image("images/ok.button.png", true,
array("style" => "margin-left: 10px;")) . '</a>';
html_print_table($table); html_print_table($table);
echo '<br />';
echo '<a href="javascript: toggleButton();">' .
html_print_image("images/icono_play.png", true, array("id" => "button")) .
'</a>';
echo '<a href="javascript: ok();">' .
html_print_image("images/icono_ok.png", true, array("style" => "margin-left: 15px;")) .
'</a>';
echo '<a href="javascript: test_sound_button();">' .
html_print_image("images/icono_test.png", true, array("id" => "button_try", "style" => "margin-left: 15px;")) .
'</a>';
?> ?>
<script src="../../include/javascript/jquery.js" type="text/javascript"></script> <script src="../../include/javascript/jquery.js" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
@ -95,6 +105,7 @@ var group = 0;
var alert_fired = true; var alert_fired = true;
var critical = true; var critical = true;
var warning = true; var warning = true;
var unknown = true;
var running = false; var running = false;
var fired = false; var fired = false;
@ -105,14 +116,48 @@ var redBackground = false;
var button_play_status = "play"; var button_play_status = "play";
var test_sound = false;
function test_sound_button() {
if (!test_sound) {
$("#button_try").attr('src', '../../images/icono_test_active.png');
$('body').append("<audio src='../../include/sounds/Star_Trek_emergency_simulation.wav' autoplay='true' hidden='true' loop='false'>");
test_sound = true;
}
else {
$("#button_try").attr('src', '../../images/icono_test.png');
$('body audio').remove();
test_sound = false;
}
}
function changeGroup() { function changeGroup() {
group = $("#group").val(); group = $("#group").val();
jQuery.post ("../../ajax.php",
{"page" : "include/ajax/agent",
"get_agents_group": 1,
"id_group": group
},
function (data) {
$("#id_agents").empty();
$("#id_agents").style("size", 0);
jQuery.each (data, function (id, value) {
if (value != "") {
$("#id_agents").append('<option value="' + id + '">' + value + '</option>');
}
});
},
"json"
);
} }
function changeType() { function changeType() {
alert_fired = $("input[name=alert_fired]").attr('checked'); alert_fired = $("input[name=alert_fired]").attr('checked');
critical = $("input[name=critical]").attr('checked'); critical = $("input[name=critical]").attr('checked');
warning = $("input[name=warning]").attr('checked'); warning = $("input[name=warning]").attr('checked');
unknown = $("input[name=unknown]").attr('checked');
} }
function toggleButton() { function toggleButton() {
@ -120,14 +165,14 @@ function toggleButton() {
if (button_play_status == 'pause') { if (button_play_status == 'pause') {
//~ if ($("#button").attr('src') == '../../images/pause.button.png') { //~ if ($("#button").attr('src') == '../../images/pause.button.png') {
$("#button").attr('src', '../../images/play.button.png'); $("#button").attr('src', '../../images/icono_play.png');
stopSound(); stopSound();
button_play_status = 'play'; button_play_status = 'play';
} }
else { else {
$("#button").attr('src', '../../images/pause.button.png'); $("#button").attr('src', '../../images/icono_pausa.png');
forgetPreviousEvents(); forgetPreviousEvents();
startSound(); startSound();
@ -152,17 +197,21 @@ function stopSound() {
} }
function startSound() { function startSound() {
//running = true; running = true;
} }
function forgetPreviousEvents() { function forgetPreviousEvents() {
var agents = $("#id_agents").val();
jQuery.post ("../../ajax.php", jQuery.post ("../../ajax.php",
{"page" : "operation/events/events", {"page" : "operation/events/events",
"get_events_fired": 1, "get_events_fired": 1,
"id_group": group, "id_group": group,
"agents[]" : agents,
"alert_fired": alert_fired, "alert_fired": alert_fired,
"critical": critical, "critical": critical,
"warning": warning, "warning": warning,
"unknown": unknown,
"id_row": id_row "id_row": id_row
}, },
function (data) { function (data) {
@ -177,15 +226,19 @@ function forgetPreviousEvents() {
} }
function check_event() { function check_event() {
var agents = $("#id_agents").val();
if (running) { if (running) {
if (!fired) { if (!fired) {
jQuery.post ("../../ajax.php", jQuery.post ("../../ajax.php",
{"page" : "operation/events/events", {"page" : "operation/events/events",
"get_events_fired": 1, "get_events_fired": 1,
"id_group": group, "id_group": group,
"agents[]" : agents,
"alert_fired": alert_fired, "alert_fired": alert_fired,
"critical": critical, "critical": critical,
"warning": warning, "warning": warning,
"unknown": unknown,
"id_row": id_row "id_row": id_row
}, },
function (data) { function (data) {

View File

@ -317,7 +317,7 @@ if (check_acl ($config['id_user'], 0, "ER")
window.open(url, window.open(url,
'<?php __('Sound Alerts'); ?>', '<?php __('Sound Alerts'); ?>',
'width=400, height=350, resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no'); 'width=400, height=380, resizable=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
} }
</script> </script>
<?php <?php

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0dev %define version 7.0dev
%define release 161130 %define release 161214
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0dev %define version 7.0dev
%define release 161130 %define release 161214
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -66,7 +66,7 @@ INSERT INTO tconfig (token, value) VALUES ('graph_res','5');
INSERT INTO tconfig (token, value) VALUES ('step_compact','1'); INSERT INTO tconfig (token, value) VALUES ('step_compact','1');
INSERT INTO tconfig (token, value) VALUES ('db_scheme_first_version','6.0orc'); INSERT INTO tconfig (token, value) VALUES ('db_scheme_first_version','6.0orc');
INSERT INTO tconfig (token, value) VALUES('db_scheme_version','7.0dev'); INSERT INTO tconfig (token, value) VALUES('db_scheme_version','7.0dev');
INSERT INTO tconfig (token, value) VALUES('db_scheme_build','PD161130'); INSERT INTO tconfig (token, value) VALUES('db_scheme_build','PD161214');
INSERT INTO tconfig (token, value) VALUES ('show_unknown','0'); INSERT INTO tconfig (token, value) VALUES ('show_unknown','0');
INSERT INTO tconfig (token, value) VALUES ('show_lastalerts','1'); INSERT INTO tconfig (token, value) VALUES ('show_lastalerts','1');
INSERT INTO tconfig (token, value) VALUES ('style','pandora'); INSERT INTO tconfig (token, value) VALUES ('style','pandora');
@ -1371,6 +1371,7 @@ EXECUTE IMMEDIATE 'ALTER TRIGGER tagent_custom_fields_inc DISABLE';
INSERT INTO tagent_custom_fields VALUES (1,'Serial&#x20;Number',0); INSERT INTO tagent_custom_fields VALUES (1,'Serial&#x20;Number',0);
INSERT INTO tagent_custom_fields VALUES (2,'Department',0); INSERT INTO tagent_custom_fields VALUES (2,'Department',0);
INSERT INTO tagent_custom_fields VALUES (3,'Additional&#x20;ID',0); INSERT INTO tagent_custom_fields VALUES (3,'Additional&#x20;ID',0);
INSERT INTO tagent_custom_fields VALUES (4,'eHorusID',0);
-- Update curr val of sequence -- Update curr val of sequence
update_currval('tagent_custom_fields', 'id_field'); update_currval('tagent_custom_fields', 'id_field');

View File

@ -290,6 +290,7 @@ CREATE TABLE tagente_modulo (
prediction_sample_window INTEGER default 0, prediction_sample_window INTEGER default 0,
prediction_samples INTEGER default 0, prediction_samples INTEGER default 0,
prediction_threshold INTEGER default 0, prediction_threshold INTEGER default 0,
parent_module_id NUMBER(10, 0),
CONSTRAINT t_agente_modulo_wizard_cons CHECK (wizard_level IN ('basic','advanced','nowizard')) CONSTRAINT t_agente_modulo_wizard_cons CHECK (wizard_level IN ('basic','advanced','nowizard'))
); );
CREATE INDEX tagente_modulo_id_agente_idx ON tagente_modulo(id_agente); CREATE INDEX tagente_modulo_id_agente_idx ON tagente_modulo(id_agente);

View File

@ -252,6 +252,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
`prediction_sample_window` int(10) default 0, `prediction_sample_window` int(10) default 0,
`prediction_samples` int(4) default 0, `prediction_samples` int(4) default 0,
`prediction_threshold` int(4) default 0, `prediction_threshold` int(4) default 0,
`parent_module_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_agente_modulo`), PRIMARY KEY (`id_agente_modulo`),
KEY `main_idx` (`id_agente_modulo`,`id_agente`), KEY `main_idx` (`id_agente_modulo`,`id_agente`),
KEY `tam_agente` (`id_agente`), KEY `tam_agente` (`id_agente`),

View File

@ -1033,7 +1033,7 @@ INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `p
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (9,'Packet&#x20;Loss','Checks&#x20;for&#x20;dropped&#x20;packages&#x20;after&#x20;X&#x20;seconds&#x20;of&#x20;testing.&#x20;It&#x20;returns&#x20;%&#x20;of&#x20;dropped&#x20;packets.&#x20;It&#x20;uses&#x20;ping&#x20;flood&#x20;mode&#x20;to&#x20;launch&#x20;50&#x20;consecutive&#x20;pings&#x20;to&#x20;a&#x20;remote&#x20;destination.&#x20;On&#x20;local,&#x20;stable&#x20;networks,&#x20;value&#x20;should&#x20;be&#x20;0.&#x0d;&#x0a;',30,0,'/usr/share/pandora_server/util/plugin/packet_loss.sh','','','','',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Test&#x20;time\",\"help\":\"\",\"value\":\"8\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Target&#x20;IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','_field1_&#x20;_field2_'); INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (9,'Packet&#x20;Loss','Checks&#x20;for&#x20;dropped&#x20;packages&#x20;after&#x20;X&#x20;seconds&#x20;of&#x20;testing.&#x20;It&#x20;returns&#x20;%&#x20;of&#x20;dropped&#x20;packets.&#x20;It&#x20;uses&#x20;ping&#x20;flood&#x20;mode&#x20;to&#x20;launch&#x20;50&#x20;consecutive&#x20;pings&#x20;to&#x20;a&#x20;remote&#x20;destination.&#x20;On&#x20;local,&#x20;stable&#x20;networks,&#x20;value&#x20;should&#x20;be&#x20;0.&#x0d;&#x0a;',30,0,'/usr/share/pandora_server/util/plugin/packet_loss.sh','','','','',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Test&#x20;time\",\"help\":\"\",\"value\":\"8\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Target&#x20;IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','_field1_&#x20;_field2_');
INSERT INTO `tagent_custom_fields` VALUES (1,'Serial&#x20;Number',0),(2,'Department',0),(3,'Additional&#x20;ID',0); INSERT INTO `tagent_custom_fields` VALUES (1,'Serial&#x20;Number',0),(2,'Department',0),(3,'Additional&#x20;ID',0),(4,'eHorusID',0);
INSERT INTO `ttag` VALUES (1,'network','Network&#x20;equipment','http://artica.es','',''),(2,'critical','Critical&#x20;modules','','',''),(3,'dmz','DMZ&#x20;Network&#x20;Zone','','',''),(4,'performance','Performance&#x20;anda&#x20;capacity&#x20;modules','','',''),(5,'configuration','','','',''); INSERT INTO `ttag` VALUES (1,'network','Network&#x20;equipment','http://artica.es','',''),(2,'critical','Critical&#x20;modules','','',''),(3,'dmz','DMZ&#x20;Network&#x20;Zone','','',''),(4,'performance','Performance&#x20;anda&#x20;capacity&#x20;modules','','',''),(5,'configuration','','','','');

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0dev-161130 Version: 7.0dev-161214
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0dev-161130" pandora_version="7.0dev-161214"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -43,7 +43,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0dev"; my $pandora_version = "7.0dev";
my $pandora_build = "161130"; my $pandora_build = "161214";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -344,7 +344,14 @@ sub process_xml_data ($$$$$) {
my $os = pandora_get_os ($dbh, $data->{'os_name'}); my $os = pandora_get_os ($dbh, $data->{'os_name'});
my $group_id = $pa_config->{'autocreate_group'}; my $group_id = $pa_config->{'autocreate_group'};
if (! defined (get_group_name ($dbh, $group_id))) { if (! defined (get_group_name ($dbh, $group_id))) {
if (defined ($data->{'group'}) && $data->{'group'} ne '') { if (defined ($data->{'group_id'}) && $data->{'group_id'} ne '') {
$group_id = $data->{'group_id'};
if (! defined (get_group_name ($dbh, $group_id))) {
pandora_event ($pa_config, "Unable to create agent '$agent_name': group ID '" . $group_id . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
logger($pa_config, "Group ID " . $group_id . " does not exist.", 3);
return;
}
} elsif (defined ($data->{'group'}) && $data->{'group'} ne '') {
$group_id = get_group_id ($dbh, $data->{'group'}); $group_id = get_group_id ($dbh, $data->{'group'});
if (! defined (get_group_name ($dbh, $group_id))) { if (! defined (get_group_name ($dbh, $group_id))) {
pandora_event ($pa_config, "Unable to create agent '$agent_name': group '" . $data->{'group'} . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh); pandora_event ($pa_config, "Unable to create agent '$agent_name': group '" . $data->{'group'} . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
@ -556,6 +563,27 @@ sub process_xml_data ($$$$$) {
} }
} }
# Link modules
foreach my $module_data (@{$data->{'module'}}) {
my $module_name = get_tag_value ($module_data, 'name', '');
$module_name =~ s/\r//g;
$module_name =~ s/\n//g;
# Unnamed module
next if ($module_name eq '');
# No parent module defined
my $parent_module_name = get_tag_value ($module_data, 'module_parent', undef);
if (! defined ($parent_module_name)) {
use Data::Dumper;
print Dumper($module_data);
next;
}
link_modules($pa_config, $dbh, $agent_id, $module_name, $parent_module_name);
}
# Process inventory modules # Process inventory modules
enterprise_hook('process_inventory_data', [$pa_config, $data, $server_id, $agent_name, enterprise_hook('process_inventory_data', [$pa_config, $data, $server_id, $agent_name,
$interval, $timestamp, $dbh]); $interval, $timestamp, $dbh]);
@ -667,7 +695,10 @@ sub process_module_data ($$$$$$$$$$) {
# The group name has to be translated to a group ID # The group name has to be translated to a group ID
if (defined $module_conf->{'module_group'}) { if (defined $module_conf->{'module_group'}) {
$module_conf->{'id_module_group'} = get_module_group_id ($dbh, $module_conf->{'module_group'}); my $id_group_module = get_module_group_id ($dbh, $module_conf->{'module_group'});
if ( $id_group_module >= 0) {
$module_conf->{'id_module_group'} = $id_group_module;
}
delete $module_conf->{'module_group'}; delete $module_conf->{'module_group'};
} }
@ -874,5 +905,25 @@ sub process_xml_server ($$$$) {
pandora_update_server ($pa_config, $dbh, $data->{'server_name'}, 0, 1, $server_type, $threads, $modules, $version, $data->{'keepalive'}); pandora_update_server ($pa_config, $dbh, $data->{'server_name'}, 0, 1, $server_type, $threads, $modules, $version, $data->{'keepalive'});
} }
###############################################################################
# Link two modules
###############################################################################
sub link_modules {
my ($pa_config, $dbh, $agent_id, $child_name, $parent_name) = @_;
# Get the child module ID.
my $child_id = get_agent_module_id ($dbh, $child_name, $agent_id);
return unless ($child_id != -1);
# Get the parent module ID.
my $parent_id = get_agent_module_id ($dbh, $parent_name, $agent_id);
return unless ($parent_id != -1);
# Link them.
logger($pa_config, "Linking module $child_name to module $parent_name for agent ID $agent_id", 10);
db_do($dbh, "UPDATE tagente_modulo SET parent_module_id = ? WHERE id_agente_modulo = ?", $parent_id, $child_id);
}
1; 1;
__END__ __END__

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0dev %define version 7.0dev
%define release 161130 %define release 161214
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0dev %define version 7.0dev
%define release 161130 %define release 161214
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0dev" PI_VERSION="7.0dev"
PI_BUILD="161130" PI_BUILD="161214"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0dev PS161130"; my $version = "7.0dev PS161214";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;
@ -92,20 +92,10 @@ sub pandora_purgedb ($$) {
log_message ('PURGE', 'Deleting old extended session data.'); log_message ('PURGE', 'Deleting old extended session data.');
} }
# Delete old data
if ($conf->{'_days_purge'} > 0) {
# Delete old numeric data
pandora_delete_old_module_data ($dbh, 'tagente_datos', $ulimit_access_timestamp, $ulimit_timestamp);
# Delete old export data
pandora_delete_old_export_data ($dbh, $ulimit_timestamp);
# Delete sessions data
pandora_delete_old_session_data ($dbh, $ulimit_timestamp);
# Delete old inventory data # Delete old inventory data
if ($conf->{'_inventory_purge'} > 0) {
if (enterprise_load (\%conf) != 0) { if (enterprise_load (\%conf) != 0) {
my $ulimit_timestamp_inventory = time() - (86400 * $conf->{'_inventory_purge'});
log_message ('PURGE', 'Deleting old inventory data.'); log_message ('PURGE', 'Deleting old inventory data.');
@ -116,7 +106,7 @@ sub pandora_purgedb ($$) {
$first_mark = get_db_value_limit ($dbh, 'SELECT utimestamp FROM tagente_datos_inventory ORDER BY utimestamp ASC', 1); $first_mark = get_db_value_limit ($dbh, 'SELECT utimestamp FROM tagente_datos_inventory ORDER BY utimestamp ASC', 1);
if (defined ($first_mark)) { if (defined ($first_mark)) {
$total_time = $ulimit_timestamp - $first_mark; $total_time = $ulimit_timestamp_inventory - $first_mark;
$purge_steps = int($total_time / $BIG_OPERATION_STEP); $purge_steps = int($total_time / $BIG_OPERATION_STEP);
if ($purge_steps > 0) { if ($purge_steps > 0) {
for (my $ax = 1; $ax <= $BIG_OPERATION_STEP; $ax++) { for (my $ax = 1; $ax <= $BIG_OPERATION_STEP; $ax++) {
@ -133,7 +123,21 @@ sub pandora_purgedb ($$) {
log_message ('PURGE', 'No data in tagente_datos_inventory.'); log_message ('PURGE', 'No data in tagente_datos_inventory.');
} }
} }
}
# Delete old data
if ($conf->{'_days_purge'} > 0) {
# Delete old numeric data
pandora_delete_old_module_data ($dbh, 'tagente_datos', $ulimit_access_timestamp, $ulimit_timestamp);
# Delete old export data
pandora_delete_old_export_data ($dbh, $ulimit_timestamp);
# Delete sessions data
pandora_delete_old_session_data ($dbh, $ulimit_timestamp);
# Delete old inventory data
# #
# Now the log4x data # Now the log4x data
@ -700,6 +704,7 @@ sub pandora_load_config ($) {
$conf->{'_history_db_step'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_step'"); $conf->{'_history_db_step'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_step'");
$conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'"); $conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'");
$conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'"); $conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'");
$conf->{'_inventory_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'inventory_purge'");
$conf->{'_enterprise_installed'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'enterprise_installed'"); $conf->{'_enterprise_installed'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'enterprise_installed'");
$conf->{'_metaconsole'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole'"); $conf->{'_metaconsole'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole'");
$conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'"); $conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'");

View File

@ -35,7 +35,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0dev PS161130"; my $version = "7.0dev PS161214";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);