Fix IPMI recon script so that it works with new style custom fields

Updates the IPMI recon script to pass parameters to the IPMI plugin using the
new style custom fields.

Add a field for specifying additonal options to ipmi-sensors.  This is required
for IPMI v2.0 devices and when using accounts with restricted privileges.

Fix some types in the description for the recon script.

Fix a bug where the recon script never completed and kept processing the subnet
over and over due to an incorrect exit condition in the loop.

Change the packet count and timeout passed to ipmiping.  The previous values
required 9 seconds per address polled.  This meant it took almost 40 minutes
to scan one 256 address subnet.
This commit is contained in:
Robert Nelson 2015-05-26 11:01:17 -07:00
parent 991c406a70
commit e943bf0ada
8 changed files with 81 additions and 33 deletions

View File

@ -120,3 +120,18 @@ INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `descri
-- ---------------------------------------------------------------------
INSERT INTO `tevent_response` VALUES (6,'Ping to module agent host','Ping to the module agent host','ping -c 5 _module_address_','command',0,620,500,0,'');
-- ---------------------------------------------------------------------
-- Table `tplugin`
-- ---------------------------------------------------------------------
UPDATE `tplugin`
SET `macros` = '{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Sensor\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Additional Options\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}',
SET `parameters` = '-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_'
WHERE `id` = 1 AND `name` = 'IPMI Plugin';
-- ---------------------------------------------------------------------
-- Table `trecon_script`
-- ---------------------------------------------------------------------
UPDATE `trecon_script`
SET `description` = 'Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es>

Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> <custom_field4>

* custom_field1 = Network i.e.: 192.168.100.0/24
* custom_field2 = Username
* custom_field3 = Password
* custom_field4 = Additional parameters i.e.: -D LAN_2_0',
SET `macros` = '{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5.  These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}'
WHERE `id_recon_script` = 2 AND `name` = 'IPMI Recon';

View File

@ -93,3 +93,19 @@ CREATE TABLE tsessions_php (
last_active NUMBER(20, 0) NOT NULL,
data CLOB default ''
);
-- ---------------------------------------------------------------------
-- Table tplugin
-- ---------------------------------------------------------------------
UPDATE tplugin
SET macros = '{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Sensor\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Additional Options\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}',
SET parameters = '-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_'
WHERE id = 1 AND name = 'IPMI Plugin';
-- ---------------------------------------------------------------------
-- Table trecon_script
-- ---------------------------------------------------------------------
UPDATE trecon_script
SET description = 'Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es>

Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> <custom_field4>

* custom_field1 = Network i.e.: 192.168.100.0/24
* custom_field2 = Username
* custom_field3 = Password
* custom_field4 = Additional parameters i.e.: -D LAN_2_0',
SET macros = '{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5.  These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}'
WHERE id_recon_script = 2 AND name = 'IPMI Recon';

View File

@ -91,3 +91,19 @@ CREATE TABLE "tsessions_php" (
"last_active" INTEGER NOT NULL,
"data" TEXT default ''
);
-- ---------------------------------------------------------------------
-- Table tplugin
-- ---------------------------------------------------------------------
UPDATE "tplugin"
SET "macros" = '{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Sensor\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Additional Options\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}',
SET "parameters" = '-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_'
WHERE "id" = 1 AND "name" = 'IPMI Plugin';
-- ---------------------------------------------------------------------
-- Table `trecon_script`
-- ---------------------------------------------------------------------
UPDATE "trecon_script"
SET "description" = 'Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es>

Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> <custom_field4>

* custom_field1 = Network i.e.: 192.168.100.0/24
* custom_field2 = Username
* custom_field3 = Password
* custom_field4 = Additional parameters i.e.: -D LAN_2_0',
SET "macros" = '{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5.  These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}'
WHERE "id_recon_script" = 2 AND "name" = 'IPMI Recon';

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1009,13 +1009,13 @@ INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (2, 'Monitoring&#x
INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (3, 'Monitoring Report Alerts', 'select t1.nombre as agent_name, t2.nombre as module_name, (select talert_templates.name from talert_templates where talert_templates.id = t3.id_alert_template) as template, (select group_concat(t02.name) from talert_template_module_actions as t01 inner join talert_actions as t02 on t01.id_alert_action = t02.id where t01.id_alert_template_module = t3.id group by t01.id_alert_template_module) as actions from tagente as t1 inner join tagente_modulo as t2 on t1.id_agente = t2.id_agente inner join talert_template_modules as t3 on t2.id_agente_modulo = t3.id_agent_module order by agent_name, module_name;');
INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (4, 'Group view', 'select t1.nombre, (select count(t3.id_agente) from tagente as t3 where t1.id_grupo = t3.id_grupo) as agents, (SELECT COUNT(t4.id_agente) FROM tagente as t4 WHERE t4.id_grupo = t1.id_grupo AND t4.disabled = 0 AND t4.ultimo_contacto < NOW() - (intervalo / (1/2))) as agent_unknown, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100) AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval / (1/2))) as monitor_unknow, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,24) AND utimestamp = 0) as monitor_no_init, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 0 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24)))) as monitor_ok, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 1 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0) as monitor_critical, (SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente WHERE tagente.id_grupo = t1.id_grupo AND tagente_modulo.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo AND times_fired > 0) as monitor_alert_fired from tgrupo as t1 where 0 < (select count(t2.id_agente) from tagente as t2 where t1.id_grupo = t2.id_grupo)');
INSERT INTO `trecon_script` VALUES (2,'IPMI Recon','Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es>

Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3>

* custom_field1 = Network i.e.: 192.168.100.0/24
* custom_field2 = Username
* custom_fiedl3 = Password','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"}}');
INSERT INTO `trecon_script` VALUES (2,'IPMI Recon','Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es>

Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> <custom_field4>

* custom_field1 = Network i.e.: 192.168.100.0/24
* custom_field2 = Username
* custom_field3 = Password
* custom_field4 = Additional parameters i.e.: -D LAN_2_0','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5.  These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}');
INSERT INTO `trecon_script` VALUES (4,'SNMP L2 Recon','Pandora FMS SNMP Recon Plugin for level 2 network topology discovery.
(c) Artica ST 2014 <info@artica.es>

Usage:

   ./snmp-recon.pl <task_id> <group_id> <create_incident> <custom_field1> <custom_field2> [custom_field3] [custom_field4]

 * custom_field1 = comma separated list of networks (i.e.: 192.168.1.0/24,192.168.2.0/24)
 * custom_field2 = comma separated list of snmp communities to try.
 * custom_field3 = a router in the network. Optional but recommended.
 * custom_field4 = set to -a to add all network interfaces (by default only interfaces that are up are added).

 Additional information:
When the script is called from a recon task the task_id, group_id and create_incident parameters are automatically filled by the Pandora FMS Server.','/usr/share/pandora_server/util/recon_scripts/snmp-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"Comma separated list of networks (i.e.: 192.168.1.0/24,192.168.2.0/24)\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Community\",\"help\":\"Comma separated list of snmp communities to try.\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Router\",\"help\":\"A router in the network. Optional but recommended.\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Optional parameter\",\"help\":\"Set to -a to add all network interfaces (by default only interfaces that are up are added).\",\"value\":\"\",\"hide\":\"\"}}');
INSERT INTO `trecon_script` VALUES (5,'WMI Recon Script','This script is used to automatically gather host information via WMI.
Available parameters:

* Network = network to scan (e.g. 192.168.100.0/24).
* WMI auth = comma separated list of WMI authentication tokens in the format username%password (e.g. Administrador%pass).

See the documentation for more information.','/usr/share/pandora_server/util/recon_scripts/wmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"WMI auth\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}');
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (1,'IPMI Plugin','Plugin to get IPMI monitors from a IPMI Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Username","help":"","value":""},"3":{"macro":"_field3_","desc":"Password","help":"","value":""}}','-h _field1_-u _field2_-p _field3_');
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (1,'IPMI Plugin','Plugin to get IPMI monitors from a IPMI Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Sensor\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Additional Options\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_');
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (2,'DNS Plugin','This plugin is used to check if a specific domain return a specific IP address, and to check how time (milisecs) takes the DNS to answer. Use IP address parameter to specify the IP of your domain. Use these custom parameters for the other parameters:

-d domain to check (for example pandorafms.com)
-s DNS Server to check  (for example 8.8.8.8)

Optional parameters:

-t Do a DNS time response check instead DNS resolve test

',15,'/usr/share/pandora_server/util/plugin/dns_plugin.sh',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Domain to check","help":"For example pandorafms.com","value":""},"3":{"macro":"_field3_","desc":"DNS Server to check","help":"For example 8.8.8.8","value":""},"4":{"macro":"_field4_","desc":"Optional parameters","help":"","value":""}}','-i _field1_ -d _field2_ -s _field3_ _field4_');

View File

@ -11,7 +11,12 @@ sub get_param($) {
for(my $i=0; $i<$#ARGV; $i++) {
if ($ARGV[$i] eq $param) {
if ($ARGV[$i] eq "--") {
if ($param eq "--") {
$value = join(' ', @ARGV[$i+1..$#ARGV]);
}
last;
} elsif ($ARGV[$i] eq $param) {
$value = $ARGV[$i+1];
last;
}
@ -40,8 +45,9 @@ my $host = get_param("h");
my $user = get_param("u");
my $pass = get_param("p");
my $sensor = get_param("s");
my $extraopts = get_param("-");
my $res = `ipmi-sensors -h $host -u $user -p $pass -s $sensor | tail -1`;
my $res = `ipmi-sensors -h $host -u $user -p $pass -s $sensor $extraopts | tail -1`;
my @aux = split(/\|/, $res);

View File

@ -21,8 +21,8 @@ use PandoraFMS::Config;
##########################################################################
# Global variables so set behaviour here:
my $pkg_count = 3; #Number of ping pkgs
my $pkg_timeout = 3; #Pkg ping timeout wait
my $pkg_count = 2; #Number of ping pkgs
my $pkg_timeout = 1; #Pkg ping timeout wait
##########################################################################
# Code begins here, do not touch
@ -44,6 +44,7 @@ my $create_incident = $ARGV[2]; # Defined by user
my $target_network = $ARGV[3]; # Filed1 defined by user
my $username = $ARGV[4]; # Field2 defined by user
my $password = $ARGV[5]; # Field3 defined by user
my $extraopts = $ARGV[6]; # Field4 defined by user
##########################################################################
@ -62,10 +63,11 @@ sub show_help {
print "\nSpecific Pandora FMS Intel DCM Discovery\n";
print "(c) Artica ST 2011 <info\@artica.es>\n\n";
print "Usage:\n\n";
print " $0 <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3>\n\n";
print " $0 <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> <custom_field4>\n\n";
print " * custom_field1 = network. i.e.: 192.168.100.0/24\n";
print " * custom_field2 = username \n";
print " * custom_fiedl3 = password \n";
print " * custom_field3 = password \n";
print " * custom_field4 = additional ipmi-sensors options \n";
exit;
}
@ -88,10 +90,10 @@ sub ipmi_ping ($$$) {
return 1;
}
sub create_ipmi_modules($$$$$$) {
my ($conf, $dbh, $addr, $user, $pass, $id_agent) = @_;
sub create_ipmi_modules($$$$$$$) {
my ($conf, $dbh, $addr, $user, $pass, $extraopts, $id_agent) = @_;
my $cmd = "ipmi-sensors -h $addr -u $user -p $pass";
my $cmd = "ipmi-sensors -h $addr -u $user -p $pass $extraopts";
my $res = `$cmd`;
@ -127,19 +129,22 @@ sub create_ipmi_modules($$$$$$) {
my $id_module_type = get_module_id($dbh, $module_type);
my $params = "-s $aux[0]";
my $macros = '{'.
'"1":{"macro":"_field1_","desc":"'.safe_input("Target IP").'","help":"","value":"'.$addr.'","hide":""},'.
'"2":{"macro":"_field2_","desc":"Username","help":"","value":"'.$user.'","hide":""},'.
'"3":{"macro":"_field3_","desc":"Password","help":"","value":"'.$pass.'","hide":"1"},'.
'"4":{"macro":"_field4_","desc":"Sensor","help":"","value":"'.$aux[0].'","hide":""},'.
'"5":{"macro":"_field5_","desc":"'.safe_input("Additional Options").'","help":"","value":"'.$extraopts.'","hide":""}'.
'}';
my %parameters;
$parameters{"nombre"} = safe_input($name);
$parameters{"id_tipo_modulo"} = $id_module_type;
$parameters{"id_agente"} = $id_agent;
$parameters{"id_plugin"} = $ipmi_plugin_id;
$parameters{"ip_target"} = $addr;
$parameters{"plugin_user"} = $user;
$parameters{"plugin_pass"} = $pass;
$parameters{"id_modulo"} = 4;
$parameters{"plugin_parameter"} = $params;
$parameters{"macros"} = $macros;
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
@ -184,17 +189,7 @@ if (! defined ($net_addr)) {
# Scan the network for host
my ($total_hosts, $hosts_found, $addr_found) = ($net_addr->num, 0, '');
my $last = 0;
for (my $i = 1; $net_addr <= $net_addr->broadcast; $i++, $net_addr++) {
if($last == 1) {
last;
}
my $net_addr_temp = $net_addr + 1;
if($net_addr eq $net_addr_temp) {
$last = 1;
}
for (my $i = 1; $net_addr < $net_addr->broadcast; $i++, $net_addr++) {
if ($net_addr =~ /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.(\d{1,3})\b/) {
if($1 eq '0' || $1 eq '255') {
next;
@ -228,7 +223,7 @@ for (my $i = 1; $net_addr <= $net_addr->broadcast; $i++, $net_addr++) {
# Create a new agent
$agent_id = pandora_create_agent (\%conf, $conf{'servername'}, $host_name, $addr, $target_group, 0, 11, '', 300, $dbh);
create_ipmi_modules(\%conf, $dbh, $addr, $username, $password, $agent_id);
create_ipmi_modules(\%conf, $dbh, $addr, $username, $password, $extraopts, $agent_id);
}
# Generate an event