Merge branch 'develop' into feature/new_networkmap
This commit is contained in:
commit
9376e9aa6d
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 6.1dev-160126
|
||||
Version: 6.1dev-160210
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="6.1dev-160126"
|
||||
pandora_version="6.1dev-160210"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -41,7 +41,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '6.1dev';
|
||||
use constant AGENT_BUILD => '160126';
|
||||
use constant AGENT_BUILD => '160210';
|
||||
|
||||
# Commands to retrieve total memory information in kB
|
||||
use constant TOTALMEMORY_CMDS => {
|
||||
|
@ -430,6 +430,8 @@ sub parse_conf_modules($) {
|
|||
$module->{'timeout'} = $1;
|
||||
} elsif ($line =~ /^\s*module_save\s+(\w+)$/) {
|
||||
$module->{'save'} = $1;
|
||||
} elsif ($line =~ /^\s*module_alert_template\s+(.*)$/) {
|
||||
$module->{'alert_template'} = $1;
|
||||
} elsif ($line =~ /^\s*module_condition\s+(.*)$/) {
|
||||
my $action = $1;
|
||||
# Numeric comparison
|
||||
|
@ -467,6 +469,7 @@ sub parse_conf_modules($) {
|
|||
}
|
||||
} elsif ($line =~ /^\s*module_crontab\s+(((\*|(\d+(-\d+){0,1}))\s*){5}).*$/) {
|
||||
$module->{'cron'} = $1;
|
||||
chomp ($module->{'cron'});
|
||||
} elsif ($line =~ /^\s*module_cron_interval\s+(\d+).*$/) {
|
||||
$module->{'cron_interval'} = $1;
|
||||
} elsif ($line =~ /^\s*module_end\s*$/) {
|
||||
|
@ -1736,12 +1739,27 @@ sub check_module_cron ($) {
|
|||
# Get interval
|
||||
my ($bottom, $top) = split (/-/, $cron_params[$i]);
|
||||
$top = $bottom unless defined ($top);
|
||||
|
||||
# Check if next execution will overflow the cron (only minutes overflow)
|
||||
# If overflow, execute the module
|
||||
my $overflow_cron = 0;
|
||||
if ($i == 0) {
|
||||
my $start_cron_seconds = $bottom*60;
|
||||
my $current_exec_seconds = $time_params[$i]*60;
|
||||
my $next_exec_seconds = $time_params[$i]*60 + $module->{'interval'}*$Conf{'interval'};
|
||||
if ($current_exec_seconds > $start_cron_seconds && $current_exec_seconds > $next_exec_seconds) {
|
||||
$start_cron_seconds += 3600;
|
||||
}
|
||||
if (($current_exec_seconds <= $start_cron_seconds) && ($start_cron_seconds <= $next_exec_seconds)) {
|
||||
$overflow_cron = 1
|
||||
}
|
||||
}
|
||||
|
||||
# Check interval
|
||||
if ($bottom <= $top) {
|
||||
return 0 if ($time_params[$i] < $bottom || $time_params[$i] > $top);
|
||||
return 0 if (($time_params[$i] < $bottom || $time_params[$i] > $top) && !$overflow_cron);
|
||||
} else {
|
||||
return 0 if ($time_params[$i] < $bottom && $time_params[$i] > $top);
|
||||
return 0 if (($time_params[$i] < $bottom && $time_params[$i] > $top) && !$overflow_cron);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1860,6 +1878,12 @@ sub write_module_xml ($@) {
|
|||
|
||||
# Module FF interval
|
||||
$Xml .= " <module_ff_interval>" . $module->{'module_ff_interval'} . "</module_ff_interval>\n" if (defined ($module->{'module_ff_interval'}));
|
||||
|
||||
# Module Alert template
|
||||
$Xml .= " <alert_template>" . $module->{'alert_template'} . "</alert_template>\n" if (defined ($module->{'alert_template'}));
|
||||
|
||||
# Module Alert template
|
||||
$Xml .= " <crontab>" . $module->{'cron'} . "</crontab>\n" if (defined ($module->{'cron'}) and ($module->{'cron'} ne ""));
|
||||
|
||||
# Data list
|
||||
if ($#data > 0) {
|
||||
|
@ -2110,6 +2134,7 @@ sub init_module ($) {
|
|||
$module->{'quiet'} = undef;
|
||||
$module->{'module_ff_interval'} = undef;
|
||||
$module->{'macros'} = {};
|
||||
$module->{'alert_template'} = undef;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 6.1dev
|
||||
%define release 160126
|
||||
%define release 160210
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -20,7 +20,6 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
|
|||
BuildArch: noarch
|
||||
PreReq: /bin/sed /bin/grep /usr/sbin/useradd
|
||||
Requires: coreutils unzip perl
|
||||
Recommends: perl-Sys-Syslog
|
||||
AutoReq: 0
|
||||
Provides: %{name}-%{version}
|
||||
|
||||
|
@ -94,8 +93,13 @@ if [ ! -e /etc/pandora/collections ]; then
|
|||
fi
|
||||
|
||||
mkdir -p /var/spool/pandora/data_out
|
||||
if [ ! -d /var/log/pandora ]; then
|
||||
mkdir -p /var/log/pandora
|
||||
fi
|
||||
/sbin/chkconfig --add pandora_agent_daemon
|
||||
/sbin/chkconfig pandora_agent_daemon on
|
||||
echo "You may need to install manually some additional required dependencies:"
|
||||
echo "perl-Sys-Syslog"
|
||||
|
||||
%preun
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 6.1dev
|
||||
%define release 160126
|
||||
%define release 160210
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="6.1dev"
|
||||
PI_BUILD="160126"
|
||||
PI_BUILD="160210"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -64,6 +64,7 @@ use threads;
|
|||
use Thread::Semaphore;
|
||||
use POSIX ":sys_wait_h";
|
||||
use Time::HiRes qw(usleep);
|
||||
use Scalar::Util qw(refaddr);
|
||||
|
||||
# Constants for Win32 services.
|
||||
use constant WIN32_SERVICE_STOPPED => 0x01;
|
||||
|
@ -684,7 +685,7 @@ sub accept_connections {
|
|||
my $pid;
|
||||
my $t_server_socket;
|
||||
|
||||
# Ignore SIGPIPE errors (happens on FreeBSD when SSL is enabled ¿?)
|
||||
# Ignore SIGPIPE
|
||||
$SIG{PIPE} = 'IGNORE';
|
||||
|
||||
# Start server
|
||||
|
@ -774,14 +775,21 @@ sub serve_proxy_connection {
|
|||
|
||||
# Forward data between the client and the server.
|
||||
eval {
|
||||
while (1) {
|
||||
if ($t_select->can_read(0)) {
|
||||
my $select = IO::Select->new ();
|
||||
$select->add($t_proxy_socket);
|
||||
$select->add($t_client_socket);
|
||||
while (my @ready = $select->can_read()) {
|
||||
foreach my $socket (@ready) {
|
||||
if (refaddr($socket) == refaddr($t_client_socket)) {
|
||||
my ($read, $data) = recv_data($t_block_size);
|
||||
return unless defined($data);
|
||||
send_data_proxy($data);
|
||||
}
|
||||
if ($t_proxy_select->can_read(0)) {
|
||||
}
|
||||
else {
|
||||
my ($read, $data) = recv_data_proxy($t_block_size);
|
||||
return unless defined($data);
|
||||
send_data($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -974,8 +982,10 @@ sub print_log {
|
|||
sub error {
|
||||
|
||||
if ($t_quiet == 0) {
|
||||
die("[err] $_[0]\n\n");
|
||||
print (STDERR "[err] $_[0]\n");
|
||||
}
|
||||
|
||||
die("\n");
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
|
Binary file not shown.
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{160126}
|
||||
{160210}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("6.1dev(Build 160126)")
|
||||
#define PANDORA_VERSION ("6.1dev(Build 160210)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(6.1dev(Build 160126))"
|
||||
VALUE "ProductVersion", "(6.1dev(Build 160210))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 6.1dev-160126
|
||||
Version: 6.1dev-160210
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="6.1dev-160126"
|
||||
pandora_version="6.1dev-160210"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -182,6 +182,7 @@ ALTER TABLE tagente_estado ADD COLUMN `last_dynamic_update` bigint(20) NOT NULL
|
|||
-- Table `tgraph_source`
|
||||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE tgraph_source ADD COLUMN `label` varchar(150) DEFAULT '';
|
||||
ALTER TABLE tgraph_source ADD COLUMN `id_server` int(11) NOT NULL default 0;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tevent_filter`
|
||||
|
|
|
@ -130,3 +130,4 @@ ALTER TABLE tevent_filter ADD COLUMN id_agent int(25) DEFAULT 0;
|
|||
-- Table `tgraph_source`
|
||||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE tgraph_source ADD COLUMN label VARCHAR2(150) DEFAULT '';
|
||||
ALTER TABLE tgraph_source ADD COLUMN "id_server" BIGINT NOT NULL default 0;
|
||||
|
|
|
@ -120,4 +120,10 @@ UPDATE `tnetwork_component` set `tcp_port`=0 WHERE id_nc=219;
|
|||
-- Table `tnetwork_component`
|
||||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE tevent_filter ADD COLUMN id_agent_module int(25) DEFAULT 0;
|
||||
ALTER TABLE tevent_filter ADD COLUMN id_agent int(25) DEFAULT 0;
|
||||
ALTER TABLE tevent_filter ADD COLUMN id_agent int(25) DEFAULT 0;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tgraph_source`
|
||||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE tgraph_source ADD COLUMN label VARCHAR2(150) DEFAULT '';
|
||||
ALTER TABLE tgraph_source ADD COLUMN id_graph NUMBER(19, 0) DEFAULT 0;
|
|
@ -536,10 +536,18 @@ $table_advanced->data[10][0] = __('Unknown instructions'). ui_print_help_tip(__(
|
|||
$table_advanced->data[10][1] = html_print_textarea ('unknown_instructions', 2, 65, $unknown_instructions, '', true);
|
||||
$table_advanced->colspan[10][1] = 6;
|
||||
|
||||
$table_advanced->data[11][0] = __('Cron') .
|
||||
ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true);
|
||||
$table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour, $minute, $mday, $month, $wday, true);
|
||||
$table_advanced->colspan[11][1] = 6;
|
||||
if (isset($id_agente) && $moduletype == MODULE_DATA) {
|
||||
$table_advanced->data[11][0] = __('Cron') .
|
||||
ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true);
|
||||
$table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour, $minute, $mday, $month, $wday, true, true);
|
||||
$table_advanced->colspan[11][1] = 6;
|
||||
}
|
||||
else {
|
||||
$table_advanced->data[11][0] = __('Cron') .
|
||||
ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true);
|
||||
$table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour, $minute, $mday, $month, $wday, true, false);
|
||||
$table_advanced->colspan[11][1] = 6;
|
||||
}
|
||||
|
||||
$table_advanced->data[12][0] = __('Timeout');
|
||||
$table_advanced->data[12][1] = html_print_input_text ('max_timeout', $max_timeout, '', 5, 10, true). ' ' . ui_print_help_tip (__('Seconds that agent will wait for the execution of the module.'), true);
|
||||
|
|
|
@ -123,7 +123,7 @@ if (is_ajax ()) {
|
|||
}
|
||||
else {
|
||||
$agents = agents_get_group_agents($id_group, $filter, "none",
|
||||
false, $recursion);
|
||||
false, $recursion, false, '|', $add_alert_bulk_op);
|
||||
}
|
||||
|
||||
// Add keys prefix
|
||||
|
|
|
@ -211,7 +211,7 @@ $(document).ready (function () {
|
|||
|
||||
var recursion;
|
||||
$("#checkbox-recursion").click(function () {
|
||||
recursion = this.checked ? 1 : 0;
|
||||
recursion = this.checked;
|
||||
$("#id_group").trigger("change");
|
||||
});
|
||||
|
||||
|
|
|
@ -139,7 +139,8 @@ $table->data[0][0] = __('Group');
|
|||
$table->data[0][1] = html_print_select_groups(false, "AW", $return_all_group, 'id_group', $id_group,
|
||||
false, '', '', true);
|
||||
$table->data[0][2] = __('Group recursion');
|
||||
$table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false);
|
||||
$table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion,
|
||||
true, false);
|
||||
|
||||
$table->data[1][0] = __('Agents with templates');
|
||||
$table->data[1][0] .= '<span id="agent_loading" class="invisible">';
|
||||
|
@ -167,7 +168,7 @@ $table->data[3][1] = html_print_select ($actions, 'action[]', '', '',
|
|||
echo '<form method="post" id="form_alert" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_action_alerts">';
|
||||
html_print_table ($table);
|
||||
|
||||
$sql = 'SELECT id_agente
|
||||
$sql = 'SELECT DISTINCT(id_agente)
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo IN (
|
||||
SELECT id_agent_module
|
||||
|
@ -179,7 +180,7 @@ foreach($agents_with_templates as $ag) {
|
|||
}
|
||||
$agents_with_templates_json = json_encode($agents_with_templates_json);
|
||||
|
||||
echo "<input type='hidden' id='hidden-agents_with_templates' value='$agents_with_templates_json'>";
|
||||
echo "<input type='hidden' id='hidden-agents_with_templates' value='".$agents_with_templates_json."'>";
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||
html_print_input_hidden ('delete', 1);
|
||||
|
@ -197,23 +198,23 @@ ui_require_jquery_file('pandora.controls');
|
|||
$(document).ready (function () {
|
||||
update_alerts();
|
||||
|
||||
var recursion;
|
||||
$("#checkbox-recursion").click(function () {
|
||||
recursion = this.checked ? 1 : 0;
|
||||
$("#id_group").trigger("change");
|
||||
});
|
||||
|
||||
var filter_agents_json = $("#hidden-agents_with_templates").val();
|
||||
var recursion = false;
|
||||
$("#checkbox-recursion").click(function () {
|
||||
recursion = this.checked;
|
||||
$("#id_group").trigger("change");
|
||||
});
|
||||
|
||||
$("#id_group").pandoraSelectGroupAgent ({
|
||||
agentSelect: "select#id_agents",
|
||||
privilege: "AW",
|
||||
recursion: function() {return recursion},
|
||||
filter_agents_json: filter_agents_json,
|
||||
add_alert_bulk_op: true,
|
||||
callbackPost: function () {
|
||||
var $select_template = $("#id_alert_templates").disable ();
|
||||
$("option", $select_template).remove ();
|
||||
}
|
||||
},
|
||||
recursion: function() {return recursion}
|
||||
});
|
||||
|
||||
$("#id_agents").change (function () {
|
||||
|
|
|
@ -188,10 +188,12 @@ if (!empty ($graphs)) {
|
|||
echo "<td>";
|
||||
echo "<div style='float: right;'>";
|
||||
if (!empty($graphs)){
|
||||
echo "<form method='post' style='float:right;' action='index.php?sec=reporting&sec2=godmode/reporting/graphs'>";
|
||||
html_print_input_hidden('multiple_delete', 1);
|
||||
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
|
||||
echo "</form>";
|
||||
if (check_acl ($config['id_user'], 0, "RW") && users_can_manage_group_all($graph['id_group'])) {
|
||||
echo "<form method='post' style='float:right;' action='index.php?sec=reporting&sec2=godmode/reporting/graphs'>";
|
||||
html_print_input_hidden('multiple_delete', 1);
|
||||
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
|
||||
echo "</form>";
|
||||
}
|
||||
}
|
||||
if (check_acl ($config['id_user'], 0, "RW")) {
|
||||
echo '<form method="post" style="float:right;" action="index.php?sec=reporting&sec2=godmode/reporting/graph_builder">';
|
||||
|
|
|
@ -43,7 +43,7 @@ if (!defined('METACONSOLE')) {
|
|||
$id_layout = (int) get_parameter ('id_layout');
|
||||
$copy_layout = (bool) get_parameter ('copy_layout');
|
||||
$delete_layout = (bool) get_parameter ('delete_layout');
|
||||
$refr = (int) get_parameter('refr', 60);
|
||||
$refr = (int) get_parameter('refr', $config['vc_refr']);
|
||||
$offset = (int) get_parameter('offset', 0);
|
||||
$pagination = (int) get_parameter ("pagination", $config["block_size"]);
|
||||
|
||||
|
|
|
@ -968,6 +968,7 @@ switch ($action) {
|
|||
// Show interfaces instead the modules
|
||||
$values['show_graph'] =
|
||||
get_parameter('checkbox_show_address_agent');
|
||||
$values['period'] = get_parameter('period');
|
||||
$good_format = true;
|
||||
break;
|
||||
case 'simple_graph':
|
||||
|
|
|
@ -619,7 +619,7 @@ switch ($activeTab) {
|
|||
if (isset($config['vc_refr']) and $config['vc_refr'] != 0)
|
||||
$view_refresh = $config['vc_refr'];
|
||||
else
|
||||
$view_refresh = '60';
|
||||
$view_refresh = '300';
|
||||
|
||||
if (!defined('METACONSOLE')) {
|
||||
$url_base = 'index.php?sec=reporting&sec2=godmode/reporting/visual_console_builder&action=';
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,7 +22,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC160126';
|
||||
$build_version = 'PC160210';
|
||||
$pandora_version = 'v6.1dev';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -192,7 +192,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ($id_agent === false) {
|
||||
else if ($id_agent === false || empty($id_agent)) {
|
||||
if ($allModules)
|
||||
$disabled = '';
|
||||
else
|
||||
|
|
|
@ -2284,7 +2284,9 @@ function api_set_create_synthetic_module($id, $thrash1, $other, $thrash3) {
|
|||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
global $config;
|
||||
|
||||
$agentName = $id;
|
||||
|
||||
io_safe_input_array($other);
|
||||
|
@ -2303,13 +2305,15 @@ function api_set_create_synthetic_module($id, $thrash1, $other, $thrash3) {
|
|||
|
||||
$name = io_safe_output($other['data'][0]);
|
||||
$name = io_safe_input($name);
|
||||
$id_tipo_modulo = db_get_row_sql ("SELECT id_tipo FROM ttipo_modulo WHERE nombre = 'generic_data'");
|
||||
|
||||
$values = array(
|
||||
'id_agente' => $idAgent,
|
||||
'id_modulo' => 5,
|
||||
'custom_integer_1' => 0,
|
||||
'custom_integer_2' => 0,
|
||||
'prediction_module' => 3,
|
||||
'prediction_module' => 3,
|
||||
'id_tipo_modulo' => $id_tipo_modulo['id_tipo']
|
||||
);
|
||||
|
||||
if ( ! $values['descripcion'] ) {
|
||||
|
@ -2338,7 +2342,7 @@ function api_set_create_synthetic_module($id, $thrash1, $other, $thrash3) {
|
|||
returnError("","[ERROR] With this type: $synthetic_type only be allow use this operator: 'x' \n\n");
|
||||
}
|
||||
|
||||
$operator = $split_data[0] == 'x' ? 'avg' : $split_data[0];
|
||||
$operator = strtolower($split_data[0]);
|
||||
$data_module = array("",$operator,$split_data[1]);
|
||||
|
||||
$text_data = implode('_',$data_module);
|
||||
|
@ -2352,15 +2356,17 @@ function api_set_create_synthetic_module($id, $thrash1, $other, $thrash3) {
|
|||
array_push($filterdata,$text_data);
|
||||
}
|
||||
else {
|
||||
if (strlen($split_data[1]) > 1 ) {
|
||||
if (strlen($split_data[1]) > 1 && $synthetic_type != 'average' ) {
|
||||
returnError("","[ERROR] You can only use +, -, *, / or x, and you use this: @split_data[1] \n\n");
|
||||
return;
|
||||
}
|
||||
if ( preg_match("/[\/|+|*|-]/",$split_data[1]) && $synthetic_type === 'average' ) {
|
||||
returnError("","[ERROR] With this type: $synthetic_type only be allow use this operator: 'x' \n\n");
|
||||
return;
|
||||
}
|
||||
|
||||
$idAgent = agents_get_agent_id(io_safe_output($split_data[0]),true);
|
||||
$operator = $split_data[1] == 'x' ? 'avg' : $split_data[1];
|
||||
$operator = strtolower($split_data[1]);
|
||||
$data_module = array($idAgent,$operator,$split_data[2]);
|
||||
$text_data = implode('_',$data_module);
|
||||
array_push($filterdata,$text_data);
|
||||
|
@ -2375,14 +2381,64 @@ function api_set_create_synthetic_module($id, $thrash1, $other, $thrash3) {
|
|||
array($idModule, $serialize_ops));
|
||||
|
||||
if ($synthetic === ENTERPRISE_NOT_HOOK) {
|
||||
returnError('error_policy_modules', 'Error Synthetic modules.');
|
||||
returnError('error_synthetic_modules', 'Error Synthetic modules.');
|
||||
db_process_sql_delete ('tagente_modulo',
|
||||
array ('id_agente_modulo' => $idModule));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
returnData('string', array('type' => 'string', 'data' => __('Synthetic module created ID: ' . $idModule)));
|
||||
$status = AGENT_MODULE_STATUS_NO_DATA;
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$result = db_process_sql_insert ('tagente_estado',
|
||||
array ('id_agente_modulo' => $idModule,
|
||||
'datos' => 0,
|
||||
'timestamp' => '01-01-1970 00:00:00',
|
||||
'estado' => $status,
|
||||
'id_agente' => (int) $idAgent,
|
||||
'utimestamp' => 0,
|
||||
'status_changes' => 0,
|
||||
'last_status' => $status,
|
||||
'last_known_status' => $status
|
||||
));
|
||||
break;
|
||||
case "postgresql":
|
||||
$result = db_process_sql_insert ('tagente_estado',
|
||||
array ('id_agente_modulo' => $idModule,
|
||||
'datos' => 0,
|
||||
'timestamp' => null,
|
||||
'estado' => $status,
|
||||
'id_agente' => (int) $idAgent,
|
||||
'utimestamp' => 0,
|
||||
'status_changes' => 0,
|
||||
'last_status' => $status,
|
||||
'last_known_status' => $status
|
||||
));
|
||||
break;
|
||||
case "oracle":
|
||||
$result = db_process_sql_insert ('tagente_estado',
|
||||
array ('id_agente_modulo' => $idModule,
|
||||
'datos' => 0,
|
||||
'timestamp' => '#to_date(\'1970-01-01 00:00:00\', \'YYYY-MM-DD HH24:MI:SS\')',
|
||||
'estado' => $status,
|
||||
'id_agente' => (int) $idAgent,
|
||||
'utimestamp' => 0,
|
||||
'status_changes' => 0,
|
||||
'last_status' => $status,
|
||||
'last_known_status' => $status
|
||||
));
|
||||
break;
|
||||
}
|
||||
if ($result === false) {
|
||||
db_process_sql_delete ('tagente_modulo',
|
||||
array ('id_agente_modulo' => $idModule));
|
||||
returnError('error_synthetic_modules', 'Error Synthetic modules.');
|
||||
}
|
||||
else {
|
||||
db_process_sql ('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=' . (int)$idAgent);
|
||||
returnData('string', array('type' => 'string', 'data' => __('Synthetic module created ID: ' . $idModule)));
|
||||
}
|
||||
}
|
||||
|
||||
//enterprise
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1274,7 +1274,7 @@ function config_process_config () {
|
|||
}
|
||||
|
||||
if (!isset ($config['vc_refr'])) {
|
||||
config_update_value ('vc_refr', 60);
|
||||
config_update_value ('vc_refr', 300);
|
||||
}
|
||||
|
||||
if (!isset($config['agent_size_text_small'])) {
|
||||
|
|
|
@ -22,7 +22,7 @@ include_once($config['homedir'] . "/include/functions_db.php");
|
|||
function cron_update_module_interval ($module_id, $cron) {
|
||||
|
||||
// Check for a valid cron
|
||||
if ($cron == '' || $cron == '* * * * *') {
|
||||
if (!cron_check_syntax($cron)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -160,4 +160,10 @@ function cron_next_execution_date ($cron, $cur_time = false) {
|
|||
return $cur_time + SECONDS_5MINUTES;
|
||||
}
|
||||
|
||||
// Check if cron is properly constructed
|
||||
function cron_check_syntax($cron) {
|
||||
|
||||
return preg_match("/^[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*]$/", $cron);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1009,7 +1009,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
if ($date == 0)
|
||||
$date = get_system_time();
|
||||
$datelimit = $date - $period;
|
||||
$search_in_history_db = db_search_in_history_db($datelimit);
|
||||
|
||||
$resolution = $config['graph_res'] * 50; //Number of points of the graph
|
||||
$interval = (int) ($period / $resolution);
|
||||
|
||||
|
@ -1079,16 +1079,36 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
|
||||
// Calculate data for each module
|
||||
for ($i = 0; $i < $module_number; $i++) {
|
||||
// If its a projection graph, first module will be data and second will be the projection
|
||||
$automatic_custom_graph_meta = false;
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[$i])) {
|
||||
$server = metaconsole_get_connection_by_id ($module_list[$i]['server']);
|
||||
metaconsole_connect($server);
|
||||
$automatic_custom_graph_meta = true;
|
||||
}
|
||||
}
|
||||
|
||||
$search_in_history_db = db_search_in_history_db($datelimit);
|
||||
|
||||
// If its a projection graph,
|
||||
// first module will be data and second will be the projection
|
||||
if ($projection != false && $i != 0) {
|
||||
$agent_module_id = $module_list[0];
|
||||
if ($automatic_custom_graph_meta)
|
||||
$agent_module_id = $module_list[0]['module'];
|
||||
else
|
||||
$agent_module_id = $module_list[0];
|
||||
|
||||
$id_module_type = modules_get_agentmodule_type ($agent_module_id);
|
||||
$module_type = modules_get_moduletype_name ($id_module_type);
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
}
|
||||
else {
|
||||
$agent_module_id = $module_list[$i];
|
||||
if ($automatic_custom_graph_meta)
|
||||
$agent_module_id = $module_list[$i]['module'];
|
||||
else
|
||||
$agent_module_id = $module_list[$i];
|
||||
|
||||
|
||||
$id_module_type = modules_get_agentmodule_type ($agent_module_id);
|
||||
$module_type = modules_get_moduletype_name ($id_module_type);
|
||||
|
@ -1365,6 +1385,13 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
//unset($graph_values[$i]);
|
||||
|
||||
//$graph_values[$i] = $graph_values[$i];
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[0])) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$temp = array();
|
||||
|
@ -1372,7 +1399,24 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
switch ($stacked) {
|
||||
case CUSTOM_GRAPH_BULLET_CHART:
|
||||
$datelimit = $date - $period;
|
||||
foreach ($module_list as $module) {
|
||||
foreach ($module_list as $module_item) {
|
||||
$automatic_custom_graph_meta = false;
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[$i])) {
|
||||
$server = metaconsole_get_connection_by_id ($module_item['server']);
|
||||
metaconsole_connect($server);
|
||||
$automatic_custom_graph_meta = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($automatic_custom_graph_meta)
|
||||
$module = $module_item['module'];
|
||||
else
|
||||
$module = $module_item;
|
||||
|
||||
$search_in_history_db = db_search_in_history_db($datelimit);
|
||||
|
||||
$temp[$module] = modules_get_agentmodule($module);
|
||||
$temp_data = db_get_value_sql('SELECT datos
|
||||
FROM tagente_datos
|
||||
|
@ -1396,6 +1440,13 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
$temp[$module]['max'] = reporting_get_agentmodule_data_max($module,$period,$date);
|
||||
$temp[$module]['min'] = reporting_get_agentmodule_data_min($module,$period,$date);
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[0])) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1404,7 +1455,23 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
$datelimit = $date - $period;
|
||||
|
||||
$label = '';
|
||||
foreach ($module_list as $module) {
|
||||
foreach ($module_list as $module_item) {
|
||||
$automatic_custom_graph_meta = false;
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[$i])) {
|
||||
$server = metaconsole_get_connection_by_id ($module_item['server']);
|
||||
metaconsole_connect($server);
|
||||
$automatic_custom_graph_meta = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($automatic_custom_graph_meta)
|
||||
$module = $module_item['module'];
|
||||
else
|
||||
$module = $module_item;
|
||||
|
||||
|
||||
$module_data = modules_get_agentmodule($module);
|
||||
$temp_data = db_get_value_sql('SELECT datos
|
||||
FROM tagente_datos
|
||||
|
@ -1421,12 +1488,31 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
$label = $agent_name . " - " .$module_data['nombre'];
|
||||
$temp[$label]['g'] = round($temp_data,4);
|
||||
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[0])) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case CUSTOM_GRAPH_PIE:
|
||||
$datelimit = $date - $period;
|
||||
$total_modules = 0;
|
||||
foreach ($module_list as $module) {
|
||||
foreach ($module_list as $module_item) {
|
||||
$automatic_custom_graph_meta = false;
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[$i])) {
|
||||
$server = metaconsole_get_connection_by_id ($module_item['server']);
|
||||
metaconsole_connect($server);
|
||||
$automatic_custom_graph_meta = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data_module = modules_get_agentmodule($module);
|
||||
$temp_data = db_get_value_sql('SELECT datos
|
||||
FROM tagente_datos
|
||||
|
@ -1450,15 +1536,35 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
$label = $data_module['nombre'];
|
||||
|
||||
$label = io_safe_output($label);
|
||||
$temp[$label] = array('value'=>$value,
|
||||
'unit'=>$data_module['unit']);
|
||||
$temp[$label] = array(
|
||||
'value'=>$value,
|
||||
'unit'=>$data_module['unit']);
|
||||
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[0])) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
}
|
||||
$temp['total_modules'] = $total_modules;
|
||||
break;
|
||||
case CUSTOM_GRAPH_GAUGE:
|
||||
$datelimit = $date - $period;
|
||||
$i = 0;
|
||||
foreach ($module_list as $module) {
|
||||
foreach ($module_list as $module_item) {
|
||||
$automatic_custom_graph_meta = false;
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[$i])) {
|
||||
$server = metaconsole_get_connection_by_id ($module_item['server']);
|
||||
metaconsole_connect($server);
|
||||
$automatic_custom_graph_meta = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$temp[$module] = modules_get_agentmodule($module);
|
||||
$temp_data = db_get_value_sql('SELECT datos
|
||||
FROM tagente_datos
|
||||
|
@ -1494,6 +1600,14 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
}
|
||||
$temp[$module]['gauge'] = "gauge_" . $i;
|
||||
$i++;
|
||||
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
// Automatic custom graph from the report template in metaconsole
|
||||
if (is_array($module_list[0])) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
include_once ("include/functions_groups.php");
|
||||
include_once ("include/functions_tags.php");
|
||||
include_once ($config['homedir'] . "/include/functions_groups.php");
|
||||
include_once ($config['homedir'] . "/include/functions_tags.php");
|
||||
|
||||
function groupview_get_all_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $agent_filter = array(), $module_filter = array()) {
|
||||
global $config;
|
||||
|
@ -29,6 +29,14 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
if ($user_strict) { //Remove groups with tags
|
||||
$groups_without_tags[$group] = $group;
|
||||
}
|
||||
$user_groups[$group] = groups_get_name($group);
|
||||
if ($tags != '') {
|
||||
$tags_group = explode(',', $tags);
|
||||
|
||||
foreach ($tags_group as $tag) {
|
||||
$user_tags[$tag] = tags_get_name($tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($user_strict) {
|
||||
|
@ -39,31 +47,61 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
}
|
||||
|
||||
if (!empty($user_groups_ids)) {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
break;
|
||||
case "postgresql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
case "oracle":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
if (is_metaconsole()) {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0)
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
break;
|
||||
case "postgresql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
case "oracle":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
break;
|
||||
case "postgresql":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
case "oracle":
|
||||
$list_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,6 +113,12 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
$list[$group['id_grupo']]['_monitors_unknown_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = 0;
|
||||
$list[$group['id_grupo']]['_total_agents_'] = 0;
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = 0;
|
||||
}
|
||||
if ($list_groups == false) {
|
||||
$list_groups = array();
|
||||
|
@ -108,7 +152,7 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
||||
// Calculate not_normal monitors
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
||||
|
||||
|
@ -204,55 +248,113 @@ function groupview_get_all_data ($id_user = false, $user_strict = false, $acltag
|
|||
$list["_server_sanity_"] = format_numeric (100 - $list["_module_sanity_"], 1);
|
||||
}
|
||||
else {
|
||||
foreach ($list_groups as $group) {
|
||||
$group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
||||
SUM(critical_count) AS _monitors_critical_,
|
||||
SUM(normal_count) AS _monitors_ok_,
|
||||
SUM(unknown_count) AS _monitors_unknown_,
|
||||
SUM(notinit_count) AS _monitors_not_init_,
|
||||
SUM(fired_count) AS _monitors_alerts_fired_,
|
||||
COUNT(*) AS _total_agents_, id_grupo, intervalo,
|
||||
ultimo_contacto, disabled
|
||||
FROM tagente WHERE id_grupo = " . $group['id_grupo'] . " AND disabled = 0 GROUP BY id_grupo");
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
||||
if ($user_strict) {
|
||||
$i = 1;
|
||||
foreach ($user_tags as $group_id => $tag_name) {
|
||||
$id = db_get_value('id_tag', 'ttag', 'name', $tag_name);
|
||||
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_'];
|
||||
$list[$i]['_id_'] = $id;
|
||||
$list[$i]['_name_'] = $tag_name;
|
||||
$list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;'));
|
||||
$list[$i]['_is_tag_'] = 1;
|
||||
|
||||
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
||||
$list[$i]['_total_agents_'] = (int) tags_get_total_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_unknown_'] = (int) tags_get_unknown_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_not_init_'] = (int) tags_get_not_init_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_monitors_ok_'] = (int) tags_get_normal_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_critical_'] = (int) tags_get_critical_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_warning_'] = (int) tags_get_warning_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_not_init_'] = (int) tags_get_not_init_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_unknown_'] = (int) tags_get_unknown_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags);
|
||||
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
||||
// Calculate not_normal monitors
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
||||
|
||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
||||
|
||||
if (($group['id_grupo'] != 0) && ($total_agents > 0)) {
|
||||
$agents = db_get_all_rows_sql("SELECT warning_count,
|
||||
critical_count,
|
||||
normal_count,
|
||||
unknown_count,
|
||||
notinit_count,
|
||||
fired_count,
|
||||
disabled
|
||||
FROM tagente
|
||||
WHERE id_grupo = " . $group['id_grupo'] );
|
||||
foreach ($agents as $agent) {
|
||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
||||
if ($agent['unknown_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] += 1;
|
||||
}
|
||||
if (! defined ('METACONSOLE')) {
|
||||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
}
|
||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0) && ($agent['unknown_count'] == 0)) {
|
||||
if ($agent['notinit_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] += 1;
|
||||
}
|
||||
else {
|
||||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($list_groups as $group) {
|
||||
$agent_not_init = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_NOT_INIT),
|
||||
array ('COUNT(*) as total'), 'AR', false);
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = isset ($agent_not_init[0]['total']) ? $agent_not_init[0]['total'] : 0;
|
||||
$agent_unknown = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_UNKNOWN),
|
||||
array ('COUNT(*) as total'), 'AR', false);
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0;
|
||||
$agent_total = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo']),
|
||||
array ('COUNT(*) as total'), 'AR', false);
|
||||
$list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = groupview_monitor_fired_alerts ($group['id_grupo'], $user_strict,array($group['id_grupo']));
|
||||
$result_list = db_get_all_rows_sql("SELECT COUNT(*) as contado, estado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp > 0
|
||||
GROUP BY estado");
|
||||
if ($result_list) {
|
||||
foreach ($result_list as $result) {
|
||||
switch ($result['estado']) {
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$result['contado'];
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$result['contado'];
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$result['contado'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result_normal = db_get_row_sql("SELECT COUNT(*) as contado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.estado = 0
|
||||
AND (tae.utimestamp > 0 OR tam.id_tipo_modulo IN(21,22,23,100))
|
||||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = isset ($result_normal['contado']) ? $result_normal['contado'] : 0;
|
||||
|
||||
$result_not_init = db_get_row_sql("SELECT COUNT(*) as contado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp = 0
|
||||
AND tae.estado IN (".AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT." )
|
||||
AND tam.id_tipo_modulo NOT IN (21,22,23,100)
|
||||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = isset ($result_not_init['contado']) ? $result_not_init['contado'] : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -460,9 +562,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
$groups_without_tags = array();
|
||||
foreach ($acltags as $group => $tags) {
|
||||
if ($user_strict) { //Remove groups with tags
|
||||
if ($tags == '') {
|
||||
$groups_without_tags[$group] = $group;
|
||||
}
|
||||
$groups_without_tags[$group] = $group;
|
||||
}
|
||||
$user_groups[$group] = groups_get_name($group);
|
||||
if ($tags != '') {
|
||||
|
@ -474,14 +574,16 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
}
|
||||
}
|
||||
|
||||
$user_groups_ids = '0,';
|
||||
if (!$user_strict)
|
||||
$acltags[0] = 0;
|
||||
|
||||
if ($user_strict) {
|
||||
$user_groups_ids .= implode(',', array_keys($groups_without_tags));
|
||||
$user_groups_ids = implode(',', array_keys($groups_without_tags));
|
||||
}
|
||||
else {
|
||||
$user_groups_ids .= implode(',', array_keys($acltags));
|
||||
$user_groups_ids = implode(',', array_keys($acltags));
|
||||
}
|
||||
|
||||
if (!empty($user_groups_ids)) {
|
||||
if (is_metaconsole()) {
|
||||
switch ($config["dbtype"]) {
|
||||
|
@ -490,7 +592,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent)
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0)
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
break;
|
||||
case "postgresql":
|
||||
|
@ -498,7 +600,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent)
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
case "oracle":
|
||||
|
@ -506,7 +608,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $user_groups_ids . ")
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent)
|
||||
AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0)
|
||||
ORDER BY nombre ASC");
|
||||
break;
|
||||
}
|
||||
|
@ -540,71 +642,83 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
}
|
||||
}
|
||||
}
|
||||
//Add the group "All" at first
|
||||
$group_all = array('id_grupo'=>0, 'nombre'=>'All', 'icon'=>'', 'parent'=>'', 'propagate'=>0, 'disabled'=>0,
|
||||
'custom_id'=>'', 'id_skin'=>0, 'description'=>'', 'contact'=>'', 'other'=>'', 'password'=>'');
|
||||
array_unshift($list_groups, $group_all);
|
||||
//Takes the parents even without agents, first ids
|
||||
$fathers_id = '';
|
||||
$list_father_groups = array();
|
||||
foreach ($list_groups as $group) {
|
||||
if ($group['parent'] != '') {
|
||||
$grup = $group['parent'];
|
||||
while ($grup != 0) {
|
||||
$recursive_fathers = db_get_row_sql ("SELECT parent FROM tgrupo
|
||||
WHERE id_grupo = " . $grup);
|
||||
$grup = $recursive_fathers['parent'];
|
||||
if (!strpos($fathers_id, $grup)) {
|
||||
$fathers_id .= ',' . $grup;
|
||||
|
||||
if (!$user_strict) {
|
||||
//Add the group "All" at first
|
||||
$group_all = array('id_grupo'=>0, 'nombre'=>'All', 'icon'=>'', 'parent'=>'', 'propagate'=>0, 'disabled'=>0,
|
||||
'custom_id'=>'', 'id_skin'=>0, 'description'=>'', 'contact'=>'', 'other'=>'', 'password'=>'');
|
||||
array_unshift($list_groups, $group_all);
|
||||
//Takes the parents even without agents, first ids
|
||||
$fathers_id = '';
|
||||
$list_father_groups = array();
|
||||
foreach ($list_groups as $group) {
|
||||
if ($group['parent'] != '') {
|
||||
$grup = $group['parent'];
|
||||
while ($grup != 0) {
|
||||
$recursive_fathers = db_get_row_sql ("SELECT parent FROM tgrupo
|
||||
WHERE id_grupo = " . $grup);
|
||||
$grup = $recursive_fathers['parent'];
|
||||
if (!strpos($fathers_id, $grup)) {
|
||||
$fathers_id .= ',' . $grup;
|
||||
}
|
||||
}
|
||||
if (!strpos($fathers_id, $group['parent'])) {
|
||||
$fathers_id .= ',' . $group['parent'];
|
||||
}
|
||||
}
|
||||
if (!strpos($fathers_id, $group['parent'])) {
|
||||
$fathers_id .= ',' . $group['parent'];
|
||||
}
|
||||
//Eliminate the first comma
|
||||
$fathers_id = substr($fathers_id, 1);
|
||||
//Takes the parents even without agents, complete groups
|
||||
if ($fathers_id) {
|
||||
$list_father_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $fathers_id . ")
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
if (!empty($list_father_groups)) {
|
||||
//Merges the arrays and eliminates the duplicates groups
|
||||
$list_groups = array_merge($list_groups, $list_father_groups);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Eliminate the first comma
|
||||
$fathers_id = substr($fathers_id, 1);
|
||||
//Takes the parents even without agents, complete groups
|
||||
$list_father_groups = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE id_grupo IN (" . $fathers_id . ")
|
||||
ORDER BY nombre COLLATE utf8_general_ci ASC");
|
||||
if (!empty($list_father_groups)) {
|
||||
//Merges the arrays and eliminates the duplicates groups
|
||||
$list_groups = array_merge($list_groups, $list_father_groups);
|
||||
}
|
||||
$list_groups = groupview_array_unique_multidim($list_groups, 'id_grupo');
|
||||
//Order groups (Father-children)
|
||||
$ordered_groups = groupview_order_groups_for_parents($list_groups);
|
||||
$ordered_ids = array();
|
||||
$ordered_ids = groupview_order_group_ids($ordered_groups, $ordered_ids);
|
||||
$final_list = array();
|
||||
array_push($final_list, $group_all);
|
||||
$list_groups = groupview_array_unique_multidim($list_groups, 'id_grupo');
|
||||
//Order groups (Father-children)
|
||||
$ordered_groups = groupview_order_groups_for_parents($list_groups);
|
||||
$ordered_ids = array();
|
||||
$ordered_ids = groupview_order_group_ids($ordered_groups, $ordered_ids);
|
||||
$final_list = array();
|
||||
array_push($final_list, $group_all);
|
||||
|
||||
foreach ($ordered_ids as $key) {
|
||||
if ($key == 'All') {
|
||||
continue;
|
||||
foreach ($ordered_ids as $key) {
|
||||
if ($key == 'All') {
|
||||
continue;
|
||||
}
|
||||
$complete_group = db_get_row_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE nombre = '" . $key . "'");
|
||||
array_push($final_list, $complete_group);
|
||||
}
|
||||
$complete_group = db_get_row_sql("
|
||||
SELECT *
|
||||
FROM tgrupo
|
||||
WHERE nombre = '" . $key . "'");
|
||||
array_push($final_list, $complete_group);
|
||||
}
|
||||
|
||||
$list_groups = $final_list;
|
||||
$list_groups = $final_list;
|
||||
}
|
||||
|
||||
$list = array();
|
||||
foreach ($list_groups as $group) {
|
||||
$list[$group['id_grupo']]['_name_'] = $group['nombre'];
|
||||
$list[$group['id_grupo']]['_id_'] = $group['id_grupo'];
|
||||
$list[$group['id_grupo']]['icon'] = $group['icon'];
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = 0;
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = 0;
|
||||
$list[$group['id_grupo']]['_total_agents_'] = 0;
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = 0;
|
||||
}
|
||||
|
||||
if ($list_groups == false) {
|
||||
|
@ -634,6 +748,9 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
||||
if ($group['icon'])
|
||||
$list[$group['id_grupo']]["_iconImg_"] = html_print_image ("images/".$group['icon'].".png", true, array ("style" => 'vertical-align: middle;'));
|
||||
|
||||
// Calculate not_normal monitors
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
||||
|
||||
|
@ -731,102 +848,117 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
$list["_server_sanity_"] = format_numeric (100 - $list["_module_sanity_"], 1);
|
||||
}
|
||||
else {
|
||||
foreach ($list_groups as $group) {
|
||||
$group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
||||
SUM(critical_count) AS _monitors_critical_,
|
||||
SUM(normal_count) AS _monitors_ok_,
|
||||
SUM(unknown_count) AS _monitors_unknown_,
|
||||
SUM(notinit_count) AS _monitors_not_init_,
|
||||
SUM(fired_count) AS _monitors_alerts_fired_,
|
||||
COUNT(*) AS _total_agents_, id_grupo, intervalo,
|
||||
ultimo_contacto, disabled
|
||||
FROM tagente WHERE id_grupo = " . $group['id_grupo'] . " AND disabled = 0 GROUP BY id_grupo");
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_'];
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_'];
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_'];
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_'];
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_'];
|
||||
if (!$user_strict) {
|
||||
foreach ($list_groups as $group) {
|
||||
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_'];
|
||||
|
||||
$list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_'];
|
||||
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
||||
// Calculate not_normal monitors
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
||||
|
||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
||||
|
||||
if (($group['id_grupo'] != 0) && ($total_agents > 0)) {
|
||||
$agents = db_get_all_rows_sql("SELECT warning_count,
|
||||
critical_count,
|
||||
normal_count,
|
||||
unknown_count,
|
||||
notinit_count,
|
||||
fired_count,
|
||||
disabled
|
||||
FROM tagente
|
||||
WHERE id_grupo = " . $group['id_grupo'] );
|
||||
foreach ($agents as $agent) {
|
||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) {
|
||||
if ($agent['unknown_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] += 1;
|
||||
}
|
||||
}
|
||||
if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0) && ($agent['unknown_count'] == 0)) {
|
||||
if ($agent['notinit_count'] > 0) {
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] += 1;
|
||||
$agent_not_init = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_NOT_INIT),
|
||||
array ('COUNT(*) as total'), 'AR', false);
|
||||
$list[$group['id_grupo']]['_agents_not_init_'] = isset ($agent_not_init[0]['total']) ? $agent_not_init[0]['total'] : 0;
|
||||
$agent_unknown = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo'],
|
||||
'status' => AGENT_STATUS_UNKNOWN),
|
||||
array ('COUNT(*) as total'), 'AR', false);
|
||||
$list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0;
|
||||
$agent_total = agents_get_agents(array (
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $group['id_grupo']),
|
||||
array ('COUNT(*) as total'), 'AR', false);
|
||||
$list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0;
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]['_monitors_alerts_fired_'] = groupview_monitor_fired_alerts ($group['id_grupo'], $user_strict,$group['id_grupo']);
|
||||
$result_list = db_get_all_rows_sql("SELECT COUNT(*) as contado, estado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp > 0
|
||||
GROUP BY estado");
|
||||
if ($result_list) {
|
||||
foreach ($result_list as $result) {
|
||||
switch ($result['estado']) {
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = (int)$result['contado'];
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = (int)$result['contado'];
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = (int)$result['contado'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result_normal = db_get_row_sql("SELECT COUNT(*) as contado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.estado = 0
|
||||
AND (tae.utimestamp > 0 OR tam.id_tipo_modulo IN(21,22,23,100))
|
||||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_ok_'] = isset ($result_normal['contado']) ? $result_normal['contado'] : 0;
|
||||
|
||||
$result_not_init = db_get_row_sql("SELECT COUNT(*) as contado
|
||||
FROM tagente_estado tae INNER JOIN tagente ta
|
||||
ON tae.id_agente = ta.id_agente
|
||||
AND ta.disabled = 0
|
||||
AND ta.id_grupo = " . $group['id_grupo'] . "
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
AND tam.disabled = 0
|
||||
WHERE tae.utimestamp = 0 AND
|
||||
tae.estado IN (".AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT." )
|
||||
AND tam.id_tipo_modulo NOT IN (21,22,23,100)
|
||||
GROUP BY estado");
|
||||
$list[$group['id_grupo']]['_monitors_not_init_'] = isset ($result_not_init['contado']) ? $result_not_init['contado'] : 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$i = 1;
|
||||
foreach ($user_tags as $group_id => $tag_name) {
|
||||
$id = db_get_value('id_tag', 'ttag', 'name', $tag_name);
|
||||
|
||||
}
|
||||
$list[$i]['_id_'] = $id;
|
||||
$list[$i]['_name_'] = $tag_name;
|
||||
$list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;'));
|
||||
$list[$i]['_is_tag_'] = 1;
|
||||
|
||||
if ($user_strict) {
|
||||
$i = 0;
|
||||
foreach ($user_tags as $group_id => $tag_name) {
|
||||
$id = db_get_value('id_tag', 'ttag', 'name', $tag_name);
|
||||
$list[$i]['_total_agents_'] = (int) tags_get_total_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_unknown_'] = (int) tags_get_unknown_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_not_init_'] = (int) tags_get_not_init_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_monitors_ok_'] = (int) tags_get_normal_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_critical_'] = (int) tags_get_critical_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_warning_'] = (int) tags_get_warning_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_not_init_'] = (int) tags_get_not_init_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_unknown_'] = (int) tags_get_unknown_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags);
|
||||
|
||||
$list[$i]['_id_'] = $id;
|
||||
$list[$i]['_name_'] = $tag_name;
|
||||
$list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;'));
|
||||
$list[$i]['_is_tag_'] = 1;
|
||||
|
||||
$list[$i]['_total_agents_'] = (int) tags_get_total_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_unknown_'] = (int) tags_get_unknown_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_agents_not_init_'] = (int) tags_get_not_init_agents ($id, $acltags, $agent_filter, $module_filter, $config["realtimestats"]);
|
||||
$list[$i]['_monitors_ok_'] = (int) tags_get_normal_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_critical_'] = (int) tags_get_critical_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_warning_'] = (int) tags_get_warning_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_not_init_'] = (int) tags_get_not_init_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_unknown_'] = (int) tags_get_unknown_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags);
|
||||
|
||||
if ($returnAllGroup) {
|
||||
$list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_'];
|
||||
$list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_'];
|
||||
$list[0]['_total_agents_'] += $list[$i]['_total_agents_'];
|
||||
$list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_'];
|
||||
$list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_'];
|
||||
$list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_'];
|
||||
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
|
||||
$list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_'];
|
||||
$list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_'];
|
||||
}
|
||||
if (! defined ('METACONSOLE')) {
|
||||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
if (! defined ('METACONSOLE')) {
|
||||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
else {
|
||||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -843,6 +975,7 @@ function groupview_order_groups_for_parents ($view_groups) {
|
|||
}
|
||||
// Build the group hierarchy
|
||||
foreach ($groups as $id => $group) {
|
||||
$groups[$id]['have_parent'] = false;
|
||||
if (!isset($groups[$id]['parent']))
|
||||
continue;
|
||||
$parent = $groups[$id]['parent'];
|
||||
|
|
|
@ -796,10 +796,11 @@ function html_print_extended_select_for_time ($name, $selected = '',
|
|||
* @param string Run month.
|
||||
* @param string Run day of the week.
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param bool Print cron grayed
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
function html_print_extended_select_for_cron ($hour = '*', $minute = '*', $mday = '*', $month = '*', $wday = '*', $return = false) {
|
||||
function html_print_extended_select_for_cron ($hour = '*', $minute = '*', $mday = '*', $month = '*', $wday = '*', $return = false, $disabled = false) {
|
||||
|
||||
# Hours
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
|
@ -842,11 +843,11 @@ function html_print_extended_select_for_cron ($hour = '*', $minute = '*', $mday
|
|||
$table->head[3] = __('Month');
|
||||
$table->head[4] = __('Week day');
|
||||
|
||||
$table->data[0][0] = html_print_select ($hours, 'hour', $hour, '', __('Any'), '*', true, false, false);
|
||||
$table->data[0][1] = html_print_select ($minutes, 'minute', $minute, '', __('Any'), '*', true, false, false);
|
||||
$table->data[0][2] = html_print_select ($mdays, 'mday', $mday, '', __('Any'), '*', true, false, false);
|
||||
$table->data[0][3] = html_print_select ($months, 'month', $month, '', __('Any'), '*', true, false, false);
|
||||
$table->data[0][4] = html_print_select ($wdays, 'wday', $wday, '', __('Any'), '*', true, false, false);
|
||||
$table->data[0][0] = html_print_select ($hours, 'hour', $hour, '', __('Any'), '*', true, false, false,'',$disabled);
|
||||
$table->data[0][1] = html_print_select ($minutes, 'minute', $minute, '', __('Any'), '*', true, false, false,'',$disabled);
|
||||
$table->data[0][2] = html_print_select ($mdays, 'mday', $mday, '', __('Any'), '*', true, false, false,'',$disabled);
|
||||
$table->data[0][3] = html_print_select ($months, 'month', $month, '', __('Any'), '*', true, false, false,'',$disabled);
|
||||
$table->data[0][4] = html_print_select ($wdays, 'wday', $wday, '', __('Any'), '*', true, false, false,'',$disabled);
|
||||
|
||||
return html_print_table ($table, $return);
|
||||
}
|
||||
|
|
|
@ -160,14 +160,22 @@ function reporting_make_reporting_data($report = null, $id_report,
|
|||
$content);
|
||||
break;
|
||||
case 'custom_graph':
|
||||
case 'automatic_custom_graph':
|
||||
$report['contents'][] =
|
||||
reporting_custom_graph(
|
||||
$report,
|
||||
$content,
|
||||
$type,
|
||||
$force_width_chart,
|
||||
$force_height_chart);
|
||||
$force_height_chart, 'custom_graph');
|
||||
break;
|
||||
case 'automatic_graph':
|
||||
$report['contents'][] =
|
||||
reporting_custom_graph(
|
||||
$report,
|
||||
$content,
|
||||
$type,
|
||||
$force_width_chart,
|
||||
$force_height_chart, 'automatic_graph');
|
||||
break;
|
||||
case 'text':
|
||||
$report['contents'][] = reporting_text(
|
||||
|
@ -4272,18 +4280,23 @@ function reporting_general($report, $content) {
|
|||
}
|
||||
|
||||
function reporting_custom_graph($report, $content, $type = 'dinamic',
|
||||
$force_width_chart = null, $force_height_chart = null) {
|
||||
$force_width_chart = null, $force_height_chart = null, $type_report = "custom_graph") {
|
||||
|
||||
global $config;
|
||||
|
||||
require_once ($config["homedir"] . '/include/functions_graph.php');
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
$id_meta = metaconsole_get_id_server($content["server_name"]);
|
||||
|
||||
|
||||
$server = metaconsole_get_connection_by_id ($id_meta);
|
||||
metaconsole_connect($server);
|
||||
if ($type_report == 'automatic_graph') {
|
||||
// Do none
|
||||
}
|
||||
else {
|
||||
if ($config['metaconsole']) {
|
||||
$id_meta = metaconsole_get_id_server($content["server_name"]);
|
||||
|
||||
|
||||
$server = metaconsole_get_connection_by_id ($id_meta);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
}
|
||||
|
||||
$graph = db_get_row ("tgraph", "id_graph", $content['id_gs']);
|
||||
|
@ -4310,7 +4323,15 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
|
|||
$graphs = array();
|
||||
|
||||
foreach ($graphs as $graph_item) {
|
||||
array_push ($modules, $graph_item['id_agent_module']);
|
||||
if ($type_report == 'automatic_graph') {
|
||||
array_push ($modules, array(
|
||||
'module' => $graph_item['id_agent_module'],
|
||||
'server' => $graph_item['id_server']));
|
||||
}
|
||||
else {
|
||||
array_push ($modules, $graph_item['id_agent_module']);
|
||||
}
|
||||
|
||||
array_push ($weights, $graph_item["weight"]);
|
||||
}
|
||||
|
||||
|
@ -4344,8 +4365,13 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
|
|||
break;
|
||||
}
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
metaconsole_restore_db();
|
||||
if ($type_report == 'automatic_graph') {
|
||||
// Do none
|
||||
}
|
||||
else {
|
||||
if ($config['metaconsole']) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
|
|
|
@ -514,7 +514,7 @@ function reports_get_report_types ($template = false, $not_editor = false) {
|
|||
$types['sql_graph_hbar'] = array('optgroup' => __('Graphs'),
|
||||
'name' => __('SQL horizonal bar graph'));
|
||||
}
|
||||
if ($template && !defined('METACONSOLE')) {
|
||||
if ($template) {
|
||||
$types['automatic_graph'] = array('optgroup' => __('Graphs'),
|
||||
'name' => __('Automatic combined Graph'));
|
||||
}
|
||||
|
|
|
@ -467,25 +467,27 @@ function servers_get_info ($id_server = -1) {
|
|||
// Get total exported modules
|
||||
$server["modules_total"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente");
|
||||
|
||||
$interval_esc = db_escape_key_identifier ("interval");
|
||||
|
||||
// Get the module lag
|
||||
$server["module_lag"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) AS module_lag
|
||||
FROM tagente, tagent_module_inventory
|
||||
WHERE utimestamp > 0
|
||||
AND tagent_module_inventory.id_agente = tagente.id_agente
|
||||
AND tagent_module_inventory.interval > 0
|
||||
AND tagent_module_inventory." . $interval_esc . " > 0
|
||||
AND tagente.server_name = '" . $server["name"] . "'
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.interval * 10)
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.interval");
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory." . $interval_esc . " * 10)
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory." . $interval_esc);
|
||||
|
||||
// Get the lag
|
||||
$server["lag"] = db_get_sql ("SELECT AVG(UNIX_TIMESTAMP() - utimestamp - tagent_module_inventory.interval)
|
||||
$server["lag"] = db_get_sql ("SELECT AVG(UNIX_TIMESTAMP() - utimestamp - tagent_module_inventory." . $interval_esc . ")
|
||||
FROM tagente, tagent_module_inventory
|
||||
WHERE utimestamp > 0
|
||||
AND tagent_module_inventory.id_agente = tagente.id_agente
|
||||
AND tagent_module_inventory.interval > 0
|
||||
AND tagent_module_inventory." . $interval_esc . " > 0
|
||||
AND tagente.server_name = '" . $server["name"] . "'
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.interval * 10)
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.interval");
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory." . $interval_esc . " * 10)
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory." . $interval_esc);
|
||||
// Export server
|
||||
}
|
||||
else if ($server["server_type"] == SERVER_TYPE_EXPORT) {
|
||||
|
|
|
@ -488,7 +488,12 @@ var TreeController = {
|
|||
|
||||
// Load the status counters
|
||||
var hasCounters = _processNodeCounters($content, element.counters, element.type);
|
||||
|
||||
//Don't show empty groups
|
||||
if (element.type == 'agent') {
|
||||
if (!hasCounters) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If exist the detail container, show the data
|
||||
if (typeof controller.detailRecipient !== 'undefined') {
|
||||
if (element.type == 'agent' || element.type == 'module') {
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '6.1dev';
|
||||
$build = '160126';
|
||||
$build = '160210';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
@ -702,18 +702,35 @@ function install_step3() {
|
|||
<td>DB Name (pandora by default)<br>
|
||||
<input class='login' type='text' name='dbname' value='pandora' size=20>
|
||||
|
||||
<tr><td valign=top>
|
||||
<tr>";
|
||||
if ($_SERVER['SERVER_ADDR'] == 'localhost' || $_SERVER['SERVER_ADDR'] == '127.0.0.1') {
|
||||
|
||||
echo "<td>DB Host Access<br>
|
||||
<span style='font-size: 9px'>Ignored if DB Hostname is localhost</span>
|
||||
<input class='login' type='text' name='dbgrant' value='" . $_SERVER['SERVER_ADDR'] . "' size=20>";
|
||||
} else {
|
||||
|
||||
echo "<td valign=top>
|
||||
Drop Database if exists<br>
|
||||
<input class='login' type='checkbox' name='drop' value=1>
|
||||
<input class='login' type='checkbox' name='drop' value=1>";
|
||||
}
|
||||
|
||||
|
||||
<td>Full path to HTTP publication directory<br>
|
||||
echo "<td>Full path to HTTP publication directory<br>
|
||||
<span style='font-size: 9px'>For example /var/www/pandora_console/</span>
|
||||
<br>
|
||||
<input class='login' type='text' name='path' style='width: 240px;'
|
||||
value='".dirname (__FILE__)."'>
|
||||
|
||||
<tr><td></td><td>URL path to Pandora FMS Console<br>
|
||||
<tr>";
|
||||
if ($_SERVER['SERVER_ADDR'] == 'localhost' || $_SERVER['SERVER_ADDR'] == '127.0.0.1') {
|
||||
echo "<td valign=top>
|
||||
Drop Database if exists<br>
|
||||
<input class='login' type='checkbox' name='drop' value=1>
|
||||
";
|
||||
} else {
|
||||
echo "<td>";
|
||||
}
|
||||
echo "<td>URL path to Pandora FMS Console<br>
|
||||
<span style='font-size: 9px'>For example '/pandora_console'</span>
|
||||
</br>
|
||||
<input class='login' type='text' name='url' style='width: 250px;'
|
||||
|
@ -750,6 +767,7 @@ function install_step4() {
|
|||
$dbname = "";
|
||||
$engine = "";
|
||||
$dbaction = "";
|
||||
$dbgrant = "";
|
||||
}
|
||||
else {
|
||||
$engine = $_POST['engine'];
|
||||
|
@ -757,6 +775,10 @@ function install_step4() {
|
|||
$dbuser = $_POST["user"];
|
||||
$dbhost = $_POST["host"];
|
||||
$dbaction = $_POST["db_action"];
|
||||
if (isset($_POST["dbgrant"]) && $_POST["dbgrant"] != "")
|
||||
$dbgrant = $_POST["dbgrant"];
|
||||
else
|
||||
$dbgrant = $_SERVER["SERVER_ADDR"];
|
||||
if (isset($_POST["drop"]))
|
||||
$dbdrop = $_POST["drop"];
|
||||
else
|
||||
|
@ -825,7 +847,7 @@ function install_step4() {
|
|||
$random_password = random_name (8);
|
||||
$host = 'localhost';
|
||||
if ($dbhost != 'localhost')
|
||||
$host = $_SERVER['SERVER_ADDR'];
|
||||
$host = $dbgrant;
|
||||
$step5 = mysql_query ("GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host
|
||||
IDENTIFIED BY '".$random_password."'");
|
||||
mysql_query ("FLUSH PRIVILEGES");
|
||||
|
|
|
@ -157,6 +157,7 @@ ui_toggle($html_toggle,
|
|||
var sort_rows = 'up';
|
||||
var filter_status = -1;
|
||||
var filter_text = "";
|
||||
reset_filter_modules ();
|
||||
|
||||
$(document).ready(function() {
|
||||
var parameters = {};
|
||||
|
|
|
@ -69,6 +69,16 @@ $strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_use
|
|||
|
||||
$all_data = groupview_status_modules_agents ($config['id_user'], $strict_user, 'AR', $strict_user);
|
||||
|
||||
$total_agentes = 0;
|
||||
$monitor_ok = 0;
|
||||
$monitor_warning = 0;
|
||||
$monitor_critical = 0;
|
||||
$monitor_unknown = 0;
|
||||
$monitor_not_init = 0;
|
||||
$agents_unknown = 0;
|
||||
$agents_notinit = 0;
|
||||
$all_alerts_fired = 0;
|
||||
|
||||
foreach ($all_data as $group_all_data) {
|
||||
$total_agentes += $group_all_data["_total_agents_"];
|
||||
$monitor_ok += $group_all_data["_monitors_ok_"];
|
||||
|
@ -76,7 +86,7 @@ foreach ($all_data as $group_all_data) {
|
|||
$monitor_critical += $group_all_data["_monitors_critical_"];
|
||||
$monitor_unknown += $group_all_data["_monitors_unknown_"];
|
||||
$monitor_not_init += $group_all_data["_monitors_not_init_"];
|
||||
|
||||
|
||||
$agents_unknown += $group_all_data["_agents_unknown_"];
|
||||
$agents_notinit += $group_all_data["_agents_not_init_"];
|
||||
|
||||
|
@ -154,7 +164,9 @@ if (!empty($result_groups)) {
|
|||
echo "<th width='10%' style='min-width: 60px;text-align:center;'>" . __("Critical") . "</th>";
|
||||
echo "<th width='10%' style='min-width: 60px;text-align:center;'>" . __("Alert fired") . "</th>";
|
||||
echo "</tr>";
|
||||
|
||||
$result_groups = array_slice($result_groups, $offset, $config['block_size']);
|
||||
|
||||
foreach ($result_groups as $data) {
|
||||
|
||||
$groups_id = $data["_id_"];
|
||||
|
@ -243,7 +255,7 @@ if (!empty($result_groups)) {
|
|||
$agent_counter = agents_get_group_agents($groups_id);
|
||||
echo $link . count($agent_counter) . "</a>";
|
||||
}
|
||||
if ($data["_total_agents_"] > 0) {
|
||||
if ($data["_total_agents_"] > 0 && $data["_id_"] != 0) {
|
||||
echo $link . $data["_total_agents_"] . "</a>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
@ -260,7 +272,7 @@ if (!empty($result_groups)) {
|
|||
if (($data["_id_"] == 0) && ($agents_unknown != 0)) {
|
||||
echo $link . $agents_unknown . "</a>";
|
||||
}
|
||||
if ($data["_agents_unknown_"] > 0) {
|
||||
if ($data["_agents_unknown_"] > 0 && ($data["_id_"] != 0)) {
|
||||
echo $link . $data["_agents_unknown_"] . "</a>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
@ -277,7 +289,7 @@ if (!empty($result_groups)) {
|
|||
if (($data["_id_"] == 0) && ($agents_notinit != 0)) {
|
||||
echo $link . $agents_notinit . "</a>";
|
||||
}
|
||||
if ($data["_agents_not_init_"] > 0) {
|
||||
if ($data["_agents_not_init_"] > 0 && ($data["_id_"] != 0)) {
|
||||
echo $link . $data["_agents_not_init_"] . "</a>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
@ -294,7 +306,7 @@ if (!empty($result_groups)) {
|
|||
if (($data["_id_"] == 0) && ($monitor_unknown != 0)) {
|
||||
echo $link . $monitor_unknown . "</a>";
|
||||
}
|
||||
if ($data["_monitors_unknown_"] > 0) {
|
||||
if ($data["_monitors_unknown_"] > 0 && ($data["_id_"] != 0)) {
|
||||
echo $link . $data["_monitors_unknown_"] . "</a>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
@ -311,7 +323,7 @@ if (!empty($result_groups)) {
|
|||
if (($data["_id_"] == 0) && ($monitor_not_init != 0)) {
|
||||
echo $link . $monitor_not_init . "</a>";
|
||||
}
|
||||
if ($data["_monitors_not_init_"] > 0) {
|
||||
if ($data["_monitors_not_init_"] > 0 && ($data["_id_"] != 0)) {
|
||||
echo $link . $data["_monitors_not_init_"] . "</a>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
@ -328,7 +340,7 @@ if (!empty($result_groups)) {
|
|||
if (($data["_id_"] == 0) && ($monitor_ok != 0)) {
|
||||
echo $link . $monitor_ok . "</a>";
|
||||
}
|
||||
if ($data["_monitors_ok_"] > 0) {
|
||||
if ($data["_monitors_ok_"] > 0 && ($data["_id_"] != 0)) {
|
||||
echo $link . $data["_monitors_ok_"] . "</a>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
@ -345,7 +357,7 @@ if (!empty($result_groups)) {
|
|||
if (($data["_id_"] == 0) && ($monitor_warning != 0)) {
|
||||
echo $link . $monitor_warning . "</a>";
|
||||
}
|
||||
if ($data["_monitors_warning_"] > 0) {
|
||||
if ($data["_monitors_warning_"] > 0 && ($data["_id_"] != 0)) {
|
||||
echo $link . $data["_monitors_warning_"] . "</a>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
@ -362,7 +374,7 @@ if (!empty($result_groups)) {
|
|||
if (($data["_id_"] == 0) && ($monitor_critical != 0)) {
|
||||
echo $link . $monitor_critical . "</a>";
|
||||
}
|
||||
if ($data["_monitors_critical_"] > 0) {
|
||||
if ($data["_monitors_critical_"] > 0 && ($data["_id_"] != 0)) {
|
||||
echo $link . $data["_monitors_critical_"] . "</a>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
@ -379,7 +391,7 @@ if (!empty($result_groups)) {
|
|||
if (($data["_id_"] == 0) && ($all_alerts_fired != 0)) {
|
||||
echo $link . $all_alerts_fired . "</a>";
|
||||
}
|
||||
if ($data["_monitors_alerts_fired_"] > 0) {
|
||||
if ($data["_monitors_alerts_fired_"] > 0 && ($data["_id_"] != 0)) {
|
||||
echo $link . $data["_monitors_alerts_fired_"] . "</a>";
|
||||
}
|
||||
echo '</td>';
|
||||
|
|
|
@ -140,16 +140,6 @@ if (check_acl ($config['id_user'], 0, "AR")) {
|
|||
"godmode/reporting/map_builder",
|
||||
"godmode/reporting/visual_console_builder");
|
||||
|
||||
if (!empty($config['vc_refr'])) {
|
||||
$sub["godmode/reporting/map_builder"]["refr"] = $config['vc_refr'];
|
||||
}
|
||||
else if (((int)get_parameter('refr', 0)) > 0) {
|
||||
$sub["godmode/reporting/map_builder"]["refr"] = (int)get_parameter('refr', 0);
|
||||
}
|
||||
else {
|
||||
$sub["godmode/reporting/map_builder"]["refr"] = 60;
|
||||
}
|
||||
|
||||
$layouts = db_get_all_rows_in_table ('tlayout', 'name');
|
||||
$sub2 = array ();
|
||||
|
||||
|
@ -248,7 +238,7 @@ if (check_acl ($config['id_user'], 0, "RR")) {
|
|||
$menu_operation["reporting"]["text"] = __('Reporting');
|
||||
$menu_operation["reporting"]["sec2"] = "godmode/reporting/reporting_builder";
|
||||
$menu_operation["reporting"]["id"] = "oper-reporting";
|
||||
$menu_operation["reporting"]["refr"] = 60;
|
||||
$menu_operation["reporting"]["refr"] = 300;
|
||||
|
||||
$sub = array ();
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ $vc_refr = false;
|
|||
if (isset($config['vc_refr']) and $config['vc_refr'] != 0)
|
||||
$view_refresh = $config['vc_refr'];
|
||||
else
|
||||
$view_refresh = '60';
|
||||
$view_refresh = '300';
|
||||
|
||||
// Get input parameter for layout id
|
||||
if (! $id_layout) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 6.1dev
|
||||
%define release 160126
|
||||
%define release 160210
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 6.1dev
|
||||
%define release 160126
|
||||
%define release 160210
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -65,7 +65,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 ('db_scheme_first_version','6.0orc');
|
||||
INSERT INTO tconfig (token, value) VALUES('db_scheme_version','6.1dev');
|
||||
INSERT INTO tconfig (token, value) VALUES('db_scheme_build','PD160126');
|
||||
INSERT INTO tconfig (token, value) VALUES('db_scheme_build','PD160210');
|
||||
INSERT INTO tconfig (token, value) VALUES ('show_unknown','0');
|
||||
INSERT INTO tconfig (token, value) VALUES ('show_lastalerts','1');
|
||||
INSERT INTO tconfig (token, value) VALUES ('style','pandora');
|
||||
|
|
|
@ -1194,6 +1194,7 @@ CREATE OR REPLACE TRIGGER tgraph_inc BEFORE INSERT ON tgraph REFERENCING NEW AS
|
|||
CREATE TABLE tgraph_source (
|
||||
id_gs NUMBER(10, 0) PRIMARY KEY,
|
||||
id_graph NUMBER(19, 0) DEFAULT 0,
|
||||
id_server NUMBER(19, 0) DEFAULT 0,
|
||||
id_agent_module NUMBER(19, 0) DEFAULT 0,
|
||||
weight BINARY_DOUBLE DEFAULT 0,
|
||||
label VARCHAR2(150) DEFAULT ''
|
||||
|
@ -2117,4 +2118,4 @@ CREATE TABLE IF NOT EXISTS trel_item (
|
|||
deleted NUMBER(1, 0) DEFAULT 0
|
||||
);
|
||||
CREATE SEQUENCE trel_item_s INCREMENT BY 1 START WITH 1;
|
||||
CREATE OR REPLACE TRIGGER trel_item_inc BEFORE INSERT ON trel_item REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT trel_item_s.nextval INTO :NEW.id FROM dual; END trel_item_inc;;
|
||||
CREATE OR REPLACE TRIGGER trel_item_inc BEFORE INSERT ON trel_item REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT trel_item_s.nextval INTO :NEW.id FROM dual; END trel_item_inc;;
|
||||
|
|
|
@ -984,9 +984,11 @@ CREATE TABLE "tgraph" (
|
|||
-- -----------------------------------------------------
|
||||
CREATE TABLE "tgraph_source" (
|
||||
"id_gs" SERIAL NOT NULL PRIMARY KEY,
|
||||
"id_server" BIGINT NOT NULL default 0,
|
||||
"id_graph" BIGINT NOT NULL default 0,
|
||||
"id_agent_module" BIGINT NOT NULL default 0,
|
||||
"weight" DOUBLE PRECISION default 0
|
||||
"weight" DOUBLE PRECISION default 0,
|
||||
"label" VARCHAR2(150) DEFAULT ''
|
||||
);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
|
@ -1771,4 +1773,4 @@ CREATE TABLE IF NOT EXISTS "trel_item" (
|
|||
"child_type" SMALLINT NOT NULL default 0,
|
||||
"id_item" INTEGER default 0,
|
||||
"deleted" SMALLINT NOT NULL default 0
|
||||
);
|
||||
);
|
||||
|
|
|
@ -1071,6 +1071,7 @@ CREATE TABLE IF NOT EXISTS `tgraph` (
|
|||
CREATE TABLE IF NOT EXISTS `tgraph_source` (
|
||||
`id_gs` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_graph` int(11) NOT NULL default 0,
|
||||
`id_server` int(11) NOT NULL default 0,
|
||||
`id_agent_module` int(11) NOT NULL default 0,
|
||||
`weight` float(8,3) NOT NULL DEFAULT 0,
|
||||
`label` varchar(150) DEFAULT '',
|
||||
|
@ -1881,4 +1882,4 @@ CREATE TABLE IF NOT EXISTS `trel_item` (
|
|||
`id_item` int(10) unsigned NOT NULL default 0,
|
||||
`deleted` int(1) unsigned NOT NULL default 0,
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 6.1dev-160126
|
||||
Version: 6.1dev-160210
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="6.1dev-160126"
|
||||
pandora_version="6.1dev-160210"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -64,6 +64,7 @@ use threads;
|
|||
use Thread::Semaphore;
|
||||
use POSIX ":sys_wait_h";
|
||||
use Time::HiRes qw(usleep);
|
||||
use Scalar::Util qw(refaddr);
|
||||
|
||||
# Constants for Win32 services.
|
||||
use constant WIN32_SERVICE_STOPPED => 0x01;
|
||||
|
@ -774,14 +775,21 @@ sub serve_proxy_connection {
|
|||
|
||||
# Forward data between the client and the server.
|
||||
eval {
|
||||
while (1) {
|
||||
if ($t_select->can_read(0)) {
|
||||
my $select = IO::Select->new ();
|
||||
$select->add($t_proxy_socket);
|
||||
$select->add($t_client_socket);
|
||||
while (my @ready = $select->can_read()) {
|
||||
foreach my $socket (@ready) {
|
||||
if (refaddr($socket) == refaddr($t_client_socket)) {
|
||||
my ($read, $data) = recv_data($t_block_size);
|
||||
return unless defined($data);
|
||||
send_data_proxy($data);
|
||||
}
|
||||
if ($t_proxy_select->can_read(0)) {
|
||||
}
|
||||
else {
|
||||
my ($read, $data) = recv_data_proxy($t_block_size);
|
||||
return unless defined($data);
|
||||
send_data($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Binary file not shown.
|
@ -43,7 +43,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "6.1dev";
|
||||
my $pandora_build = "160126";
|
||||
my $pandora_build = "160210";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
|
|
@ -2203,6 +2203,8 @@ sub pandora_update_server ($$$$$$;$$$) {
|
|||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
|
||||
$version = $pa_config->{'version'} . ' (P) ' . $pa_config->{'build'} unless defined($version);
|
||||
|
||||
my $master = ($server_type == SATELLITESERVER) ? 0 : $pa_config->{'pandora_master'};
|
||||
|
||||
# First run
|
||||
if ($server_id == 0) {
|
||||
|
||||
|
@ -2224,12 +2226,12 @@ sub pandora_update_server ($$$$$$;$$$) {
|
|||
|
||||
db_do ($dbh, 'UPDATE tserver SET status = ?, keepalive = ?, master = ?, laststart = ?, version = ?, threads = ?, queued_modules = ?
|
||||
WHERE id_server = ?',
|
||||
1, $timestamp, $pa_config->{'pandora_master'}, $timestamp, $version, $num_threads, $queue_size, $server_id);
|
||||
1, $timestamp, $master, $timestamp, $version, $num_threads, $queue_size, $server_id);
|
||||
return;
|
||||
}
|
||||
|
||||
db_do ($dbh, 'UPDATE tserver SET status = ?, keepalive = ?, master = ?, version = ?, threads = ?, queued_modules = ?
|
||||
WHERE id_server = ?', $status, $timestamp, $pa_config->{'pandora_master'}, $version, $num_threads, $queue_size, $server_id);
|
||||
WHERE id_server = ?', $status, $timestamp, $master, $version, $num_threads, $queue_size, $server_id);
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
|
|
@ -544,7 +544,7 @@ sub process_module_data ($$$$$$$$$) {
|
|||
'datalist' => 0, 'status' => 0, 'unit' => 0, 'timestamp' => 0, 'module_group' => 0, 'custom_id' => '',
|
||||
'str_warning' => '', 'str_critical' => '', 'critical_instructions' => '', 'warning_instructions' => '',
|
||||
'unknown_instructions' => '', 'tags' => '', 'critical_inverse' => 0, 'warning_inverse' => 0, 'quiet' => 0,
|
||||
'module_ff_interval' => 0, 'alert_template' => ''};
|
||||
'module_ff_interval' => 0, 'alert_template' => '', 'crontab' => ''};
|
||||
|
||||
# Other tags will be saved here
|
||||
$module_conf->{'extended_info'} = '';
|
||||
|
@ -558,6 +558,9 @@ sub process_module_data ($$$$$$$$$) {
|
|||
}
|
||||
}
|
||||
|
||||
# Reload alert_template to get all alerts like an array
|
||||
$module_conf->{'alert_template'} = get_tag_value ($data, 'alert_template', '', 1);
|
||||
|
||||
# Description XML tag and column name don't match
|
||||
$module_conf->{'descripcion'} = $module_conf->{'description'};
|
||||
$module_conf->{'descripcion'} = '' unless defined ($module_conf->{'descripcion'});
|
||||
|
@ -628,6 +631,11 @@ sub process_module_data ($$$$$$$$$) {
|
|||
$initial_alert_template = $module_conf->{'alert_template'};
|
||||
delete $module_conf->{'alert_template'};
|
||||
}
|
||||
|
||||
if(cron_check_syntax ($module_conf->{'crontab'})) {
|
||||
$module_conf->{'cron_interval'} = $module_conf->{'crontab'};
|
||||
}
|
||||
delete $module_conf->{'crontab'};
|
||||
|
||||
# Create the module
|
||||
my $module_id = pandora_create_module_from_hash ($pa_config, $module_conf, $dbh);
|
||||
|
@ -656,14 +664,16 @@ sub process_module_data ($$$$$$$$$) {
|
|||
}
|
||||
}
|
||||
|
||||
# Assign alert-template if the spceicied one exists
|
||||
# Assign alert-templates if exist
|
||||
if( $initial_alert_template ) {
|
||||
my $id_alert_template = get_db_value ($dbh,
|
||||
'SELECT id FROM talert_templates WHERE talert_templates.name = ?',
|
||||
safe_input($initial_alert_template) );
|
||||
foreach my $individual_template (@{$initial_alert_template}){
|
||||
my $id_alert_template = get_db_value ($dbh,
|
||||
'SELECT id FROM talert_templates WHERE talert_templates.name = ?',
|
||||
safe_input($individual_template) );
|
||||
|
||||
if( defined($id_alert_template) ) {
|
||||
pandora_create_template_module ($pa_config, $dbh, $module->{'id_agente_modulo'}, $id_alert_template);
|
||||
if( defined($id_alert_template) ) {
|
||||
pandora_create_template_module ($pa_config, $dbh, $module->{'id_agente_modulo'}, $id_alert_template);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,6 +265,7 @@ sub data_consumer ($$) {
|
|||
# End of GIS code -----------------------------
|
||||
else {
|
||||
# Create a new agent
|
||||
logger ($pa_config, "Creating an agent through recon task: " . $host_name, 10);
|
||||
$agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'},
|
||||
$host_name, $addr, $task->{'id_group'},
|
||||
$parent_id, $id_os, '', 300, $dbh);
|
||||
|
@ -362,9 +363,11 @@ sub get_host_parent {
|
|||
# Check if the host exists
|
||||
my $agent = get_agent_from_addr ($dbh, $host_addr);
|
||||
if (defined ($agent)) {
|
||||
# Move to the next host
|
||||
$parent_id = $agent->{'id_agente'};
|
||||
next;
|
||||
# Move to the next host if module is not in learning mode
|
||||
if ($agent->{'modo'} != 1) {
|
||||
$parent_id = $agent->{'id_agente'};
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -392,10 +395,20 @@ sub get_host_parent {
|
|||
}
|
||||
|
||||
# Create the host
|
||||
my $agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'}, $host_name, $host_addr, $group, $parent_id, $id_os, '', 300, $dbh);
|
||||
$agent_id = 0 unless defined ($parent_id);
|
||||
db_do ($dbh, 'INSERT INTO taddress_agent (id_a, id_agent)
|
||||
VALUES (?, ?)', $addr_id, $agent_id);
|
||||
my $agent_id = 0;
|
||||
my $agent_parent = get_agent_from_addr ($dbh, $host_addr);
|
||||
if (!defined($agent_parent)) {
|
||||
$agent_parent = get_agent_from_name($dbh, $host_addr);
|
||||
}
|
||||
if (defined ($agent_parent)) {
|
||||
$agent_id = $agent_parent->{'id_agente'};
|
||||
logger ($pa_config, "Updating agent " . $agent_id . " with parent $parent_id in host $host_addr");
|
||||
db_do ($dbh, 'UPDATE tagente SET id_parent=? WHERE id_agente=?', $parent_id, $agent_id);
|
||||
} else {
|
||||
$agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'}, $host_name, $host_addr, $group, $parent_id, $id_os, '', 300, $dbh);
|
||||
db_do ($dbh, 'INSERT INTO taddress_agent (id_a, id_agent)
|
||||
VALUES (?, ?)', $addr_id, $agent_id);
|
||||
}
|
||||
|
||||
# Move to the next host
|
||||
$parent_id = $agent_id;
|
||||
|
|
|
@ -64,6 +64,7 @@ our @EXPORT = qw(
|
|||
cron_get_closest_in_range
|
||||
cron_next_execution
|
||||
cron_next_execution_date
|
||||
cron_check_syntax
|
||||
pandora_daemonize
|
||||
logger
|
||||
pandora_rotate_logfile
|
||||
|
@ -647,11 +648,14 @@ sub print_message ($$$) {
|
|||
# Returns the value of an XML tag from a hash returned by XMLin (one level
|
||||
# depth).
|
||||
##########################################################################
|
||||
sub get_tag_value ($$$) {
|
||||
my ($hash_ref, $tag, $def_value) = @_;
|
||||
sub get_tag_value ($$$;$) {
|
||||
my ($hash_ref, $tag, $def_value, $all_array) = @_;
|
||||
$all_array = 0 unless defined ($all_array);
|
||||
|
||||
return $def_value unless defined ($hash_ref->{$tag}) and ref ($hash_ref->{$tag});
|
||||
|
||||
# If all array is required, returns the array
|
||||
return $hash_ref->{$tag} if ($all_array == 1);
|
||||
# Return the first found value
|
||||
foreach my $value (@{$hash_ref->{$tag}}) {
|
||||
|
||||
|
@ -1243,7 +1247,15 @@ sub cron_next_execution ($) {
|
|||
# Something went wrong, default to 5 minutes
|
||||
return 300;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Get the number of seconds left to the next execution of the given cron entry.
|
||||
###############################################################################
|
||||
sub cron_check_syntax ($) {
|
||||
my ($cron) = @_;
|
||||
|
||||
return 0 if !defined ($cron);
|
||||
return ($cron =~ m/^(\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+$/);
|
||||
}
|
||||
###############################################################################
|
||||
# Get the next execution date for the given cron entry in seconds since epoch.
|
||||
###############################################################################
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 6.1dev
|
||||
%define release 160126
|
||||
%define release 160210
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
@ -29,7 +29,6 @@ Requires: perl-NetAddr-IP net-snmp net-tools
|
|||
Requires: perl-IO-Socket-INET6 perl-Socket6 perl-Net-Telnet
|
||||
Requires: nmap wmic sudo perl-JSON
|
||||
Requires: perl-Time-HiRes perl-Encode-Locale
|
||||
Recommends: perl-Sys-Syslog
|
||||
|
||||
%description
|
||||
Pandora FMS is a monitoring system for big IT environments. It uses remote tests, or local agents to grab information. Pandora supports all standard OS (Linux, AIX, HP-UX, Solaris and Windows XP,2000/2003), and support multiple setups in HA enviroments.
|
||||
|
@ -132,6 +131,9 @@ fi
|
|||
|
||||
echo "Don't forget to start Tentacle Server daemon if you want to receive"
|
||||
echo "data using tentacle"
|
||||
echo " "
|
||||
echo "You may need to install manually some additional required dependencies:"
|
||||
echo "perl-Sys-Syslog"
|
||||
|
||||
%preun
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 6.1dev
|
||||
%define release 160126
|
||||
%define release 160210
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="6.1dev"
|
||||
PI_BUILD="160126"
|
||||
PI_BUILD="160210"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -33,7 +33,7 @@ use PandoraFMS::Tools;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "6.1dev PS160126";
|
||||
my $version = "6.1dev PS160210";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
|
|
@ -35,7 +35,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "6.1dev PS160126";
|
||||
my $version = "6.1dev PS160210";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
@ -3343,9 +3343,8 @@ sub cli_create_synthetic() {
|
|||
my $id_agent = int(get_agent_id($dbh,$agent_name));
|
||||
|
||||
if ($id_agent > 0) {
|
||||
|
||||
foreach my $data (@module_data) {
|
||||
my @split_data = split(',',$data);
|
||||
foreach my $i (0 .. $#module_data) {
|
||||
my @split_data = split(',',$module_data[$i]);
|
||||
if (@split_data[0] =~ m/(x|\/|\+|\*|\-)/ && length(@split_data[0]) == 1 ) {
|
||||
if ( @split_data[0] =~ m/(\/|\+|\*|\-)/ && $synthetic_type eq 'average' ) {
|
||||
print("[ERROR] With this type: $synthetic_type only be allow use this operator: 'x' \n\n");
|
||||
|
@ -3373,7 +3372,13 @@ sub cli_create_synthetic() {
|
|||
print("[ERROR] With this type: $synthetic_type only be allow use this operator: 'x' \n\n");
|
||||
exit 1;
|
||||
}
|
||||
@data_module = (safe_output(@split_data[0]),@split_data[1],safe_output(@split_data[2]));
|
||||
if ( $synthetic_type eq 'arithmetic' && $i == 0) {
|
||||
@data_module = (safe_output(@split_data[0]),'',safe_output(@split_data[2]));
|
||||
}
|
||||
else {
|
||||
@data_module = (safe_output(@split_data[0]),@split_data[1],safe_output(@split_data[2]));
|
||||
}
|
||||
|
||||
my $text_data = join(',',@data_module);
|
||||
push (@filterdata,$text_data);
|
||||
}
|
||||
|
@ -3395,6 +3400,11 @@ sub cli_create_synthetic() {
|
|||
my $result = enterprise_hook('create_synthetic_operations',
|
||||
[$dbh,int($id_module), @filterdata]);
|
||||
if ($result) {
|
||||
db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado,
|
||||
last_status, last_known_status, last_try, datos)
|
||||
VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\', \'\')', $id_module, $id_agent, 4, 4, 4);
|
||||
# Update the module status count. When the module is created disabled dont do it
|
||||
pandora_mark_agent_for_module_update ($dbh, $id_agent);
|
||||
print("[OK] The modules are creating ID: $id_module \n\n");
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -795,7 +795,7 @@ sub create_pandora_agent($) {
|
|||
$agent = get_agent_from_name($DBH, $device);
|
||||
}
|
||||
|
||||
my $agent_id;
|
||||
my ($agent_id, $agent_learning);
|
||||
if (!defined($agent)) {
|
||||
my $id_os = 10; # Other.
|
||||
my $device_type = $VISITED_DEVICES{$device}->{'type'};
|
||||
|
@ -809,9 +809,11 @@ sub create_pandora_agent($) {
|
|||
$agent_id = pandora_create_agent(\%CONF, $CONF{'servername'}, $device, $device, $GROUP_ID, 0, $id_os, '', 300, $DBH);
|
||||
return undef unless defined ($agent_id) and ($agent_id > 0);
|
||||
pandora_event(\%CONF, "[RECON] New $device_type found (" . join(',', keys(%{$VISITED_DEVICES{$device}->{'addr'}})) . ").", $GROUP_ID, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $DBH);
|
||||
$agent_learning = 1 == 1;
|
||||
}
|
||||
else {
|
||||
$agent_id = $agent->{'id_agente'};
|
||||
$agent_learning = $agent->{'modo'} == 1;
|
||||
}
|
||||
|
||||
# Add found IP addresses to the agent.
|
||||
|
@ -830,7 +832,7 @@ sub create_pandora_agent($) {
|
|||
|
||||
# Create a ping module.
|
||||
my $module_id = get_agent_module_id($DBH, "ping", $agent_id);
|
||||
if ($module_id <= 0) {
|
||||
if ($module_id <= 0 && $agent_learning) {
|
||||
my %module = ('id_tipo_modulo' => 6,
|
||||
'id_modulo' => 2,
|
||||
'nombre' => "ping",
|
||||
|
@ -866,7 +868,7 @@ sub create_pandora_agent($) {
|
|||
|
||||
# Check whether the module already exists.
|
||||
my $module_id = get_agent_module_id($DBH, "ifOperStatus_${if_name}", $agent_id);
|
||||
next if ($module_id > 0);
|
||||
next if ($module_id > 0 && !$agent_learning);
|
||||
|
||||
# Encode problematic characters.
|
||||
$if_name = safe_input($if_name);
|
||||
|
@ -1044,7 +1046,7 @@ sub show_help {
|
|||
print " * custom_field3 = a router in the network. Optional but recommended.\n\n";
|
||||
print " * custom_field4 = set to -a to add all network interfaces (by default only interfaces that are up are added).\n\n";
|
||||
print " Additional information:\nWhen the script is called from a recon task the task_id, group_id and create_incident";
|
||||
print " parameters are automatically filled by the Pandora FMS Server.";
|
||||
print " parameters are automatically filled by the Pandora FMS Server.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -1082,23 +1084,26 @@ sub traceroute_connectivity($) {
|
|||
|
||||
# Look for parents.
|
||||
my $parent_id = 0;
|
||||
my $child_id = $agent->{'id_agente'};
|
||||
foreach my $hop (@hops) {
|
||||
my $host_addr = $hop->ipaddr ();
|
||||
|
||||
# Check if the parent agent exists.
|
||||
my $agent = get_agent_from_addr ($DBH, $host_addr);
|
||||
if (!defined($agent)) {
|
||||
$agent = get_agent_from_name($DBH, $host_addr);
|
||||
my $agent_parent = get_agent_from_addr ($DBH, $host_addr);
|
||||
if (!defined($agent_parent)) {
|
||||
$agent_parent = get_agent_from_name($DBH, $host_addr);
|
||||
}
|
||||
if (defined ($agent)) {
|
||||
$parent_id = $agent->{'id_agente'};
|
||||
last;
|
||||
if (defined ($agent_parent)) {
|
||||
$parent_id = $agent_parent->{'id_agente'};
|
||||
next unless ($agent_parent->{'modo'} == 1);
|
||||
} else {
|
||||
$parent_id = create_pandora_agent ($host_addr);
|
||||
}
|
||||
# Connect the host to its parent.
|
||||
if ($parent_id > 0) {
|
||||
db_do($DBH, 'UPDATE tagente SET id_parent=? WHERE id_agente=?', $parent_id, $child_id);
|
||||
$child_id = $parent_id;
|
||||
}
|
||||
}
|
||||
|
||||
# Connect the host to its parent.
|
||||
if ($parent_id > 0) {
|
||||
db_do($DBH, 'UPDATE tagente SET id_parent=? WHERE id_agente=?', $parent_id, $agent->{'id_agente'});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue