Merge branch 'develop' into 2007-Monitorizacion-de-cluster-fase-2-API

Conflicts:
	pandora_console/include/functions_api.php
This commit is contained in:
enriquecd 2018-04-20 10:10:33 +02:00
commit 676835ddc8
80 changed files with 1023 additions and 388 deletions

View File

@ -1,3 +1,4 @@
# Dockerfile for the Pandora FMS image.
FROM debian:jessie FROM debian:jessie
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added

50
extras/docker/Dockerfile Normal file
View File

@ -0,0 +1,50 @@
FROM pandorafms/pandorafms-base
# Build variables.
ARG BRANCH=develop
ARG DB_PASS=pandora
# Clone the Pandora FMS repo.
RUN git clone --depth 1 -b "$BRANCH" https://github.com/pandorafms/pandorafms.git /tmp/pandorafms
# Install the Pandora FMS Server.
RUN cd /tmp/pandorafms/pandora_server && \
yes | ./pandora_server_installer --install && \
sed -i "s/^dbuser.*/dbuser root/" /etc/pandora/pandora_server.conf && \
sed -i "s/^dbpass.*/dbpass $DB_PASS/" /etc/pandora/pandora_server.conf
# Install the Pandora FMS Agent.
RUN cd /tmp/pandorafms/pandora_agents/unix && \
./pandora_agent_installer --install
# Set the server's name in Apache's configuration file to avoid warnings.
RUN sed -i "s/#ServerName.*/ServerName localhost:80/" /etc/httpd/conf/httpd.conf
# Install the Pandora FMS Console.
RUN service mysqld start && \
/usr/bin/mysqladmin -u root password "$DB_PASS" && \
service httpd start && \
cp -r /tmp/pandorafms/pandora_console /var/www/html && \
chown -R apache.apache /var/www/html/pandora_console/ && \
python /tmp/pandorafms/tests/install_console.py
# Redirect HTTP requests to / to the Pandora FMS Console.
RUN echo '<meta http-equiv="refresh" content="0;url=/pandora_console">' > /var/www/html/index.html
# Create the entrypoint script.
RUN echo -e '#/bin/bash\n \
service mysqld start &&\n \
service httpd start &&\n \
service crond start &&\n \
/etc/init.d/pandora_agent_daemon start && \
/etc/init.d/pandora_server start && \
tail -f /var/log/pandora/pandora_server.log' \
>> /entrypoint.sh && \
chmod +x /entrypoint.sh
# Clean-up.
RUN rm -rf /tmp/pandorafms
RUN yum clean all
EXPOSE 80 3306 41121
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View File

@ -0,0 +1,3 @@
#!/bin/bash
docker build --rm=true --build-arg BRANCH="develop" --build-arg DB_PASS="pandora" -t pandorafms/pandorafms:7 . && \
docker push pandorafms/pandorafms:7

View File

@ -65,7 +65,8 @@ $PANDHOME_ENT/pandora_plugins/MTL/pandora_mtl.pl \
$PANDHOME_ENT/pandora_plugins/Informix/informix.pl \ $PANDHOME_ENT/pandora_plugins/Informix/informix.pl \
$PANDHOME_ENT/pandora_plugins/Ruckus/ruckus.pl \ $PANDHOME_ENT/pandora_plugins/Ruckus/ruckus.pl \
$PANDHOME_ENT/pandora_plugins/UX/pandora_ux.pl \ $PANDHOME_ENT/pandora_plugins/UX/pandora_ux.pl \
$PANDHOME_ENT/pandora_server/util/plugins/vmware-plugin.pl " $PANDHOME_ENT/pandora_plugins/JMX/pandora_plugin_jmx.pl \
$PANDHOME_ENT/pandora_server/util/plugin/vmware-plugin.pl "
PLUGIN_LIB_FILE="$CODEHOME/pandora_server/lib/PandoraFMS/PluginTools.pm" PLUGIN_LIB_FILE="$CODEHOME/pandora_server/lib/PandoraFMS/PluginTools.pm"
# Update version in spec files # Update version in spec files

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.720-180321 Version: 7.0NG.720-180409
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -42,7 +42,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.720'; use constant AGENT_VERSION => '7.0NG.720';
use constant AGENT_BUILD => '180321'; use constant AGENT_BUILD => '180409';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.720 %define version 7.0NG.720
%define release 180321 %define release 180409
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.720 %define version 7.0NG.720
%define release 180321 %define release 180409
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.720" PI_VERSION="7.0NG.720"
PI_BUILD="180321" PI_BUILD="180409"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -215,6 +215,7 @@ sub print_log (@) {
$output .= "<source><![CDATA[" . $Module_name . "]]></source>\n"; $output .= "<source><![CDATA[" . $Module_name . "]]></source>\n";
$output .= "<data><![CDATA["; $output .= "<data><![CDATA[";
foreach my $line (@data) { foreach my $line (@data) {
$line =~ s/\]\]/]]]]><![CDATA[/g;
$output .= $line; $output .= $line;
} }
$output .= "]]></data>"; $output .= "]]></data>";
@ -229,6 +230,7 @@ sub print_log (@) {
$output .= "<type><![CDATA[async_string]]></type>\n"; $output .= "<type><![CDATA[async_string]]></type>\n";
$output .= "<datalist>\n"; $output .= "<datalist>\n";
foreach my $line (@data) { foreach my $line (@data) {
$line =~ s/\]\]/]]]]><![CDATA[/g;
$output .= "<data><value><![CDATA[$line]]></value></data>\n"; $output .= "<data><value><![CDATA[$line]]></value></data>\n";
} }
$output .= "</datalist>\n"; $output .= "</datalist>\n";

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{180321} {180409}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -532,6 +532,7 @@ Pandora_Module::getXml () {
try { try {
data_clean = strreplace (this->getDataOutput (data), data_clean = strreplace (this->getDataOutput (data),
"%", "%%" ); "%", "%%" );
data_clean = strreplace (data_clean, "]]>", "]]><![CDATA[");
} catch (Module_Exception e) { } catch (Module_Exception e) {
continue; continue;
} }
@ -542,6 +543,7 @@ Pandora_Module::getXml () {
data = data_list->front (); data = data_list->front ();
try { try {
data_clean = strreplace (this->getDataOutput (data), "%", "%%" ); data_clean = strreplace (this->getDataOutput (data), "%", "%%" );
data_clean = strreplace (data_clean, "]]>", "]]><![CDATA[");
module_xml += data_clean; module_xml += data_clean;
} catch (Module_Exception e) { } catch (Module_Exception e) {

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.720(Build 180321)") #define PANDORA_VERSION ("7.0NG.720(Build 180409)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.720-180321 Version: 7.0NG.720-180409
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -122,7 +122,7 @@ function pandora_realtime_graphs () {
echo '</form>'; echo '</form>';
// Define a custom action to save the OID selected in the SNMP browser to the form // Define a custom action to save the OID selected in the SNMP browser to the form
html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/hand_point.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false); html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/input_filter.disabled.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false);
html_print_input_hidden ('incremental_base', '0'); html_print_input_hidden ('incremental_base', '0');
echo '<script type="text/javascript" src="extensions/realtime_graphs/realtime_graphs.js"></script>'; echo '<script type="text/javascript" src="extensions/realtime_graphs/realtime_graphs.js"></script>';

View File

@ -4,4 +4,14 @@ UPDATE `tagente` SET `id_os` = 100 WHERE `id_os` = 21 and (select `id_os` from `
DELETE FROM `tconfig_os` where `id_os` = 21 and `name` = 'Cluster'; DELETE FROM `tconfig_os` where `id_os` = 21 and `name` = 'Cluster';
SET @st_oum721 = (SELECT IF(
(SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tuser_task_scheduled') > 0,
"ALTER TABLE tuser_task_scheduled ADD (id_grupo int(10) unsigned NOT NULL Default 0)",
"0"
));
PREPARE pr_oum721 FROM @st_oum721;
EXECUTE pr_oum721;
DEALLOCATE PREPARE pr_oum721;
COMMIT; COMMIT;

View File

@ -1368,6 +1368,7 @@ END IF;
SET @vv2 = (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tuser_task_scheduled'); SET @vv2 = (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tuser_task_scheduled');
IF @vv2>0 THEN IF @vv2>0 THEN
ALTER TABLE tuser_task_scheduled MODIFY args TEXT NOT NULL; ALTER TABLE tuser_task_scheduled MODIFY args TEXT NOT NULL;
ALTER TABLE tuser_task_scheduled ADD (id_grupo int(10) unsigned NOT NULL Default 0);
END IF; END IF;
END; END;
// //

View File

@ -49,8 +49,17 @@ ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no cl
echo __('<b>Clusters to guarantee service</b>: these are active - passive (A/P) mode clusters. It means that one of the nodes (or machines that make up the cluster) will be running (primary) and another won\'t (secondary). When the primary goes down, the secondary must take over and give the service instead. Although many of the elements of this cluster are active-passive, it will also have active elements in both of them that indicate that the passive node is "online", so that in the case of a service failure in the master, the active node collects this information.'); echo __('<b>Clusters to guarantee service</b>: these are active - passive (A/P) mode clusters. It means that one of the nodes (or machines that make up the cluster) will be running (primary) and another won\'t (secondary). When the primary goes down, the secondary must take over and give the service instead. Although many of the elements of this cluster are active-passive, it will also have active elements in both of them that indicate that the passive node is "online", so that in the case of a service failure in the master, the active node collects this information.');
?></p> ?></p>
<?php
if(check_acl ($config['id_user'], 0, "AW")) {
?>
<form action="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&step=1" method="post"> <form action="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&step=1" method="post">
<input style="margin-bottom:20px;" type="submit" class="button_task" value="<?php echo __('Create Cluster'); ?>" /> <input style="margin-bottom:20px;" type="submit" class="button_task" value="<?php echo __('Create Cluster'); ?>" />
</form> </form>
<?php
}
?>
</div> </div>
</div> </div>

View File

@ -555,7 +555,7 @@ if ($id_agente) {
$help_header = 'plugins_tab'; $help_header = 'plugins_tab';
break; break;
case "module": case "module":
$type_module_t = (int) get_parameter ('moduletype', ''); $type_module_t = get_parameter ('moduletype', '');
$tab_description = '- '. __('Modules'); $tab_description = '- '. __('Modules');
if($type_module_t == 'webux'){ if($type_module_t == 'webux'){
$help_header = 'wux_console'; $help_header = 'wux_console';

View File

@ -27,7 +27,7 @@ html_print_input_hidden ('ajax_url', ui_get_full_url("ajax.php"), false);
html_print_input_hidden ('search_matches_translation', __("Search matches"), false); html_print_input_hidden ('search_matches_translation', __("Search matches"), false);
// Define a custom action to save the OID selected in the SNMP browser to the form // Define a custom action to save the OID selected in the SNMP browser to the form
html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/hand_point.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false); html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/input_filter.disabled.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false);
$isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); $isFunctionPolicies = enterprise_include_once('include/functions_policies.php');

View File

@ -168,9 +168,8 @@ if ($create_action) {
$result = alerts_create_alert_action ($name, $id_alert_command, $result = alerts_create_alert_action ($name, $id_alert_command,
$values); $values);
$info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command . $info = '{"Name":"'.$name.'", "ID alert Command":"'.$id_alert_command.'", "Field information":"'.$info_fields.'", "Group":"'.$values['id_group'].'",
$info_fields . ' Group: ' . $values['id_group'] . "Action threshold":"'.$values['action_threshold'].'"}';
' Action threshold: ' . $values['action_threshold'];
} }
if ($result) { if ($result) {
@ -245,10 +244,6 @@ if ($update_action) {
} }
else { else {
$result = alerts_update_alert_action ($id, $values); $result = alerts_update_alert_action ($id, $values);
$info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command .
$info_fields . ' Group: ' . $group .
' Action threshold: ' . $action_threshold;
} }
if ($result) { if ($result) {

View File

@ -294,7 +294,7 @@ if ($create_command) {
$result = alerts_create_alert_command ($name, $command, $result = alerts_create_alert_command ($name, $command,
$values); $values);
$info = 'Name: ' . $name . ' Command: ' . $command . ' Description: ' . $description. ' ' .$info_fields; $info = '{"Name":"'.$name.'","Command":"'.$command.'","Description":"'.$description. ' '.$info_fields.'"}';
} }
else { else {
$result = ''; $result = '';

View File

@ -133,7 +133,7 @@ if ($create_special_day) {
} }
else { else {
$result = alerts_create_alert_special_day ($date, $same_day, $values); $result = alerts_create_alert_special_day ($date, $same_day, $values);
$info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $values['description']; $info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$values['description'].'"}';
} }
} }
@ -186,12 +186,12 @@ if ($update_special_day) {
} }
else { else {
$result = alerts_update_alert_special_day ($id, $values); $result = alerts_update_alert_special_day ($id, $values);
$info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $description; $info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$description.'"}';
} }
} }
else { else {
$result = alerts_update_alert_special_day ($id, $values); $result = alerts_update_alert_special_day ($id, $values);
$info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $description; $info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$description.'"}';
} }
} }

View File

@ -79,7 +79,7 @@ if ($update_command) {
} }
else { else {
$result = alerts_update_alert_command ($id, $values); $result = alerts_update_alert_command ($id, $values);
$info = 'Name: ' . $name . ' Command: ' . $command . ' Description: ' . $description. ' ' .$info_fields; $info = '{"Name":"'.$name.'","Command":"'.$command.'","Description":"'.$description. ' '.$info_fields.'"}';
} }
if ($result) { if ($result) {

View File

@ -418,13 +418,11 @@ if ($create_template) {
$result = ''; $result = '';
} }
if ($result) { if ($result) {
//db_pandora_audit("Command management", "Create alert command " . $result, false, false, json_encode($values));
db_pandora_audit("Template alert management", db_pandora_audit("Template alert management",
"Create alert template #" . $result, false, false, "Create alert template #" . $result, false, false,
json_encode($values)); json_encode($values));
} }
else { else {
//db_pandora_audit("Command management", "Fail try to create alert command", false, false, json_encode($values));
db_pandora_audit("Template alert management", db_pandora_audit("Template alert management",
"Fail try to create alert template", false, false, "Fail try to create alert template", false, false,
json_encode($values)); json_encode($values));

View File

@ -104,11 +104,12 @@ if ($add) {
$results = false; $results = false;
} }
} }
$info = array('Agents' => implode(',',$id_agents),
db_pandora_audit("Massive management", "Add alert action " . json_encode($id_agents), false, false, 'Agents: ' . 'Alerts' => addslashes(io_json_mb_encode($agent_alerts)),
json_encode($id_agents) . ' Alerts : ' . json_encode($agent_alerts) . 'Fires Min' => $fires_min,
' Fires Min: ' . $fires_min . ' Fires Max: ' . $fires_max . ' Actions: ' . implode(',',$actions)); 'Fires_max' => $fires_max,
'Actions' => implode(',',$actions));
db_pandora_audit("Massive management", "Add alert action " . json_encode($id_agents), false, false, json_encode($info));
ui_print_result_message ($results, __('Successfully added'), __('Could not be added')); ui_print_result_message ($results, __('Successfully added'), __('Could not be added'));
} }
} }

View File

@ -43,15 +43,18 @@ $do_operation = (bool) get_parameter ('do_operation');
if ($do_operation) { if ($do_operation) {
$result = agents_process_manage_config($source_id_agent, $result = agents_process_manage_config($source_id_agent,
$destiny_id_agents); $destiny_id_agents);
$info = array('Source agent' => $source_id_agent,
'Destinity agent' => implode(",",$destiny_id_agents));
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Copy modules", false, db_pandora_audit("Massive management", "Copy modules", false,
false, false, json_encode($info));
'Source agent: ' . json_encode($source_id_agent) . ' Destinity agent: ' . json_encode($destiny_id_agents));
} }
else { else {
db_pandora_audit("Massive management", db_pandora_audit("Massive management",
"Fail to try copy modules", false, false, "Fail to try copy modules", false, false,json_encode($info));
'Source agent: ' . json_encode($source_id_agent) . ' Destinity agent: ' . json_encode($destiny_id_agents));
} }
} }

View File

@ -98,16 +98,15 @@ if ($delete) {
} }
} }
} }
$info = array('Agents' => implode(',',$id_agents),
'Alert templates' => implode(",",$id_alert_templates),
'Actions' => implode(',',$actions));
if ($results) { if ($results) {
db_pandora_audit("Massive management", "Delete alert action", false, false, db_pandora_audit("Massive management", "Delete alert action", false, false,json_encode($info));
'Agent: ' . json_encode($id_agents) . ' Alert templates: ' . json_encode($id_alert_templates) .
' Actions: ' . implode(',',$actions));
} }
else { else {
db_pandora_audit("Massive management", "Fail try to delete alert action", false, false, db_pandora_audit("Massive management", "Fail try to delete alert action", false, false, json_encode($info));
'Agent: ' . json_encode($id_agents) . ' Alert templates: ' . json_encode($id_alert_templates) .
' Actions: ' . implode(',',$actions));
} }
ui_print_result_message ($results, ui_print_result_message ($results,

View File

@ -76,13 +76,12 @@ $delete = (bool) get_parameter_post ('delete');
if ($delete) { if ($delete) {
$result = process_manage_delete ($id_agents); $result = process_manage_delete ($id_agents);
$info = '{"Agent":"'.implode(",",$id_agents).'"}';
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Delete agent ", false, false, db_pandora_audit("Massive management", "Delete agent ", false, false,$info);
'Agent: ' . json_encode($id_agents));
} }
else { else {
db_pandora_audit("Massive management", "Fail try to delete agent", false, false, db_pandora_audit("Massive management", "Fail try to delete agent", false, false,$info);
'Agent: ' . json_encode($id_agents));
} }
} }

View File

@ -170,13 +170,14 @@ $delete = (bool) get_parameter_post ('delete');
if ($delete) { if ($delete) {
$result = process_manage_delete ($id_alert_template, $id_agents, $module_names); $result = process_manage_delete ($id_alert_template, $id_agents, $module_names);
$info = array('Agent' => implode(",",$id_agents),
'Template' => $id_alert_template, 'Module' => implode(",",$module_names));
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Delete alert ", false, false, db_pandora_audit("Massive management", "Delete alert ", false, false,json_encode($info));
'Agent: ' . json_encode($id_agents) . ' Template: ' . $id_alert_template . ' Module: ' . $module_names);
} }
else { else {
db_pandora_audit("Massive management", "Fail try to delete alert", false, false, db_pandora_audit("Massive management", "Fail try to delete alert", false, false,json_encode($info));
'Agent: ' . json_encode($id_agents) . ' Template: ' . $id_alert_template . ' Module: ' . $module_names);
} }
} }

View File

@ -349,13 +349,12 @@ if ($delete) {
$result = process_manage_delete ($modules_, $agents_, $modules_selection_mode); $result = process_manage_delete ($modules_, $agents_, $modules_selection_mode);
} }
$info = array('Agent' => implode(",",$agents_), 'Module' => implode(",",$modules_));
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Delete module ", false, false, db_pandora_audit("Massive management", "Delete module ", false, false, json_encode($info));
'Agent: ' . json_encode($agents_) . ' Module: ' . $module_name);
} }
else { else {
db_pandora_audit("Massive management", "Fail try to delete module", false, false, db_pandora_audit("Massive management", "Fail try to delete module", false, false, json_encode($info));
'Agent: ' . json_encode($agents_) . ' Module: ' . $module_name);
} }
} }

View File

@ -74,13 +74,12 @@ if ($delete_profiles) {
} }
} }
$info = array('Profiles' => implode(",",$profiles_id), 'Groups' => implode(",",$groups_id), 'Users' => implode(",",$users_id));
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Delete profile ", false, false, db_pandora_audit("Massive management", "Delete profile ", false, false, json_encode($info));
'Profiles: ' . json_encode($profiles_id) . ' Groups: ' . $groups_id . ' Users: ' . $users_id);
} }
else { else {
db_pandora_audit("Massive management", "Fail try to delete profile", false, false, db_pandora_audit("Massive management", "Fail try to delete profile", false, false, json_encode($info));
'Profiles: ' . json_encode($profiles_id) . ' Groups: ' . $groups_id . ' Users: ' . $users_id);
} }
ui_print_result_message ($result, ui_print_result_message ($result,

View File

@ -197,14 +197,18 @@ if ($update_agents) {
} }
} }
$info = array();
// Update Custom Fields // Update Custom Fields
foreach ($fields as $field) { foreach ($fields as $field) {
$info[$field['id_field']] = $field['name'];
if (get_parameter_post ('customvalue_' . $field['id_field'], '') != '') { if (get_parameter_post ('customvalue_' . $field['id_field'], '') != '') {
$key = $field['id_field']; $key = $field['id_field'];
$value = get_parameter_post ('customvalue_' . $field['id_field'], ''); $value = get_parameter_post ('customvalue_' . $field['id_field'], '');
$old_value = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $id_agent, 'id_field' => $key)); $old_value = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $id_agent, 'id_field' => $key));
if ($old_value === false) { if ($old_value === false) {
// Create custom field if not exist // Create custom field if not exist
$result = db_process_sql_insert ('tagent_custom_data', $result = db_process_sql_insert ('tagent_custom_data',
@ -225,11 +229,11 @@ if ($update_agents) {
if ($result !== false) { if ($result !== false) {
db_pandora_audit("Massive management", "Update agent " . $id_agent, false, false, json_encode($fields)); db_pandora_audit("Massive management", "Update agent " . $id_agent, false, false, json_encode($info));
} }
else { else {
if (isset ($id_agent)) { if (isset ($id_agent)) {
db_pandora_audit("Massive management", "Try to update agent " . $id_agent, false, false, json_encode($fields)); db_pandora_audit("Massive management", "Try to update agent " . $id_agent, false, false, json_encode($info));
} }
} }

View File

@ -162,7 +162,7 @@ if ($update) {
__('Successfully updated') . "(" . $success . "/" . $count . ")", __('Successfully updated') . "(" . $success . "/" . $count . ")",
$error_msg); $error_msg);
$info = 'Modules: ' . json_encode($modules_) . ' Agents: ' . json_encode($agents_); $info = '{"Modules":"'.implode(",",$modules_).'","Agents":"'.implode(",",$agents_).'"}';
if ($success > 0) { if ($success > 0) {
db_pandora_audit("Massive management", "Edit module", false, false, $info); db_pandora_audit("Massive management", "Edit module", false, false, $info);
} }

View File

@ -77,7 +77,7 @@ switch ($action) {
ui_print_result_message ($result, __('Successfully enabled'), __('Could not be enabled')); ui_print_result_message ($result, __('Successfully enabled'), __('Could not be enabled'));
$info = 'Alert: ' . json_encode($id_disabled_alerts); $info = '{"Alert":"'.implode(",",$id_disabled_alerts).'"}';
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Enable alert", false, false, $info); db_pandora_audit("Massive management", "Enable alert", false, false, $info);
} }
@ -95,7 +95,7 @@ switch ($action) {
ui_print_result_message ($result, __('Successfully disabled'), __('Could not be disabled')); ui_print_result_message ($result, __('Successfully disabled'), __('Could not be disabled'));
$info = 'Alert: ' . json_encode($id_enabled_alerts); $info = '{"Alert":"'.implode(",",$id_enabled_alerts).'"}';
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Disable alert", false, false, $info); db_pandora_audit("Massive management", "Disable alert", false, false, $info);
} }

View File

@ -77,7 +77,7 @@ switch($action) {
ui_print_result_message ($result, __('Successfully set off standby'), __('Could not be set off standby')); ui_print_result_message ($result, __('Successfully set off standby'), __('Could not be set off standby'));
$info = 'Alert: ' . json_encode($id_standby_alerts); $info = '{"Alert":"'.implode(",",$id_standby_alerts).'"}';
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Set off standby alerts", false, false, $info); db_pandora_audit("Massive management", "Set off standby alerts", false, false, $info);
} }
@ -95,7 +95,7 @@ switch($action) {
ui_print_result_message ($result, __('Successfully set standby'), __('Could not be set standby')); ui_print_result_message ($result, __('Successfully set standby'), __('Could not be set standby'));
$info = 'Alert: ' . json_encode($id_not_standby_alerts); $info = '{"Alert":"'.implode(",",$id_not_standby_alerts).'"}';
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Set on standby alerts", false, false, $info); db_pandora_audit("Massive management", "Set on standby alerts", false, false, $info);
} }

View File

@ -352,9 +352,8 @@ foreach ($items as $item) {
$row[1] = get_report_name($item['type']); $row[1] = get_report_name($item['type']);
$custom_graph_name = db_get_row_sql('select name from tgraph where id_graph = '.$item['id_gs']);
if($item['type'] == 'custom_graph'){ if($item['type'] == 'custom_graph'){
$custom_graph_name = db_get_row_sql('select name from tgraph where id_graph = '.$item['id_gs']);
$row[1] = get_report_name($item['type']).' ('.$custom_graph_name['name'].')'; $row[1] = get_report_name($item['type']).' ('.$custom_graph_name['name'].')';
} }

View File

@ -182,40 +182,30 @@ if ($update_profile) {
if ($name) { if ($name) {
$ret = db_process_sql_update('tperfil', $values, array('id_perfil' => $id_profile)); $ret = db_process_sql_update('tperfil', $values, array('id_perfil' => $id_profile));
if ($ret !== false) { if ($ret !== false) {
$info = 'Name: ' . $name . $info = '{"Name":"'.$incident_view.'",
"Incident view":"'.$incident_view.'",
' Incident view: ' . $incident_view . "Incident edit":"'.$incident_edit.'",
' Incident edit: ' . $incident_edit . "Incident management":"'.$incident_management.'",
' Incident management: ' . $incident_management . "Agent view":"'.$agent_view.'",
"Agent edit":"'.$agent_edit.'",
' Agent view: ' . $agent_view . "Agent disable":"'.$agent_disable.'",
' Agent edit: ' . $agent_edit . "Alert edit":"'.$alert_edit.'",
' Agent disable: ' . $agent_disable . "Alert management":"'.$alert_management.'",
"User management":"'.$user_management.'",
' Alert edit: ' . $alert_edit . "DB management":"'.$db_management.'",
' Alert management: ' . $alert_management . "Event view":"'.$event_view.'",
"Event edit":"'.$event_edit.'",
' User management: ' . $user_management . "Event management":"'.$event_management.'",
"Report view":"'.$report_view.'",
' DB management: ' . $db_management . "Report edit":"'.$report_edit.'",
"Report management":"'.$report_management.'",
' Event view: ' . $event_view . "Network map view":"'.$map_view.'",
' Event edit: ' . $event_edit . "Network map edit":"'.$map_edit.'",
' Event management: ' . $event_management . "Network map management":"'.$map_management.'",
"Visual console view":"'.$vconsole_view.'",
' Report view: ' . $report_view . "Visual console edit":"'.$vconsole_edit.'",
' Report edit: ' . $report_edit . "Visual console management":"'.$vconsole_management.'",
' Report management: ' . $report_management . "Pandora Management":"'.$pandora_management.'"}';
' Network map view: ' . $map_view .
' Network map edit: ' . $map_edit .
' Network map management: ' . $map_management .
' Visual console view: ' . $vconsole_view .
' Visual console edit: ' . $vconsole_edit .
' Visual console management: ' . $vconsole_management .
' Pandora Management: ' . $pandora_management;
db_pandora_audit("User management", db_pandora_audit("User management",
"Update profile ". $name, false, false, $info); "Update profile ". $name, false, false, $info);
@ -239,41 +229,30 @@ if ($create_profile) {
if ($ret !== false) { if ($ret !== false) {
ui_print_success_message(__('Successfully created')); ui_print_success_message(__('Successfully created'));
$info = '{"Name":"'.$incident_view.'",
$info = 'Name: ' . $name . "Incident view":"'.$incident_view.'",
"Incident edit":"'.$incident_edit.'",
' Incident view: ' . $incident_view . "Incident management":"'.$incident_management.'",
' Incident edit: ' . $incident_edit . "Agent view":"'.$agent_view.'",
' Incident management: ' . $incident_management . "Agent edit":"'.$agent_edit.'",
"Agent disable":"'.$agent_disable.'",
' Agent view: ' . $agent_view . "Alert edit":"'.$alert_edit.'",
' Agent edit: ' . $agent_edit . "Alert management":"'.$alert_management.'",
' Agent disable: ' . $agent_disable . "User management":"'.$user_management.'",
"DB management":"'.$db_management.'",
' Alert edit: ' . $alert_edit . "Event view":"'.$event_view.'",
' Alert management: ' . $alert_management . "Event edit":"'.$event_edit.'",
"Event management":"'.$event_management.'",
' User management: ' . $user_management . "Report view":"'.$report_view.'",
"Report edit":"'.$report_edit.'",
' DB management: ' . $db_management . "Report management":"'.$report_management.'",
"Network map view":"'.$map_view.'",
' Event view: ' . $event_view . "Network map edit":"'.$map_edit.'",
' Event edit: ' . $event_edit . "Network map management":"'.$map_management.'",
' Event management: ' . $event_management . "Visual console view":"'.$vconsole_view.'",
"Visual console edit":"'.$vconsole_edit.'",
' Report view: ' . $report_view . "Visual console management":"'.$vconsole_management.'",
' Report edit: ' . $report_edit . "Pandora Management":"'.$pandora_management.'"}';
' Report management: ' . $report_management .
' Network map view: ' . $map_view .
' Network map edit: ' . $map_edit .
' Network map management: ' . $map_management .
' Visual console view: ' . $vconsole_view .
' Visual console edit: ' . $vconsole_edit .
' Visual console management: ' . $vconsole_management .
' Pandora Management: ' . $pandora_management;
db_pandora_audit("User management", db_pandora_audit("User management",
"Created profile ". $name, false, false, $info); "Created profile ". $name, false, false, $info);

View File

@ -114,9 +114,17 @@ class Tree {
$agents_normal_count = "($agent_table $agents_normal_count = "($agent_table
$agent_normal_filter) AS total_normal_count"; $agent_normal_filter) AS total_normal_count";
// Not init // Not init
if($this->filter['show_not_init_agents']){
$agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT); $agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT);
$agents_not_init_count = "($agent_table $agents_not_init_count = "($agent_table
$agent_not_init_filter) AS total_not_init_count"; $agent_not_init_filter) AS total_not_init_count";
}
else{
$agent_not_init_filter = 0;
$agents_not_init_count = 0;
}
// Alerts fired // Alerts fired
$agents_fired_count = "($agent_table $agents_fired_count = "($agent_table
AND ta.fired_count > 0) AS total_fired_count"; AND ta.fired_count > 0) AS total_fired_count";
@ -287,13 +295,19 @@ class Tree {
// Modules join // Modules join
$modules_join = ""; $modules_join = "";
$module_status_join = ""; $module_status_join = "";
if (!empty($module_search_filter) || !empty($module_status_filter)) { if (!empty($module_search_filter) || !empty($module_status_filter) || !$this->filter['show_not_init_agents']) {
if (!empty($module_status_filter)) { if (!empty($module_status_filter) || !$this->filter['show_not_init_agents']) {
$module_status_join = "INNER JOIN tagente_estado tae $module_status_join = "INNER JOIN tagente_estado tae
ON tam.id_agente_modulo IS NOT NULL ON tam.id_agente_modulo IS NOT NULL
AND tam.id_agente_modulo = tae.id_agente_modulo AND tam.id_agente_modulo = tae.id_agente_modulo
$module_status_filter"; $module_status_filter";
if(!$this->filter['show_not_init_modules'] || ($this->filter['show_not_init_modules'] && !$this->filter['show_not_init_agents'])){
if($type != 'agent' || ($type == 'agent' && !$this->filter['show_not_init_modules'] && !$this->filter['show_not_init_agents'])){
$module_status_join .= ' AND tae.estado <> '.AGENT_MODULE_STATUS_NO_DATA.' AND tae.estado <> '.AGENT_MODULE_STATUS_NOT_INIT.' ';
}
}
} }
$modules_join = "INNER JOIN tagente_modulo tam $modules_join = "INNER JOIN tagente_modulo tam
@ -304,8 +318,22 @@ class Tree {
} }
if (empty($module_status_join)) { if (empty($module_status_join)) {
$module_status_join = "LEFT JOIN tagente_estado tae if(!$this->filter['show_not_init_modules'] || !$this->filter['show_not_init_agents']){
ON tam.id_agente_modulo = tae.id_agente_modulo"; if($type == "agent"){
$module_status_join = 'INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo ';
}
else{
$module_status_join = 'LEFT JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo ';
}
$module_status_join .= ' AND 1=1 AND tae.estado <> '.AGENT_MODULE_STATUS_NO_DATA.' AND tae.estado <> '.AGENT_MODULE_STATUS_NOT_INIT.' ';
}
else{
$module_status_join = 'LEFT JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo ';
}
} }
$sql = false; $sql = false;
@ -407,7 +435,7 @@ class Tree {
else { else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente)) $agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente ta FROM tagente ta
INNER JOIN tagente_modulo tam LEFT JOIN tagente_modulo tam
ON tam.disabled = 0 ON tam.disabled = 0
AND ta.id_agente = tam.id_agente AND ta.id_agente = tam.id_agente
$module_search_filter $module_search_filter
@ -1147,6 +1175,23 @@ class Tree {
if (empty($data)) if (empty($data))
return array(); return array();
foreach ($data[0] as $key => $value) {
if($key != 'total_count' && strpos($key, 'count')){
$zero_counter += $value;
}
}
if(!$zero_counter){
$data[0]['total_count'] = 0;
}
else{
$data[0]['total_count'] = $zero_counter;
}
// [26/10/2017] It seems the module hierarchy should be only available into the tree by group // [26/10/2017] It seems the module hierarchy should be only available into the tree by group
if ($this->rootType == 'group' && $this->type == 'agent') { if ($this->rootType == 'group' && $this->type == 'agent') {
$data = $this->getProcessedModules($data); $data = $this->getProcessedModules($data);
@ -1161,7 +1206,6 @@ class Tree {
if (!empty($counters)) { if (!empty($counters)) {
$counters = array_pop($counters); $counters = array_pop($counters);
} }
return $counters; return $counters;
} }
@ -2046,6 +2090,18 @@ class Tree {
$items = $this->getItems(); $items = $this->getItems();
$this->processModules($items); $this->processModules($items);
$processed_items = $items; $processed_items = $items;
if(!$this->filter['show_not_init_modules']){
foreach ($items as $key => $value) {
if($items[$key]['total_count'] != $items[$key]['notinit_count']){
$items[$key]['total_count'] = $items[$key]['total_count'] - $items[$key]['notinit_count'];
$items[$key]['notinit_count'] = 0;
}
}
}
} }
else { else {
$items = array(); $items = array();
@ -2261,6 +2317,28 @@ class Tree {
// Agents // Agents
else { else {
$items = $this->getItems(); $items = $this->getItems();
if(!$this->filter['show_not_init_modules']){
foreach ($items as $key => $value) {
$items[$key]['total_count'] = $items[$key]['total_count'] - $items[$key]['notinit_count'];
$items[$key]['notinit_count'] = 0;
}
}
if(!$this->filter['show_not_init_agents']){
foreach ($items as $key => $value) {
if($items[$key]['total_count'] == $items[$key]['notinit_count']){
unset($items[$key]);
}
}
}
$this->processAgents($items); $this->processAgents($items);
$processed_items = $items; $processed_items = $items;
} }
@ -2733,7 +2811,12 @@ class Tree {
$group_stats[$group['id_group']]['total_critical_count'] = $group['critical']; $group_stats[$group['id_group']]['total_critical_count'] = $group['critical'];
$group_stats[$group['id_group']]['total_unknown_count'] = $group['unknown']; $group_stats[$group['id_group']]['total_unknown_count'] = $group['unknown'];
$group_stats[$group['id_group']]['total_warning_count'] = $group['warning']; $group_stats[$group['id_group']]['total_warning_count'] = $group['warning'];
if($this->filter['show_not_init_modules']){
$group_stats[$group['id_group']]['total_not_init_count'] = $group['non-init']; $group_stats[$group['id_group']]['total_not_init_count'] = $group['non-init'];
}
else{
$group_stats[$group['id_group']]['total_not_init_count'] = 0;
}
$group_stats[$group['id_group']]['total_normal_count'] = $group['normal']; $group_stats[$group['id_group']]['total_normal_count'] = $group['normal'];
$group_stats[$group['id_group']]['total_fired_count'] = $group['alerts_fired']; $group_stats[$group['id_group']]['total_fired_count'] = $group['alerts_fired'];
} }

View File

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

View File

@ -1354,7 +1354,11 @@ function agents_get_name ($id_agent, $case = "none") {
* @return string Alias of the given agent. * @return string Alias of the given agent.
*/ */
function agents_get_alias ($id_agent, $case = 'none') { function agents_get_alias ($id_agent, $case = 'none') {
if(is_metaconsole()){
$alias = (string) db_get_value ('alias', 'tmetaconsole_agent', 'id_tagente', (int) $id_agent);
} else {
$alias = (string) db_get_value ('alias', 'tagente', 'id_agente', (int) $id_agent); $alias = (string) db_get_value ('alias', 'tagente', 'id_agente', (int) $id_agent);
}
switch ($case) { switch ($case) {
case 'upper': case 'upper':

View File

@ -34,7 +34,6 @@ enterprise_include_once ('include/functions_local_components.php');
enterprise_include_once ('include/functions_events.php'); enterprise_include_once ('include/functions_events.php');
enterprise_include_once ('include/functions_agents.php'); enterprise_include_once ('include/functions_agents.php');
enterprise_include_once ('include/functions_modules.php'); enterprise_include_once ('include/functions_modules.php');
enterprise_include_once ('include/functions_collection.php');
/** /**
* Parse the "other" parameter. * Parse the "other" parameter.
@ -10472,4 +10471,147 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
} }
function api_set_apply_module_template($id_template, $id_agent, $thrash3, $thrash4) {
if (isset ($id_template)) {
// Take agent data
$row = db_get_row ("tagente", "id_agente", $id_agent);
if ($row !== false) {
$intervalo = $row["intervalo"];
$nombre_agente = $row["nombre"];
$direccion_agente =$row["direccion"];
$ultima_act = $row["ultimo_contacto"];
$ultima_act_remota =$row["ultimo_contacto_remoto"];
$comentarios = $row["comentarios"];
$id_grupo = $row["id_grupo"];
$id_os= $row["id_os"];
$os_version = $row["os_version"];
$agent_version = $row["agent_version"];
$disabled= $row["disabled"];
}
else {
return;
}
$id_np = $id_template;
$name_template = db_get_value ('name', 'tnetwork_profile', 'id_np', $id_np);
$npc = db_get_all_rows_field_filter ("tnetwork_profile_component", "id_np", $id_np);
if ($npc === false) {
$npc = array ();
}
$success_count = $error_count = 0;
$modules_already_added = array();
foreach ($npc as $row) {
$nc = db_get_all_rows_field_filter ("tnetwork_component", "id_nc", $row["id_nc"]);
if ($nc === false) {
$nc = array ();
}
foreach ($nc as $row2) {
// Insert each module from tnetwork_component into agent
$values = array(
'id_agente' => $id_agent,
'id_tipo_modulo' => $row2["type"],
'descripcion' => __('Created by template ').$name_template. ' . '.$row2["description"],
'max' => $row2["max"],
'min' => $row2["min"],
'module_interval' => $row2["module_interval"],
'tcp_port' => $row2["tcp_port"],
'tcp_send' => $row2["tcp_send"],
'tcp_rcv' => $row2["tcp_rcv"],
'snmp_community' => $row2["snmp_community"],
'snmp_oid' => $row2["snmp_oid"],
'ip_target' => $direccion_agente,
'id_module_group' => $row2["id_module_group"],
'id_modulo' => $row2["id_modulo"],
'plugin_user' => $row2["plugin_user"],
'plugin_pass' => $row2["plugin_pass"],
'plugin_parameter' => $row2["plugin_parameter"],
'unit' => $row2["unit"],
'max_timeout' => $row2["max_timeout"],
'max_retries' => $row2["max_retries"],
'id_plugin' => $row2['id_plugin'],
'post_process' => $row2['post_process'],
'dynamic_interval' => $row2['dynamic_interval'],
'dynamic_max' => $row2['dynamic_max'],
'dynamic_min' => $row2['dynamic_min'],
'dynamic_two_tailed' => $row2['dynamic_two_tailed'],
'min_warning' => $row2['min_warning'],
'max_warning' => $row2['max_warning'],
'str_warning' => $row2['str_warning'],
'min_critical' => $row2['min_critical'],
'max_critical' => $row2['max_critical'],
'str_critical' => $row2['str_critical'],
'critical_inverse' => $row2['critical_inverse'],
'warning_inverse' => $row2['warning_inverse'],
'critical_instructions' => $row2['critical_instructions'],
'warning_instructions' => $row2['warning_instructions'],
'unknown_instructions' => $row2['unknown_instructions'],
'id_category' => $row2['id_category'],
'macros' => $row2['macros'],
'each_ff' => $row2['each_ff'],
'min_ff_event' => $row2['min_ff_event'],
'min_ff_event_normal' => $row2['min_ff_event_normal'],
'min_ff_event_warning' => $row2['min_ff_event_warning'],
'min_ff_event_critical' => $row2['min_ff_event_critical']
);
$name = $row2["name"];
// Put tags in array if the component has to add them later
if(!empty($row2["tags"])) {
$tags = explode(',', $row2["tags"]);
}
else {
$tags = array();
}
// Check if this module exists in the agent
$module_name_check = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('delete_pending' => 0, 'nombre' => $name, 'id_agente' => $id_agent));
if ($module_name_check !== false) {
$modules_already_added[] = $row2["name"];
$error_count++;
}
else {
$id_agente_modulo = modules_create_agent_module($id_agent, $name, $values);
if ($id_agente_modulo === false) {
$error_count++;
}
else {
if(!empty($tags)) {
// Creating tags
$tag_ids = array();
foreach ($tags as $tag_name) {
$tag_id = tags_get_id($tag_name);
//If tag exists in the system we store to create it
$tag_ids[] = $tag_id;
}
tags_insert_module_tag ($id_agente_modulo, $tag_ids);
}
$success_count++;
}
}
}
}
if ($error_count > 0) {
if (empty($modules_already_added))
ui_print_error_message(__('Error adding modules') . sprintf(' (%s)', $error_count));
else
ui_print_error_message(__('Error adding modules. The following errors already exists: ') . implode(', ', $modules_already_added));
}
if ($success_count > 0)
ui_print_success_message(__('Modules successfully added'));
}
}
?> ?>

View File

@ -2042,9 +2042,17 @@ function events_page_custom_fields ($event) {
$data = array(); $data = array();
$data[0] = $field['name']; $data[0] = $field['name'];
$data[1] = empty($fields_data[$field['id_field']]) if(empty($fields_data[$field['id_field']])){
? '<i>'.__('N/A').'</i>' $data[1] = '<i>'.__('N/A').'</i>';
: ui_bbcode_to_html($fields_data[$field['id_field']]); }
else{
if($field['is_password_type']){
$data[1] = '&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;';
}
else{
$data[1] = ui_bbcode_to_html($fields_data[$field['id_field']]);
}
}
$field['id_field']; $field['id_field'];

View File

@ -1967,7 +1967,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
} }
foreach ($module_list as $key => $value) { foreach ($module_list as $key => $value) {
if (is_metaconsole()) { if (is_metaconsole() && is_array($value)) {
$server = metaconsole_get_connection_by_id ($value['server']); $server = metaconsole_get_connection_by_id ($value['server']);
metaconsole_connect($server); metaconsole_connect($server);
$value = $value['module']; $value = $value['module'];
@ -1987,14 +1987,14 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$module_name_list[$key] = $alias . " / " . $module_name; $module_name_list[$key] = $alias . " / " . $module_name;
} }
} }
if (is_metaconsole()) { if (is_metaconsole() && is_array($value)) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
} }
if (!is_null($percentil) && $percentil) { if (!is_null($percentil) && $percentil) {
foreach ($module_list as $key => $value) { foreach ($module_list as $key => $value) {
if (is_metaconsole()) { if (is_metaconsole() && is_array($value)) {
$server = metaconsole_get_connection_by_id ($value['server']); $server = metaconsole_get_connection_by_id ($value['server']);
metaconsole_connect($server); metaconsole_connect($server);
$value = $value['module']; $value = $value['module'];
@ -2004,7 +2004,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$alias = db_get_value ("alias","tagente","nombre",$agent_name); $alias = db_get_value ("alias","tagente","nombre",$agent_name);
$module_name = io_safe_output( modules_get_agentmodule_name ($value) ); $module_name = io_safe_output( modules_get_agentmodule_name ($value) );
if (is_metaconsole()) { if (is_metaconsole() && is_array($value)) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -2413,7 +2413,7 @@ function fullscale_data_combined($module_list, $period, $date, $flash_charts, $p
$array_percentil = array(); $array_percentil = array();
} }
if (is_metaconsole()) { if (is_metaconsole() && is_array($value_module)) {
$server = metaconsole_get_connection_by_id ($value_module['server']); $server = metaconsole_get_connection_by_id ($value_module['server']);
metaconsole_connect($server); metaconsole_connect($server);
$previous_data = modules_get_previous_data ($value_module['module'], $datelimit); $previous_data = modules_get_previous_data ($value_module['module'], $datelimit);
@ -2428,7 +2428,6 @@ function fullscale_data_combined($module_list, $period, $date, $flash_charts, $p
foreach ($data_uncompress as $key_data => $value_data) { foreach ($data_uncompress as $key_data => $value_data) {
foreach ($value_data['data'] as $k => $v) { foreach ($value_data['data'] as $k => $v) {
$real_date = $v['utimestamp']; $real_date = $v['utimestamp'];
if(!isset($v['datos'])){ if(!isset($v['datos'])){
$v['datos'] = $previous_data; $v['datos'] = $previous_data;
} }

View File

@ -1087,20 +1087,13 @@ function modules_get_agentmodule_descripcion ($id_agente_modulo) {
* *
* @return string Module type of the given agent module. * @return string Module type of the given agent module.
*/ */
function modules_get_agentmodule_type ($id_agentmodule, $metaconsole = false, $id_server = null) { function modules_get_agentmodule_type ($id_agentmodule) {
$return = db_get_value (
if ($metaconsole) { 'id_tipo_modulo',
$server = db_get_row('tmetaconsole_setup', 'id', $id_server); 'tagente_modulo',
'id_agente_modulo',
$return = db_get_value ('id_tipo_modulo', (int) $id_agentmodule
'tagente_modulo', 'id_agente_modulo', (int) $id_agentmodule); );
metaconsole_restore_db();
}
else {
$return = db_get_value ('id_tipo_modulo',
'tagente_modulo', 'id_agente_modulo', (int) $id_agentmodule);
}
return (int) $return; return (int) $return;
} }
@ -2321,7 +2314,7 @@ function modules_get_first_date($id_agent_module, $datelimit = 0) {
//check datatype string or normal //check datatype string or normal
$table = "tagente_datos"; $table = "tagente_datos";
$module_type_str = modules_get_type_name ($id_agent_module); $module_type_str = modules_get_agentmodule_type($id_agent_module);
if (strstr ($module_type_str, 'string') !== false) { if (strstr ($module_type_str, 'string') !== false) {
$table = "tagente_datos_string"; $table = "tagente_datos_string";
} }

View File

@ -39,7 +39,7 @@ function networkmap_process_networkmap($id = 0) {
$numNodes = (int)db_get_num_rows(' $numNodes = (int)db_get_num_rows('
SELECT * SELECT *
FROM titem FROM titem
WHERE id_map = ' . $id . ';'); WHERE id_map = ' . $id . ' and deleted = 0');
$networkmap = db_get_row_filter('tmap', $networkmap = db_get_row_filter('tmap',
array('id' => $id)); array('id' => $id));
@ -836,6 +836,11 @@ function networkmap_links_to_js_links($relations, $nodes_graph) {
$item['source'] = $node['id']; $item['source'] = $node['id'];
} }
} }
if (($item['target'] == -1) && ($item['source'] == -1) && $relation['parent_type'] == 1 && $relation['child_type'] == 1) {
continue;
}
$return[] = $item; $return[] = $item;
} }
return $return; return $return;

View File

@ -2721,26 +2721,48 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic
$filter = array( $filter = array(
'id_grupo' => $content['id_group'], 'id_grupo' => $content['id_group'],
'disabled' => 0); 'disabled' => 0);
$network_interfaces_by_agents = agents_get_network_interfaces(false, $filter);
$return['failed'] = null;
$return['data'] = array();
if ($config['metaconsole']) {
$server_names = metaconsole_get_connection_names();
if(isset($server_names) && is_array($server_names)){
foreach ($server_names as $key => $value) {
$id_meta = metaconsole_get_id_server($value);
$connection = metaconsole_get_connection_by_id ($id_meta);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
else{
$network_interfaces_by_agents = agents_get_network_interfaces(false, $filter);
$return = agents_get_network_interfaces_array($network_interfaces_by_agents, $return, $type, $content, $report, $fullscale);
metaconsole_restore_db();
}
}
}
}
else{
$network_interfaces_by_agents = agents_get_network_interfaces(false, $filter);
$return = agents_get_network_interfaces_array($network_interfaces_by_agents, $return, $type, $content, $report, $fullscale);
}
return reporting_check_structure_content($return);
}
function agents_get_network_interfaces_array($network_interfaces_by_agents, $return, $type, $content, $report, $fullscale){
if (empty($network_interfaces_by_agents)) { if (empty($network_interfaces_by_agents)) {
$return['failed'] = $return['failed'] =
__('The group has no agents or none of the agents has any network interface'); __('The group has no agents or none of the agents has any network interface');
$return['data'] = array(); $return['data'] = array();
} }
else { else {
$return['failed'] = null;
$return['data'] = array();
foreach ($network_interfaces_by_agents as $agent_id => $agent) { foreach ($network_interfaces_by_agents as $agent_id => $agent) {
$row_data = array(); $row_data = array();
$row_data['agent'] = $agent['name']; $row_data['agent'] = $agent['name'];
$row_data['interfaces'] = array(); $row_data['interfaces'] = array();
foreach ($agent['interfaces'] as $interface_name => $interface) { foreach ($agent['interfaces'] as $interface_name => $interface) {
$row_interface = array(); $row_interface = array();
$row_interface['name'] = $interface_name; $row_interface['name'] = $interface_name;
$row_interface['ip'] = $interface['ip']; $row_interface['ip'] = $interface['ip'];
$row_interface['mac'] = $interface['mac']; $row_interface['mac'] = $interface['mac'];
@ -2818,14 +2840,12 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic
} }
break; break;
} }
$row_data['interfaces'][] = $row_interface; $row_data['interfaces'][] = $row_interface;
} }
$return['data'][] = $row_data; $return['data'][] = $row_data;
} }
} }
return reporting_check_structure_content($return); return $return;
} }
/** /**

View File

@ -383,7 +383,7 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
else { else {
$snmptranslate_bin = $config['snmptranslate']; $snmptranslate_bin = $config['snmptranslate'];
} }
exec ($snmptranslate_bin . " -Td " . escapeshellarg($oid), exec ($snmptranslate_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . " -Td " . escapeshellarg($oid),
$translate_output); $translate_output);
foreach ($translate_output as $line) { foreach ($translate_output as $line) {
if (preg_match ('/SYNTAX\s+(.*)/', $line, $matches) == 1) { if (preg_match ('/SYNTAX\s+(.*)/', $line, $matches) == 1) {
@ -400,11 +400,16 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
} }
} }
// Parse the description // Parse the description. First search for it in custom values
$custom_data = db_get_row('ttrap_custom_values', 'oid', $oid);
if ($custom_data === false) {
$translate_output = implode ('', $translate_output); $translate_output = implode ('', $translate_output);
if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) { if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) {
$oid_data['description'] = $matches[1]; $oid_data['description'] = $matches[1];
} }
} else {
$oid_data['description'] = $custom_data['description'];
}
$full_value = explode (':', trim ($full_oid[1])); $full_value = explode (':', trim ($full_oid[1]));
if (! isset ($full_value[1])) { if (! isset ($full_value[1])) {
@ -487,21 +492,21 @@ function snmp_browser_print_oid ($oid = array(), $custom_action = '',
$closer .= html_print_image ("images/blade.png", true, array ("title" => __('Close'), "style" => 'vertical-align: middle;'), false); $closer .= html_print_image ("images/blade.png", true, array ("title" => __('Close'), "style" => 'vertical-align: middle;'), false);
$closer .= '</a>'; $closer .= '</a>';
$table->head[0] = $closer;
$table->head[1] = __('OID Information');
// Add a span for custom actions // Add a span for custom actions
if ($custom_action != '') { if ($custom_action != '') {
$output .= '<span id="snmp_custom_action">' . $closer . $custom_action . '</span>'; $table->head[0] = '<span id="snmp_custom_action">' . $closer . $custom_action . '</span>';
} else {
$table->head[0] = $closer;
} }
$table->head[1] = __('OID Information');
$output .= html_print_table($table, true); $output .= html_print_table($table, true);
$url = "index.php?" . $url = "index.php?" .
"sec=gmodules&" . "sec=gmodules&" .
"sec2=godmode/modules/manage_network_components"; "sec2=godmode/modules/manage_network_components";
$output .= '<form style="text-align: center;" method="post" action="' . $url . '">'; $output .= '<form style="text-align: center; margin: 10px" method="post" action="' . $url . '">';
$output .= html_print_input_hidden('create_network_from_snmp_browser', 1, true); $output .= html_print_input_hidden('create_network_from_snmp_browser', 1, true);
$output .= html_print_input_hidden('id_component_type', 2, true); $output .= html_print_input_hidden('id_component_type', 2, true);
$output .= html_print_input_hidden('type', 17, true); $output .= html_print_input_hidden('type', 17, true);
@ -519,7 +524,7 @@ function snmp_browser_print_oid ($oid = array(), $custom_action = '',
$output .= html_print_input_hidden('snmp_community', $community, true); $output .= html_print_input_hidden('snmp_community', $community, true);
$output .= html_print_input_hidden('snmp_version', $snmp_version, true); $output .= html_print_input_hidden('snmp_version', $snmp_version, true);
$output .= html_print_submit_button(__('Create network component'), $output .= html_print_submit_button(__('Create network component'),
'', false, '', true); '', false, 'class="sub add"', true);
$output .= '</form>'; $output .= '</form>';
if ($return) { if ($return) {
@ -672,7 +677,7 @@ function snmp_browser_print_container ($return = false, $width = '100%', $height
$output .= '<div id="search_results" style="display: none; padding: 5px; background-color: #EAEAEA; border: 1px solid #E2E2E2; border-radius: 4px;"></div>'; $output .= '<div id="search_results" style="display: none; padding: 5px; background-color: #EAEAEA; border: 1px solid #E2E2E2; border-radius: 4px;"></div>';
$output .= '<div id="spinner" style="position: absolute; top:0; left:0px; display:none; padding: 5px;">' . html_print_image ("images/spinner.gif", true) . '</div>'; $output .= '<div id="spinner" style="position: absolute; top:0; left:0px; display:none; padding: 5px;">' . html_print_image ("images/spinner.gif", true) . '</div>';
$output .= '<div id="snmp_browser" style="height: 100%; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>'; $output .= '<div id="snmp_browser" style="height: 100%; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>';
$output .= '<div id="snmp_data" style="margin: 5px;"></div>'; $output .= '<div class="databox" id="snmp_data" style="margin: 5px;"></div>';
$output .= '</div>'; $output .= '</div>';
$output .= '</div>'; $output .= '</div>';
$output .= '</div>'; $output .= '</div>';

View File

@ -695,7 +695,13 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
if (!empty($custom_value)) { if (!empty($custom_value)) {
$row = array(); $row = array();
$row['title'] = $field['name'] . ui_print_help_tip (__('Custom field'), true); $row['title'] = $field['name'] . ui_print_help_tip (__('Custom field'), true);
if($field['is_password_type']){
$row['data'] = '&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;';
}
else{
$row['data'] = ui_bbcode_to_html($custom_value); $row['data'] = ui_bbcode_to_html($custom_value);
}
$table->data['custom_field_'.$field['id_field']] = $row; $table->data['custom_field_'.$field['id_field']] = $row;
} }
} }

View File

@ -962,8 +962,14 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f
if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM")) { if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM")) {
$data[$index['validate']] = ''; $data[$index['validate']] = '';
$data[$index['validate']] .= html_print_checkbox (
$data[$index['validate']] .= html_print_checkbox ("validate[]", $alert["id"], false, true); "validate[]",
$alert["id"],
false,
true,
false,
'',
true);
} }
} }

View File

@ -735,7 +735,17 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
'icon', 'label', 'datos'); 'icon', 'label', 'datos');
$form_items_advance['element_group_row']['html'] = '<td align="left">'. $form_items_advance['element_group_row']['html'] = '<td align="left">'.
__('Restrict access to group') . '</td>' . __('Restrict access to group') . '</td>' .
'<td align="left">' . html_print_select($user_groups, 'element_group', '', '', '', 0, true) . '<td align="left">' .
html_print_select_groups(
$config['id_user'],
"VR",
true,
'element_group',
__('All'),
'',
'',
0,
true) .
ui_print_help_tip ( ui_print_help_tip (
__("If selected, restrict visualization of this item in the visual console to users who have access to selected group. This is also used on calculating child visual consoles."), true) . __("If selected, restrict visualization of this item in the visual console to users who have access to selected group. This is also used on calculating child visual consoles."), true) .
'</td>'; '</td>';

View File

@ -653,13 +653,13 @@ function hbar_graph($flash_chart, $chart_data, $width, $height,
else { else {
foreach ($chart_data as $key => $value) { foreach ($chart_data as $key => $value) {
if(strlen($key) > 40){ $str_key = io_safe_output($key);
if(strpos($key, ' - ') != -1){ if(strlen($str_key) > 40){
$key_temp = explode(" - ",$key); if(strpos($str_key, ' - ') != -1){
$key_temp[0] = $key_temp[0]." \n"; $key_temp = explode(" - ",$str_key);
$key_temp[0] = $key_temp[0]." <br>";
$key_temp[1]= '...'.substr($key_temp[1],-20); $key_temp[1]= '...'.substr($key_temp[1],-20);
$key2 = $key_temp[0].$key_temp[1]; $key2 = $key_temp[0].$key_temp[1];
io_safe_output($key2);
} }
$chart_data[$key2]['g'] = $chart_data[$key]['g']; $chart_data[$key2]['g'] = $chart_data[$key]['g'];
unset($chart_data[$key]); unset($chart_data[$key]);

View File

@ -419,28 +419,22 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark,
for (i = 0; i < labels_total.length; i++) { for (i = 0; i < labels_total.length; i++) {
var label = labels_total[i][1]; var label = labels_total[i][1];
// var shortLabel = reduceText(label, 25); // var shortLabel = reduceText(label, 25);
var title = ''; var title = label;
// if (label !== shortLabel) { var margin_top = 0;
title = label;
// label = shortLabel;
// }
if(label.length > 30){ if(label.length > 30){
if(label.indexOf(" - ")){ label = reduceText(label, 30);
var label_temp = label.split(" - ");
} }
else if(label.indexOf(" ")){ var div_attributes = 'style="font-size:'+font_size+'pt !important;'
var label_temp = label.split(" "); + ' margin: 0; max-width: 150px;'
} + 'margin-right:5px;';
else{
var label_temp = ''; if (label.indexOf("<br>") != -1) {
label_temp[0] = label.substring(0, (label.length/2)); div_attributes += "min-height: 2.5em;";
label_temp[1] = label.substring((label.length/2));
}
label = reduceText(label_temp[0], 20)+"<br>"+reduceText(label_temp[1], 20);
} }
format.push([i,'<div style="font-size:'+font_size+'pt !important; word-break:keep-all; max-width: 150px;margin-right:20px;" title="'+title+'" class="'+font+'">' div_attributes += '" title="'+title+'" class="'+font+'" '+ ' style="overflow: hidden;"';
format.push([i,'<div ' + div_attributes + '>'
+ label + label
+ '</div>']); + '</div>']);
} }
@ -669,7 +663,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
} }
format.push([i, format.push([i,
'<div class="'+font+'" title="'+title+'" style="word-break: normal; transform: rotate(-45deg); position:relative; top:+30px; left:0px; max-width: 100px;font-size:'+font_size+'pt !important;">' '<div class="'+font+'" title="'+title+'" style="word-break: normal; overflow:hidden; transform: rotate(-45deg); position:relative; top:+30px; left:0px; max-width: 100px;font-size:'+font_size+'pt !important;">'
+ label + label
+ '</div>']); + '</div>']);
} }
@ -2325,8 +2319,9 @@ function add_threshold (data_base, threshold_data, y_min, y_max,
} }
function reduceText (text, maxLength) { function reduceText (text, maxLength) {
if(!text) return text;
if (text.length <= maxLength) return text if (text.length <= maxLength) return text
var firstSlideEnd = parseInt((maxLength - 3) / 2); var firstSlideEnd = parseInt((maxLength - 3)/1.6);
var str_cut = text.substr(0, firstSlideEnd); var str_cut = text.substr(0, firstSlideEnd);
return str_cut + '...' + text.substr(-firstSlideEnd - 3); return str_cut + '...<br>' + text.substr(-firstSlideEnd - 3);
} }

View File

@ -712,7 +712,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font =
$data = array(); $data = array();
foreach ($graph_data as $label => $values) { foreach ($graph_data as $label => $values) {
$labels[] = $label; $labels[] = io_safe_output($label);
$i--; $i--;
foreach ($values as $key => $value) { foreach ($values as $key => $value) {

View File

@ -522,7 +522,7 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
if ($legend_position != 'hidden') { if ($legend_position != 'hidden') {
// This is a hardcore adjustment to match most of the graphs, please don't alter // This is a hardcore adjustment to match most of the graphs, please don't alter
$legend_with_aprox = 32 + (4.5 * $max_chars); $legend_with_aprox = 32 + (9.5 * $max_chars);
$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10)); $PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
} }

View File

@ -2334,7 +2334,7 @@ var digitPattern = [
digit.select("path:nth-child(5)").classed("lit", function(d) { return digitPattern[4][d]; }); digit.select("path:nth-child(5)").classed("lit", function(d) { return digitPattern[4][d]; });
digit.select("path:nth-child(6)").classed("lit", function(d) { return digitPattern[5][d]; }); digit.select("path:nth-child(6)").classed("lit", function(d) { return digitPattern[5][d]; });
digit.select("path:nth-child(7)").classed("lit", function(d) { return digitPattern[6][d]; }); digit.select("path:nth-child(7)").classed("lit", function(d) { return digitPattern[6][d]; });
separator.classed("lit", seconds & 1); separator.classed("lit", 1);
setTimeout(tick, 1000 - now % 1000); setTimeout(tick, 1000 - now % 1000);
})(); })();

View File

@ -945,9 +945,9 @@ function load_interfaces(selected_links) {
}); });
$("#relations_table-template_row-node_source", template_relation_row) $("#relations_table-template_row-node_source", template_relation_row)
.html(link_each.source['raw_text']); .html(link_each.source['raw_text'] != 'undefined' ? link_each.source['text'] : link_each.source['raw_text']);
$("#relations_table-template_row-node_target", template_relation_row) $("#relations_table-template_row-node_target", template_relation_row)
.html(link_each.target['raw_text']); .html(link_each.target['raw_text'] != 'undefined' ? link_each.target['text'] : link_each.target['raw_text']);
$("#relations_table-template_row-edit", template_relation_row) $("#relations_table-template_row-edit", template_relation_row)
.attr("align", "center"); .attr("align", "center");
$("#relations_table-template_row-edit .delete_icon", template_relation_row) $("#relations_table-template_row-edit .delete_icon", template_relation_row)

View File

@ -205,6 +205,7 @@ function hideOIDData() {
$("#snmp_data").empty(); $("#snmp_data").empty();
$("#snmp_data").css('display', 'none'); $("#snmp_data").css('display', 'none');
$(".forced_title_layer").css('display', 'none');
} }
// Search the SNMP tree for a matching string // Search the SNMP tree for a matching string

View File

@ -37,6 +37,7 @@ var TreeController = {
// Load branch // Load branch
function _processGroup (container, elements, rootGroup) { function _processGroup (container, elements, rootGroup) {
var $group = $("<ul></ul>"); var $group = $("<ul></ul>");
// First group // First group
@ -157,7 +158,8 @@ var TreeController = {
$counters.addClass('tree-node-counters'); $counters.addClass('tree-node-counters');
if (typeof counters.total != 'undefined' if (typeof counters.total != 'undefined'
&& counters.total > 0) { && counters.total >= 0) {
var $totalCounter = $("<div></div>"); var $totalCounter = $("<div></div>");
$totalCounter $totalCounter
.addClass('tree-node-counter') .addClass('tree-node-counter')

View File

@ -4620,3 +4620,16 @@ form ul.form_flex li ul li{
.events_bar { .events_bar {
margin:0 auto; margin:0 auto;
} }
#snmp_data {
background: #f9faf9;
}
#snmp_data .databox {
border: 0px;
}
.tickLabel {
white-space: nowrap;
line-height: 1.05em!important;
}

View File

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

View File

@ -78,19 +78,22 @@ else {
$data[1] = html_print_image('images/delete.png', true); $data[1] = html_print_image('images/delete.png', true);
} }
$custom_value = db_get_value_filter('description', $custom_value = db_get_all_rows_sql("select tagent_custom_data.description,tagent_custom_fields.is_password_type from tagent_custom_fields
'tagent_custom_data', array( INNER JOIN tagent_custom_data ON tagent_custom_fields.id_field = tagent_custom_data.id_field where tagent_custom_fields.id_field = ".$field['id_field']." and tagent_custom_data.id_agent = ".$id_agente);
'id_field' => $field['id_field'],
'id_agent' => $id_agente));
if ($custom_value === false || $custom_value == '') { if ($custom_value[0]['description'] === false || $custom_value[0]['description'] == '') {
$custom_value = '<i>-'.__('empty').'-</i>'; $custom_value[0]['description'] = '<i>-'.__('empty').'-</i>';
} }
else { else {
$custom_value = ui_bbcode_to_html($custom_value); $custom_value[0]['description'] = ui_bbcode_to_html($custom_value[0]['description']);
} }
$data[2] = $custom_value; if($custom_value[0]['is_password_type']){
$data[2] = '&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;';
}
else{
$data[2] = $custom_value[0]['description'];
}
array_push ($table->data, $data); array_push ($table->data, $data);
} }

View File

@ -381,16 +381,23 @@ foreach ($fields as $field) {
$data = array(); $data = array();
$data[0] = '<b>' . $field['name'] . $data[0] = '<b>' . $field['name'] .
ui_print_help_tip (__('Custom field'), true) . '</b>'; ui_print_help_tip (__('Custom field'), true) . '</b>';
$custom_value = db_get_value_filter( $custom_value = db_get_all_rows_sql("select tagent_custom_data.description,tagent_custom_fields.is_password_type from tagent_custom_fields
'description', 'tagent_custom_data', INNER JOIN tagent_custom_data ON tagent_custom_fields.id_field = tagent_custom_data.id_field where tagent_custom_fields.id_field = ".$field['id_field']." and tagent_custom_data.id_agent = ".$id_agente);
array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if ($custom_value === false || $custom_value == '') { if ($custom_value[0]['description'] === false || $custom_value[0]['description'] == '') {
$custom_value = '<i>'.__('N/A').'</i>'; $custom_value[0]['description'] = '<i>-'.__('empty').'-</i>';
} }
else { else {
$custom_value = ui_bbcode_to_html($custom_value); $custom_value[0]['description'] = ui_bbcode_to_html($custom_value[0]['description']);
} }
$data[1] = $custom_value;
if($custom_value[0]['is_password_type']){
$data[1] = '&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;';
}
else{
$data[1] = $custom_value[0]['description'];
}
$table_data->data[] = $data; $table_data->data[] = $data;
} }

View File

@ -44,12 +44,16 @@ if (is_ajax ()) {
$get_agentmodule_status_tooltip = (bool) get_parameter ("get_agentmodule_status_tooltip"); $get_agentmodule_status_tooltip = (bool) get_parameter ("get_agentmodule_status_tooltip");
$get_group_status_tooltip = (bool) get_parameter ("get_group_status_tooltip"); $get_group_status_tooltip = (bool) get_parameter ("get_group_status_tooltip");
$get_agent_id = (bool) get_parameter ("get_agent_id"); $get_agent_id = (bool) get_parameter ("get_agent_id");
$cluster_mode = (bool) get_parameter ("cluster_mode",0);
$agent_alias = get_parameter('alias', '');
$agents_inserted = get_parameter('agents_inserted', array());
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
if ($get_agents_group_json) { if ($get_agents_group_json) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$recursion = get_parameter ('recursion'); $recursion = get_parameter ('recursion');
$id_os = get_parameter('id_os', ''); $id_os = get_parameter('id_os', '');
$agent_name = get_parameter('name', ''); $agent_name = get_parameter('name', '');
$privilege = (string) get_parameter ('privilege', "AR"); $privilege = (string) get_parameter ('privilege', "AR");
// Is is possible add keys prefix to avoid auto sorting in js object conversion // Is is possible add keys prefix to avoid auto sorting in js object conversion
$keys_prefix = (string) get_parameter ('keys_prefix', ''); $keys_prefix = (string) get_parameter ('keys_prefix', '');
@ -75,6 +79,8 @@ if (is_ajax ()) {
$filter['id_os'] = $id_os; $filter['id_os'] = $id_os;
if (!empty($agent_name)) if (!empty($agent_name))
$filter['nombre'] = '%' . $agent_name . '%'; $filter['nombre'] = '%' . $agent_name . '%';
if (!empty($agent_alias))
$filter['alias'] = '%' . $agent_alias . '%';
switch ($status_agents) { switch ($status_agents) {
case AGENT_STATUS_NORMAL: case AGENT_STATUS_NORMAL:
@ -98,6 +104,43 @@ if (is_ajax ()) {
} }
$filter['order'] = "alias ASC"; $filter['order'] = "alias ASC";
if($cluster_mode){
$agent_id_os = db_get_all_rows_sql('select id_os from tconfig_os where id_os != 100');
foreach ($agent_id_os as $key => $value) {
$agent_id_os_array[] = $agent_id_os[$key]['id_os'];
}
$filter['id_os'] = $agent_id_os_array;
if($agents_inserted[0] != ''){
$agents_id_list = '';
foreach($agents_inserted as $elem) {
if ($elem === end($agents_inserted)) {
$agents_id_list .= $elem;
}
else{
$agents_id_list .= $elem.',';
}
}
$agent_id_agente = db_get_all_rows_sql('select id_agente from tagente where id_agente not in ('.$agents_id_list.')');
foreach ($agent_id_agente as $key => $value) {
$agent_id_agente_array[] = $agent_id_agente[$key]['id_agente'];
}
$filter['id_agente'] = $agent_id_agente_array;
}
}
// Build fields // Build fields
$fields = array('id_agente', 'alias'); $fields = array('id_agente', 'alias');

View File

@ -275,7 +275,7 @@ if ($id_agent != 0) {
} }
$text_module = (string) get_parameter('module_search', ''); $text_module = (string) get_parameter('module_search', '');
$id_agent_module = get_parameter('module_search_hidden', 0); $id_agent_module = get_parameter('module_search_hidden', get_parameter('id_agent_module',0));
if ($id_agent_module != 0) { if ($id_agent_module != 0) {
$text_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); $text_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_agent_module);
if ($text_module == false) { if ($text_module == false) {

View File

@ -23,6 +23,8 @@ $search_agent = get_parameter('searchAgent', '');
$status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL); $status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL);
$search_module = get_parameter('searchModule', ''); $search_module = get_parameter('searchModule', '');
$status_module = get_parameter('statusModule', -1); $status_module = get_parameter('statusModule', -1);
$show_not_init_agents = get_parameter('show_not_init_agents', true);
$show_not_init_modules = get_parameter('show_not_init_modules', true);
$group_id = (int) get_parameter('group_id'); $group_id = (int) get_parameter('group_id');
$tag_id = (int) get_parameter('tag_id'); $tag_id = (int) get_parameter('tag_id');
$strict_acl = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']); $strict_acl = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
@ -127,9 +129,9 @@ $table->style[0] = 'font-weight: bold;';
$table->style[2] = 'font-weight: bold;'; $table->style[2] = 'font-weight: bold;';
$table->size = array(); $table->size = array();
$table->size[0] = '10%'; $table->size[0] = '10%';
$table->size[1] = '35%'; $table->size[1] = '20%';
$table->size[2] = '9%'; $table->size[2] = '10%';
$table->size[3] = '10%'; $table->size[3] = '5%';
$table->size[4] = '10%'; $table->size[4] = '10%';
// Agent filter // Agent filter
$agent_status_arr = array(); $agent_status_arr = array();
@ -142,19 +144,30 @@ $agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init');
$row = array(); $row = array();
$row[] = __('Search group'); $row[] = __('Search group');
$row[] = html_print_input_text("search_group", $search_group, '', is_metaconsole() ? 70 : 40, 30, true); $row[] = html_print_input_text("search_group", $search_group, '', is_metaconsole() ? 50 : 40, 30, true);
if (is_metaconsole()) {
$row[] = __('Show not init modules');
$row[] = html_print_checkbox("show_not_init_modules", $show_not_init_modules, true, true);
}
$table->data[] = $row; $table->data[] = $row;
$row = array(); $row = array();
$row[] = __('Search agent'); $row[] = __('Search agent');
$row[] = html_print_input_text("search_agent", $search_agent, '', is_metaconsole() ? 70 : 40, 30, true); $row[] = html_print_input_text("search_agent", $search_agent, '', is_metaconsole() ? 50 : 40, 30, true);
$row[] = __('Show not init agents');
$row[] = html_print_checkbox("show_not_init_agents", $show_not_init_agents, true, true);
$row[] = __('Show full hirearchy'); $row[] = __('Show full hirearchy');
$row[] = html_print_checkbox("serach_hirearchy", $serach_hirearchy, false, true); $row[] = html_print_checkbox("serach_hirearchy", $serach_hirearchy, false, true);
$row[] = __('Agent status'); $row[] = __('Agent status');
$row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true); $row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true);
$row[] = html_print_input_hidden('show_not_init_modules_hidden', $show_not_init_modules, true);
// Button // Button
$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true); $row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true);
@ -175,6 +188,13 @@ if (!is_metaconsole()) {
$row = array(); $row = array();
$row[] = __('Search module'); $row[] = __('Search module');
$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true); $row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true);
$row[] = __('Show not init modules');
$row[] = html_print_checkbox("show_not_init_modules", $show_not_init_modules, true, true);
$row[] = '';
$row[] = '';
$row[] = __('Module status'); $row[] = __('Module status');
$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true); $row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true);
@ -270,6 +290,22 @@ enterprise_hook('close_meta_frame');
parameters['filter']['searchHirearchy'] = 0; parameters['filter']['searchHirearchy'] = 0;
} }
if($("#checkbox-show_not_init_agents").is(':checked')){
parameters['filter']['show_not_init_agents'] = 1;
}
else{
parameters['filter']['show_not_init_agents'] = 0;
}
if($("#checkbox-show_not_init_modules").is(':checked')){
parameters['filter']['show_not_init_modules'] = 1;
$('#hidden-show_not_init_modules_hidden').val(1);
}
else{
parameters['filter']['show_not_init_modules'] = 0;
$('#hidden-show_not_init_modules_hidden').val(0);
}
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>", url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.720 %define version 7.0NG.720
%define release 180321 %define release 180409
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.720 %define version 7.0NG.720
%define release 180321 %define release 180409
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.720-180321 Version: 7.0NG.720-180409
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

@ -31,7 +31,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.720"; my $pandora_version = "7.0NG.720";
my $pandora_build = "180321"; my $pandora_build = "180409";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );
@ -417,10 +417,12 @@ sub print_module {
$data->{value} = trim($data->{value}); $data->{value} = trim($data->{value});
} }
$data->{value} = '' if empty($data->{value});
$data->{tags} = $data->{tags}?$data->{tags}:($conf->{MODULE_TAG_LIST}?$conf->{MODULE_TAG_LIST}:undef); $data->{tags} = $data->{tags}?$data->{tags}:($conf->{MODULE_TAG_LIST}?$conf->{MODULE_TAG_LIST}:undef);
$data->{interval} = $data->{interval}?$data->{interval}:($conf->{MODULE_INTERVAL}?$conf->{MODULE_INTERVAL}:undef); $data->{interval} = $data->{interval}?$data->{interval}:($conf->{MODULE_INTERVAL}?$conf->{MODULE_INTERVAL}:undef);
$data->{module_group} = $data->{module_group}?$data->{module_group}:($conf->{MODULE_GROUP}?$conf->{MODULE_GROUP}:undef); $data->{module_group} = $data->{module_group}?$data->{module_group}:($conf->{MODULE_GROUP}?$conf->{MODULE_GROUP}:undef);
# Global instructions (if defined) # Global instructions (if defined)
$data->{unknown_instructions} = $conf->{unknown_instructions} unless (defined($data->{unknown_instructions}) || (!defined($conf->{unknown_instructions}))); $data->{unknown_instructions} = $conf->{unknown_instructions} unless (defined($data->{unknown_instructions}) || (!defined($conf->{unknown_instructions})));
$data->{warning_instructions} = $conf->{warning_instructions} unless (defined($data->{warning_instructions}) || (!defined($conf->{warning_instructions}))); $data->{warning_instructions} = $conf->{warning_instructions} unless (defined($data->{warning_instructions}) || (!defined($conf->{warning_instructions})));
@ -605,8 +607,11 @@ sub transfer_xml {
$file_name .= "_" . time() . ".data"; $file_name .= "_" . time() . ".data";
} }
logger($conf, "transfer_xml", "Failed to generate file name.") if empty($file_name);
$conf->{temp} = $conf->{tmp} if (empty($conf->{temp}) && defined($conf->{tmp})); $conf->{temp} = $conf->{tmp} if (empty($conf->{temp}) && defined($conf->{tmp}));
$conf->{temp} = $conf->{temporal} if (empty($conf->{temporal}) && defined($conf->{temporal})); $conf->{temp} = $conf->{temporal} if (empty($conf->{temp}) && defined($conf->{temporal}));
$conf->{temp} = $conf->{__system}->{tmp} if (empty($conf->{temp}) && defined($conf->{__system})) && (ref($conf->{__system}) eq "HASH");
$file_path = $conf->{temp} . "/" . $file_name; $file_path = $conf->{temp} . "/" . $file_name;
@ -734,7 +739,7 @@ sub print_execution_result {
} }
print_module($conf, { print_module($conf, {
name => "Plugin execution result", name => "Plugin execution result " . $0,
type => "generic_proc", type => "generic_proc",
value => (defined($value)?$value:0), value => (defined($value)?$value:0),
desc => $msg, desc => $msg,
@ -745,12 +750,12 @@ sub print_execution_result {
## Plugin devolution in case of error ## Plugin devolution in case of error
################################################################################ ################################################################################
sub print_error { sub print_error {
my ($conf, $msg, $value) = @_; my ($conf, $msg, $value, $always_show) = @_;
$value = 0 unless defined($value); $value = 0 unless defined($value);
if (!(is_enabled($conf->{informational_modules}))) { if (!(is_enabled($conf->{informational_modules}) || is_enabled($always_show))) {
return 0; exit 1;
} }
if (is_enabled($conf->{'as_server_plugin'})) { if (is_enabled($conf->{'as_server_plugin'})) {
@ -760,7 +765,7 @@ sub print_error {
} }
print_module($conf, { print_module($conf, {
name => (empty($conf->{'global_plugin_module'})?"Plugin execution result":$conf->{'global_plugin_module'}), name => (empty($conf->{'global_plugin_module'})?"Plugin execution result " . $0:$conf->{'global_plugin_module'}),
type => "generic_proc", type => "generic_proc",
value => $value, value => $value,
desc => $msg, desc => $msg,
@ -786,32 +791,39 @@ sub print_stderror {
my $log_aux_flag = 0; my $log_aux_flag = 0;
sub logger { sub logger {
my ($conf, $tag, $message) = @_; my ($conf, $tag, $message) = @_;
my $file = $conf->{log}; my $file = $conf->{'log'};
print_error($conf, "Log file undefined\n") unless defined $file;
print_error($conf, "[ERROR] Log file is not defined.", 0, 1) unless defined($file);
# Log rotation # Log rotation
if (-e $file && (stat($file))[7] > 32000000) { if (defined($file) && -e $file && (stat($file))[7] > 32000000) {
rename ($file, $file.'.old'); rename ($file, $file.'.old');
} }
my $LOGFILE; my $LOGFILE;
if ($log_aux_flag == 0) { if ($log_aux_flag == 0) {
# Log starts # Log starts
if (! open ($LOGFILE, "> $file")) { if (! open ($LOGFILE, "> $file")) {
print_error ($conf, "[ERROR] Could not open logfile '$file'"); print_error ($conf, "[ERROR] Could not open logfile '$file'", 0, 1);
} }
$log_aux_flag = 1; $log_aux_flag = 1;
} }
else { else {
if (! open ($LOGFILE, ">> $file")) { if (! open ($LOGFILE, ">> $file")) {
print_error ($conf, "[ERROR] Could not open logfile '$file'"); print_error ($conf, "[ERROR] Could not open logfile '$file'", 0, 1);
} }
} }
$message = '' if empty($message); if (empty($message)) {
$message = "[" . $tag . "] " . $message if empty($tag); $message = $tag;
$message = "" if empty($message);
}
else {
$message = "[" . $tag . "] " . $message unless empty($tag);
}
if (!(empty($conf->{agent_name}))){
$message = "[" . $conf->{agent_xml_name} . "] " . $message; if (!(empty($conf->{'agent_name'}))){
$message = "[" . $conf->{'agent_name'} . "] " . $message;
} }
print $LOGFILE strftime ("%Y-%m-%d %H:%M:%S", localtime()) . " - " . $message . "\n"; print $LOGFILE strftime ("%Y-%m-%d %H:%M:%S", localtime()) . " - " . $message . "\n";
@ -824,7 +836,7 @@ sub logger {
sub is_enabled { sub is_enabled {
my $value = shift; my $value = shift;
if ((defined ($value)) && ($value > 0)){ if ((defined ($value)) && looks_like_number($value) && ($value > 0)){
# return true # return true
return 1; return 1;
} }
@ -931,6 +943,7 @@ sub init_system {
$system{grep} = "findstr"; $system{grep} = "findstr";
$system{echo} = "echo"; $system{echo} = "echo";
$system{wcl} = "wc -l"; $system{wcl} = "wc -l";
$system{tmp} = ".\\";
} }
else { else {
$system{devnull} = "/dev/null"; $system{devnull} = "/dev/null";
@ -940,6 +953,7 @@ sub init_system {
$system{grep} = "grep"; $system{grep} = "grep";
$system{echo} = "echo"; $system{echo} = "echo";
$system{wcl} = "wc -l"; $system{wcl} = "wc -l";
$system{tmp} = "/tmp";
if ($^O =~ /hpux/i) { if ($^O =~ /hpux/i) {
$system{os} = "HPUX"; $system{os} = "HPUX";
@ -970,6 +984,41 @@ sub get_sys_environment {
################################################################################ ################################################################################
# Parses any configuration, from file (1st arg to program) or direct arguments # Parses any configuration, from file (1st arg to program) or direct arguments
#
# Custom evals are defined in an array reference of hash references:
#
# $custom_eval = [
# {
# 'exp' => 'regular expression to match',
# 'target' => \&target_custom_method_to_parse_line
# },
# {
# 'exp' => 'another regular expression to search',
# 'target' => \&target_custom_method_to_parse_line2
# },
# ]
#
# Target is an user defined function wich will be invoked with following
# arguments:
#
# $config : The configuration read to the point the regex matches
# $exp : The matching regex which fires this action
# $line : The complete line readed from the file
# $file_pointer : A pointer to the file which is being parsed.
# $current_entity : The current_entity (optional) when regex matches
#
# E.g.
#
# sub target_custom_method_to_parse_line {
# my ($config, $exp, $line, $file_pointer, $current_entity) = @_;
#
# if ($line =~ /$exp/) {
# $config->{'my_key'} = complex_operation_on_data($1,$2,$3);
# }
#
# return $config;
# }
#
################################################################################ ################################################################################
sub read_configuration { sub read_configuration {
my ($config, $separator, $custom_eval) = @_; my ($config, $separator, $custom_eval) = @_;
@ -979,6 +1028,20 @@ sub read_configuration {
} }
$config = merge_hashes($config, parse_arguments(\@ARGV)); $config = merge_hashes($config, parse_arguments(\@ARGV));
if(is_enabled($config->{'as_agent_plugin'})) {
$config->{'as_server_plugin'} = 0 if (empty($config->{'as_server_plugin'}));
}
else {
$config->{'as_server_plugin'} = 1 if (empty($config->{'as_server_plugin'}));
}
if(is_enabled($config->{'as_server_plugin'})) {
$config->{'as_agent_plugin'} = 0 if (empty($config->{'as_agent_plugin'}));
}
else {
$config->{'as_agent_plugin'} = 1 if (empty($config->{'as_agent_plugin'}));
}
return $config; return $config;
} }
@ -1034,11 +1097,16 @@ sub parse_arguments {
# $current_entity : The current_entity (optional) when regex matches # $current_entity : The current_entity (optional) when regex matches
# #
################################################################################ ################################################################################
sub parse_configuration;
sub parse_configuration { sub parse_configuration {
my ($conf_file, $separator, $custom_eval, $detect_entities, $entities_list) = @_; my ($conf_file, $separator, $custom_eval, $detect_entities, $entities_list) = @_;
my @arguments = @_;
shift(@arguments);
$separator = "=" unless defined($separator); $separator = "=" unless defined($separator);
my $_CFILE; my $_CFILE;
my $_config; my $_config;
@ -1124,6 +1192,24 @@ sub parse_configuration {
next; next;
} }
} }
if ($key =~ /^include$/i) {
my $file_included = trim($value);
my $aux;
eval {
$aux = parse_configuration($file_included, @arguments);
};
if($@) {
Carp::croak ("Failed to parse configuration");
}
if (empty($_config)) {
$_config = $aux;
}
elsif (!empty($aux) && (ref ($aux) eq "HASH")) {
$_config = merge_hashes($_config, $aux);
}
next;
}
$_config->{trim($key)} = trim($value); $_config->{trim($key)} = trim($value);
} }
close ($_CFILE); close ($_CFILE);

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.720 %define version 7.0NG.720
%define release 180321 %define release 180409
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.720 %define version 7.0NG.720
%define release 180321 %define release 180409
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.720" PI_VERSION="7.0NG.720"
PI_BUILD="180321" PI_BUILD="180409"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.720 PS180321"; my $version = "7.0NG.720 PS180409";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.720 PS180321"; my $version = "7.0NG.720 PS180409";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -126,6 +126,9 @@ sub help_screen{
help_screen_line('--clean_conf_file', '<agent_name>', "Clean a local conf of a given agent deleting all modules, \n\t policies, file collections and comments"); help_screen_line('--clean_conf_file', '<agent_name>', "Clean a local conf of a given agent deleting all modules, \n\t policies, file collections and comments");
help_screen_line('--get_bad_conf_files', '', 'Get the files bad configured (without essential tokens)'); help_screen_line('--get_bad_conf_files', '', 'Get the files bad configured (without essential tokens)');
help_screen_line('--locate_agent', '<agent_name>', 'Search a agent into of nodes of metaconsole. Only Enterprise.'); help_screen_line('--locate_agent', '<agent_name>', 'Search a agent into of nodes of metaconsole. Only Enterprise.');
help_screen_line('--migration_agent_queue', '<id_node> <source_node_name> <target_node_name> [<db_only>]', 'Migrate agent only metaconsole');
help_screen_line('--migration_agent', '<id_node> ', 'Is migrating the agent only metaconsole');
help_screen_line('--apply_module_template', '<id_template> <id_agent>', 'Apply module template to agent');
print "\nMODULES:\n\n" unless $param ne ''; print "\nMODULES:\n\n" unless $param ne '';
help_screen_line('--create_data_module', "<module_name> <module_type> <agent_name> [<description> <module_group> \n\t <min> <max> <post_process> <interval> <warning_min> <warning_max> <critical_min> <critical_max> \n\t <history_data> <definition_file> <warning_str> <critical_str>\n\t <unknown_events> <ff_threshold> <each_ff> <ff_threshold_normal>\n\t <ff_threshold_warning> <ff_threshold_critical> <ff_timeout> <warning_inverse> <critical_inverse>\n\t <critical_instructions> <warning_instructions> <unknown_instructions>]", 'Add data server module to agent'); help_screen_line('--create_data_module', "<module_name> <module_type> <agent_name> [<description> <module_group> \n\t <min> <max> <post_process> <interval> <warning_min> <warning_max> <critical_min> <critical_max> \n\t <history_data> <definition_file> <warning_str> <critical_str>\n\t <unknown_events> <ff_threshold> <each_ff> <ff_threshold_normal>\n\t <ff_threshold_warning> <ff_threshold_critical> <ff_timeout> <warning_inverse> <critical_inverse>\n\t <critical_instructions> <warning_instructions> <unknown_instructions>]", 'Add data server module to agent');
help_screen_line('--create_web_module', "<module_name> <module_type> <agent_name> [<description> <module_group> \n\t <min> <max> <post_process> <interval> <warning_min> <warning_max> <critical_min> <critical_max> \n\t <history_data> <definition_file> <warning_str> <critical_str>\n\t <unknown_events> <ff_threshold> <each_ff> <ff_threshold_normal>\n\t <ff_threshold_warning> <ff_threshold_critical> <ff_timeout> <warning_inverse> <critical_inverse>\n\t <critical_instructions> <warning_instructions> <unknown_instructions>].\n\t The valid data types are web_data, web_proc, web_content_data or web_content_string", 'Add web server module to agent'); help_screen_line('--create_web_module', "<module_name> <module_type> <agent_name> [<description> <module_group> \n\t <min> <max> <post_process> <interval> <warning_min> <warning_max> <critical_min> <critical_max> \n\t <history_data> <definition_file> <warning_str> <critical_str>\n\t <unknown_events> <ff_threshold> <each_ff> <ff_threshold_normal>\n\t <ff_threshold_warning> <ff_threshold_critical> <ff_timeout> <warning_inverse> <critical_inverse>\n\t <critical_instructions> <warning_instructions> <unknown_instructions>].\n\t The valid data types are web_data, web_proc, web_content_data or web_content_string", 'Add web server module to agent');
@ -157,7 +160,6 @@ sub help_screen{
help_screen_line('--delete_special_day', '<special_day>', 'Delete special day'); help_screen_line('--delete_special_day', '<special_day>', 'Delete special day');
help_screen_line('--update_special_day', "<special_day> <field_to_change> <new_value>", 'Update a field of a special day'); help_screen_line('--update_special_day', "<special_day> <field_to_change> <new_value>", 'Update a field of a special day');
help_screen_line('--create_data_module_from_local_component', '<agent_name> <component_name>', "Create a new data \n\t module from a local component"); help_screen_line('--create_data_module_from_local_component', '<agent_name> <component_name>', "Create a new data \n\t module from a local component");
help_screen_line('--create_web_module_from_local_component', '<agent_name> <component_name>', "Create a new web \n\t module from a local component");
help_screen_line('--create_local_component', "<component_name> <data> [<description> <id_os> <os_version> \n\t <id_network_component_group> <type> <min> <max> <module_interval> <id_module_group> <history_data> <min_warning> \n\t <max_warning> <str_warning> <min_critical> <max_critical>\n\t <str_critical> <min_ff_event> <post_process> <unit>\n\t <wizard_level> <critical_instructions>\n\t <warning_instructions> <unknown_instructions> <critical_inverse>\n\t <warning_inverse> <id_category> <disabled_types_event>\n\t <tags> <min_ff_event_normal> <min_ff_event_warning>\n\t <min_ff_event_critical> <each_ff> <ff_timeout>]", 'Create local component'); help_screen_line('--create_local_component', "<component_name> <data> [<description> <id_os> <os_version> \n\t <id_network_component_group> <type> <min> <max> <module_interval> <id_module_group> <history_data> <min_warning> \n\t <max_warning> <str_warning> <min_critical> <max_critical>\n\t <str_critical> <min_ff_event> <post_process> <unit>\n\t <wizard_level> <critical_instructions>\n\t <warning_instructions> <unknown_instructions> <critical_inverse>\n\t <warning_inverse> <id_category> <disabled_types_event>\n\t <tags> <min_ff_event_normal> <min_ff_event_warning>\n\t <min_ff_event_critical> <each_ff> <ff_timeout>]", 'Create local component');
print "\nUSERS:\n\n" unless $param ne ''; print "\nUSERS:\n\n" unless $param ne '';
@ -195,7 +197,6 @@ sub help_screen{
<critical_instructions> <warning_instructions> <unknown_instructions>\n\t <warning_inverse> <critical_inverse>]", 'Add snmp network module to policy'); <critical_instructions> <warning_instructions> <unknown_instructions>\n\t <warning_inverse> <critical_inverse>]", 'Add snmp network module to policy');
help_screen_line('--create_policy_plugin_module', "<policy_name> <module_name> <module_type> \n\t <module_port> <plugin_name> <user> <password> <parameters> [<description> <module_group> <min> \n\t <max> <post_process> <interval> <warning_min> <warning_max> <critical_min> <critical_max>\n\t <history_data> <ff_threshold> <warning_str> <critical_str>\n\t <unknown_events> <each_ff> <ff_threshold_normal>\n\t <ff_threshold_warning> <ff_threshold_critical>\n\t <critical_instructions> <warning_instructions> <unknown_instructions>\n\t <warning_inverse> <critical_inverse>]", 'Add plug-in module to policy'); help_screen_line('--create_policy_plugin_module', "<policy_name> <module_name> <module_type> \n\t <module_port> <plugin_name> <user> <password> <parameters> [<description> <module_group> <min> \n\t <max> <post_process> <interval> <warning_min> <warning_max> <critical_min> <critical_max>\n\t <history_data> <ff_threshold> <warning_str> <critical_str>\n\t <unknown_events> <each_ff> <ff_threshold_normal>\n\t <ff_threshold_warning> <ff_threshold_critical>\n\t <critical_instructions> <warning_instructions> <unknown_instructions>\n\t <warning_inverse> <critical_inverse>]", 'Add plug-in module to policy');
help_screen_line('--create_policy_data_module_from_local_component', '<policy_name> <component_name>'); help_screen_line('--create_policy_data_module_from_local_component', '<policy_name> <component_name>');
help_screen_line('--create_policy_web_module_from_local_component', '<policy_name> <component_name>');
help_screen_line('--add_collection_to_policy', "<policy_name> <collection_name>"); help_screen_line('--add_collection_to_policy', "<policy_name> <collection_name>");
help_screen_line('--validate_policy_alerts', '<policy_name>', 'Validate the alerts of a given policy'); help_screen_line('--validate_policy_alerts', '<policy_name>', 'Validate the alerts of a given policy');
help_screen_line('--get_policy_modules', '<policy_name>', 'Get the modules of a policy'); help_screen_line('--get_policy_modules', '<policy_name>', 'Get the modules of a policy');
@ -1355,23 +1356,28 @@ sub cli_create_web_module($) {
my $in_policy = shift; my $in_policy = shift;
my ($policy_name, $module_name, $module_type, $agent_name, $description, $module_group, my ($policy_name, $module_name, $module_type, $agent_name, $description, $module_group,
$min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min, $min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min,
$critical_max, $history_data, $definition_file, $configuration_data, $warning_str, $critical_str, $enable_unknown_events, $critical_max, $history_data, $retries, $requests, $agent_browser_id, $auth_server, $auth_realm,
$definition_file, $http_auth_login, $http_auth_password,
$proxy_url, $proxy_auth_login, $proxy_auth_password, $configuration_data, $warning_str, $critical_str, $enable_unknown_events,
$ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout,
$warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions); $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions);
if ($in_policy == 0) { if ($in_policy == 0) {
($module_name, $module_type, $agent_name, $description, $module_group, ($module_name, $module_type, $agent_name, $description, $module_group,
$min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min, $min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min,
$critical_max, $history_data, $definition_file, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $critical_max, $history_data, $retries, $requests, $agent_browser_id, $auth_server, $auth_realm,
$each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, $definition_file, $http_auth_login, $http_auth_password,
$warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..30]; $proxy_url, $proxy_auth_login, $proxy_auth_password, $warning_str, $critical_str,
$enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout,
$warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..40];
} }
else { else {
($policy_name, $module_name, $module_type, $description, $module_group, ($policy_name, $module_name, $module_type, $description, $module_group,
$min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min, $min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min,
$critical_max, $history_data, $configuration_data, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $critical_max, $history_data, $retries, $requests, $agent_browser_id, $auth_server, $auth_realm, $configuration_data, $http_auth_login, $http_auth_password,
$each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, $proxy_url, $proxy_auth_login, $proxy_auth_password, $warning_str, $critical_str,
$warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..31]; $enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout,
$warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..40];
} }
my $module_name_def; my $module_name_def;
@ -1530,6 +1536,17 @@ sub cli_create_web_module($) {
$parameters{'warning_instructions'} = $warning_instructions unless !defined ($warning_instructions); $parameters{'warning_instructions'} = $warning_instructions unless !defined ($warning_instructions);
$parameters{'unknown_instructions'} = $unknown_instructions unless !defined ($unknown_instructions); $parameters{'unknown_instructions'} = $unknown_instructions unless !defined ($unknown_instructions);
$parameters{'max_retries'} = $retries unless !defined ($retries);
$parameters{'plugin_pass'} = $requests unless !defined ($requests);
$parameters{'plugin_user'} = $agent_browser_id unless !defined ($agent_browser_id);
$parameters{'http_user'} = $http_auth_login unless !defined ($http_auth_login);
$parameters{'http_pass'} = $http_auth_password unless !defined ($http_auth_password);
$parameters{'snmp_oid'} = defined ($proxy_url) ? $proxy_url : '';
$parameters{'tcp_send'} = $proxy_auth_login unless !defined ($proxy_auth_login);
$parameters{'tcp_rcv'} = $proxy_auth_password unless !defined ($proxy_auth_password);
$parameters{'ip_target'} = $auth_server unless !defined ($auth_server);
$parameters{'snmp_community'} = $auth_realm unless !defined ($auth_realm);
if ($in_policy == 0) { if ($in_policy == 0) {
pandora_create_module_from_hash ($conf, \%parameters, $dbh); pandora_create_module_from_hash ($conf, \%parameters, $dbh);
} }
@ -5612,6 +5629,9 @@ sub cli_export_visual_console() {
print_log "[INFO] JSON file now contents: \n" . $data_to_json . "\n\n"; print_log "[INFO] JSON file now contents: \n" . $data_to_json . "\n\n";
} }
############################################################################### ###############################################################################
############################################################################### ###############################################################################
# MAIN # MAIN
@ -5681,7 +5701,7 @@ sub pandora_manage_main ($$$) {
cli_create_data_module(0); cli_create_data_module(0);
} }
elsif ($param eq '--create_web_module') { elsif ($param eq '--create_web_module') {
param_check($ltotal, 30, 24); param_check($ltotal, 40, 33);
cli_create_web_module(0); cli_create_web_module(0);
} }
elsif ($param eq '--create_module_group') { elsif ($param eq '--create_module_group') {
@ -5828,10 +5848,6 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 2, 2); param_check($ltotal, 2, 2);
cli_create_policy_data_module_from_local_component(); cli_create_policy_data_module_from_local_component();
} }
elsif ($param eq '--create_policy_web_module_from_local_component') {
param_check($ltotal, 2, 2);
cli_create_policy_web_module_from_local_component();
}
elsif ($param eq '--create_policy') { elsif ($param eq '--create_policy') {
param_check($ltotal, 3, 2); param_check($ltotal, 3, 2);
cli_create_policy(); cli_create_policy();
@ -5841,7 +5857,7 @@ sub pandora_manage_main ($$$) {
cli_create_data_module(1); cli_create_data_module(1);
} }
elsif ($param eq '--create_policy_web_module') { elsif ($param eq '--create_policy_web_module') {
param_check($ltotal, 28, 20); param_check($ltotal, 38, 29);
cli_create_web_module(1); cli_create_web_module(1);
} }
elsif ($param eq '--create_policy_network_module') { elsif ($param eq '--create_policy_network_module') {
@ -5990,10 +6006,6 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 2); param_check($ltotal, 2);
cli_create_data_module_from_local_component(); cli_create_data_module_from_local_component();
} }
elsif ($param eq '--create_web_module_from_local_component') {
param_check($ltotal, 2);
cli_create_web_module_from_local_component();
}
elsif ($param eq '--create_local_component') { elsif ($param eq '--create_local_component') {
param_check($ltotal, 35, 33); param_check($ltotal, 35, 33);
cli_create_local_component(); cli_create_local_component();
@ -6066,6 +6078,18 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 3, 2); param_check($ltotal, 3, 2);
cli_export_visual_console(); cli_export_visual_console();
} }
elsif ($param eq '--apply_module_template') {
param_check($ltotal, 2, 2);
cli_apply_module_template();
}
elsif ($param eq '--migration_agent_queue') {
param_check($ltotal, 4, 1);
cli_migration_agent_queue();
}
elsif ($param eq '--migration_agent') {
param_check($ltotal, 1, 0);
cli_migration_agent();
}
else { else {
print_log "[ERROR] Invalid option '$param'.\n\n"; print_log "[ERROR] Invalid option '$param'.\n\n";
$param = ''; $param = '';
@ -6232,30 +6256,6 @@ sub cli_create_data_module_from_local_component() {
#~ pandora_create_module_from_local_component ($conf, $component, $agent_id, $dbh); #~ pandora_create_module_from_local_component ($conf, $component, $agent_id, $dbh);
enterprise_hook('pandora_create_module_from_local_component',[$conf, $component, $agent_id, $dbh]); enterprise_hook('pandora_create_module_from_local_component',[$conf, $component, $agent_id, $dbh]);
} }
##############################################################################
# Create web module from local component.
# Related option: --create_web_module_from_local_component
##############################################################################
sub cli_create_web_module_from_local_component() {
my ($agent_name, $component_name) = @ARGV[2..3];
my $agent_id = get_agent_id($dbh,$agent_name);
exist_check($agent_id,'agent',$agent_name);
my $lc_id = pandora_get_local_component_id($dbh, $component_name);
exist_check($lc_id,'local component',$component_name);
my $module_exists = get_agent_module_id($dbh, $component_name, $agent_id);
non_exist_check($module_exists, 'module name', $component_name);
# Get local component data
my $component = get_db_single_row ($dbh, 'SELECT * FROM tlocal_component WHERE id = ?', $lc_id);
#~ pandora_create_module_from_local_component ($conf, $component, $agent_id, $dbh);
enterprise_hook('pandora_create_module_from_local_component',[$conf, $component, $agent_id, $dbh]);
}
############################################################################## ##############################################################################
# Create policy data module from local component. # Create policy data module from local component.
# Related option: --create_policy_data_module_from_local_component # Related option: --create_policy_data_module_from_local_component
@ -6275,25 +6275,6 @@ sub cli_create_policy_data_module_from_local_component() {
enterprise_hook('pandora_create_policy_data_module_from_local_component',[$conf, $component, $policy_id, $dbh]); enterprise_hook('pandora_create_policy_data_module_from_local_component',[$conf, $component, $policy_id, $dbh]);
} }
##############################################################################
# Create policy web module from local component.
# Related option: --create_policy_web_module_from_local_component
##############################################################################
sub cli_create_policy_web_module_from_local_component() {
my ($policy_name, $component_name) = @ARGV[2..3];
my $policy_id = enterprise_hook('get_policy_id',[$dbh, safe_input($policy_name)]);
exist_check($policy_id,'policy',$policy_name);
my $lc_id = pandora_get_local_component_id($dbh, $component_name);
exist_check($lc_id,'local component',$component_name);
# Get local component web
my $component = get_db_single_row ($dbh, 'SELECT * FROM tlocal_component WHERE id = ?', $lc_id);
enterprise_hook('pandora_create_policy_web_module_from_local_component',[$conf, $component, $policy_id, $dbh]);
}
############################################################################## ##############################################################################
# Create local component. # Create local component.
# Related option: --create_local_component # Related option: --create_local_component
@ -6436,3 +6417,135 @@ sub cli_add_tag_to_module() {
my $result = api_call(\%conf, 'set', 'add_tag_module', $module_id, $tag_id); my $result = api_call(\%conf, 'set', 'add_tag_module', $module_id, $tag_id);
print "\n$result\n"; print "\n$result\n";
} }
##############################################################################
# Only meta migrate agent
##############################################################################
sub cli_migration_agent_queue() {
my ($id_agent, $source_name, $target_name, $only_db) = @ARGV[2..5];
if( !defined($id_agent) || !defined($source_name) || !defined($target_name) ){
print "\n0\n";
}
if(!defined($only_db)){
$only_db = 0;
}
# Call the API.
my $result = api_call( $conf, 'set', 'migrate_agent', $id_agent, 0, "$source_name|$target_name|$only_db" );
print "\n$result\n";
}
##############################################################################
# Only meta is migrate agent
##############################################################################
sub cli_migration_agent() {
my ($id_agent) = @ARGV[2];
if( !defined($id_agent) ){
print "\n0\n";
}
# Call the API.
my $result = api_call( $conf, 'get', 'migrate_agent', $id_agent);
if( defined($result) && "$result" ne "" ){
print "\n1\n";
}
else{
print "\n0\n";
}
}
sub cli_apply_module_template() {
my ($id_template, $id_agent) = @ARGV[2..3];
my @row = get_db_rows ($dbh,"select * from tagente where id_agente = ".$id_agent);
return if (scalar (@row) == 0);
my $name_template = get_db_value ($dbh,'select name from tnetwork_profile where id_np = '.$id_template);
my @npc = get_db_rows($dbh,"select * from tnetwork_profile_component where id_np = ".$id_template);
foreach my $component (@npc) {
my @template_values = get_db_rows ($dbh,"SELECT * FROM tnetwork_component where id_nc = ".$component->{'id_nc'});
return if (scalar (@template_values) == 0);
foreach my $element (@template_values) {
my $agent_values;
$agent_values->{'id_agente'} = $id_agent;
$agent_values->{'id_tipo_modulo'} = $element->{"type"};
$agent_values->{'descripcion'} = 'Created by template '.$name_template.' '.$element->{"description"};
$agent_values->{'max'} = $element->{"max"};
$agent_values->{'min'} = $element->{"min"};
$agent_values->{'module_interval'} = $element->{"module_interval"};
$agent_values->{'tcp_port'} = $element->{"tcp_port"};
$agent_values->{'tcp_send'} = $element->{"tcp_send"};
$agent_values->{'tcp_rcv'} = $element->{"tcp_rcv"};
$agent_values->{'snmp_community'} = $element->{"snmp_community"};
$agent_values->{'snmp_oid'} = $element->{"snmp_oid"};
$agent_values->{'ip_target'} = $row[0]->{"direccion"};
$agent_values->{'id_module_group'} = $element->{"id_module_group"};
$agent_values->{'id_modulo'} = $element->{"id_modulo"};
$agent_values->{'plugin_user'} = $element->{"plugin_user"};
$agent_values->{'plugin_pass'} = $element->{"plugin_pass"};
$agent_values->{'plugin_parameter'} = $element->{"plugin_parameter"};
$agent_values->{'unit'} = $element->{"unit"};
$agent_values->{'max_timeout'} = $element->{"max_timeout"};
$agent_values->{'max_retries'} = $element->{"max_retries"};
$agent_values->{'id_plugin'} = $element->{"id_plugin"};
$agent_values->{'post_process'} = $element->{"post_process"};
$agent_values->{'dynamic_interval'} = $element->{"dynamic_interval"};
$agent_values->{'dynamic_max'} = $element->{"dynamic_max"};
$agent_values->{'dynamic_min'} = $element->{"dynamic_min"};
$agent_values->{'dynamic_two_tailed'} = $element->{"dynamic_two_tailed"};
$agent_values->{'min_warning'} = $element->{"min_warning"};
$agent_values->{'max_warning'} = $element->{"max_warning"};
$agent_values->{'str_warning'} = $element->{"str_warning"};
$agent_values->{'min_critical'} = $element->{"min_critical"};
$agent_values->{'max_critical'} = $element->{"max_critical"};
$agent_values->{'str_critical'} = $element->{"str_critical"};
$agent_values->{'critical_inverse'} = $element->{"critical_inverse"};
$agent_values->{'warning_inverse'} = $element->{"warning_inverse"};
$agent_values->{'critical_instructions'} = $element->{"critical_instructions"};
$agent_values->{'warning_instructions'} = $element->{"warning_instructions"};
$agent_values->{'unknown_instructions'} = $element->{"unknown_instructions"};
$agent_values->{'id_category'} = $element->{"id_category"};
$agent_values->{'macros'} = $element->{"macros"};
$agent_values->{'each_ff'} = $element->{"each_ff"};
$agent_values->{'min_ff_event'} = $element->{"min_ff_event"};
$agent_values->{'min_ff_event_normal'} = $element->{"min_ff_event_normal"};
$agent_values->{'min_ff_event_warning'} = $element->{"min_ff_event_warning"};
$agent_values->{'min_ff_event_critical'} = $element->{"min_ff_event_critical"};
$agent_values->{'nombre'} = $element->{"name"};
my @tags;
if($element->{"tags"} ne '') {
@tags = split(',', $element->{"tags"});
}
my $module_name_check = get_db_value ($dbh,'select id_agente_modulo from tagente_modulo where delete_pending = 0 and nombre ="'.$agent_values->{'nombre'}.'" and id_agente = '.$id_agent);
if (!defined($module_name_check)) {
my $id_agente_modulo = pandora_create_module_from_hash(\%conf,$agent_values,$dbh);
if ($id_agente_modulo != -1) {
foreach my $tag_name (@tags) {
my $tag_id = get_db_value($dbh,'select id_tag from ttag where name = "'.$tag_name.'"');
db_do($dbh,'insert into ttag_module (id_tag,id_agente_modulo) values ("'.$tag_id.'","'.$id_agente_modulo.'")');
}
}
}
}
}
}