Merge branch 'feature/alias_friendly_name' into 'develop'

Feature/alias friendly name

See merge request !188
This commit is contained in:
Daniel Maya 2017-02-21 16:46:05 +01:00
commit a36e74990d
77 changed files with 1081 additions and 434 deletions

View File

@ -39,7 +39,9 @@ udp_server_auth_address 0.0.0.0
# To define agent name by specific command, define 'agent_name_cmd'. # To define agent name by specific command, define 'agent_name_cmd'.
# (In the following example, agent name is 'hostname_IP') # (In the following example, agent name is 'hostname_IP')
#agent_name_cmd /bin/echo -n `hostname` ; /bin/echo -n "_" ; /bin/echo `/sbin/ifconfig bce0 | /usr/bin/grep 'inet' | /usr/bin/awk '{print $2;}' | cut -d: -f2` # If set to __rand__ the agent will generate a random name.
#agent_name_cmd LANG=C; /bin/echo -n `hostname`; /bin/echo -n "_"; /bin/echo `/sbin/ifconfig eth0 | /bin/grep 'inet addr' | /usr/bin/awk '{print $2;}' | /usr/bin/cut -d: -f2`
agent_name_cmd __rand__
#Parent agent_name #Parent agent_name
#parent_agent_name parent_name #parent_agent_name parent_name

View File

@ -39,7 +39,9 @@ udp_server_auth_address 0.0.0.0
# To define agent name by specific command, define 'agent_name_cmd'. # To define agent name by specific command, define 'agent_name_cmd'.
# (In the following example, agent name is 'hostname_IP') # (In the following example, agent name is 'hostname_IP')
# If set to __rand__ the agent will generate a random name.
#agent_name_cmd LANG=C; /bin/echo -n `hostname`; /bin/echo -n "_"; /bin/echo `/sbin/ifconfig eth0 | /bin/grep 'inet addr' | /usr/bin/awk '{print $2;}' | /usr/bin/cut -d: -f2` #agent_name_cmd LANG=C; /bin/echo -n `hostname`; /bin/echo -n "_"; /bin/echo `/sbin/ifconfig eth0 | /bin/grep 'inet addr' | /usr/bin/awk '{print $2;}' | /usr/bin/cut -d: -f2`
agent_name_cmd __rand__
#Parent agent_name #Parent agent_name
#parent_agent_name caprica #parent_agent_name caprica

330
pandora_agents/unix/pandora_agent Normal file → Executable file
View File

@ -100,6 +100,9 @@ use constant DF_CMDS => {
aix => 'df -kP', aix => 'df -kP',
freebsd => 'df -k' freebsd => 'df -k'
}; };
# 2 to the power of 32.
use constant POW232 => 2**32;
# OS and OS version # OS and OS version
my $OS = $^O; my $OS = $^O;
@ -131,8 +134,9 @@ my %DefaultConf = (
'temporal' => '/var/spool/pandora', 'temporal' => '/var/spool/pandora',
'interval' => 300, 'interval' => 300,
'debug' => 0, 'debug' => 0,
'agent_name' => '',
'agent_alias' => hostname(),
'ehorus_conf' => undef, 'ehorus_conf' => undef,
'agent_name' => hostname (),
'agent_name_cmd' => '', 'agent_name_cmd' => '',
'description' => '', 'description' => '',
'group' => '', 'group' => '',
@ -800,17 +804,24 @@ sub read_config (;$) {
parse_conf_modules(\@file); parse_conf_modules(\@file);
# If agent_name_cmd is defined, agent_name is set by command result. # If agent_name_cmd is defined, agent_name is set by command result.
if ($Conf{'agent_name_cmd'} ne '') { if ($Conf{'agent_name'} eq '') {
my $result = `$Conf{'agent_name_cmd'}`; if ($Conf{'agent_name_cmd'} eq '__rand__') {
$Conf{'agent_name'} = generate_agent_name();
# Use only the first line. config_update('agent_name', $Conf{'agent_name'});
my ($temp_agent_name, $remain) = split(/\n/, $result); } elsif ($Conf{'agent_name_cmd'} ne '') {
chomp ($temp_agent_name); my $result = `$Conf{'agent_name_cmd'}`;
# Remove white spaces of the first and last. # Use only the first line.
$temp_agent_name =~ s/^ *(.*?) *$/$1/; my ($temp_agent_name, $remain) = split(/\n/, $result);
chomp ($temp_agent_name);
$Conf{'agent_name'} = $temp_agent_name if ($temp_agent_name ne '');
# Remove white spaces of the first and last.
$temp_agent_name =~ s/^ *(.*?) *$/$1/;
$Conf{'agent_name'} = $temp_agent_name if ($temp_agent_name ne '');
} else {
$Conf{'agent_name'} = hostname();
}
} }
# Update the agent MD5 since agent_name may have changed # Update the agent MD5 since agent_name may have changed
@ -1196,73 +1207,78 @@ sub check_collections () {
} }
############################################################################### ###############################################################################
# MD5 leftrotate function. See http://en.wikipedia.org/wiki/MD5#Pseudocode. # Return the MD5 checksum of the given string as a hex string.
# Pseudocode from: http://en.wikipedia.org/wiki/MD5#Pseudocode
############################################################################### ###############################################################################
sub leftrotate ($$) { my @S = (
my ($x, $c) = @_; 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
return (0xFFFFFFFF & ($x << $c)) | ($x >> (32 - $c)); 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
} 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
);
############################################################################### my @K = (
# Initialize some variables needed by the MD5 algorithm. 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
# See http://en.wikipedia.org/wiki/MD5#Pseudocode. 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
############################################################################### 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
my (@R, @K); 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
sub md5_init () { 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
# R specifies the per-round shift amounts 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
@R = (7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21); 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
# Use binary integer part of the sines of integers (radians) as constants 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
for (my $i = 0; $i < 64; $i++) { 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
$K[$i] = floor(abs(sin($i + 1)) * MOD232); 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
} 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
} );
sub md5 {
###############################################################################
# Return the MD5 checksum of the given string.
# Pseudocode from http://en.wikipedia.org/wiki/MD5#Pseudocode.
###############################################################################
sub md5 ($) {
my $str = shift; my $str = shift;
# Note: All variables are unsigned 32 bits and wrap modulo 2^32 when calculating # No input!
if (!defined($str)) {
return "";
}
# Initialize variables # Note: All variables are unsigned 32 bits and wrap modulo 2^32 when
# calculating.
# Initialize variables.
my $h0 = 0x67452301; my $h0 = 0x67452301;
my $h1 = 0xEFCDAB89; my $h1 = 0xEFCDAB89;
my $h2 = 0x98BADCFE; my $h2 = 0x98BADCFE;
my $h3 = 0x10325476; my $h3 = 0x10325476;
# Pre-processing # Pre-processing.
my $msg = unpack ("B*", pack ("A*", $str)); my $msg = unpack ("B*", pack ("A*", $str));
my $bit_len = length ($msg); my $bit_len = length ($msg);
# Append "1" bit to message # Append "1" bit to message.
$msg .= '1'; $msg .= '1';
# Append "0" bits until message length in bits ≡ 448 (mod 512) # Append "0" bits until message length in bits ≡ 448 (mod 512).
$msg .= '0' while ((length ($msg) % 512) != 448); $msg .= '0' while ((length ($msg) % 512) != 448);
# Append bit /* bit, not byte */ length of unpadded message as 64-bit little-endian integer to message # Append bit /* bit, not byte */ length of unpadded message as 64-bit
$msg .= unpack ("B64", pack ("VV", $bit_len)); # little-endian integer to message.
$msg .= unpack ("B32", pack ("V", $bit_len));
$msg .= unpack ("B32", pack ("V", $bit_len >> 32));
# Process the message in successive 512-bit chunks # Process the message in successive 512-bit chunks.
for (my $i = 0; $i < length ($msg); $i += 512) { for (my $i = 0; $i < length ($msg); $i += 512) {
my @w; my @w;
my $chunk = substr ($msg, $i, 512); my $chunk = substr ($msg, $i, 512);
# Break chunk into sixteen 32-bit little-endian words w[i], 0 <= i <= 15 # Break chunk into sixteen 32-bit little-endian words w[i], 0 <= i <=
# 15.
for (my $j = 0; $j < length ($chunk); $j += 32) { for (my $j = 0; $j < length ($chunk); $j += 32) {
push (@w, unpack ("V", pack ("B32", substr ($chunk, $j, 32)))); push (@w, unpack ("V", pack ("B32", substr ($chunk, $j, 32))));
} }
# Initialize hash value for this chunk # Initialize hash value for this chunk.
my $a = $h0; my $a = $h0;
my $b = $h1; my $b = $h1;
my $c = $h2; my $c = $h2;
@ -1270,7 +1286,7 @@ sub md5 ($) {
my $f; my $f;
my $g; my $g;
# Main loop # Main loop.
for (my $y = 0; $y < 64; $y++) { for (my $y = 0; $y < 64; $y++) {
if ($y <= 15) { if ($y <= 15) {
$f = $d ^ ($b & ($c ^ $d)); $f = $d ^ ($b & ($c ^ $d));
@ -1292,19 +1308,163 @@ sub md5 ($) {
my $temp = $d; my $temp = $d;
$d = $c; $d = $c;
$c = $b; $c = $b;
$b = ($b + leftrotate (($a + $f + $K[$y] + $w[$g]) % MOD232, $R[$y])) % MOD232; $b = ($b + leftrotate (($a + $f + $K[$y] + $w[$g]) % POW232, $S[$y])) % POW232;
$a = $temp; $a = $temp;
} }
# Add this chunk's hash to result so far # Add this chunk's hash to result so far.
$h0 = ($h0 + $a) % MOD232; $h0 = ($h0 + $a) % POW232;
$h1 = ($h1 + $b) % MOD232; $h1 = ($h1 + $b) % POW232;
$h2 = ($h2 + $c) % MOD232; $h2 = ($h2 + $c) % POW232;
$h3 = ($h3 + $d) % MOD232; $h3 = ($h3 + $d) % POW232;
} }
# Digest := h0 append h1 append h2 append h3 #(expressed as little-endian) # Digest := h0 append h1 append h2 append h3 #(expressed as little-endian)
return unpack ("H*", pack ("V", $h0)) . unpack ("H*", pack ("V", $h1)) . unpack ("H*", pack ("V", $h2)) . unpack ("H*", pack ("V", $h3)); return unpack ("H*", pack ("V", $h0)) .
unpack ("H*", pack ("V", $h1)) .
unpack ("H*", pack ("V", $h2)) .
unpack ("H*", pack ("V", $h3));
}
###############################################################################
# MD5 leftrotate function. See: http://en.wikipedia.org/wiki/MD5#Pseudocode
###############################################################################
sub leftrotate {
my ($x, $c) = @_;
return (0xFFFFFFFF & ($x << $c)) | ($x >> (32 - $c));
}
###############################################################################
# Return the SHA256 checksum of the given string as a hex string.
# Pseudocode from: http://en.wikipedia.org/wiki/SHA-2#Pseudocode
###############################################################################
my @K2 = (
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
);
sub sha256 {
my $str = shift;
# No input!
if (!defined($str)) {
return "";
}
# Note: All variables are unsigned 32 bits and wrap modulo 2^32 when
# calculating.
# First 32 bits of the fractional parts of the square roots of the first 8
# primes.
my $h0 = 0x6a09e667;
my $h1 = 0xbb67ae85;
my $h2 = 0x3c6ef372;
my $h3 = 0xa54ff53a;
my $h4 = 0x510e527f;
my $h5 = 0x9b05688c;
my $h6 = 0x1f83d9ab;
my $h7 = 0x5be0cd19;
# Pre-processing.
my $msg = unpack ("B*", pack ("A*", $str));
my $bit_len = length ($msg);
# Append "1" bit to message.
$msg .= '1';
# Append "0" bits until message length in bits = 448 (mod 512).
$msg .= '0' while ((length ($msg) % 512) != 448);
# Append bit /* bit, not byte */ length of unpadded message as 64-bit
# big-endian integer to message.
$msg .= unpack ("B32", pack ("N", $bit_len >> 32));
$msg .= unpack ("B32", pack ("N", $bit_len));
# Process the message in successive 512-bit chunks.
for (my $i = 0; $i < length ($msg); $i += 512) {
my @w;
my $chunk = substr ($msg, $i, 512);
# Break chunk into sixteen 32-bit big-endian words.
for (my $j = 0; $j < length ($chunk); $j += 32) {
push (@w, unpack ("N", pack ("B32", substr ($chunk, $j, 32))));
}
# Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array:
for (my $i = 16; $i < 64; $i++) {
my $s0 = rightrotate($w[$i - 15], 7) ^ rightrotate($w[$i - 15], 18) ^ ($w[$i - 15] >> 3);
my $s1 = rightrotate($w[$i - 2], 17) ^ rightrotate($w[$i - 2], 19) ^ ($w[$i - 2] >> 10);
$w[$i] = ($w[$i - 16] + $s0 + $w[$i - 7] + $s1) % POW232;
}
# Initialize working variables to current hash value.
my $a = $h0;
my $b = $h1;
my $c = $h2;
my $d = $h3;
my $e = $h4;
my $f = $h5;
my $g = $h6;
my $h = $h7;
# Compression function main loop.
for (my $i = 0; $i < 64; $i++) {
my $S1 = rightrotate($e, 6) ^ rightrotate($e, 11) ^ rightrotate($e, 25);
my $ch = ($e & $f) ^ ((0xFFFFFFFF & (~ $e)) & $g);
my $temp1 = ($h + $S1 + $ch + $K2[$i] + $w[$i]) % POW232;
my $S0 = rightrotate($a, 2) ^ rightrotate($a, 13) ^ rightrotate($a, 22);
my $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c);
my $temp2 = ($S0 + $maj) % POW232;
$h = $g;
$g = $f;
$f = $e;
$e = ($d + $temp1) % POW232;
$d = $c;
$c = $b;
$b = $a;
$a = ($temp1 + $temp2) % POW232;
}
# Add the compressed chunk to the current hash value.
$h0 = ($h0 + $a) % POW232;
$h1 = ($h1 + $b) % POW232;
$h2 = ($h2 + $c) % POW232;
$h3 = ($h3 + $d) % POW232;
$h4 = ($h4 + $e) % POW232;
$h5 = ($h5 + $f) % POW232;
$h6 = ($h6 + $g) % POW232;
$h7 = ($h7 + $h) % POW232;
}
# Produce the final hash value (big-endian).
return unpack ("H*", pack ("N", $h0)) .
unpack ("H*", pack ("N", $h1)) .
unpack ("H*", pack ("N", $h2)) .
unpack ("H*", pack ("N", $h3)) .
unpack ("H*", pack ("N", $h4)) .
unpack ("H*", pack ("N", $h5)) .
unpack ("H*", pack ("N", $h6)) .
unpack ("H*", pack ("N", $h7));
}
###############################################################################
# Rotate a 32-bit number a number of bits to the right.
###############################################################################
sub rightrotate {
my ($x, $c) = @_;
return (0xFFFFFFFF & ($x << (32 - $c))) | ($x >> $c);
} }
################################################################################ ################################################################################
@ -2196,6 +2356,46 @@ sub init_module ($) {
$module->{'alert_template'} = undef; $module->{'alert_template'} = undef;
} }
################################################################################
# Generate a unique agent name.
################################################################################
sub generate_agent_name {
return sha256(join('|', ($Conf{'agent_alias'}, $Conf{server_ip}, time(), sprintf("%04d", rand(10000)))));
}
################################################################################
# Set the value of a token in the configuration file. If the token does not
# exist, it is appended to the end of the file.
################################################################################
sub config_update ($$) {
my ($token, $value) = @_;
# Read the original configuration file.
open(my $fh, '<', "$ConfDir/$ConfFile") or die($!);
my @lines = <$fh>;
close ($fh);
# Set the new value for the configuration token.
my $found = 0;
for(my $i = 0; $i < $#lines; $i++) {
if ($lines[$i] =~ m/[#\s]*$token/) {
$lines[$i] = "$token $value\n";
$found = 1;
last;
}
}
# Append the token to the end if it was not found in the file.
if ($found == 0) {
push(@lines, "$token $value\n");
}
# Write the changes to the configuration file.
open($fh, '>', "$ConfDir/$ConfFile") or die($!);
print $fh @lines;
close($fh);
}
################################################################################ ################################################################################
# Get the eHorus key from the eHorus agent configuration file. # Get the eHorus key from the eHorus agent configuration file.
################################################################################ ################################################################################
@ -2261,9 +2461,6 @@ if (defined ($pandora_user)) {
# Guess the OS version # Guess the OS version
$OS_VERSION = guess_os_version ($OS); $OS_VERSION = guess_os_version ($OS);
# Initialize MD5 variables
md5_init ();
# Start logging # Start logging
start_log (); start_log ();
log_message ('log', 'Running as user ' . getpwuid ($>)); log_message ('log', 'Running as user ' . getpwuid ($>));
@ -2472,8 +2669,9 @@ while (1) {
(defined($Conf{'group_id'}) ? ("' group_id='" . $Conf{'group_id'}) : '') . (defined($Conf{'group_id'}) ? ("' group_id='" . $Conf{'group_id'}) : '') .
"' os_name='$OS' os_version='$OS_VERSION' interval='" . $Conf{'interval'} . "' os_name='$OS' os_version='$OS_VERSION' interval='" . $Conf{'interval'} .
"' version='" . AGENT_VERSION . '(Build ' . AGENT_BUILD . ')' . ($Conf{'autotime'} eq '1' ? '' : "' timestamp='" . strftime ('%Y/%m/%d %H:%M:%S', localtime ())) . "' version='" . AGENT_VERSION . '(Build ' . AGENT_BUILD . ')' . ($Conf{'autotime'} eq '1' ? '' : "' timestamp='" . strftime ('%Y/%m/%d %H:%M:%S', localtime ())) .
"' agent_name='" . $Conf{'agent_name'} . "' timezone_offset='". $Conf{'timezone_offset'} . "' agent_name='" . $Conf{'agent_name'} . "' agent_alias='". $Conf{'agent_alias'} .
"' custom_id='" . $Conf{'custom_id'} . "' url_address='". $Conf{'url_address'}; "' timezone_offset='". $Conf{'timezone_offset'} . "' custom_id='" . $Conf{'custom_id'} .
"' url_address='". $Conf{'url_address'};
if (defined ($Conf{'address'})) { if (defined ($Conf{'address'})) {
$xml_header .= "' address='" .$address; $xml_header .= "' address='" .$address;

0
pandora_agents/unix/pandora_agent_installer Normal file → Executable file
View File

View File

@ -1,9 +1,9 @@
bin_PROGRAMS = PandoraAgent bin_PROGRAMS = PandoraAgent
if DEBUG if DEBUG
PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp
PandoraAgent_CXXFLAGS=-g -O0 PandoraAgent_CXXFLAGS=-g -O0
else else
PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc
PandoraAgent_CXXFLAGS=-O2 PandoraAgent_CXXFLAGS=-O2
endif endif

View File

@ -33,7 +33,10 @@ temporal "%ProgramFiles%\pandora_agent\temp"
# To define agent name by specific command, define 'agent_name_cmd'. # To define agent name by specific command, define 'agent_name_cmd'.
# If agent_name_cmd is defined, agent_name is ignored. # If agent_name_cmd is defined, agent_name is ignored.
# (In the following example, agent name is 'hostname_IP') # (In the following example, agent name is 'hostname_IP')
# If set to __rand__ the agent will generate a random name.
#agent_name_cmd cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\agentname.vbs" #agent_name_cmd cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\agentname.vbs"
agent_name_cmd __rand__
#Parent agent_name #Parent agent_name
#parent_agent_name caprica #parent_agent_name caprica

View File

@ -0,0 +1,44 @@
/* Pandora agents service for Win32.
Copyright (C) 2016 Artica ST.
Written by Ramon Novoa.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include "openssl/sha.h"
#include "sha256.h"
void
sha256(const char *data, char hex_digest[SHA256_HEX_LENGTH + 1])
{
int i, j;
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
// Calculate the SHA-256 hash.
SHA256_Init(&sha256);
SHA256_Update(&sha256, data, strlen(data));
SHA256_Final(hash, &sha256);
// Convert it to a hexadecimal string.
for(i = 0, j = 0; i < SHA256_DIGEST_LENGTH, j < SHA256_HEX_LENGTH; i++, j+=2) {
sprintf(&(hex_digest[j]), "%02x", hash[i]);
}
// Add a NULL terminator.
hex_digest[SHA256_HEX_LENGTH] = 0;
}

View File

@ -0,0 +1,29 @@
/* Pandora agents service for Win32.
Copyright (C) 2016 Artica ST.
Written by Ramon Novoa.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SHA256_H_
#define _SHA256_H_
// Length of the sha256 hex string.
#define SHA256_HEX_LENGTH 64
void sha256(const char *data, char hex_digest[SHA256_HEX_LENGTH + 1]);
#endif

View File

@ -99,6 +99,15 @@ Key_Value::getKey () {
return key; return key;
} }
/**
* Set the key of the object.
*
*/
void
Key_Value::setKey (const string key) {
this->key = key;
}
/** /**
* Get the value of the object. * Get the value of the object.
* *
@ -109,6 +118,16 @@ Key_Value::getValue () {
return value; return value;
} }
/**
* Set the value of the object.
*
* @return The value
*/
void
Key_Value::setValue (const string value) {
this->value = value;
}
void void
pandoraWriteLog (string filename, string line) { pandoraWriteLog (string filename, string line) {
string buffer; string buffer;

View File

@ -62,7 +62,9 @@ namespace Pandora {
void parseLine (string str); void parseLine (string str);
void parseLineByPosition (string str, int pos); void parseLineByPosition (string str, int pos);
string getKey (); string getKey ();
void setKey (const string value);
string getValue (); string getValue ();
void setValue (const string value);
}; };
static const HKEY hkey = HKEY_LOCAL_MACHINE; static const HKEY hkey = HKEY_LOCAL_MACHINE;

View File

@ -350,6 +350,70 @@ Pandora::Pandora_Agent_Conf::setFile (string filename) {
file.close (); file.close ();
} }
/**
* Update a configuration value in the configuration file. If it is not found,
* it is appended at the end of the file.
*
* @param string key Name of the configuration option.
* @param string value New value.
*/
void
Pandora::Pandora_Agent_Conf::updateFile (string key, string value){
string buffer, filename, temp_filename;
int pos;
/* Open the configuration file. */
filename = Pandora::getPandoraInstallDir ();
filename += "pandora_agent.conf";
ifstream file (filename.c_str ());
if (!file.is_open ()) {
return;
}
/* Open the temporary file. */
temp_filename = filename + ".tmp";
ofstream temp_file (temp_filename.c_str ());
if (!temp_file.is_open ()) {
return;
}
/* Look for the configuration value. */
bool found = false;
while (!file.eof ()) {
getline (file, buffer);
/* Copy the rest of the file if the key was found. */
if (found) {
temp_file << buffer << std::endl;
continue;
}
/* We will only look for the key in the first three characters, hoping
to catch "key", "#key" and "# key". We would also catch "..key", but
no such keys exist in the configuration file. */
pos = buffer.find(key);
if (pos == std::string::npos || pos > 2) {
temp_file << buffer << std::endl;
continue;
}
/* Match! */
found = true;
temp_file << key + " " + value << std::endl;
}
/* Append the value at the end of the file if it was not found. */
if (!found) {
temp_file << key + " " + value << std::endl;
}
/* Rename the temporary file. */
file.close ();
temp_file.close ();
remove(filename.c_str());
rename(temp_filename.c_str(), filename.c_str());
}
/** /**
* Queries for a configuration value. * Queries for a configuration value.
* *
@ -375,6 +439,33 @@ Pandora::Pandora_Agent_Conf::getValue (const string key)
return ""; return "";
} }
/**
* Sets a configuration value.
*
* @param key Key to look for.
* @param string New value.
*
*/
void
Pandora::Pandora_Agent_Conf::setValue (const string key, const string value)
{
std::list<Key_Value>::iterator i;
// Update.
for (i = this->key_values->begin (); i != this->key_values->end (); i++) {
if ((*i).getKey () == key) {
(*i).setValue (value);
return;
}
}
// Append.
Key_Value kv;
kv.setKey(key);
kv.setValue(value);
this->key_values->push_back (kv);
}
/** /**
* Queries for a collection name. * Queries for a collection name.
* *

View File

@ -55,7 +55,9 @@ namespace Pandora {
void parseFile(string path_file, Collection *aux); void parseFile(string path_file, Collection *aux);
void setFile (string *all_conf); void setFile (string *all_conf);
void setFile (string filename); void setFile (string filename);
void updateFile (string key, string value);
string getValue (const string key); string getValue (const string key);
void setValue (const string key, const string value);
string getCurrentCollectionName(); string getCurrentCollectionName();
unsigned char getCurrentCollectionVerify(); unsigned char getCurrentCollectionVerify();

View File

@ -26,6 +26,7 @@
#include "ssh/pandora_ssh_client.h" #include "ssh/pandora_ssh_client.h"
#include "ftp/pandora_ftp_client.h" #include "ftp/pandora_ftp_client.h"
#include "misc/pandora_file.h" #include "misc/pandora_file.h"
#include "misc/sha256.h"
#include "windows/pandora_windows_info.h" #include "windows/pandora_windows_info.h"
#include "udp_server/udp_server.h" #include "udp_server/udp_server.h"
@ -39,6 +40,8 @@
#include <pandora_agent_conf.h> #include <pandora_agent_conf.h>
#include <fstream> #include <fstream>
#include <unistd.h> #include <unistd.h>
#include <sstream>
#include <string>
#define BUFSIZE 4096 #define BUFSIZE 4096
@ -207,7 +210,7 @@ void
Pandora_Windows_Service::pandora_init () { Pandora_Windows_Service::pandora_init () {
string conf_file, interval, debug, disable_logfile, intensive_interval, util_dir, path, env; string conf_file, interval, debug, disable_logfile, intensive_interval, util_dir, path, env;
string udp_server_enabled, udp_server_port, udp_server_addr, udp_server_auth_addr; string udp_server_enabled, udp_server_port, udp_server_addr, udp_server_auth_addr;
string name_agent, name; string agent_name, agent_name_cmd, agent_alias, pandora_agent;
string proxy_mode, server_ip; string proxy_mode, server_ip;
string *all_conf; string *all_conf;
int pos, num; int pos, num;
@ -255,12 +258,60 @@ Pandora_Windows_Service::pandora_init () {
this->modules = new Pandora_Module_List (conf_file); this->modules = new Pandora_Module_List (conf_file);
delete []all_conf; delete []all_conf;
name = checkAgentName(conf_file); // Get the agent name.
if (name.empty ()) { agent_name = conf->getValue ("agent_name");
name = Pandora_Windows_Info::getSystemName (); printf("AGENT NAME: %s\n", agent_name.c_str());
if (agent_name == "") {
agent_name_cmd = conf->getValue ("agent_name_cmd");
// Random name.
if (agent_name_cmd == "__rand__") {
agent_name = generateAgentName();
this->conf->setValue("agent_name", agent_name);
conf->updateFile("agent_name", agent_name); // Write random names to disk!
}
// Name from command.
else if (agent_name_cmd != "") {
agent_name_cmd = "cmd.exe /c \"" + agent_name_cmd + "\"";
static string temp_agent_name = getAgentNameFromCmdExec(agent_name_cmd);
// Delete new line and carriage return.
pos = temp_agent_name.find("\n");
if(pos != string::npos) {
temp_agent_name.erase(pos, temp_agent_name.size () - pos);
}
pos = temp_agent_name.find("\r");
if(pos != string::npos) {
temp_agent_name.erase(pos, temp_agent_name.size () - pos);
}
// Remove leading and trailing white spaces.
temp_agent_name = trim(temp_agent_name);
if (temp_agent_name != "") {
agent_name = temp_agent_name;
this->conf->setValue("agent_name", agent_name);
}
}
} }
name_agent = "PANDORA_AGENT=" + name;
putenv(name_agent.c_str()); printf("AGENT NAME2: %s\n", agent_name.c_str());
// Fall back to the hostname if agent_name is still empty.
if (agent_name == "") {
agent_name = Pandora_Windows_Info::getSystemName ();
this->conf->setValue("agent_name", agent_name);
}
printf("AGENT NAME3: %s\n", agent_name.c_str());
printf("AGENT NAME4: %s\n", this->conf->getValue("agent_name").c_str());
// Get the agent alias.
conf->getValue ("agent_alias");
if (agent_alias == "") {
agent_alias = Pandora_Windows_Info::getSystemName ();
this->conf->setValue("agent_alias", agent_alias);
}
pandora_agent = "PANDORA_AGENT=" + agent_name;
putenv(pandora_agent.c_str());
debug = conf->getValue ("debug"); debug = conf->getValue ("debug");
setPandoraDebug (is_enabled (debug)); setPandoraDebug (is_enabled (debug));
@ -383,7 +434,7 @@ Pandora_Windows_Service::launchTentacleProxy() {
string string
Pandora_Windows_Service::getXmlHeader () { Pandora_Windows_Service::getXmlHeader () {
char timestamp[20]; char timestamp[20];
string agent_name, os_name, os_version, encoding, value, xml, address, parent_agent_name, agent_name_cmd; string agent_name, os_name, os_version, encoding, value, xml, address, parent_agent_name, agent_name_cmd, agent_alias;
string custom_id, url_address, latitude, longitude, altitude, position_description, gis_exec, gis_result, agent_mode; string custom_id, url_address, latitude, longitude, altitude, position_description, gis_exec, gis_result, agent_mode;
string group_password, group_id, ehorus_conf; string group_password, group_id, ehorus_conf;
time_t ctime; time_t ctime;
@ -392,30 +443,9 @@ Pandora_Windows_Service::getXmlHeader () {
// Get agent name // Get agent name
agent_name = conf->getValue ("agent_name"); agent_name = conf->getValue ("agent_name");
if (agent_name == "") {
agent_name = Pandora_Windows_Info::getSystemName ();
}
agent_name_cmd = conf->getValue ("agent_name_cmd"); // Get agent alias
if (agent_name_cmd != "") { conf->getValue ("agent_alias");
agent_name_cmd = "cmd.exe /c \"" + agent_name_cmd + "\"";
static string temp_agent_name = getAgentNameFromCmdExec(agent_name_cmd);
// Delete carriage return if is provided
pos = temp_agent_name.find("\n");
if(pos != string::npos) {
temp_agent_name.erase(pos, temp_agent_name.size () - pos);
}
pos = temp_agent_name.find("\r");
if(pos != string::npos) {
temp_agent_name.erase(pos, temp_agent_name.size () - pos);
}
// Remove white spaces of the first and last.
temp_agent_name = trim(temp_agent_name);
if (temp_agent_name != "") {
agent_name = temp_agent_name;
}
}
// Get parent agent name // Get parent agent name
parent_agent_name = conf->getValue ("parent_agent_name"); parent_agent_name = conf->getValue ("parent_agent_name");
@ -443,6 +473,7 @@ Pandora_Windows_Service::getXmlHeader () {
xml = "<?xml version=\"1.0\" encoding=\"" + encoding + "\" ?>\n" + xml = "<?xml version=\"1.0\" encoding=\"" + encoding + "\" ?>\n" +
"<agent_data agent_name=\"" + agent_name + "<agent_data agent_name=\"" + agent_name +
"\" agent_alias=\"" + agent_alias +
"\" description=\"" + conf->getValue ("description") + "\" description=\"" + conf->getValue ("description") +
"\" version=\"" + getPandoraAgentVersion (); "\" version=\"" + getPandoraAgentVersion ();
@ -1492,35 +1523,8 @@ Pandora_Windows_Service::checkConfig (string file) {
} }
/* Get agent name */ /* Get agent name */
tmp = checkAgentName(file); tmp = conf->getValue ("agent_name");
if (tmp.empty ()) {
tmp = Pandora_Windows_Info::getSystemName ();
}
agent_name = tmp;
/* Get agent name cmd */
tmp = conf->getValue ("agent_name_cmd");
if (!tmp.empty ()) {
tmp = "cmd.exe /c \"" + tmp + "\"";
tmp = getCoordinatesFromCmdExec(tmp);
// Delete carriage return if is provided
pos = tmp.find("\n");
if(pos != string::npos) {
tmp.erase(pos, tmp.size () - pos);
}
pos = tmp.find("\r");
if(pos != string::npos) {
tmp.erase(pos, tmp.size () - pos);
}
// Remove white spaces of the first and last.
tmp = trim (tmp);
if (tmp != "") {
agent_name = tmp;
}
}
/* Error getting agent name */ /* Error getting agent name */
if (agent_name.empty ()) { if (agent_name.empty ()) {
@ -1722,10 +1726,6 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
/* Generate temporal filename */ /* Generate temporal filename */
random_integer = inttostr (rand()); random_integer = inttostr (rand());
tmp_filename = conf->getValue ("agent_name"); tmp_filename = conf->getValue ("agent_name");
if (tmp_filename == "") {
tmp_filename = Pandora_Windows_Info::getSystemName ();
}
tmp_filename += "." + random_integer + ".data"; tmp_filename += "." + random_integer + ".data";
xml_filename = conf->getValue ("temporal"); xml_filename = conf->getValue ("temporal");
@ -2098,3 +2098,17 @@ Pandora_Windows_Service::getIntensiveInterval () {
return this->intensive_interval; return this->intensive_interval;
} }
string
Pandora_Windows_Service::generateAgentName () {
stringstream data;
char digest[SHA256_HEX_LENGTH + 1];
std::srand(std::time(0));
data << this->conf->getValue("agent_alias") <<
this->conf->getValue("server_ip") <<
time(NULL) <<
std::rand();
sha256(data.str().c_str(), digest);
return std::string(digest);
}

View File

@ -44,6 +44,7 @@ namespace Pandora {
Pandora_Module_List *modules; Pandora_Module_List *modules;
long execution_number; long execution_number;
string agent_name; string agent_name;
string alias;
time_t timestamp; time_t timestamp;
time_t run_time; time_t run_time;
bool started; bool started;
@ -117,6 +118,7 @@ namespace Pandora {
string getEHKey (string ehorus_conf); string getEHKey (string ehorus_conf);
long getInterval (); long getInterval ();
long getIntensiveInterval (); long getIntensiveInterval ();
string generateAgentName ();
}; };
} }

View File

@ -223,9 +223,10 @@ function mainAgentsAlerts() {
} }
foreach ($agents as $agent) { foreach ($agents as $agent) {
$alias = db_get_row ('tagente', 'id_agente', $agent['id_agente']);
echo '<tr>'; echo '<tr>';
// Name of the agent // Name of the agent
echo '<td style="font-weight:bold;">'.$agent['nombre'].'</td>'; echo '<td style="font-weight:bold;">'.$alias['alias'].'</td>';
// Alerts of the agent // Alerts of the agent
$anyfired = false; $anyfired = false;

View File

@ -386,6 +386,10 @@ function mainAgentsModules() {
foreach ($agents as $agent) { foreach ($agents as $agent) {
// Get stats for this group // Get stats for this group
$agent_status = agents_get_status($agent['id_agente']); $agent_status = agents_get_status($agent['id_agente']);
$alias = db_get_row ("tagente", "id_agente", $agent['id_agente']);
if (empty($alias['alias'])){
$alias['alias'] = $agent['nombre'];
}
switch($agent_status) { switch($agent_status) {
case 4: // Alert fired status case 4: // Alert fired status
@ -411,7 +415,7 @@ function mainAgentsModules() {
echo "<td class='$rowcolor'> echo "<td class='$rowcolor'>
<a class='$rowcolor' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$agent['id_agente']."'>" . <a class='$rowcolor' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$agent['id_agente']."'>" .
ui_print_truncate_text(io_safe_output($agent['nombre']), 'agent_size_text_small', true, true, true, '...', 'font-size:10px; font-weight: bold;') . $alias['alias'] .
"</a></td>"; "</a></td>";
$agent_modules = agents_get_modules($agent['id_agente'], false, $filter_module_group, true, true); $agent_modules = agents_get_modules($agent['id_agente'], false, $filter_module_group, true, true);
@ -639,4 +643,4 @@ extensions_add_main_function('mainAgentsModules');
"json" "json"
); );
} }
</script> </script>

View File

@ -37,10 +37,12 @@ function createXMLData($agent, $agentModule, $time, $data) {
$xml = sprintf($xmlTemplate, io_safe_output(get_os_name($agent['id_os'])), $xml = sprintf($xmlTemplate, io_safe_output(get_os_name($agent['id_os'])),
io_safe_output($agent['os_version']), $agent['intervalo'], io_safe_output($agent['os_version']), $agent['intervalo'],
io_safe_output($agent['agent_version']), $time, io_safe_output($agent['agent_version']), $time,
io_safe_output($agent['nombre']), $agent['timezone_offset'], io_safe_output($agent['nombre']),
io_safe_output($agent['alias']), $agent['timezone_offset'],
io_safe_output($agentModule['nombre']), io_safe_output($agentModule['descripcion']), modules_get_type_name($agentModule['id_tipo_modulo']), $data); io_safe_output($agentModule['nombre']), io_safe_output($agentModule['descripcion']), modules_get_type_name($agentModule['id_tipo_modulo']), $data);
if (false === @file_put_contents($config['remote_config'] . '/' . io_safe_output($agent['nombre']) . '.' . strtotime($time) . '.data', $xml)) {
if (false === @file_put_contents($config['remote_config'] . '/' . io_safe_output($agent['alias']) . '.' . strtotime($time) . '.data', $xml)) {
return false; return false;
} }
else { else {
@ -61,6 +63,14 @@ function mainInsertData() {
$save = (bool)get_parameter('save', false); $save = (bool)get_parameter('save', false);
$id_agent = (string)get_parameter('id_agent', ''); $id_agent = (string)get_parameter('id_agent', '');
foreach ($_POST as $key => $value) {
if(strpos($key,"agent_autocomplete_idagent")!== false){
$id_agente = $value;
}
}
$id_agent_module = (int)get_parameter('id_agent_module', ''); $id_agent_module = (int)get_parameter('id_agent_module', '');
$data = (string)get_parameter('data'); $data = (string)get_parameter('data');
$date = (string) get_parameter('date', date(DATE_FORMAT)); $date = (string) get_parameter('date', date(DATE_FORMAT));
@ -83,7 +93,8 @@ function mainInsertData() {
ui_print_error_message(__('You haven\'t privileges for insert data in the agent.')); ui_print_error_message(__('You haven\'t privileges for insert data in the agent.'));
} }
else { else {
$agent = db_get_row_filter('tagente', array('nombre' => $id_agent));
$agent = db_get_row_filter('tagente', array('id_agente' => $id_agente));
$agentModule = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $id_agent_module)); $agentModule = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $id_agent_module));
$done = 0; $done = 0;
@ -116,14 +127,14 @@ function mainInsertData() {
} }
if ($errors > 0) { if ($errors > 0) {
$msg = sprintf(__('Can\'t save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']); $msg = sprintf(__('Can\'t save agent (%s), module (%s) data xml.'), $agent['alias'], $agentModule['nombre']);
if ($errors > 1) { if ($errors > 1) {
$msg .= " ($errors)"; $msg .= " ($errors)";
} }
ui_print_error_message($msg); ui_print_error_message($msg);
} }
if ($done > 0) { if ($done > 0) {
$msg = sprintf(__('Save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']); $msg = sprintf(__('Save agent (%s), module (%s) data xml.'), $agent['alias'], $agentModule['nombre']);
if ($done > 1) { if ($done > 1) {
$msg .= " ($done)"; $msg .= " ($done)";
} }
@ -153,14 +164,19 @@ function mainInsertData() {
$params['javascript_is_function_select'] = true; $params['javascript_is_function_select'] = true;
$params['javascript_name_function_select'] = 'custom_select_function'; $params['javascript_name_function_select'] = 'custom_select_function';
$params['javascript_code_function_select'] = ''; $params['javascript_code_function_select'] = '';
$params['use_hidden_input_idagent'] = true;
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-autocomplete_id_agent';
$table->data[0][1] = ui_print_agent_autocomplete_input($params); $table->data[0][1] = ui_print_agent_autocomplete_input($params);
$table->data[1][0] = __('Module'); $table->data[1][0] = __('Module');
$modules = array (); $modules = array ();
if ($id_agent) if ($id_agente){
$modules = agents_get_modules ($id_agent, false, array("delete_pending" => 0)); $modules = agents_get_modules ($id_agente, false, array("delete_pending" => 0));
}
$table->data[1][1] = html_print_select ($modules, 'id_agent_module', $id_agent_module, true, $table->data[1][1] = html_print_select ($modules, 'id_agent_module', $id_agent_module, true,
__('Select'), 0, true, false, true, '', ($id_agent === '')); __('Select'), 0, true, false, true, '', ($id_agente === ''));
$table->data[2][0] = __('Data'); $table->data[2][0] = __('Data');
$table->data[2][1] = html_print_input_text('data', $data, __('Data'), 40, 60, true); $table->data[2][1] = html_print_input_text('data', $data, __('Data'), 40, 60, true);
$table->data[3][0] = __('Date'); $table->data[3][0] = __('Date');
@ -206,9 +222,10 @@ function mainInsertData() {
function custom_select_function(agent_name) { function custom_select_function(agent_name) {
$('#id_agent_module').empty (); $('#id_agent_module').empty ();
var inputs = []; var inputs = [];
inputs.push ("agent_name=" + agent_name); var id_agent = $('#hidden-autocomplete_id_agent').val();
inputs.push ("id_agent=" + id_agent);
inputs.push ("delete_pending=0"); inputs.push ("delete_pending=0");
inputs.push ("get_agent_modules_json=1"); inputs.push ("get_agent_modules_json=1");
inputs.push ("page=operation/agentes/ver_agente"); inputs.push ("page=operation/agentes/ver_agente");

View File

@ -97,12 +97,12 @@ function output_xml_report($id) {
echo "<description>" . io_safe_output($item['description']) . "</description>\n"; echo "<description>" . io_safe_output($item['description']) . "</description>\n";
echo "<period>" . io_safe_output($item['period']) . "</period>\n"; echo "<period>" . io_safe_output($item['period']) . "</period>\n";
if ($item['id_agent'] != 0) { if ($item['id_agent'] != 0) {
$agent = agents_get_name($item['id_agent']); $agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
} }
if ($item['id_agent_module'] != 0) { if ($item['id_agent_module'] != 0) {
$module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']); $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']);
$id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']); $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']);
$agent = agents_get_name($item['id_agent']); $agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
echo "<module><![CDATA[" . io_safe_output($module) . "]]></module>\n"; echo "<module><![CDATA[" . io_safe_output($module) . "]]></module>\n";
} }
@ -140,7 +140,7 @@ function output_xml_report($id) {
foreach ($slas as $sla) { foreach ($slas as $sla) {
$module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']); $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']);
$id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']); $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']);
$agent = agents_get_name($item['id_agent']); $agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
echo "<sla>"; echo "<sla>";
echo "<agent><![CDATA[" . $agent . "]]></agent>\n"; echo "<agent><![CDATA[" . $agent . "]]></agent>\n";
echo "<module><![CDATA[" . io_safe_output($module) . "]]></module>\n"; echo "<module><![CDATA[" . io_safe_output($module) . "]]></module>\n";
@ -245,8 +245,14 @@ function output_xml_visual_console($id) {
foreach ($items as $item) { foreach ($items as $item) {
echo "<item>\n"; echo "<item>\n";
echo "<other_id>" . $item['id'] . "</other_id>\n"; //OLD ID USE FOR parent item echo "<other_id>" . $item['id'] . "</other_id>\n"; //OLD ID USE FOR parent item
$agent = '';
if ($item['id_agent'] != 0) {
$agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
}
if (!empty($item['label'])) { if (!empty($item['label'])) {
echo "<label><![CDATA[" . io_safe_output($item['label']) . "]]></label>\n"; $aux = explode("-",$item['label']);
$label = $agent .' -'. $aux[1];
echo "<label><![CDATA[" . io_safe_output($label) . "]]></label>\n";
} }
echo "<x>" . $item['pos_x'] . "</x>\n"; echo "<x>" . $item['pos_x'] . "</x>\n";
echo "<y>" . $item['pos_y'] . "</y>\n"; echo "<y>" . $item['pos_y'] . "</y>\n";
@ -263,15 +269,11 @@ function output_xml_visual_console($id) {
if ($item['period'] != 0) { if ($item['period'] != 0) {
echo "<period>" . $item['period'] . "</period>\n"; echo "<period>" . $item['period'] . "</period>\n";
} }
$agent = '';
if ($item['id_agent'] != 0) {
$agent = agents_get_name($item['id_agent']);
}
if (isset($item['id_agente_modulo'])) { if (isset($item['id_agente_modulo'])) {
if ($item['id_agente_modulo'] != 0) { if ($item['id_agente_modulo'] != 0) {
$module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']); $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']);
$id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']); $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']);
$agent = agents_get_name($id_agent); $agent = db_get_value ("alias","tagente","id_agente",$id_agent);
echo "<module><![CDATA[" . io_safe_output($module) . "]]></module>\n"; echo "<module><![CDATA[" . io_safe_output($module) . "]]></module>\n";
} }

View File

@ -219,7 +219,9 @@ ALTER TABLE tnetwork_component ADD COLUMN `dynamic_two_tailed` tinyint(1) unsign
ALTER TABLE tagente ADD `transactional_agent` tinyint(1) NOT NULL default 0; ALTER TABLE tagente ADD `transactional_agent` tinyint(1) NOT NULL default 0;
ALTER TABLE tagente ADD `remote` tinyint(1) NOT NULL default 0; ALTER TABLE tagente ADD `remote` tinyint(1) NOT NULL default 0;
ALTER TABLE tagente ADD `cascade_protection_module` int(10) unsigned default '0'; ALTER TABLE tagente ADD `cascade_protection_module` int(10) unsigned default '0';
ALTER TABLE tagente ADD COLUMN (alias varchar(600) not null default '');
UPDATE tagente SET tagente.alias = tagente.nombre;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tlayout` -- Table `tlayout`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------

View File

@ -134,7 +134,9 @@ ALTER TABLE tnetwork_component ADD COLUMN dynamic_two_tailed tinyint(1) unsigned
ALTER TABLE tagente ADD transactional_agent tinyint(1) NOT NULL default 0; ALTER TABLE tagente ADD transactional_agent tinyint(1) NOT NULL default 0;
ALTER TABLE tagente ADD remoteto tinyint(1) NOT NULL default 0; ALTER TABLE tagente ADD remoteto tinyint(1) NOT NULL default 0;
ALTER TABLE tagente ADD cascade_protection_module int(10) unsigned default '0'; ALTER TABLE tagente ADD cascade_protection_module int(10) unsigned default '0';
ALTER TABLE tagente ADD COLUMN (alias VARCHAR2(600) not null DEFAULT '');
UPDATE `tagente` SET tagente.alias = tagente.nombre;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tlayout` -- Table `tlayout`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------

View File

@ -30,10 +30,10 @@ if (is_ajax ()) {
switch ($config['dbtype']) { switch ($config['dbtype']) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
$filter[] = '(nombre COLLATE utf8_general_ci LIKE "%' . $string . '%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")'; $filter[] = '(nombre COLLATE utf8_general_ci LIKE "%' . $string . '%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%" OR alias LIKE "%'.$string.'%")';
break; break;
case "oracle": case "oracle":
$filter[] = '(upper(nombre) LIKE upper(\'%'.$string.'%\') OR upper(direccion) LIKE upper(\'%'.$string.'%\') OR upper(comentarios) LIKE upper(\'%'.$string.'%\'))'; $filter[] = '(upper(nombre) LIKE upper(\'%'.$string.'%\') OR upper(direccion) LIKE upper(\'%'.$string.'%\') OR upper(comentarios) LIKE upper(\'%'.$string.'%\') OR upper(alias) LIKE upper(\'%'.$string.'%\'))';
break; break;
} }
$filter[] = 'id_agente != ' . $id_agent; $filter[] = 'id_agente != ' . $id_agent;
@ -151,21 +151,26 @@ $table->data = array ();
$table->align[2] = 'center'; $table->align[2] = 'center';
$table->data[0][0] = __('Agent name') . if(!$new_agent && $alias != ''){
ui_print_help_tip (__("The agent's name must be the same as the one defined at the console"), true); $table->data[0][0] = __('Agent name') .
$table->data[0][1] = html_print_input_text ('agente', $nombre_agente, '', 50, 100,true); ui_print_help_tip (__("The agent's name must be the same as the one defined at the console"), true);
$table->data[0][1] = html_print_input_text ('agente', $nombre_agente, '', 50, 100,true);
$table->data[0][2] = __('QR Code Agent view'); $table->data[0][2] = __('QR Code Agent view');
if ($id_agente) { if ($id_agente) {
$table->data[0][1] .= "&nbsp;<b>" . __("ID") . "</b>&nbsp; $id_agente &nbsp;"; $table->data[0][1] .= "&nbsp;<b>" . __("ID") . "</b>&nbsp; $id_agente &nbsp;";
$table->data[0][1] .= '&nbsp;&nbsp;<a href="index.php?sec=gagente&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">'; $table->data[0][1] .= '&nbsp;&nbsp;<a href="index.php?sec=gagente&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">';
$table->data[0][1] .= html_print_image ("images/zoom.png", $table->data[0][1] .= html_print_image ("images/zoom.png",
true, array ("border" => 0, "title" => __('Agent detail'))); true, array ("border" => 0, "title" => __('Agent detail')));
$table->data[0][1] .= '</a>'; $table->data[0][1] .= '</a>';
}
} }
// Remote configuration available // Remote configuration available
if (!$new_agent) { if (!$new_agent) {
if (isset($filename)) { if (isset($filename)) {
@ -197,17 +202,21 @@ if (!$new_agent) {
if (!$new_agent) { if (!$new_agent) {
$table->data[0][1] .= "&nbsp;&nbsp;<span align='right'><a onClick=\"if (!confirm('" . __('Are you sure?') . "')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'>" . html_print_image('images/cross.png', true, array('title' => __("Delete agent"))) . "</a>"; $table->data[0][1] .= "&nbsp;&nbsp;<span align='right'><a onClick=\"if (!confirm('" . __('Are you sure?') . "')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'>" . html_print_image('images/cross.png', true, array('title' => __("Delete agent"))) . "</a>";
} }
$table->data[1][0] = __('Alias');
$table->data[1][1] = html_print_input_text ('alias', $alias, '', 50, 100, true);
$table->data[1][0] = __('IP Address');
$table->data[1][1] = html_print_input_text ('direccion', $direccion_agente, '', 16, 100, true);
$table->data[2][0] = __('IP Address');
$table->data[2][1] = html_print_input_text ('direccion', $direccion_agente, '', 16, 100, true);
if ($id_agente) { if ($id_agente) {
$table->data[1][1] .= '&nbsp;&nbsp;&nbsp;&nbsp;'; $table->data[2][1] .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$ip_all = agents_get_addresses ($id_agente); $ip_all = agents_get_addresses ($id_agente);
$table->data[1][1] .= html_print_select ($ip_all, "address_list", $direccion_agente, '', '', 0, true); $table->data[2][1] .= html_print_select ($ip_all, "address_list", $direccion_agente, '', '', 0, true);
$table->data[1][1] .= "&nbsp;". html_print_checkbox ("delete_ip", 1, false, true).__('Delete selected'); $table->data[2][1] .= "&nbsp;". html_print_checkbox ("delete_ip", 1, false, true).__('Delete selected');
} }
?> ?>
@ -217,77 +226,83 @@ if ($id_agente) {
} }
</style> </style>
<?php <?php
$table->rowspan[1][2] = 3; if(!$new_agent){
if ($id_agente) { $table->rowspan[2][2] = 3;
$table->data[1][2] = if ($id_agente) {
"<a id='qr_code_agent_view' href='javascript: show_dialog_qrcode(null, \"" . $table->data[2][2] =
ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente) . "\" );'></a>"; "<a id='qr_code_agent_view' href='javascript: show_dialog_qrcode(null, \"" .
} ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente) . "\" );'></a>";
else { }
$table->data[1][2] = __("Only it is show when<br />the agent is saved."); else {
$table->data[2][2] = __("Only it is show when<br />the agent is saved.");
}
} }
$groups = users_get_groups ($config["id_user"], "AR",false); $groups = users_get_groups ($config["id_user"], "AR",false);
$agents = agents_get_group_agents (array_keys ($groups)); $agents = agents_get_group_agents (array_keys ($groups));
$modules = db_get_all_rows_sql("SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo $modules = db_get_all_rows_sql("SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo
WHERE id_agente = " . $id_parent); WHERE id_agente = " . $id_parent);
$modules_values = array(); $modules_values = array();
$modules_values[0] = __('Any'); $modules_values[0] = __('Any');
foreach ($modules as $m) { foreach ($modules as $m) {
$modules_values[$m['id_module']] = $m['name']; $modules_values[$m['id_module']] = $m['name'];
} }
$table->data[2][0] = __('Parent'); $table->data[3][0] = __('Parent');
$params = array(); $params = array();
$params['return'] = true; $params['return'] = true;
$params['show_helptip'] = true; $params['show_helptip'] = true;
$params['input_name'] = 'id_parent'; $params['input_name'] = 'id_parent';
$params['value'] = agents_get_name ($id_parent); $params['print_hidden_input_idagent'] = true;
$table->data[2][1] = ui_print_agent_autocomplete_input($params); $params['hidden_input_idagent_name'] = 'id_agent_parent';
$params['hidden_input_idagent_value'] = $id_parent;
$params['value'] = db_get_value ("alias","tagente","id_agente",$id_parent);
$table->data[3][1] = ui_print_agent_autocomplete_input($params);
$table->data[2][1] .= html_print_checkbox ("cascade_protection", 1, $cascade_protection, true).__('Cascade protection'). "&nbsp;" . ui_print_help_icon("cascade_protection", true); $table->data[3][1] .= html_print_checkbox ("cascade_protection", 1, $cascade_protection, true).__('Cascade protection'). "&nbsp;" . ui_print_help_icon("cascade_protection", true);
$table->data[2][1] .= "&nbsp;&nbsp;" . __('Module') . "&nbsp;" . html_print_select ($modules_values, "cascade_protection_module", $cascade_protection_module, "", "", 0, true); $table->data[3][1] .= "&nbsp;&nbsp;" . __('Module') . "&nbsp;" . html_print_select ($modules_values, "cascade_protection_module", $cascade_protection_module, "", "", 0, true);
$table->data[3][0] = __('Group'); $table->data[4][0] = __('Group');
$table->data[3][1] = html_print_select_groups(false, "AR", false, 'grupo', $grupo, '', '', 0, true); $table->data[4][1] = html_print_select_groups(false, "AR", false, 'grupo', $grupo, '', '', 0, true);
$table->data[3][1] .= ' <span id="group_preview">'; $table->data[4][1] .= ' <span id="group_preview">';
$table->data[3][1] .= ui_print_group_icon ($grupo, true); $table->data[4][1] .= ui_print_group_icon ($grupo, true);
$table->data[3][1] .= '</span>'; $table->data[4][1] .= '</span>';
$table->data[4][0] = __('Interval'); $table->data[5][0] = __('Interval');
$table->data[4][1] = html_print_extended_select_for_time ('intervalo', $intervalo, '', '', '0', 10, true); $table->data[5][1] = html_print_extended_select_for_time ('intervalo', $intervalo, '', '', '0', 10, true);
if ($intervalo < SECONDS_5MINUTES) { if ($intervalo < SECONDS_5MINUTES) {
$table->data[4][1] .= clippy_context_help("interval_agent_min"); $table->data[5][1] .= clippy_context_help("interval_agent_min");
} }
$table->data[5][0] = __('OS'); $table->data[6][0] = __('OS');
$table->data[5][1] = html_print_select_from_sql ('SELECT id_os, name FROM tconfig_os', $table->data[6][1] = html_print_select_from_sql ('SELECT id_os, name FROM tconfig_os',
'id_os', $id_os, '', '', '0', true); 'id_os', $id_os, '', '', '0', true);
$table->data[5][1] .= ' <span id="os_preview">'; $table->data[6][1] .= ' <span id="os_preview">';
$table->data[5][1] .= ui_print_os_icon ($id_os, false, true); $table->data[6][1] .= ui_print_os_icon ($id_os, false, true);
$table->data[5][1] .= '</span>'; $table->data[6][1] .= '</span>';
// Network server // Network server
$servers = servers_get_names(); $servers = servers_get_names();
if (!array_key_exists($server_name, $servers)) { if (!array_key_exists($server_name, $servers)) {
$server_Name = 0; //Set the agent have not server. $server_Name = 0; //Set the agent have not server.
} }
$table->data[6][0] = __('Server'); $table->data[7][0] = __('Server');
if ($new_agent) { if ($new_agent) {
//Set first server by default. //Set first server by default.
$servers_get_names = servers_get_names(); $servers_get_names = servers_get_names();
$array_keys_servers_get_names = array_keys($servers_get_names); $array_keys_servers_get_names = array_keys($servers_get_names);
$server_name = reset($array_keys_servers_get_names); $server_name = reset($array_keys_servers_get_names);
} }
$table->data[6][1] = html_print_select (servers_get_names (), $table->data[7][1] = html_print_select (servers_get_names (),
'server_name', $server_name, '', __('None'), 0, true). ' ' . ui_print_help_icon ('agent_server', true); 'server_name', $server_name, '', __('None'), 0, true). ' ' . ui_print_help_icon ('agent_server', true);
// Description // Description
$table->data[7][0] = __('Description'); $table->data[8][0] = __('Description');
$table->data[7][1] = html_print_input_text ('comentarios', $comentarios, $table->data[8][1] = html_print_input_text ('comentarios', $comentarios,
'', 45, 200, true); '', 45, 200, true);
html_print_table ($table); html_print_table ($table);
@ -593,5 +608,7 @@ ui_require_jquery_file('bgiframe');
echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente); echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente);
?>", ?>",
"#qr_code_agent_view", 128, 128); "#qr_code_agent_view", 128, 128);
$("#text-agente").prop('disabled', true);
}); });
</script> </script>

View File

@ -73,6 +73,7 @@ $campo_3 = "";
$maximo = 0; $maximo = 0;
$minimo = 0; $minimo = 0;
$nombre_agente = ""; $nombre_agente = "";
$alias = get_parameter('alias', '');
$direccion_agente = get_parameter('direccion', ''); $direccion_agente = get_parameter('direccion', '');
$direccion_agente = trim(io_safe_output($direccion_agente)); $direccion_agente = trim(io_safe_output($direccion_agente));
$direccion_agente = io_safe_input($direccion_agente); $direccion_agente = io_safe_input($direccion_agente);
@ -147,7 +148,8 @@ $module_macros = array ();
// Create agent // Create agent
if ($create_agent) { if ($create_agent) {
$nombre_agente = (string) get_parameter_post("agente",''); $nombre_agente = md5($alias . $direccion_agente);
$alias = (string) get_parameter_post("alias",'');
$direccion_agente = (string) get_parameter_post("direccion",''); $direccion_agente = (string) get_parameter_post("direccion",'');
$direccion_agente = trim(io_safe_output($direccion_agente)); $direccion_agente = trim(io_safe_output($direccion_agente));
$direccion_agente = io_safe_input($direccion_agente); $direccion_agente = io_safe_input($direccion_agente);
@ -179,18 +181,19 @@ if ($create_agent) {
} }
// Check if agent exists (BUG WC-50518-2) // Check if agent exists (BUG WC-50518-2)
if ($nombre_agente == "") { if ($alias == "") {
$agent_creation_error = __('No agent name specified'); $agent_creation_error = __('No agent alias specified');
$agent_created_ok = 0; $agent_created_ok = 0;
} }
elseif (agents_get_agent_id ($nombre_agente)) { /*elseif (agents_get_agent_id ($nombre_agente)) {
$agent_creation_error = $agent_creation_error =
__('There is already an agent in the database with this name'); __('There is already an agent in the database with this name');
$agent_created_ok = 0; $agent_created_ok = 0;
} }*/
else { else {
$id_agente = db_process_sql_insert ('tagente', $id_agente = db_process_sql_insert ('tagente',
array ('nombre' => $nombre_agente, array ('nombre' => $nombre_agente,
'alias' => $alias,
'direccion' => $direccion_agente, 'direccion' => $direccion_agente,
'id_grupo' => $grupo, 'id_grupo' => $grupo,
'intervalo' => $intervalo, 'intervalo' => $intervalo,
@ -241,7 +244,7 @@ if ($create_agent) {
' Quiet: ' . (int)$quiet; ' Quiet: ' . (int)$quiet;
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Created agent $nombre_agente", false, true, $info); "Created agent $alias", false, true, $info);
} }
else { else {
$id_agente = 0; $id_agente = 0;
@ -554,10 +557,9 @@ if ($id_agente) {
default: default:
break; break;
} }
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
ui_print_page_header ( ui_print_page_header ($agent["nombre"],
agents_get_name ($id_agente) . ' ' . $tab_description, "images/setup.png", false, $help_header , true, $onheader, false, '', GENERIC_SIZE_TEXT, $agent["alias"] . ' ' . $tab_description);
"images/setup.png", false, $help_header , true, $onheader);
} }
else { else {
// Create agent // Create agent
@ -641,6 +643,7 @@ $update_agent = (bool) get_parameter ('update_agent');
if ($update_agent) { // if modified some agent paramenter if ($update_agent) { // if modified some agent paramenter
$id_agente = (int) get_parameter_post ("id_agente"); $id_agente = (int) get_parameter_post ("id_agente");
$nombre_agente = str_replace('`','&lsquo;',(string) get_parameter_post ("agente", "")); $nombre_agente = str_replace('`','&lsquo;',(string) get_parameter_post ("agente", ""));
$alias = str_replace('`','&lsquo;',(string) get_parameter_post ("alias", ""));
$direccion_agente = (string) get_parameter_post ("direccion", ''); $direccion_agente = (string) get_parameter_post ("direccion", '');
$direccion_agente = trim(io_safe_output($direccion_agente)); $direccion_agente = trim(io_safe_output($direccion_agente));
$direccion_agente = io_safe_input($direccion_agente); $direccion_agente = io_safe_input($direccion_agente);
@ -705,14 +708,14 @@ if ($update_agent) { // if modified some agent paramenter
} }
//Verify if there is another agent with the same name but different ID //Verify if there is another agent with the same name but different ID
if ($nombre_agente == "") { if ($alias == "") {
ui_print_error_message(__('No agent name specified')); ui_print_error_message(__('No agent alias specified'));
//If there is an agent with the same name, but a different ID //If there is an agent with the same name, but a different ID
} }
elseif (agents_get_agent_id ($nombre_agente) > 0 && /*elseif (agents_get_agent_id ($nombre_agente) > 0 &&
agents_get_agent_id ($nombre_agente) != $id_agente) { agents_get_agent_id ($nombre_agente) != $id_agente) {
ui_print_error_message(__('There is already an agent in the database with this name')); ui_print_error_message(__('There is already an agent in the database with this name'));
} }*/
else { else {
//If different IP is specified than previous, add the IP //If different IP is specified than previous, add the IP
if ($direccion_agente != '' && if ($direccion_agente != '' &&
@ -732,7 +735,7 @@ if ($update_agent) { // if modified some agent paramenter
'id_parent' => $id_parent, 'id_parent' => $id_parent,
'id_os' => $id_os, 'id_os' => $id_os,
'modo' => $modo, 'modo' => $modo,
'nombre' => $nombre_agente, 'alias' => $alias,
'direccion' => $direccion_agente, 'direccion' => $direccion_agente,
'id_grupo' => $grupo, 'id_grupo' => $grupo,
'intervalo' => $intervalo, 'intervalo' => $intervalo,
@ -778,8 +781,8 @@ if ($update_agent) { // if modified some agent paramenter
enterprise_hook ('update_agent', array ($id_agente)); enterprise_hook ('update_agent', array ($id_agente));
ui_print_success_message (__('Successfully updated')); ui_print_success_message (__('Successfully updated'));
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Updated agent $nombre_agente", false, false, $info); "Updated agent $alias", false, false, $info);
} }
} }
} }
@ -804,6 +807,12 @@ if ($id_agente) {
$intervalo = $agent["intervalo"]; // Define interval in seconds $intervalo = $agent["intervalo"]; // Define interval in seconds
$nombre_agente = $agent["nombre"]; $nombre_agente = $agent["nombre"];
if(empty($alias)){
$alias = $agent["alias"];
if(empty($alias)){
$alias = $nombre_agente;
}
}
$direccion_agente = $agent["direccion"]; $direccion_agente = $agent["direccion"];
$grupo = $agent["id_grupo"]; $grupo = $agent["id_grupo"];
$ultima_act = $agent["ultimo_contacto"]; $ultima_act = $agent["ultimo_contacto"];
@ -1200,7 +1209,7 @@ if ($update_module) {
$edit_module = true; $edit_module = true;
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Fail to try update module '$name' for agent " . $agent["nombre"]); "Fail to try update module '$name' for agent " . $agent["alias"]);
} }
else { else {
if ($prediction_module == 3) { if ($prediction_module == 3) {
@ -1218,7 +1227,7 @@ if ($update_module) {
$agent = db_get_row ('tagente', 'id_agente', $id_agente); $agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Updated module '$name' for agent ".$agent["nombre"], false, false, io_json_mb_encode($values)); "Updated module '$name' for agent ".$agent["alias"], false, false, io_json_mb_encode($values));
} }
} }
@ -1336,7 +1345,7 @@ if ($create_module) {
$edit_module = true; $edit_module = true;
$moduletype = $id_module; $moduletype = $id_module;
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Fail to try added module '$name' for agent ".$agent["nombre"]); "Fail to try added module '$name' for agent ".$agent["alias"]);
} }
else { else {
if ($prediction_module == 3) { if ($prediction_module == 3) {
@ -1354,7 +1363,7 @@ if ($create_module) {
$agent = db_get_row ('tagente', 'id_agente', $id_agente); $agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Added module '$name' for agent ".$agent["nombre"], false, true, io_json_mb_encode($values)); "Added module '$name' for agent ".$agent["alias"], false, true, io_json_mb_encode($values));
} }
} }
@ -1471,7 +1480,7 @@ if ($delete_module) { // DELETE agent module !
$agent = db_get_row ('tagente', 'id_agente', $id_agente); $agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Deleted module '".$module_data["nombre"]."' for agent ".$agent["nombre"]); "Deleted module '".$module_data["nombre"]."' for agent ".$agent["alias"]);
} }
} }
@ -1502,11 +1511,11 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
if ($result) { if ($result) {
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Duplicate module '".$id_duplicate_module."' for agent " . $agent["nombre"] . " with the new id for clon " . $result); "Duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"] . " with the new id for clon " . $result);
} }
else { else {
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Fail to try duplicate module '".$id_duplicate_module."' for agent " . $agent["nombre"]); "Fail to try duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"]);
} }
} }

View File

@ -215,14 +215,14 @@ switch ($sortField) {
switch ($sort) { switch ($sort) {
case 'up': case 'up':
$selectNameUp = $selected; $selectNameUp = $selected;
$order = array('field' => 'nombre ' . $order_collation, $order = array('field' => 'alias ' . $order_collation,
'field2' => 'nombre ' . $order_collation, 'field2' => 'alias ' . $order_collation,
'order' => 'ASC'); 'order' => 'ASC');
break; break;
case 'down': case 'down':
$selectNameDown = $selected; $selectNameDown = $selected;
$order = array('field' => 'nombre ' . $order_collation, $order = array('field' => 'alias ' . $order_collation,
'field2' => 'nombre ' . $order_collation, 'field2' => 'alias ' . $order_collation,
'order' => 'DESC'); 'order' => 'DESC');
break; break;
} }
@ -232,13 +232,13 @@ switch ($sortField) {
case 'up': case 'up':
$selectOsUp = $selected; $selectOsUp = $selected;
$order = array('field' => 'id_os', $order = array('field' => 'id_os',
'field2' => 'nombre ' . $order_collation, 'field2' => 'alias ' . $order_collation,
'order' => 'ASC'); 'order' => 'ASC');
break; break;
case 'down': case 'down':
$selectOsDown = $selected; $selectOsDown = $selected;
$order = array('field' => 'id_os', $order = array('field' => 'id_os',
'field2' => 'nombre ' . $order_collation, 'field2' => 'alias ' . $order_collation,
'order' => 'DESC'); 'order' => 'DESC');
break; break;
} }
@ -248,13 +248,13 @@ switch ($sortField) {
case 'up': case 'up':
$selectGroupUp = $selected; $selectGroupUp = $selected;
$order = array('field' => 'id_grupo', $order = array('field' => 'id_grupo',
'field2' => 'nombre ' . $order_collation, 'field2' => 'alias ' . $order_collation,
'order' => 'ASC'); 'order' => 'ASC');
break; break;
case 'down': case 'down':
$selectGroupDown = $selected; $selectGroupDown = $selected;
$order = array('field' => 'id_grupo', $order = array('field' => 'id_grupo',
'field2' => 'nombre ' . $order_collation, 'field2' => 'alias ' . $order_collation,
'order' => 'DESC'); 'order' => 'DESC');
break; break;
} }
@ -266,8 +266,8 @@ switch ($sortField) {
$selectOsDown = ''; $selectOsDown = '';
$selectGroupUp = ''; $selectGroupUp = '';
$selectGroupDown = ''; $selectGroupDown = '';
$order = array('field' => 'nombre ' . $order_collation, $order = array('field' => 'alias ' . $order_collation,
'field2' => 'nombre ' . $order_collation, 'field2' => 'alias ' . $order_collation,
'order' => 'ASC'); 'order' => 'ASC');
break; break;
} }
@ -292,8 +292,9 @@ if ($search != "") {
} }
$search_sql .= ")"; $search_sql .= ")";
}else{ }else{
$search_sql = " AND ( LOWER(nombre) " . $order_collation . " $search_sql = " AND ( nombre " . $order_collation . "
LIKE LOWER('%$search%')) "; LIKE '%$search%' OR alias " . $order_collation . "
LIKE '%$search%') ";
} }
} }
@ -386,7 +387,7 @@ else {
FROM tagente FROM tagente
WHERE 1=1 WHERE 1=1
%s %s
ORDER BY %s %s %s LIMIT %d OFFSET %d', $search_sql, $order['field'], $order['field2'], ORDER BY %s %s, %s %s LIMIT %d OFFSET %d', $search_sql, $order['field'],$order['order'], $order['field2'],
$order['order'], $config["block_size"], $offset); $order['order'], $config["block_size"], $offset);
break; break;
case "oracle": case "oracle":
@ -397,7 +398,7 @@ else {
FROM tagente FROM tagente
WHERE 1=1 WHERE 1=1
%s %s
ORDER BY %s %s %s', $search_sql, $order['field'], $order['field2'], $order['order']); ORDER BY %s %s, %s %s', $search_sql, $order['field'],$order['order'], $order['field2'], $order['order']);
$sql = oracle_recode_query ($sql, $set); $sql = oracle_recode_query ($sql, $set);
break; break;
} }
@ -547,11 +548,14 @@ if ($agents !== false) {
else { else {
$main_tab = 'module'; $main_tab = 'module';
} }
echo "<a href='index.php?sec=gagente& if($agent["alias"] == ''){
$agent["alias"] = $agent["nombre"];
}
echo "<a alt =".$agent["nombre"]." href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=$main_tab& sec2=godmode/agentes/configurar_agente&tab=$main_tab&
id_agente=" . $agent["id_agente"] . "'>" . id_agente=" . $agent["id_agente"] . "'>" .
ui_print_truncate_text($agent["nombre"], 'agent_medium', true, true, true, '[&hellip;]', 'font-size: 7pt') . '<span style="font-size: 7pt" title="' . $agent["nombre"] . '">'.$agent["alias"].'</span>' .
"</a>"; "</a>";
echo "</strong>"; echo "</strong>";
if ($agent["disabled"]) { if ($agent["disabled"]) {

View File

@ -672,7 +672,7 @@ if ($id_downtime > 0) {
} }
$sql = sprintf("SELECT tagente.id_agente, tagente.nombre $sql = sprintf("SELECT tagente.id_agente, tagente.alias
FROM tagente FROM tagente
WHERE tagente.id_agente NOT IN ( WHERE tagente.id_agente NOT IN (
SELECT tagente.id_agente SELECT tagente.id_agente
@ -687,7 +687,7 @@ if ($id_downtime > 0) {
$agents = array(); $agents = array();
$agent_ids = extract_column($agents, 'id_agente'); $agent_ids = extract_column($agents, 'id_agente');
$agent_names = extract_column($agents, 'nombre'); $agent_names = extract_column($agents, 'alias');
// item[<id>] = <name>; // item[<id>] = <name>;
$agents = array_combine($agent_ids, $agent_names); $agents = array_combine($agent_ids, $agent_names);
if ($agents === false) if ($agents === false)
@ -765,7 +765,8 @@ if ($id_downtime > 0) {
foreach ($downtimes_agents as $downtime_agent) { foreach ($downtimes_agents as $downtime_agent) {
$data = array (); $data = array ();
$data[0] = $downtime_agent['nombre']; $alias = db_get_value("alias","tagente","id_agente",$downtime_agent['id_agente']);
$data[0] = $alias;
$data[1] = db_get_sql ("SELECT nombre $data[1] = db_get_sql ("SELECT nombre
FROM tgrupo FROM tgrupo

View File

@ -150,7 +150,7 @@ if (!empty($downtimes)) {
$affected_items = array(); $affected_items = array();
$sql_agents = "SELECT tpda.id_agent AS agent_id, tpda.all_modules AS all_modules, ta.nombre AS agent_name $sql_agents = "SELECT tpda.id_agent AS agent_id, tpda.all_modules AS all_modules, ta.nombre AS agent_name, ta.alias
FROM tplanned_downtime_agents tpda, tagente ta FROM tplanned_downtime_agents tpda, tagente ta
WHERE tpda.id_downtime = $id WHERE tpda.id_downtime = $id
AND tpda.id_agent = ta.id_agente"; AND tpda.id_agent = ta.id_agente";
@ -159,7 +159,7 @@ if (!empty($downtimes)) {
if (!empty($downtime_agents)) { if (!empty($downtime_agents)) {
foreach ($downtime_agents as $downtime_agent) { foreach ($downtime_agents as $downtime_agent) {
$downtime_items = array(); $downtime_items = array();
$downtime_items[] = $downtime_agent['agent_name']; $downtime_items[] = $downtime_agent[alias];
if (!$downtime_agent['all_modules']) { if (!$downtime_agent['all_modules']) {
$agent_id = $downtime_agent['agent_id']; $agent_id = $downtime_agent['agent_id'];

View File

@ -189,12 +189,12 @@ if ($searchFlag) {
case "postgresql": case "postgresql":
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo $where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente
WHERE t1.nombre LIKE '" . trim($agentName) . "')"; WHERE t1.alias LIKE '" . trim($agentName) . "')";
break; break;
case "oracle": case "oracle":
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo $where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente
WHERE t1.nombre LIKE '" . trim($agentName) . "')"; WHERE t1.alias LIKE '" . trim($agentName) . "')";
break; break;
} }
} }
@ -459,8 +459,8 @@ foreach ($simple_alerts as $alert) {
if ($alert['disabled']) if ($alert['disabled'])
$data[0] .= '<span style="font-style: italic; color: #aaaaaa;">'; $data[0] .= '<span style="font-style: italic; color: #aaaaaa;">';
$agent_name = agents_get_name ($id_agent); $alias = db_get_value ("alias","tagente","id_agente",$id_agent);
$data[0] .= ui_print_truncate_text($agent_name, 'agent_small', false, true, true, '[&hellip;]', 'display:block;font-size: 7.2pt'); $data[0] .= $alias;
if ($alert['disabled']) if ($alert['disabled'])
$data[0] .= '</span>'; $data[0] .= '</span>';

View File

@ -82,7 +82,7 @@ if ($id) {
} }
} }
if ($id_agent != 0) { if ($id_agent != 0) {
$text_agent = db_get_value('nombre', 'tagente', 'id_agente', $id_agent); $text_agent = db_get_value('alias', 'tagente', 'id_agente', $id_agent);
if ($text_agent == false) { if ($text_agent == false) {
$text_agent = ''; $text_agent = '';
} }

View File

@ -49,13 +49,13 @@ if (is_ajax ()) {
$agents_alerts = array(); $agents_alerts = array();
foreach( $groups as $group ) { foreach( $groups as $group ) {
$agents_alerts_one_group = alerts_get_agents_with_alert_template ($id_alert_template, $group, $agents_alerts_one_group = alerts_get_agents_with_alert_template ($id_alert_template, $group,
false, array ('tagente.nombre', 'tagente.id_agente')); false, array ('tagente.alias', 'tagente.id_agente'));
if (is_array($agents_alerts_one_group)) { if (is_array($agents_alerts_one_group)) {
$agents_alerts = array_merge($agents_alerts, $agents_alerts_one_group); $agents_alerts = array_merge($agents_alerts, $agents_alerts_one_group);
} }
} }
$agents = index_array ($agents_alerts, 'id_agente', 'nombre'); $agents = index_array ($agents_alerts, 'id_agente', 'alias');
asort($agents); asort($agents);
@ -220,8 +220,9 @@ $table->data[2][0] .= '<span id="agent_loading" class="invisible">';
$table->data[2][0] .= html_print_image('images/spinner.png', true); $table->data[2][0] .= html_print_image('images/spinner.png', true);
$table->data[2][0] .= '</span>'; $table->data[2][0] .= '</span>';
$agents_alerts = alerts_get_agents_with_alert_template ($id_alert_template, $id_group, $agents_alerts = alerts_get_agents_with_alert_template ($id_alert_template, $id_group,
false, array ('tagente.nombre', 'tagente.id_agente')); false, array ('tagente.alias', 'tagente.id_agente'));
$table->data[2][1] = html_print_select (index_array ($agents_alerts, 'id_agente', 'nombre'), html_debug($agents_alerts);
$table->data[2][1] = html_print_select (index_array ($agents_alerts, 'id_agente', 'alias'),
'id_agents[]', '', '', '', '', true, true, true, '', $id_alert_template == 0); 'id_agents[]', '', '', '', '', true, true, true, '', $id_alert_template == 0);
$table->data[2][2] = __('When select agents'); $table->data[2][2] = __('When select agents');
$table->data[2][2] .= '<br>'; $table->data[2][2] .= '<br>';

View File

@ -39,10 +39,10 @@ if (is_ajax ()) {
$agents_modules = modules_get_agents_with_module_name ($module_name, $id_group, $agents_modules = modules_get_agents_with_module_name ($module_name, $id_group,
array ('delete_pending' => 0, array ('delete_pending' => 0,
'tagente_modulo.disabled' => 0), 'tagente_modulo.disabled' => 0),
array ('tagente.id_agente', 'tagente.nombre'), array ('tagente.id_agente', 'tagente.alias'),
$recursion); $recursion);
echo json_encode (index_array ($agents_modules, 'id_agente', 'nombre')); echo json_encode (index_array ($agents_modules, 'id_agente', 'alias'));
return; return;
} }
return; return;
@ -702,7 +702,7 @@ $(document).ready (function () {
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente"]) .attr ("value", value["id_agente"])
.html (value["nombre"]); .html (value["alias"]);
$("#id_agents").append (option); $("#id_agents").append (option);
}); });
}, },
@ -729,6 +729,12 @@ $(document).ready (function () {
} }
}); });
if("<?php echo $delete ?>"){
if("<?php echo $selection_mode ?>" == 'agents'){
$("#groups_select").trigger("change");
}
}
$("#status_module").change(function() { $("#status_module").change(function() {
selector = $("#form_modules input[name=selection_mode]:checked").val(); selector = $("#form_modules input[name=selection_mode]:checked").val();
if(selector == 'agents') { if(selector == 'agents') {

View File

@ -59,7 +59,7 @@ if ($update_agents) {
if (get_parameter ('id_os', '') != -1) if (get_parameter ('id_os', '') != -1)
$values['id_os'] = get_parameter ('id_os'); $values['id_os'] = get_parameter ('id_os');
if (get_parameter ('id_parent', '') != '') if (get_parameter ('id_parent', '') != '')
$values['id_parent'] = agents_get_agent_id(get_parameter('id_parent')); $values['id_parent'] = get_parameter('id_agent_parent', 0);
if (get_parameter ('server_name', '') != -1) if (get_parameter ('server_name', '') != -1)
$values['server_name'] = get_parameter ('server_name'); $values['server_name'] = get_parameter ('server_name');
if (get_parameter ('description', '') != '') if (get_parameter ('description', '') != '')
@ -282,7 +282,10 @@ $params = array();
$params['return'] = true; $params['return'] = true;
$params['show_helptip'] = true; $params['show_helptip'] = true;
$params['input_name'] = 'id_parent'; $params['input_name'] = 'id_parent';
$params['value'] = agents_get_name ($id_parent); $params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent_parent';
$params['hidden_input_idagent_value'] = $id_parent;
$params['value'] = db_get_value ("alias","tagente","id_agente",$id_parent);
$table->data[0][1] = ui_print_agent_autocomplete_input($params); $table->data[0][1] = ui_print_agent_autocomplete_input($params);
$table->data[0][1] .= "<b>" . __('Cascade protection'). "</b>&nbsp;" . $table->data[0][1] .= "<b>" . __('Cascade protection'). "</b>&nbsp;" .

View File

@ -1010,7 +1010,7 @@ $(document).ready (function () {
option = $("<option></option>") option = $("<option></option>")
.attr("value", value["id_agente"]) .attr("value", value["id_agente"])
.html(value["nombre"]); .html(value["alias"]);
$("#id_agents").append (option); $("#id_agents").append (option);
}); });
}, },
@ -1023,6 +1023,13 @@ $(document).ready (function () {
$("#groups_select").trigger("change"); $("#groups_select").trigger("change");
}); });
if("<?php echo $update ?>"){
if("<?php echo $selection_mode ?>" == 'agents'){
$("#groups_select").trigger("change");
}
}
$("#status_module").change(function() { $("#status_module").change(function() {
selector = $("#form_edit input[name=selection_mode]:checked").val(); selector = $("#form_edit input[name=selection_mode]:checked").val();
@ -1033,6 +1040,7 @@ $(document).ready (function () {
$("#module_type").trigger("change"); $("#module_type").trigger("change");
} }
}); });
}); });
function disabled_status () { function disabled_status () {

View File

@ -49,8 +49,8 @@ if (is_ajax ()) {
$disabled = (int) get_parameter ('disabled'); $disabled = (int) get_parameter ('disabled');
$agents_alerts = alerts_get_agents_with_alert_template ($id_alert_templates, false, $agents_alerts = alerts_get_agents_with_alert_template ($id_alert_templates, false,
array('order' => 'tagente.nombre, talert_template_modules.disabled', 'talert_template_modules.disabled' => $disabled), array('order' => 'tagente.alias, talert_template_modules.disabled', 'talert_template_modules.disabled' => $disabled),
array ('CONCAT(tagente.nombre, " - ", tagente_modulo.nombre) as agent_agentmodule_name', array ('CONCAT(tagente.alias, " - ", tagente_modulo.nombre) as agent_agentmodule_name',
'talert_template_modules.id as template_module_id'), $id_agents); 'talert_template_modules.id as template_module_id'), $id_agents);
echo json_encode (index_array ($agents_alerts, 'template_module_id', 'agent_agentmodule_name')); echo json_encode (index_array ($agents_alerts, 'template_module_id', 'agent_agentmodule_name'));
@ -156,8 +156,8 @@ $table->data[3][0] .= '<span id="alerts_loading" class="invisible">';
$table->data[3][0] .= html_print_image("images/spinner.png", true); $table->data[3][0] .= html_print_image("images/spinner.png", true);
$table->data[3][0] .= '</span>'; $table->data[3][0] .= '</span>';
$agents_alerts = alerts_get_agents_with_alert_template ($id_alert_templates, $id_group, $agents_alerts = alerts_get_agents_with_alert_template ($id_alert_templates, $id_group,
false, array ('tagente.nombre', 'tagente.id_agente')); false, array ('tagente.alias', 'tagente.id_agente'));
$table->data[3][1] = html_print_select (index_array ($agents_alerts, 'id_agente', 'nombre'), $table->data[3][1] = html_print_select (index_array ($agents_alerts, 'id_agente', 'alias'),
'id_enabled_alerts[]', '', '', '', '', true, true, true, '', $id_alert_templates == 0); 'id_enabled_alerts[]', '', '', '', '', true, true, true, '', $id_alert_templates == 0);
$table->data[4][0] = __('Action'); $table->data[4][0] = __('Action');

View File

@ -49,8 +49,8 @@ if (is_ajax ()) {
$standby = (int) get_parameter ('standby'); $standby = (int) get_parameter ('standby');
$agents_alerts = alerts_get_agents_with_alert_template ($id_alert_templates, false, $agents_alerts = alerts_get_agents_with_alert_template ($id_alert_templates, false,
array('order' => 'tagente.nombre, talert_template_modules.standby', 'talert_template_modules.standby' => $standby), array('order' => 'tagente.alias, talert_template_modules.standby', 'talert_template_modules.standby' => $standby),
array ('CONCAT(tagente.nombre, " - ", tagente_modulo.nombre) as agent_agentmodule_name', array ('CONCAT(tagente.alias, " - ", tagente_modulo.nombre) as agent_agentmodule_name',
'talert_template_modules.id as template_module_id'), $id_agents); 'talert_template_modules.id as template_module_id'), $id_agents);
echo json_encode (index_array ($agents_alerts, 'template_module_id', 'agent_agentmodule_name')); echo json_encode (index_array ($agents_alerts, 'template_module_id', 'agent_agentmodule_name'));
@ -156,8 +156,8 @@ $table->data[3][0] .= '<span id="alerts_loading" class="invisible">';
$table->data[3][0] .= html_print_image('images/spinner.png', true); $table->data[3][0] .= html_print_image('images/spinner.png', true);
$table->data[3][0] .= '</span>'; $table->data[3][0] .= '</span>';
$agents_alerts = alerts_get_agents_with_alert_template ($id_alert_templates, $id_group, $agents_alerts = alerts_get_agents_with_alert_template ($id_alert_templates, $id_group,
false, array ('tagente.nombre', 'tagente.id_agente')); false, array ('tagente.alias', 'tagente.id_agente'));
$table->data[3][1] = html_print_select (index_array ($agents_alerts, 'id_agente', 'nombre'), $table->data[3][1] = html_print_select (index_array ($agents_alerts, 'id_agente', 'alias'),
'id_not_standby_alerts[]', '', '', '', '', true, true, true, '', $id_alert_templates == 0); 'id_not_standby_alerts[]', '', '', '', '', true, true, true, '', $id_alert_templates == 0);
$table->data[4][0] = __('Action'); $table->data[4][0] = __('Action');
@ -172,7 +172,7 @@ $table->data[5][0] = __('Standby alerts').ui_print_help_tip(__('Format').":<br>
$table->data[5][0] .= '<span id="alerts_loading2" class="invisible">'; $table->data[5][0] .= '<span id="alerts_loading2" class="invisible">';
$table->data[5][0] .= html_print_image('images/spinner.png', true); $table->data[5][0] .= html_print_image('images/spinner.png', true);
$table->data[5][0] .= '</span>'; $table->data[5][0] .= '</span>';
$table->data[5][1] = html_print_select (index_array ($agents_alerts, 'id_agente2', 'nombre'), $table->data[5][1] = html_print_select (index_array ($agents_alerts, 'id_agente2', 'alias'),
'id_standby_alerts[]', '', '', '', '', true, true, true, '', $id_alert_templates == 0); 'id_standby_alerts[]', '', '', '', '', true, true, true, '', $id_alert_templates == 0);
$table->data[5][1] .= '</form>'; $table->data[5][1] .= '</form>';

View File

@ -41,7 +41,7 @@ if (isset ($_GET["get_agent"])) {
if ($editGraph) { if ($editGraph) {
$graphRows = db_get_all_rows_sql("SELECT t1.*, $graphRows = db_get_all_rows_sql("SELECT t1.*,
(SELECT t3.nombre (SELECT t3.alias
FROM tagente t3 FROM tagente t3
WHERE t3.id_agente = WHERE t3.id_agente =
(SELECT t2.id_agente (SELECT t2.id_agente

View File

@ -87,7 +87,8 @@ else {
$agents = array(); $agents = array();
foreach ($rows as $row) { foreach ($rows as $row) {
$agents[$row['id_agente']] = $row['nombre']; $alias = db_get_value ("alias","tagente","id_agente",$row['id_agente']);
$agents[$row['id_agente']] = $alias;
} }
switch ($config['dbtype']) { switch ($config['dbtype']) {
@ -372,15 +373,17 @@ foreach ($items as $item) {
$agent_name_db = array(); $agent_name_db = array();
foreach ($agents as $a) { foreach ($agents as $a) {
$agent_name_db[] = agents_get_name($a);
$alias = db_get_value ("alias","tagente","id_agente",$a);
$agent_name_db[] = $alias;
} }
$agent_name_db = implode('<br>',$agent_name_db); $agent_name_db = implode('<br>',$agent_name_db);
$module_name_db = implode('<br>',$modules); $module_name_db = implode('<br>',$modules);
} }
else { else {
$agent_name_db = agents_get_name(agents_get_agent_id_by_module_id($item['id_agent_module'])); $alias = db_get_value ("alias","tagente","id_agente",agents_get_agent_id_by_module_id($item['id_agent_module']));
$agent_name_db = ui_print_truncate_text($agent_name_db, 'agent_small'); $agent_name_db = '<span title='. agents_get_name(agents_get_agent_id_by_module_id($item['id_agent_module'])) . '>' .$alias . '</span>';
$module_name_db = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); $module_name_db = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
$module_name_db = ui_print_truncate_text(io_safe_output($module_name_db), 'module_small'); $module_name_db = ui_print_truncate_text(io_safe_output($module_name_db), 'module_small');
} }
@ -390,7 +393,8 @@ foreach ($items as $item) {
} }
} }
else { else {
$row[2] = ui_print_truncate_text(agents_get_name($item['id_agent']), 'agent_small'); $alias = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
$row[2] = '<span title='. agents_get_name($item['id_agent']) . '>' .$alias . '</span>';
if ($item['id_agent_module'] == '') { if ($item['id_agent_module'] == '') {
$row [3] = ''; $row [3] = '';

View File

@ -437,6 +437,7 @@ function readFields() {
values['left'] = $("input[name=left]").val(); values['left'] = $("input[name=left]").val();
values['top'] = $("input[name=top]").val(); values['top'] = $("input[name=top]").val();
values['agent'] = $("input[name=agent]").val(); values['agent'] = $("input[name=agent]").val();
values['id_agent'] = $("input[name=id_agent]").val();
values['module'] = $("select[name=module]").val(); values['module'] = $("select[name=module]").val();
values['process_simple_value'] = $("select[name=process_value]").val(); values['process_simple_value'] = $("select[name=process_value]").val();
values['background'] = $("#background_image").val(); values['background'] = $("#background_image").val();
@ -997,6 +998,9 @@ function loadFieldsFromDB(item) {
$("input[name=agent]").val(val); $("input[name=agent]").val(val);
//Reload no-sincrone the select of modules //Reload no-sincrone the select of modules
} }
if (key == 'id_agent') {
$("input[name=id_agent]").val(val);
}
if (key == 'modules_html') { if (key == 'modules_html') {
$("select[name=module]").empty().html(val); $("select[name=module]").empty().html(val);
$("select[name=module]").val(moduleId); $("select[name=module]").val(moduleId);

View File

@ -87,10 +87,7 @@ echo "<div id='background_grid'
//Print the layout datas from the DB. //Print the layout datas from the DB.
foreach ($layoutDatas as $layoutData) { foreach ($layoutDatas as $layoutData) {
$layoutData['status_calculated'] = visual_map_get_status_element($layoutData);
$layoutData['status_calculated'] =
visual_map_get_status_element($layoutData);
// Pending delete and disable modules must be ignored // Pending delete and disable modules must be ignored
$delete_pending_module = db_get_value ("delete_pending", $delete_pending_module = db_get_value ("delete_pending",

View File

@ -370,7 +370,10 @@ foreach ($layoutDatas as $layoutData) {
"none", $layoutData['id_metaconsole'], true); "none", $layoutData['id_metaconsole'], true);
} }
else { else {
$params['value'] = agents_get_name($layoutData['id_agent']); $params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent_' . $idLayoutData;
$params['hidden_input_idagent_value'] = $layoutData['id_agent'];
$params['value'] = db_get_value ("alias","tagente","id_agente",$layoutData['id_agent']);
} }
if ($layoutData['id_agent'] == 0 and $layoutData['id_custom_graph'] != 0) { if ($layoutData['id_agent'] == 0 and $layoutData['id_custom_graph'] != 0) {

View File

@ -365,7 +365,8 @@ switch ($activeTab) {
$values['id_agent'] = (int) get_parameter('id_agent_' . $id, 0); $values['id_agent'] = (int) get_parameter('id_agent_' . $id, 0);
} }
else { else {
$values['id_agent'] = agents_get_agent_id($agentName); $agent_id = (int) get_parameter('id_agent_' . $id, 0);
$values['id_agent'] = $agent_id;
} }
$values['id_agente_modulo'] = get_parameter('module_' . $id, 0); $values['id_agente_modulo'] = get_parameter('module_' . $id, 0);
$values['id_custom_graph'] = get_parameter('custom_graph_' . $id, 0); $values['id_custom_graph'] = get_parameter('custom_graph_' . $id, 0);

View File

@ -113,11 +113,12 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
$filter_agents[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\'))'; $filter_agents[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\'))';
break; break;
} }
$agents = agents_get_agents($filter_agents, array ('id_agente', 'nombre', 'direccion')); $agents = agents_get_agents($filter_agents, array ('id_agente', 'nombre', 'direccion','alias'));
if ($agents !== false) { if ($agents !== false) {
foreach ($agents as $agent) { foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'], $data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']), 'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'ip' => io_safe_output($agent['direccion']), 'ip' => io_safe_output($agent['direccion']),
'filter' => 'agent'); 'filter' => 'agent');
} }
@ -136,11 +137,12 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
$filter_address[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) LIKE UPPER(\'%'.$string.'%\'))'; $filter_address[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) LIKE UPPER(\'%'.$string.'%\'))';
break; break;
} }
$agents = agents_get_agents($filter_address, array ('id_agente', 'nombre', 'direccion')); $agents = agents_get_agents($filter_address, array ('id_agente', 'nombre', 'direccion', 'alias'));
if ($agents !== false) { if ($agents !== false) {
foreach ($agents as $agent) { foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'], $data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']), 'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'ip' => io_safe_output($agent['direccion']), 'ip' => io_safe_output($agent['direccion']),
'filter' => 'address'); 'filter' => 'address');
} }
@ -159,16 +161,40 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
$filter_description[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))'; $filter_description[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
break; break;
} }
$agents = agents_get_agents($filter_description, array ('id_agente', 'nombre', 'direccion')); $agents = agents_get_agents($filter_description, array ('id_agente', 'nombre', 'direccion', 'alias'));
if ($agents !== false) { if ($agents !== false) {
foreach ($agents as $agent) { foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'], $data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']), 'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'ip' => io_safe_output($agent['direccion']), 'ip' => io_safe_output($agent['direccion']),
'filter' => 'description'); 'filter' => 'description');
} }
} }
//Get agents for only the alias
$filter_description = $filter;
switch ($config['dbtype']) {
case "mysql":
$filter_description[] = '(nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion NOT LIKE "%'.$string.'%" AND comentarios NOT LIKE "%'.$string.'%" AND alias LIKE "%'.$string.'%")';
break;
case "postgresql":
$filter_description[] = '(nombre NOT LIKE \'%'.$string.'%\' AND direccion NOT LIKE \'%'.$string.'%\' AND comentarios NOT LIKE \'%'.$string.'%\' AND alias LIKE \'%'.$string.'%\')';
break;
case "oracle":
$filter_description[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(alias) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = agents_get_agents($filter_description, array ('id_agente', 'nombre', 'direccion', 'alias'));
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'alias' => io_safe_output($agent['alias']),
'ip' => io_safe_output($agent['direccion']),
'filter' => 'alias');
}
}
echo json_encode($data); echo json_encode($data);
return; return;
} }

View File

@ -478,6 +478,9 @@ switch ($action) {
$values['id_agent'] = $id_agent; $values['id_agent'] = $id_agent;
} }
} }
else if (!empty($id_agent)) {
$values['id_agent'] = $id_agent;
}
else if ($agent !== null) { else if ($agent !== null) {
$id_agent = agents_get_agent_id($agent); $id_agent = agents_get_agent_id($agent);
$values['id_agent'] = $id_agent; $values['id_agent'] = $id_agent;
@ -664,12 +667,12 @@ switch ($action) {
if (!empty($connection['server_name'])) { if (!empty($connection['server_name'])) {
$elementFields['agent_name'] = $elementFields['agent_name'] =
io_safe_output(agents_get_name($elementFields['id_agent'])) io_safe_output(agents_get_alias($elementFields['id_agent']))
. " (" . io_safe_output($connection['server_name']) . ")"; . " (" . io_safe_output($connection['server_name']) . ")";
} }
else { else {
$elementFields['agent_name'] = $elementFields['agent_name'] =
io_safe_output(agents_get_name($elementFields['id_agent'])); io_safe_output(agents_get_alias($elementFields['id_agent']));
} }
//Make the html of select box of modules about id_agent. //Make the html of select box of modules about id_agent.
@ -784,10 +787,15 @@ switch ($action) {
$values['id_agent'] = $id_agent; $values['id_agent'] = $id_agent;
} }
else { else {
if ($agent != '') if (!empty($id_agent)) {
$values['id_agent'] = $id_agent;
}
else if (!empty($agent)) {
$values['id_agent'] = agents_get_agent_id($agent); $values['id_agent'] = agents_get_agent_id($agent);
else }
else {
$values['id_agent'] = 0; $values['id_agent'] = 0;
}
} }
$values['id_agente_modulo'] = $id_module; $values['id_agente_modulo'] = $id_module;
$values['id_layout_linked'] = $map_linked; $values['id_layout_linked'] = $map_linked;

View File

@ -234,7 +234,7 @@ class Tree {
// Agent name filter // Agent name filter
$agent_search_filter = ""; $agent_search_filter = "";
if (!empty($this->filter['searchAgent'])) { if (!empty($this->filter['searchAgent'])) {
$agent_search_filter = " AND LOWER(ta.nombre) LIKE LOWER('%".$this->filter['searchAgent']."%')"; $agent_search_filter = " AND LOWER(ta.nombre) LIKE LOWER('%".$this->filter['searchAgent']."%') OR ta.alias LIKE '%".$this->filter['searchAgent']."%'";
} }
// Agent status filter // Agent status filter
@ -409,15 +409,15 @@ class Tree {
} }
else { else {
if (! is_metaconsole() || $this->strictACL) { if (! is_metaconsole() || $this->strictACL) {
$columns = 'ta.id_agente AS id, ta.nombre AS name, $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre, $group_by_fields = 'ta.id_agente, ta.nombre, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $order_fields = 'ta.alias ASC, ta.id_agente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente ta FROM tagente ta
@ -435,11 +435,11 @@ class Tree {
ORDER BY $order_fields"; ORDER BY $order_fields";
} }
else { else {
$columns = 'ta.id_tagente AS id, ta.nombre AS name, $columns = 'ta.id_tagente AS id, ta.nombre AS name, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet, id_tmetaconsole_setup AS server_id'; ta.total_count, ta.quiet, id_tmetaconsole_setup AS server_id';
$order_fields = 'ta.nombre ASC, ta.id_tagente ASC'; $order_fields = 'ta.alias ASC, ta.id_tagente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tmetaconsole_agent ta FROM tmetaconsole_agent ta
@ -595,15 +595,15 @@ class Tree {
} }
} }
else { else {
$columns = 'ta.id_agente AS id, ta.nombre AS name, $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre, $group_by_fields = 'ta.id_agente, ta.nombre, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $order_fields = 'ta.alias ASC, ta.id_agente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente ta FROM tagente ta
@ -718,15 +718,15 @@ class Tree {
} }
} }
else { else {
$columns = 'ta.id_agente AS id, ta.nombre AS name, $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre, $group_by_fields = 'ta.id_agente, ta.nombre, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $order_fields = 'ta.alias ASC, ta.id_agente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente ta FROM tagente ta
@ -847,15 +847,15 @@ class Tree {
} }
} }
else { else {
$columns = 'ta.id_agente AS id, ta.nombre AS name, $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre, $group_by_fields = 'ta.id_agente, ta.nombre, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $order_fields = 'ta.alias ASC, ta.id_agente ASC';
$sql = "SELECT $columns $sql = "SELECT $columns
FROM tagente ta FROM tagente ta
@ -978,15 +978,15 @@ class Tree {
} }
} }
else { else {
$columns = 'ta.id_agente AS id, ta.nombre AS name, $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre, $group_by_fields = 'ta.id_agente, ta.nombre, ta.alias,
ta.fired_count, ta.normal_count, ta.warning_count, ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count, ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet'; ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $order_fields = 'ta.alias ASC, ta.id_agente ASC';
$symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~'; $symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~';
$name = $rootID; $name = $rootID;

View File

@ -221,7 +221,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
} }
} }
$selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name, t3.nombre AS agent_name, t4.name AS template_name'; $selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name, t3.alias AS agent_name, t4.name AS template_name';
if ($count !== false) { if ($count !== false) {
$selectText = 'COUNT(talert_template_modules.id) AS count'; $selectText = 'COUNT(talert_template_modules.id) AS count';
} }
@ -890,6 +890,21 @@ function agents_get_group_agents ($id_group = 0, $search = false,
unset ($search["name"]); unset ($search["name"]);
} }
if (isset ($search["alias"])) {
$name = io_safe_input ($search["alias"]);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$filter[] = "alias COLLATE utf8_general_ci LIKE '$name'";
break;
case "oracle":
$filter[] = "UPPER(alias) LIKE UPPER('$name')";
break;
}
unset ($search["alias"]);
}
if (isset($search['status'])) { if (isset($search['status'])) {
switch ($search['status']) { switch ($search['status']) {
case AGENT_STATUS_NORMAL: case AGENT_STATUS_NORMAL:
@ -941,14 +956,14 @@ function agents_get_group_agents ($id_group = 0, $search = false,
$filter['disabled'] = 0; $filter['disabled'] = 0;
} }
$filter['order'] = 'nombre'; $filter['order'] = 'alias';
if (is_metaconsole()) { if (is_metaconsole()) {
$table_name = 'tmetaconsole_agent'; $table_name = 'tmetaconsole_agent';
$fields = array( $fields = array(
'id_tagente AS id_agente', 'id_tagente AS id_agente',
'nombre', 'alias',
'id_tmetaconsole_setup AS id_server' 'id_tmetaconsole_setup AS id_server'
); );
} }
@ -957,7 +972,7 @@ function agents_get_group_agents ($id_group = 0, $search = false,
$fields = array( $fields = array(
'id_agente', 'id_agente',
'nombre' 'alias'
); );
} }
@ -968,7 +983,7 @@ function agents_get_group_agents ($id_group = 0, $search = false,
$agents = array (); $agents = array ();
foreach ($result as $row) { foreach ($result as $row) {
if (!isset($row["id_agente"]) || !isset($row["nombre"])) if (!isset($row["id_agente"]) || !isset($row["alias"]))
continue; continue;
if ($serialized && isset($row["id_server"])) { if ($serialized && isset($row["id_server"])) {
@ -980,13 +995,13 @@ function agents_get_group_agents ($id_group = 0, $search = false,
switch ($case) { switch ($case) {
case "lower": case "lower":
$value = mb_strtolower ($row["nombre"], "UTF-8"); $value = mb_strtolower ($row["alias"], "UTF-8");
break; break;
case "upper": case "upper":
$value = mb_strtoupper ($row["nombre"], "UTF-8"); $value = mb_strtoupper ($row["alias"], "UTF-8");
break; break;
default: default:
$value = $row["nombre"]; $value = $row["alias"];
break; break;
} }
@ -1310,6 +1325,28 @@ function agents_get_name ($id_agent, $case = "none") {
} }
} }
/**
* Get alias of an agent.
*
* @param int $id_agent Agent id.
* @param string $case Case (upper, lower, none)
*
* @return string Alias of the given agent.
*/
function agents_get_alias ($id_agent, $case = 'none') {
$alias = (string) db_get_value ('alias', 'tagente', 'id_agente', (int) $id_agent);
switch ($case) {
case 'upper':
return mb_strtoupper($alias, 'UTF-8');
case 'lower':
return mb_strtolower($alias, 'UTF-8');
case 'none':
default:
return ($alias);
}
}
/** /**
* Get the number of pandora data packets in the database. * Get the number of pandora data packets in the database.
* *

View File

@ -1822,7 +1822,7 @@ function get_group_alerts($id_group, $filter = '', $options = false,
} }
} }
$selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name, t3.nombre AS agent_name, t4.name AS template_name'; $selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name, t3.alias AS agent_name, t4.name AS template_name';
if ($count !== false) { if ($count !== false) {
$selectText = 'COUNT(talert_template_modules.id) AS count'; $selectText = 'COUNT(talert_template_modules.id) AS count';
} }

View File

@ -979,7 +979,7 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret
$myclass = get_priority_class ($event["criticity"]); $myclass = get_priority_class ($event["criticity"]);
$data[4] = "<a class='$myclass' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event["id_agente"]."'>". $data[4] = "<a class='$myclass' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event["id_agente"]."'>".
agents_get_name ($event["id_agente"]). "</A>"; agents_get_alias($event["id_agente"]). "</A>";
// ui_print_agent_name ($event["id_agente"], true, 25, '', true); // ui_print_agent_name ($event["id_agente"], true, 25, '', true);
// for System or SNMP generated alerts // for System or SNMP generated alerts
@ -2017,10 +2017,13 @@ function events_page_details ($event, $server = "") {
$data = array(); $data = array();
$data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Name').'</div>'; $data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Name').'</div>';
if (can_user_access_node ()) { if (can_user_access_node ()) {
$data[1] = ui_print_agent_name ($event["id_agente"], true, 'agent_medium', '', false, $serverstring, $hashstring, $agent['nombre']); //$data[1] = ui_print_agent_name ($event["id_agente"], true, 'agent_medium', '', false, $serverstring, $hashstring, $agent['nombre']);
$alias = db_get_row ("tagente","id_agente",$event["id_agente"]);
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $event["id_agente"] . '" title='.$alias['nombre']. '>';
$data[1] .= '<b>' . $alias['alias'] . '</a></b>';
} }
else { else {
$data[1] = ui_print_truncate_text($agent['nombre'], 'agent_medium', true, true, true); $data[1] = ui_print_truncate_text($agent['alias'], 'agent_medium', true, true, true);
} }
$table_details->data[] = $data; $table_details->data[] = $data;

View File

@ -1221,19 +1221,21 @@ function graphic_combined_module ($module_list, $weight_list, $period,
else { else {
$agent_name = io_safe_output( $agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($agent_module_id)); modules_get_agentmodule_agent_name ($agent_module_id));
$alias = db_get_value ("alias","tagente","nombre",$agent_name);
$module_name = io_safe_output( $module_name = io_safe_output(
modules_get_agentmodule_name ($agent_module_id)); modules_get_agentmodule_name ($agent_module_id));
if ($flash_charts) if ($flash_charts)
$module_name_list[$i] = '<span style=\"font-size:' . ($config['font_size']) . 'pt;font-family: smallfontFont;\" >' . $agent_name . " / " . $module_name. '</span>'; $module_name_list[$i] = '<span style=\"font-size:' . ($config['font_size']) . 'pt;font-family: smallfontFont;\" >' . $alias . " / " . $module_name. '</span>';
else else
$module_name_list[$i] = $agent_name . " / " . $module_name; $module_name_list[$i] = $alias . " / " . $module_name;
} }
} }
else { else {
//Get and process agent name //Get and process agent name
$agent_name = io_safe_output( $agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($agent_module_id)); modules_get_agentmodule_agent_name ($agent_module_id));
$alias = db_get_value ("alias","tagente","nombre",$agent_name);
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false); $agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false);
$agent_id = agents_get_agent_id ($agent_name); $agent_id = agents_get_agent_id ($agent_name);
@ -1252,13 +1254,13 @@ function graphic_combined_module ($module_list, $weight_list, $period,
else else
$module_name_list[$i] = '<span style=\"font-size:' . $module_name_list[$i] = '<span style=\"font-size:' .
($config['font_size']) . 'pt;font-family: smallfontFont;\" >' . ($config['font_size']) . 'pt;font-family: smallfontFont;\" >' .
$agent_name . ' / ' . $module_name . '</span>'; $alias . ' / ' . $module_name . '</span>';
} }
else { else {
if ($labels[$agent_module_id] != '') if ($labels[$agent_module_id] != '')
$module_name_list[$i] = $labels[$agent_module_id]; $module_name_list[$i] = $labels[$agent_module_id];
else else
$module_name_list[$i] = $agent_name . ' / ' . $module_name; $module_name_list[$i] = $alias . ' / ' . $module_name;
} }
} }
@ -1522,11 +1524,13 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$value = false; $value = false;
} }
if ( !empty($labels) && isset($labels[$module]) ){
if ( !empty($labels) && isset($labels[$module]) ) $label = io_safe_input($labels[$module]);
$label = io_safe_input($labels[$module]); }else{
else $alias = db_get_value ("alias","tagente","id_agente",$temp[$module]['id_agente']);
$label = agents_get_name($temp[$module]['id_agente']) . ': ' . $temp[$module]['nombre']; $label = $alias . ': ' . $temp[$module]['nombre'];
}
$temp[$module]['label'] = $label; $temp[$module]['label'] = $label;
$temp[$module]['value'] = $value; $temp[$module]['value'] = $value;
@ -1589,10 +1593,13 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$agent_name = io_safe_output( $agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($module)); modules_get_agentmodule_agent_name ($module));
if (!empty($labels) && isset($labels[$module]) ) if (!empty($labels) && isset($labels[$module]) ){
$label = $labels[$module]; $label = $labels[$module];
else }else {
$label = $agent_name . " - " .$module_data['nombre']; $alias = db_get_value ("alias","tagente","id_agente",$module_data['id_agente']);
$label = $alias . " - " .$module_data['nombre'];
}
$temp[$label]['g'] = round($temp_data,4); $temp[$label]['g'] = round($temp_data,4);
@ -1649,8 +1656,8 @@ function graphic_combined_module ($module_list, $weight_list, $period,
if ( !empty($labels) && isset($labels[$module]) ){ if ( !empty($labels) && isset($labels[$module]) ){
$label = io_safe_output($labels[$module]); $label = io_safe_output($labels[$module]);
}else { }else {
$agent_name = agents_get_name($data_module['id_agente']); $alias = db_get_value ("alias","tagente","id_agente",$data_module['id_agente']);
$label = io_safe_output($agent_name . ": " . $data_module['nombre']); $label = io_safe_output($alias . ": " . $data_module['nombre']);
} }
$temp[$label] = array('value'=>$value, $temp[$label] = array('value'=>$value,
@ -3126,7 +3133,9 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
$name = mb_substr (io_safe_output($row['agent_name']), 0, 14)." (".$row["count"].")"; $name = mb_substr (io_safe_output($row['agent_name']), 0, 14)." (".$row["count"].")";
} }
else { else {
$name = mb_substr (agents_get_name ($row["id_agente"], "lower"), 0, 14)." (".$row["count"].")"; $alias = db_get_value ("alias","tagente","id_agente",$row["id_agente"]);
//$name = mb_substr (agents_get_name ($row["id_agente"], "lower"), 0, 14)." (".$row["count"].")";
$name = mb_substr ($alias, 0, 14)." (".$row["count"].")";
} }
$data[$name] = $row["count"]; $data[$name] = $row["count"];
} }

View File

@ -1023,6 +1023,18 @@ function modules_get_agentmodule_agent_name ($id_agentmodule) {
return (string) agents_get_name (modules_get_agentmodule_agent ($id_agentmodule)); return (string) agents_get_name (modules_get_agentmodule_agent ($id_agentmodule));
} }
/**
* Get agent alias of an agent module.
*
* @param int $id_agente_modulo Agent module id.
*
* @return string The alias of the given agent module.
*/
function modules_get_agentmodule_agent_alias ($id_agentmodule) {
// Since this is a helper function we don't need to do casting
return (string) agents_get_alias (modules_get_agentmodule_agent ($id_agentmodule));
}
/** /**
* Get the module name of an agent module. * Get the module name of an agent module.
* *

View File

@ -851,7 +851,7 @@ function networkmap_loadfile($id = 0, $file = '',
case 'agent': case 'agent':
$data['id_agent'] = $ids[$node_id]['id_agent']; $data['id_agent'] = $ids[$node_id]['id_agent'];
$text = agents_get_name($ids[$node_id]['id_agent']); $text = agents_get_alias($ids[$node_id]['id_agent']);
$text = io_safe_output($text); $text = io_safe_output($text);
$text = ui_print_truncate_text($text, $text = ui_print_truncate_text($text,
'agent_medium', false, true, false, 'agent_medium', false, true, false,

View File

@ -152,6 +152,10 @@ function reporting_html_print_report($report, $mini = false, $report_info = 1) {
} }
else else
$label = ''; $label = '';
$aux = explode("-",$item['subtitle']);
$item['subtitle'] = db_get_value ("alias","tagente","nombre",$item['agent_name']) .' -'. $aux[1];
reporting_html_header($table, reporting_html_header($table,
$mini, $item['title'], $mini, $item['title'],
$item['subtitle'], $item['subtitle'],
@ -1224,8 +1228,9 @@ function reporting_html_inventory_changes($table, $item) {
$table1->data[2][0] = __('Added'); $table1->data[2][0] = __('Added');
$table1->colspan[2][0] = 2; $table1->colspan[2][0] = 2;
if (count ($module_item['added'])) {
$table1->data = array_merge($table1->data, $module_item['added']); $table1->data = array_merge($table1->data, $module_item['added']);
}
$table1->cellstyle[3 + count($module_item['added'])][0] = $table1->cellstyle[3 + count($module_item['added'])][0] =
@ -1233,8 +1238,9 @@ function reporting_html_inventory_changes($table, $item) {
$table1->data[3 + count($module_item['added'])][0] = __('Deleted'); $table1->data[3 + count($module_item['added'])][0] = __('Deleted');
$table1->colspan[3 + count($module_item['added'])][0] = 2; $table1->colspan[3 + count($module_item['added'])][0] = 2;
if (count ($module_item['deleted'])) {
$table1->data = array_merge($table1->data, $module_item['deleted']); $table1->data = array_merge($table1->data, $module_item['deleted']);
}
$table->colspan[ $table->colspan[

View File

@ -522,8 +522,9 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
else { else {
$cellName = ''; $cellName = '';
} }
$cellName .= ui_print_agent_name ($agent["id_agente"], true, 500, "text-transform: uppercase;", true, $console_url, $url_hash, false, $user_access_node); $cellName .= '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$agent["id_agente"].'">' .
'<b><span style="font-weight:bold;text-transform:uppercase;" title="' . $agent["nombre"] . '">'.$agent["alias"].'</span></b></a>';
if ($agent['disabled']) { if ($agent['disabled']) {
$cellName .= ui_print_help_tip(__('Disabled'), true) . "</em>"; $cellName .= ui_print_help_tip(__('Disabled'), true) . "</em>";
@ -780,4 +781,4 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
return; return;
} }
?> ?>

View File

@ -787,6 +787,7 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f
// Get agent id // Get agent id
$id_agent = modules_get_agentmodule_agent ($alert['id_agent_module']); $id_agent = modules_get_agentmodule_agent ($alert['id_agent_module']);
$agente = db_get_row ('tagente', 'id_agente', $id_agent);
$template = alerts_get_alert_template ($alert['id_alert_template']); $template = alerts_get_alert_template ($alert['id_alert_template']);
$description = io_safe_output($template['name']); $description = io_safe_output($template['name']);
@ -847,10 +848,10 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f
} }
else { else {
if ($agent_style !== false) { if ($agent_style !== false) {
$data[$index['agent_name']] .= ui_print_agent_name ($id_agent, true, 'agent_medium', $styleDisabled . " $agent_style", false, $console_url, $url_hash, $agent_name); $data[$index['agent_name']] .='<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'"> <span style="font-size: 7pt;font-weight:bold" title ="' . $agente['nombre']. '">'.$agente["alias"].'</span></a>';
} }
else { else {
$data[$index['agent_name']] .= ui_print_agent_name ($id_agent, true, 'agent_medium', $styleDisabled, false, $console_url, $url_hash); $data[$index['agent_name']] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'"> <span style="font-size: 7pt;font-weight:bold" title ="' . $agente['nombre']. '">'.$agente["alias"].'</span></a>';
} }
} }
@ -2390,7 +2391,8 @@ function ui_get_full_url ($url = '', $no_proxy = false, $add_name_php_file = fal
* @return string Header HTML * @return string Header HTML
*/ */
function ui_print_page_header ($title, $icon = "", $return = false, $help = "", $godmode = false, $options = "",$modal = false, $message = "", $numChars = GENERIC_SIZE_TEXT) {
function ui_print_page_header ($title, $icon = "", $return = false, $help = "", $godmode = false, $options = "", $modal = false, $message = "", $numChars = GENERIC_SIZE_TEXT, $alias = "") {
$title = io_safe_input_html($title); $title = io_safe_input_html($title);
if (($icon == "") && ($godmode == true)) { if (($icon == "") && ($godmode == true)) {
$icon = "images/gm_setup.png"; $icon = "images/gm_setup.png";
@ -2415,9 +2417,14 @@ function ui_print_page_header ($title, $icon = "", $return = false, $help = "",
$buffer .= '<ul class="mn"><li class="' . $type . '">&nbsp;' . '&nbsp; '; $buffer .= '<ul class="mn"><li class="' . $type . '">&nbsp;' . '&nbsp; ';
$buffer .= '<span style="margin-right:10px;">' . if(strpos($title, "Monitoring » Services »") != -1){
ui_print_truncate_text($title, $numChars); $title = str_replace("Monitoring » Services » Service Map » ",'',$title);
}
$buffer .= '<span style="margin-right:10px;">';
if (empty($alias)) $buffer .= ui_print_truncate_text($title, $numChars);
else $buffer .= ui_print_truncate_text($alias, $numChars);
if ($modal && !enterprise_installed()){ if ($modal && !enterprise_installed()){
$buffer .= " $buffer .= "
<div id='".$message."' class='publienterprise' title='Community version' style='float: right;margin-top: -2px !important; margin-left: 2px !important;'><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div> <div id='".$message."' class='publienterprise' title='Community version' style='float: right;margin-top: -2px !important; margin-left: 2px !important;'><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>
@ -3206,7 +3213,7 @@ function ui_print_agent_autocomplete_input($parameters) {
select: function( event, ui ) { select: function( event, ui ) {
var agent_name = ui.item.name; var agent_name = ui.item.alias;
var agent_id = ui.item.id; var agent_id = ui.item.id;
var server_name = ""; var server_name = "";
var server_id = ""; var server_id = "";
@ -3264,10 +3271,10 @@ function ui_print_agent_autocomplete_input($parameters) {
}) })
.data("ui-autocomplete")._renderItem = function( ul, item ) { .data("ui-autocomplete")._renderItem = function( ul, item ) {
if (item.ip == "") { if (item.ip == "") {
text = "<a>" + item.name + "</a>"; text = "<a>" + item.alias+ "</a>";
} }
else { else {
text = "<a>" + item.name text = "<a>" + item.alias
+ "<br><span style=\"font-size: 70%; font-style: italic;\">IP:" + item.ip + "</span></a>"; + "<br><span style=\"font-size: 70%; font-style: italic;\">IP:" + item.ip + "</span></a>";
} }
@ -3291,6 +3298,12 @@ function ui_print_agent_autocomplete_input($parameters) {
.append(text) .append(text)
.appendTo(ul); .appendTo(ul);
break; break;
case \'alias\':
return $("<li style=\'background: #a8e7eb;\'></li>")
.data("item.autocomplete", item)
.append(text)
.appendTo(ul);
break;
} }

View File

@ -122,8 +122,6 @@ function visual_map_print_item($mode = "read", $layoutData,
$left = $left * $proportion['proportion_width']; $left = $left * $proportion['proportion_width'];
} }
$agentname = agents_get_name(agents_get_module_id ($id_module));
$label = str_replace(ui_print_truncate_text($agentname, 'agent_small', false, true, false, '…', false), $agentname, $label);
$text = '<span id="text_' . $id . '" class="text">' . $label .'</span>'; $text = '<span id="text_' . $id . '" class="text">' . $label .'</span>';
if($height == 0){ if($height == 0){
@ -1670,7 +1668,7 @@ function visual_map_process_wizard_add ($id_agents, $image, $id_layout, $range,
break; break;
} }
$label = agents_get_name($id_agent); $label = agents_get_alias($id_agent);
$value_label = '(_VALUE_)'; $value_label = '(_VALUE_)';
if ($type === SIMPLE_VALUE) { if ($type === SIMPLE_VALUE) {
@ -1747,12 +1745,12 @@ function visual_map_process_wizard_add_modules ($id_modules, $image,
} }
} }
$id_agent = modules_get_agentmodule_agent ($id_module); $id_agent = modules_get_agentmodule_agent($id_module);
switch ($label_type) { switch ($label_type) {
case 'agent_module': case 'agent_module':
default: default:
$agent_label = agents_get_name ($id_agent); $agent_label = agents_get_alias($id_agent);
$module_label = modules_get_agentmodule_name($id_module); $module_label = modules_get_agentmodule_name($id_module);
$label = '<p><span class="visual_font_size_'.$fonts.'" style="font-family:'.$fontf.';">'.$agent_label . " - " . $module_label.'</span></p>'; $label = '<p><span class="visual_font_size_'.$fonts.'" style="font-family:'.$fontf.';">'.$agent_label . " - " . $module_label.'</span></p>';
break; break;
@ -1761,7 +1759,7 @@ function visual_map_process_wizard_add_modules ($id_modules, $image,
$label = '<p><span class="visual_font_size_'.$fonts.'" style="font-family:'.$fontf.';">'.$module_label.'</span></p>'; $label = '<p><span class="visual_font_size_'.$fonts.'" style="font-family:'.$fontf.';">'.$module_label.'</span></p>';
break; break;
case 'agent': case 'agent':
$agent_label = agents_get_name ($id_agent); $agent_label = agents_get_alias($id_agent);
$label = '<p><span class="visual_font_size_'.$fonts.'" style="font-family:'.$fontf.';">'.$agent_label.'</span></p>'; $label = '<p><span class="visual_font_size_'.$fonts.'" style="font-family:'.$fontf.';">'.$agent_label.'</span></p>';
break; break;
case 'none': case 'none':
@ -1953,9 +1951,7 @@ function visual_map_process_wizard_add_agents ($id_agents, $image,
switch ($label_type) { switch ($label_type) {
case 'agent': case 'agent':
$agent_label = $label = agents_get_alias($id_agent);
agents_get_name($id_agent);
$label = $agent_label;
break; break;
case 'none': case 'none':
$label = ''; $label = '';

View File

@ -284,6 +284,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$params['javascript_is_function_select'] = true; $params['javascript_is_function_select'] = true;
$params['use_hidden_input_idagent'] = true; $params['use_hidden_input_idagent'] = true;
$params['print_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent';
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$params['javascript_ajax_page'] = '../../ajax.php'; $params['javascript_ajax_page'] = '../../ajax.php';
$params['disabled_javascript_on_blur_function'] = true; $params['disabled_javascript_on_blur_function'] = true;

View File

@ -369,7 +369,7 @@ var TreeController = {
$content.append($alertImage); $content.append($alertImage);
} }
$content.append(element.name); $content.append(element.alias);
break; break;
case 'module': case 'module':
// Status image // Status image

View File

@ -179,7 +179,7 @@ if ($free_search != '') {
WHERE id_agente IN ( WHERE id_agente IN (
SELECT id_agente SELECT id_agente
FROM tagente FROM tagente
WHERE nombre LIKE "%' . $free_search . '%"))' . WHERE nombre LIKE "%' . $free_search . '%") OR alias LIKE "%' . $free_search . '%")' .
')'; ')';
break; break;
@ -214,7 +214,7 @@ if ($free_search != '') {
WHERE id_agente IN ( WHERE id_agente IN (
SELECT id_agente SELECT id_agente
FROM tagente FROM tagente
WHERE nombre LIKE \'%' . $free_search . '%\'))' . WHERE nombre LIKE \'%' . $free_search . '%\' OR alias LIKE \'%' . $free_search . '%\'))' .
')'; ')';
break; break;

View File

@ -258,13 +258,13 @@ switch ($sortField) {
switch ($sort) { switch ($sort) {
case 'up': case 'up':
$selectNameUp = $selected; $selectNameUp = $selected;
$order = array('field' => 'nombre' . $order_collation, $order = array('field' => 'alias' . $order_collation,
'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); 'field2' => 'alias' . $order_collation, 'order' => 'ASC');
break; break;
case 'down': case 'down':
$selectNameDown = $selected; $selectNameDown = $selected;
$order = array('field' => 'nombre' . $order_collation, $order = array('field' => 'alias' . $order_collation,
'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); 'field2' => 'alias' . $order_collation, 'order' => 'DESC');
break; break;
} }
break; break;
@ -273,12 +273,12 @@ switch ($sortField) {
case 'up': case 'up':
$selectOsUp = $selected; $selectOsUp = $selected;
$order = array('field' => 'id_os', $order = array('field' => 'id_os',
'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); 'field2' => 'alias' . $order_collation, 'order' => 'ASC');
break; break;
case 'down': case 'down':
$selectOsDown = $selected; $selectOsDown = $selected;
$order = array('field' => 'id_os', $order = array('field' => 'id_os',
'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); 'field2' => 'alias' . $order_collation, 'order' => 'DESC');
break; break;
} }
break; break;
@ -287,12 +287,12 @@ switch ($sortField) {
case 'up': case 'up':
$selectIntervalUp = $selected; $selectIntervalUp = $selected;
$order = array('field' => 'intervalo', $order = array('field' => 'intervalo',
'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); 'field2' => 'alias' . $order_collation, 'order' => 'ASC');
break; break;
case 'down': case 'down':
$selectIntervalDown = $selected; $selectIntervalDown = $selected;
$order = array('field' => 'intervalo', $order = array('field' => 'intervalo',
'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); 'field2' => 'alias' . $order_collation, 'order' => 'DESC');
break; break;
} }
break; break;
@ -301,12 +301,12 @@ switch ($sortField) {
case 'up': case 'up':
$selectGroupUp = $selected; $selectGroupUp = $selected;
$order = array('field' => 'id_grupo', $order = array('field' => 'id_grupo',
'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); 'field2' => 'alias' . $order_collation, 'order' => 'ASC');
break; break;
case 'down': case 'down':
$selectGroupDown = $selected; $selectGroupDown = $selected;
$order = array('field' => 'id_grupo', $order = array('field' => 'id_grupo',
'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); 'field2' => 'alias' . $order_collation, 'order' => 'DESC');
break; break;
} }
break; break;
@ -315,12 +315,12 @@ switch ($sortField) {
case 'up': case 'up':
$selectLastContactUp = $selected; $selectLastContactUp = $selected;
$order = array('field' => 'ultimo_contacto', $order = array('field' => 'ultimo_contacto',
'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); 'field2' => 'alias' . $order_collation, 'order' => 'DESC');
break; break;
case 'down': case 'down':
$selectLastContactDown = $selected; $selectLastContactDown = $selected;
$order = array('field' => 'ultimo_contacto', $order = array('field' => 'ultimo_contacto',
'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); 'field2' => 'alias' . $order_collation, 'order' => 'ASC');
break; break;
} }
break; break;
@ -329,12 +329,12 @@ switch ($sortField) {
case 'up': case 'up':
$selectLastContactUp = $selected; $selectLastContactUp = $selected;
$order = array('field' => 'comentarios', $order = array('field' => 'comentarios',
'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); 'field2' => 'alias' . $order_collation, 'order' => 'DESC');
break; break;
case 'down': case 'down':
$selectLastContactDown = $selected; $selectLastContactDown = $selected;
$order = array('field' => 'comentarios', $order = array('field' => 'comentarios',
'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); 'field2' => 'alias' . $order_collation, 'order' => 'ASC');
break; break;
} }
break; break;
@ -349,8 +349,8 @@ switch ($sortField) {
$selectGroupDown = ''; $selectGroupDown = '';
$selectLastContactUp = ''; $selectLastContactUp = '';
$selectLastContactDown = ''; $selectLastContactDown = '';
$order = array('field' => 'nombre' . $order_collation, $order = array('field' => 'alias' . $order_collation,
'field2' => 'nombre' . $order_collation, 'field2' => 'alias' . $order_collation,
'order' => 'ASC'); 'order' => 'ASC');
break; break;
} }
@ -377,7 +377,7 @@ if ($search != "") {
$search_sql .= ")"; $search_sql .= ")";
}else{ }else{
$search_sql = " AND ( nombre " . $order_collation . " $search_sql = " AND ( nombre " . $order_collation . "
LIKE '%$search%') "; LIKE '%$search%' OR alias ".$order_collation." LIKE '%$search%') ";
} }
} }
@ -453,6 +453,8 @@ else {
array ('id_agente', array ('id_agente',
'id_grupo', 'id_grupo',
'nombre',
'alias',
'id_os', 'id_os',
'ultimo_contacto', 'ultimo_contacto',
'intervalo', 'intervalo',
@ -569,7 +571,7 @@ foreach ($agents as $agent) {
if ($agent['quiet']) { if ($agent['quiet']) {
$data[0] .= html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) . "&nbsp;"; $data[0] .= html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) . "&nbsp;";
} }
$data[0] .= ui_print_agent_name($agent["id_agente"], true, 60, 'font-size:8pt !important;', true); $data[0] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].'"> <span style="font-size: 7pt;font-weight:bold" title ="' . $agent["nombre"]. '">'.$agent["alias"].'</span></a>';
$data[0] .= '</span>'; $data[0] .= '</span>';
$data[0] .= '<div class="agentleft_' . $agent["id_agente"] . '" style="visibility: hidden; clear: left;">'; $data[0] .= '<div class="agentleft_' . $agent["id_agente"] . '" style="visibility: hidden; clear: left;">';
$data[0] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].'">'.__('View').'</a>'; $data[0] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].'">'.__('View').'</a>';

View File

@ -73,8 +73,12 @@ $table_agent->styleTable = 'padding:0px;';
$table_agent->data = array(); $table_agent->data = array();
$data = array(); $data = array();
$agent_name = ui_print_agent_name ($agent["id_agente"], true, 500, /*$agent_name = ui_print_agent_name ($agent["id_agente"], true, 500,
"font-size: medium;", true); "font-size: medium;", true);*/
$agent_name = "<a alt =".$agent["nombre"]." href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=" . $agent["id_agente"] . "'>" .
'<span style="font-size: medium;font-weight:bold" title="' . $agent["nombre"] . '">'.$agent["alias"].'</span>' .
"</a>";
if ($agent['disabled']) { if ($agent['disabled']) {
$agent_name = "<em>" . $agent_name . "</em>" . ui_print_help_tip(__('Disabled'), true); $agent_name = "<em>" . $agent_name . "</em>" . ui_print_help_tip(__('Disabled'), true);

View File

@ -138,7 +138,8 @@ if (!empty ($module)) {
foreach ($data as $key => $module) { foreach ($data as $key => $module) {
$output .= $rowstart; $output .= $rowstart;
$output .= io_safe_output($module['agent_name']); $alias = db_get_value ("alias","tagente","id_agente",$module['agent_id']);
$output .= io_safe_output($alias);
$output .= $divider; $output .= $divider;
$output .= io_safe_output($module['module_name']); $output .= io_safe_output($module['module_name']);
$output .= $divider; $output .= $divider;

View File

@ -137,7 +137,8 @@ if (!empty ($module)) {
foreach ($data as $key => $module) { foreach ($data as $key => $module) {
$output .= $rowstart; $output .= $rowstart;
$output .= io_safe_output($module['agent_name']); $alias = db_get_value ("alias","tagente","id_agente",$module['agent_id']);
$output .= io_safe_output($alias);
$output .= $divider; $output .= $divider;
$output .= io_safe_output($module['module_name']); $output .= io_safe_output($module['module_name']);
$output .= $divider; $output .= $divider;

View File

@ -160,7 +160,8 @@ if (!empty ($export_btn) && !empty ($module)) {
foreach ($data as $key => $module) { foreach ($data as $key => $module) {
$output .= $rowstart; $output .= $rowstart;
$output .= io_safe_output($module['agent_name']); $alias = db_get_value ("alias","tagente","id_agente",$module['agent_id']);
$output .= io_safe_output($alias);
$output .= $divider; $output .= $divider;
$output .= io_safe_output($module['module_name']); $output .= io_safe_output($module['module_name']);
$output .= $divider; $output .= $divider;

View File

@ -59,6 +59,9 @@ echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/
$label = get_parameter('label'); $label = get_parameter('label');
$label = base64_decode($label); $label = base64_decode($label);
$id = get_parameter('id'); $id = get_parameter('id');
$id_agent = db_get_value ("id_agente","tagente_modulo","id_agente_modulo",$id);
$alias = db_get_value ("alias","tagente","id_agente",$id_agent);
//$agent = agents_get_agent_with_ip ("192.168.50.31");
//$label = rawurldecode(urldecode(base64_decode(get_parameter('label', '')))); //$label = rawurldecode(urldecode(base64_decode(get_parameter('label', ''))));
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -74,7 +77,7 @@ $id = get_parameter('id');
} }
?> ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pandora FMS Graph (<?php echo modules_get_agentmodule_agent_name ($id) . ' - ' . $label; ?>)</title> <title>Pandora FMS Graph (<?php echo $alias . ' - ' . $label; ?>)</title>
<link rel="stylesheet" href="../../include/styles/pandora_minimal.css" type="text/css" /> <link rel="stylesheet" href="../../include/styles/pandora_minimal.css" type="text/css" />
<link rel="stylesheet" href="../../include/styles/jquery-ui-1.10.0.custom.css" type="text/css" /> <link rel="stylesheet" href="../../include/styles/jquery-ui-1.10.0.custom.css" type="text/css" />
<script type='text/javascript' src='../../include/javascript/pandora.js'></script> <script type='text/javascript' src='../../include/javascript/pandora.js'></script>

View File

@ -47,7 +47,7 @@ else {
$ag_freestring = get_parameter ('ag_freestring'); $ag_freestring = get_parameter ('ag_freestring');
$moduletype = (string) get_parameter ('moduletype'); $moduletype = (string) get_parameter ('moduletype');
$datatype = (string) get_parameter ('datatype'); $datatype = (string) get_parameter ('datatype');
$ag_modulename = (string) get_parameter ('ag_modulename'); $ag_modulename = (string) get_parameter ('ag_modulename');
$refr = (int) get_parameter('refr', 0); $refr = (int) get_parameter('refr', 0);
$offset = (int) get_parameter ('offset', 0); $offset = (int) get_parameter ('offset', 0);
@ -164,6 +164,7 @@ if ($moduletype != '') {
// Freestring selector // Freestring selector
if ($ag_freestring != '') { if ($ag_freestring != '') {
$sql_conditions .= sprintf (' AND (tagente.nombre LIKE \'%%%s%%\' $sql_conditions .= sprintf (' AND (tagente.nombre LIKE \'%%%s%%\'
OR tagente.alias LIKE \'%%%s%%\'
OR tagente_modulo.nombre LIKE \'%%%s%%\' OR tagente_modulo.nombre LIKE \'%%%s%%\'
OR tagente_modulo.descripcion LIKE \'%%%s%%\')', OR tagente_modulo.descripcion LIKE \'%%%s%%\')',
$ag_freestring, $ag_freestring, $ag_freestring); $ag_freestring, $ag_freestring, $ag_freestring);
@ -568,12 +569,12 @@ switch ($sortField) {
switch ($sort) { switch ($sort) {
case 'up': case 'up':
$selectAgentNameUp = $selected; $selectAgentNameUp = $selected;
$order = array('field' => 'tagente.nombre', $order = array('field' => 'tagente.alias',
'order' => 'ASC'); 'order' => 'ASC');
break; break;
case 'down': case 'down':
$selectAgentNameDown = $selected; $selectAgentNameDown = $selected;
$order = array('field' => 'tagente.nombre', $order = array('field' => 'tagente.alias',
'order' => 'DESC'); 'order' => 'DESC');
break; break;
} }
@ -706,7 +707,7 @@ switch ($sortField) {
$selectTimestampUp = ''; $selectTimestampUp = '';
$selectTimestampDown = ''; $selectTimestampDown = '';
$order = array( $order = array(
'field' => 'tagente.nombre', 'field' => 'tagente.alias',
'order' => 'ASC'); 'order' => 'ASC');
break; break;
} }
@ -724,7 +725,8 @@ switch ($config['dbtype']) {
tagente_modulo.id_agente_modulo, tagente_modulo.id_agente_modulo,
tagente_modulo.id_modulo, tagente_modulo.id_modulo,
tagente.intervalo AS agent_interval, tagente.intervalo AS agent_interval,
tagente.nombre AS agent_name, tagente.alias AS agent_alias,
tagente.nombre AS agent_name,
tagente_modulo.nombre AS module_name, tagente_modulo.nombre AS module_name,
tagente_modulo.history_data, tagente_modulo.history_data,
tagente_modulo.flag AS flag, tagente_modulo.flag AS flag,
@ -771,6 +773,7 @@ switch ($config['dbtype']) {
tagente_modulo.id_agente_modulo, tagente_modulo.id_agente_modulo,
tagente_modulo.id_modulo, tagente_modulo.id_modulo,
tagente.intervalo AS agent_interval, tagente.intervalo AS agent_interval,
tagente.alias AS agent_alias,
tagente.nombre AS agent_name, tagente.nombre AS agent_name,
tagente_modulo.nombre AS module_name, tagente_modulo.nombre AS module_name,
tagente_modulo.history_data, tagente_modulo.history_data,
@ -814,7 +817,8 @@ switch ($config['dbtype']) {
tagente_modulo.id_agente_modulo, tagente_modulo.id_agente_modulo,
tagente_modulo.id_modulo, tagente_modulo.id_modulo,
tagente.intervalo AS agent_interval, tagente.intervalo AS agent_interval,
tagente.nombre AS agent_name, tagente.alias AS agent_alias,
tagente.nombre AS agent_name,
tagente_modulo.nombre AS module_name, tagente_modulo.nombre AS module_name,
tagente_modulo.history_data, tagente_modulo.history_data,
tagente_modulo.flag AS flag, tagente_modulo.flag AS flag,
@ -942,8 +946,8 @@ if (!empty($result)) {
$table->head[0] = '<span title=\'' . __('Policy') . '\'>' . __('P.') . '</span>'; $table->head[0] = '<span title=\'' . __('Policy') . '\'>' . __('P.') . '</span>';
$table->head[1] = __('Agent'); $table->head[1] = __('Agent');
$table->head[1] .=' <a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;datatype='.$datatype . '&amp;moduletype='.$moduletype . '&amp;modulegroup='.$modulegroup . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=agent_name&amp;sort=up">' . html_print_image('images/sort_up.png', true, array('style' => $selectAgentNameUp, 'alt' => 'up')) . '</a>' . $table->head[1] .=' <a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;datatype='.$datatype . '&amp;moduletype='.$moduletype . '&amp;modulegroup='.$modulegroup . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=agent_alias&amp;sort=up">' . html_print_image('images/sort_up.png', true, array('style' => $selectAgentNameUp, 'alt' => 'up')) . '</a>' .
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;datatype='.$datatype . '&amp;moduletype='.$moduletype . '&amp;modulegroup='.$modulegroup . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=agent_name&amp;sort=down">' . html_print_image('images/sort_down.png', true, array('style' => $selectAgentNameDown, 'alt' => 'down')) . '</a>'; '<a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;datatype='.$datatype . '&amp;moduletype='.$moduletype . '&amp;modulegroup='.$modulegroup . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=agent_alias&amp;sort=down">' . html_print_image('images/sort_down.png', true, array('style' => $selectAgentNameDown, 'alt' => 'down')) . '</a>';
$table->head[2] = __('Data Type'); $table->head[2] = __('Data Type');
$table->head[2] .= ' <a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;datatype='.$datatype . '&amp;moduletype='.$moduletype . '&amp;refr=' . $refr . '&amp;modulegroup='.$modulegroup . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=type&amp;sort=up">' . html_print_image('images/sort_up.png', true, array('style' => $selectTypeUp, 'alt' => 'up')) . '</a>' . $table->head[2] .= ' <a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;datatype='.$datatype . '&amp;moduletype='.$moduletype . '&amp;refr=' . $refr . '&amp;modulegroup='.$modulegroup . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=type&amp;sort=up">' . html_print_image('images/sort_up.png', true, array('style' => $selectTypeUp, 'alt' => 'up')) . '</a>' .
@ -1052,6 +1056,8 @@ if (!empty($result)) {
} }
} }
$agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name'];
// TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$agent_link = '<a href="'. $agent_link = '<a href="'.
@ -1062,19 +1068,19 @@ if (!empty($result)) {
'loginhash=auto&amp;' . 'loginhash=auto&amp;' .
'loginhash_data=' . $row['hashdata'] . '&amp;' . 'loginhash_data=' . $row['hashdata'] . '&amp;' .
'loginhash_user=' . str_rot13($row['user']) . '">'; 'loginhash_user=' . str_rot13($row['user']) . '">';
$agent_name = ui_print_truncate_text($row['agent_name'], $agent_alias = ui_print_truncate_text($agent_alias,
'agent_small', false, true, false, '[&hellip;]', 'agent_small', false, true, false, '[&hellip;]',
'font-size:7.5pt;'); 'font-size:7.5pt;');
if (can_user_access_node ()) { if (can_user_access_node ()) {
$data[1] = $agent_link . '<b>' . $agent_name . '</b></a>'; $data[1] = $agent_link . '<b>' . $agent_alias . '</b></a>';
} }
else { else {
$data[1] = $agent_name; $data[1] = $agent_alias;
} }
} }
else { else {
$data[1] = '<strong><a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$row['id_agent'].'">'; $data[1] = '<strong><a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$row['id_agent'].'">';
$data[1] .= ui_print_truncate_text($row['agent_name'], 'agent_medium', false, true, false, '[&hellip;]', 'font-size:7.5pt;'); $data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[&hellip;]', 'font-size:7.5pt;');
$data[1] .= '</a></strong>'; $data[1] .= '</a></strong>';
} }

View File

@ -100,8 +100,8 @@ if (is_ajax ()) {
$filter['order'] = "nombre ASC"; $filter['order'] = "nombre ASC";
// Build fields // Build fields
$fields = array('id_agente', 'nombre'); $fields = array('id_agente', 'alias');
// Perform search // Perform search
$agents = db_get_all_rows_filter('tagente', $filter, $fields); $agents = db_get_all_rows_filter('tagente', $filter, $fields);
if (empty($agents)) $agents = array(); if (empty($agents)) $agents = array();
@ -226,8 +226,8 @@ if (is_ajax ()) {
$groups = users_get_groups ($config["id_user"], "AW", false); $groups = users_get_groups ($config["id_user"], "AW", false);
$group_id_list = ($groups ? join(",",array_keys($groups)):"0"); $group_id_list = ($groups ? join(",",array_keys($groups)):"0");
$sql = 'SELECT DISTINCT(t1.nombre) as name $sql = 'SELECT DISTINCT(t1.alias) as name
FROM tagente t1, tagente_modulo t2 FROM tagente t1, tagente_modulo t2
WHERE t1.id_agente = t2.id_agente WHERE t1.id_agente = t2.id_agente
AND t1.id_grupo IN (' . $group_id_list .') AND t1.id_grupo IN (' . $group_id_list .')
@ -266,9 +266,9 @@ if (is_ajax ()) {
WHERE t3.id_agente = t4.id_agente AND t1.nombre = t3.nombre WHERE t3.id_agente = t4.id_agente AND t1.nombre = t3.nombre
AND t4.nombre IN (\'' . implode('\',\'', $nameModules) . '\')) = '.count($nameModules); AND t4.nombre IN (\'' . implode('\',\'', $nameModules) . '\')) = '.count($nameModules);
} }
$sql .= ' ORDER BY t1.nombre'; $sql .= ' ORDER BY t1.alias';
$nameAgents = db_get_all_rows_sql($sql); $nameAgents = db_get_all_rows_sql($sql);
if ($nameAgents == false) if ($nameAgents == false)
@ -672,7 +672,7 @@ HAVING count(nombre) = (SELECT count(nombre) FROM tagente_modulo))';
if ($agentName != null) { if ($agentName != null) {
$search = array(); $search = array();
$search['name'] = io_safe_output($agentName); $search['alias'] = io_safe_output($agentName);
} }
else else
$search = false; $search = false;
@ -1314,8 +1314,7 @@ switch($tab) {
break; break;
} }
ui_print_page_header(agents_get_name($id_agente) . ui_print_page_header($agent["nombre"] , $icon, false, "", false, $onheader, false, '', GENERIC_SIZE_TEXT, $agent["alias"] . $header_description);
$header_description, $icon, false, "", false, $onheader);
switch ($tab) { switch ($tab) {

View File

@ -436,7 +436,9 @@ else {
} }
} }
else { else {
$data[$i] .= ui_print_agent_name ($event["id_agente"], true); $agent = db_get_row ("tagente","id_agente",$event["id_agente"]);
$data[$i] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $event["id_agente"] . '" title='.$agent['nombre']. '>';
$data[$i] .= '<b>' . $agent['alias'] . '</a></b>';
} }
} }
else { else {

View File

@ -94,7 +94,7 @@ $result = db_get_all_rows_sql ($sql);
foreach ($result as $row) { foreach ($result as $row) {
$agente = ""; $agente = "";
if ($row["id_agente"] != 0) { if ($row["id_agente"] != 0) {
$agente = db_get_sql ("SELECT nombre $agente = db_get_sql ("SELECT alias
FROM tagente FROM tagente
WHERE id_agente = ". $row["id_agente"]); WHERE id_agente = ". $row["id_agente"]);
$agente = $agente . " : "; $agente = $agente . " : ";

View File

@ -105,6 +105,7 @@ echo chr (13);
$new = true; $new = true;
while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) { while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) {
$new = false; $new = false;
$alias = db_get_value ("alias","tagente","id_agente",$event["id_agente"]);
if ((!check_acl($config["id_user"], $event["id_grupo"], "ER") && if ((!check_acl($config["id_user"], $event["id_grupo"], "ER") &&
!check_acl($config["id_user"], $event["id_grupo"], "EW") && !check_acl($config["id_user"], $event["id_grupo"], "EM") ) || !check_acl($config["id_user"], $event["id_grupo"], "EW") && !check_acl($config["id_user"], $event["id_grupo"], "EM") ) ||
(!check_acl($config["id_user"], 0, "PM") && $event["event_type"] == 'system')) (!check_acl($config["id_user"], 0, "PM") && $event["event_type"] == 'system'))
@ -112,7 +113,7 @@ while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) {
echo $event["timestamp"]; echo $event["timestamp"];
echo ","; echo ",";
echo io_safe_output(agents_get_name($event["id_agente"])); echo io_safe_output($alias);
echo ","; echo ",";
echo io_safe_output(groups_get_name($event["id_grupo"])); echo io_safe_output(groups_get_name($event["id_grupo"]));
echo ","; echo ",";

View File

@ -351,7 +351,7 @@ echo '<td class="datos">';
$params = array(); $params = array();
$params['show_helptip'] = true; $params['show_helptip'] = true;
$params['input_name'] = 'agent'; $params['input_name'] = 'agent';
$params['value'] = agents_get_name ($id_agent); $params['value'] = db_get_value("alias","tagente","id_agente",$id_agent);
$params['print_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_value'] = $id_agent; $params['hidden_input_idagent_value'] = $id_agent;
$params['hidden_input_idagent_name'] = 'id_agent'; $params['hidden_input_idagent_name'] = 'id_agent';

View File

@ -139,6 +139,13 @@ unset($report['private']);
unset($report['custom_logo']); unset($report['custom_logo']);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
//change agent name
if(count($report['contents']) > 0){
for($i = 0;$i < count($report['contents']); $i++){
$aux = explode("-",$report['contents'][$i]['subtitle']);
$report['contents'][$i]['subtitle'] = db_get_value ("alias","tagente","nombre",$report['contents'][$i]['agent_name']) .' -'. $aux[1];
}
}
$xml = null; $xml = null;
$xml = array2XML($report, "report", $xml); $xml = array2XML($report, "report", $xml);

View File

@ -138,7 +138,8 @@ if ($searchAgents) {
}else{ }else{
$search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR $search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
t2.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR t2.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
t1.direccion COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%'"; t1.direccion COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
t1.alias COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%'";
} }
$sql = " $sql = "
FROM tagente t1 FROM tagente t1
@ -190,7 +191,8 @@ if ($searchAgents) {
}else{ }else{
$search_sql = " lower(t1.nombre) LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR $search_sql = " lower(t1.nombre) LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR
lower(t2.nombre) LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR lower(t2.nombre) LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR
lower(t1.direccion) LIKE '%%" . strtolower($stringSearchSQL) . "%%'"; lower(t1.direccion) LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR
lower(t1.alias) LIKE '%%" . strtolower($stringSearchSQL) . "%%'";
} }
$sql = " $sql = "
FROM tagente t1 FROM tagente t1
@ -220,8 +222,8 @@ if ($searchAgents) {
"; ";
break; break;
} }
$select = "SELECT t1.id_agente, t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled"; $select = "SELECT t1.id_agente, t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias";
if ($only_count) { if ($only_count) {
$limit = " ORDER BY " . $order['field'] . " " . $order['order'] . $limit = " ORDER BY " . $order['field'] . " " . $order['order'] .
" LIMIT " . $config["block_size"] . " OFFSET 0"; " LIMIT " . $config["block_size"] . " OFFSET 0";

View File

@ -87,10 +87,12 @@ else {
$modulesCell = reporting_tiny_stats($agent_info, true); $modulesCell = reporting_tiny_stats($agent_info, true);
if ($agent['disabled']) { if ($agent['disabled']) {
$cellName = "<em>" . ui_print_agent_name ($agent["id_agente"], true, "text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . "</em>"; $cellName = "<em>" . '<a style href=index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].' title='.$agent["nombre"].'><b>'.
'<span style>'.$agent["alias"].'</span></b></a>'. ui_print_help_tip(__('Disabled'), true) . "</em>";
} }
else { else {
$cellName = ui_print_agent_name ($agent["id_agente"], true, "text-transform: uppercase;"); $cellName = '<a style href=index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].' title='.$agent["nombre"].'><b>'.
'<span style>'.$agent["alias"].'</span></b></a>';
} }
$last_time = strtotime ($agent["ultimo_contacto"]); $last_time = strtotime ($agent["ultimo_contacto"]);

View File

@ -87,8 +87,9 @@ else {
$utimestamp_sql = $utimestamp_sql[0]; $utimestamp_sql = $utimestamp_sql[0];
$agentCell = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $module['id_agente'] . '">' . $agent = db_get_row ('tagente', 'id_agente', $module['id_agente']);
$module['agent_name'] . '</a>'; $agentCell = '<a title='.$module['agent_name'].' href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $module['id_agente'] . '">' .
$agent['alias'] . '</a>';
$typeCell = ui_print_moduletype_icon($module["id_tipo_modulo"], true); $typeCell = ui_print_moduletype_icon($module["id_tipo_modulo"], true);

0
pandora_console/pandora_console_install Normal file → Executable file
View File

View File

@ -82,6 +82,7 @@ CREATE TABLE IF NOT EXISTS `tagente` (
`fired_count` bigint(20) NOT NULL default '0', `fired_count` bigint(20) NOT NULL default '0',
`update_module_count` tinyint(1) NOT NULL default '0', `update_module_count` tinyint(1) NOT NULL default '0',
`update_alert_count` tinyint(1) NOT NULL default '0', `update_alert_count` tinyint(1) NOT NULL default '0',
`alias` varchar(600) BINARY NOT NULL default '',
`transactional_agent` tinyint(1) NOT NULL default '0', `transactional_agent` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`id_agente`), PRIMARY KEY (`id_agente`),
KEY `nombre` (`nombre`(255)), KEY `nombre` (`nombre`(255)),

View File

@ -2878,12 +2878,12 @@ Create a new entry in B<tagente> optionaly with position information
=cut =cut
########################################################################## ##########################################################################
sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$) { sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$) {
my ($pa_config, $server_name, $agent_name, $address, my ($pa_config, $server_name, $agent_name, $address,
$group_id, $parent_id, $os_id, $group_id, $parent_id, $os_id,
$description, $interval, $dbh, $timezone_offset, $description, $interval, $dbh, $timezone_offset,
$longitude, $latitude, $altitude, $position_description, $longitude, $latitude, $altitude, $position_description,
$custom_id, $url_address, $agent_mode) = @_; $custom_id, $url_address, $agent_mode, $alias) = @_;
logger ($pa_config, "Server '$server_name' creating agent '$agent_name' address '$address'.", 10); logger ($pa_config, "Server '$server_name' creating agent '$agent_name' address '$address'.", 10);
@ -2909,7 +2909,8 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$) {
'modo' => $agent_mode, 'modo' => $agent_mode,
'custom_id' => $custom_id, 'custom_id' => $custom_id,
'url_address' => $url_address, 'url_address' => $url_address,
'timezone_offset' => $timezone_offset 'timezone_offset' => $timezone_offset,
'alias' => $alias
}); });
my $agent_id = db_insert ($dbh, 'id_agente', "INSERT INTO tagente $columns", @{$values}); my $agent_id = db_insert ($dbh, 'id_agente', "INSERT INTO tagente $columns", @{$values});
@ -2923,7 +2924,7 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$) {
} }
logger ($pa_config, "Server '$server_name' CREATED agent '$agent_name' address '$address'.", 10); logger ($pa_config, "Server '$server_name' CREATED agent '$agent_name' address '$address'.", 10);
pandora_event ($pa_config, "Agent [$agent_name] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh); pandora_event ($pa_config, "Agent [$alias] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh);
return $agent_id; return $agent_id;
} }
@ -4508,7 +4509,7 @@ sub pandora_self_monitoring ($$) {
my $xml_output = ""; my $xml_output = "";
$xml_output = "<agent_data os_name='$OS' os_version='$OS_VERSION' version='" . $pa_config->{'version'} . "' description='Pandora FMS Server version " . $pa_config->{'version'} . "' agent_name='".$pa_config->{'servername'}."' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >"; $xml_output = "<agent_data os_name='$OS' os_version='$OS_VERSION' version='" . $pa_config->{'version'} . "' description='Pandora FMS Server version " . $pa_config->{'version'} . "' agent_name='".$pa_config->{'servername'} . "' agent_alias='".$pa_config->{'servername'} . "' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >";
$xml_output .=" <module>"; $xml_output .=" <module>";
$xml_output .=" <name>Status</name>"; $xml_output .=" <name>Status</name>";
$xml_output .=" <type>generic_proc</type>"; $xml_output .=" <type>generic_proc</type>";

View File

@ -374,9 +374,10 @@ sub process_xml_data ($$$$$) {
my $description = ''; my $description = '';
$description = $data->{'description'} if (defined ($data->{'description'})); $description = $data->{'description'} if (defined ($data->{'description'}));
my $alias = (defined ($data->{'agent_alias'}) && $data->{'agent_alias'} ne '') ? $data->{'agent_alias'} : $data->{'agent_name'};
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, $address, $group_id, $parent_id, $os, $agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, $address, $group_id, $parent_id, $os,
$description, $interval, $dbh, $timezone_offset, undef, undef, undef, undef, $custom_id, $url_address, $agent_mode); $description, $interval, $dbh, $timezone_offset, undef, undef, undef, undef, $custom_id, $url_address, $agent_mode, $alias);
if (! defined ($agent_id)) { if (! defined ($agent_id)) {
return; return;

0
pandora_server/pandora_server_installer Normal file → Executable file
View File

View File

@ -936,6 +936,12 @@ sub pandora_checkdb_consistency {
log_message ('CHECKDB', log_message ('CHECKDB',
"Deleting non-existing module $id_agente_modulo in state table."); "Deleting non-existing module $id_agente_modulo in state table.");
} }
#-------------------------------------------------------------------
# 3. Update empty aliases.
#-------------------------------------------------------------------
log_message ('CHECKDB', "Updating empty aliases.");
db_do ($dbh, "UPDATE tagente SET alias=nombre WHERE alias=''");
} }
############################################################################## ##############################################################################