diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 59870dccbc..62b8de0357 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150526 +Version: 6.0dev-150602 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 31a2101fa1..a3362ae49c 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150526" +pandora_version="6.0dev-150602" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 831549f32a..aef77506bd 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1,7 +1,7 @@ #!/usr/bin/perl # ********************************************************************** # Pandora FMS Generic Unix/Perl Agent -# (c) 2009-2011 Artica Soluciones Tecnológicas +# (c) 2009-2015 Artica Soluciones Tecnológicas # with the help of many people. Please see http://pandorafms.org # This code is licensed under GPL 2.0 license. # ********************************************************************** @@ -12,7 +12,7 @@ pandora_agent - Pandora FMS Agent =head1 VERSION -Version 5.0 +Version 6.0 =head1 USAGE @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150526'; +use constant AGENT_BUILD => '150602'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { @@ -132,6 +132,7 @@ my %DefaultConf = ( 'encoding' => 'UTF-8', 'server_port' => 41121, 'transfer_mode' => 'tentacle', + 'transfer_timeout' => 30, 'server_user' => 'pandora', 'server_pwd' => '', 'server_ssl' => 'no', @@ -145,6 +146,7 @@ my %DefaultConf = ( 'secondary_server_path' => '/var/spool/pandora/data_in', 'secondary_server_port' => 41121, 'secondary_transfer_mode' => 'tentacle', + 'secondary_transfer_timeout' => 30, 'secondary_server_user' => 'pandora', 'secondary_server_pwd' => '', 'secondary_server_ssl' => 'no', @@ -814,29 +816,38 @@ sub send_file { my ($file, $secondary) = @_; my $output; - if ($Conf{'transfer_mode'} eq 'tentacle') { - $output = `tentacle_client -v -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} "$file" 2>&1 >$DevNull`; - } elsif ($Conf{'transfer_mode'} eq 'ssh') { - $output = `scp -P $Conf{'server_port'} "$file" pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`; - } elsif ($Conf{'transfer_mode'} eq 'ftp') { - my $base = basename ($file); - my $dir = dirname ($file); + eval { + local $SIG{'ALRM'} = sub {die}; + alarm ($Conf{'transfer_timeout'}); + if ($Conf{'transfer_mode'} eq 'tentacle') { + $output = `tentacle_client -v -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} "$file" 2>&1 >$DevNull`; + } elsif ($Conf{'transfer_mode'} eq 'ssh') { + $output = `scp -P $Conf{'server_port'} "$file" pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`; + } elsif ($Conf{'transfer_mode'} eq 'ftp') { + my $base = basename ($file); + my $dir = dirname ($file); - $output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <&1 >$DevNull`; + $output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <&1 >$DevNull`; + } + alarm (0); + }; + + if ($@) { + $output = "File transfer command is not responding."; } # Get the errorlevel my $rc = $? >> 8; - if ($rc != 0) { + if ($rc != 0 || $@) { log_message ('error', "Error sending file '$file': $output"); } @@ -876,6 +887,7 @@ sub swap_servers () { ($Conf{'server_path'}, $Conf{'secondary_server_path'}) = ($Conf{'secondary_server_path'}, $Conf{'server_path'}); ($Conf{'server_port'}, $Conf{'secondary_server_port'}) = ($Conf{'secondary_server_port'}, $Conf{'server_port'}); ($Conf{'transfer_mode'}, $Conf{'secondary_transfer_mode'}) = ($Conf{'secondary_transfer_mode'}, $Conf{'transfer_mode'}); + ($Conf{'transfer_timeout'}, $Conf{'secondary_transfer_timeout'}) = ($Conf{'secondary_transfer_timeout'}, $Conf{'transfer_timeout'}); ($Conf{'server_user'}, $Conf{'secondary_server_user'}) = ($Conf{'secondary_server_user'}, $Conf{'server_user'}); ($Conf{'server_pwd'}, $Conf{'secondary_server_pwd'}) = ($Conf{'secondary_server_pwd'}, $Conf{'server_pwd'}); ($Conf{'server_ssl'}, $Conf{'secondary_server_ssl'}) = ($Conf{'secondary_server_ssl'}, $Conf{'server_ssl'}); @@ -889,29 +901,38 @@ sub recv_file ($) { my $file = shift; my $output; - if ($Conf{'transfer_mode'} eq 'tentacle') { - $output = `cd "$Conf{'temporal'}"$CmdSep tentacle_client -v -g -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >$DevNull` - } elsif ($Conf{'transfer_mode'} eq 'ssh') { - $output = `scp -P $Conf{'server_port'} pandora@"$Conf{'server_ip'}:$Conf{'server_path'}/$file" $Conf{'temporal'} 2>&1 >$DevNull`; - } elsif ($Conf{'transfer_mode'} eq 'ftp') { - my $base = basename ($file); - my $dir = dirname ($file); + eval { + local $SIG{'ALRM'} = sub {die}; + alarm ($Conf{'transfer_timeout'}); + if ($Conf{'transfer_mode'} eq 'tentacle') { + $output = `cd "$Conf{'temporal'}"$CmdSep tentacle_client -v -g -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >$DevNull` + } elsif ($Conf{'transfer_mode'} eq 'ssh') { + $output = `scp -P $Conf{'server_port'} pandora@"$Conf{'server_ip'}:$Conf{'server_path'}/$file" $Conf{'temporal'} 2>&1 >$DevNull`; + } elsif ($Conf{'transfer_mode'} eq 'ftp') { + my $base = basename ($file); + my $dir = dirname ($file); - $output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <&1 >$DevNull`; + $output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <&1 >$DevNull`; + } + alarm (0); + }; + + if ($@) { + $output = "File transfer command is not responding."; } # Get the errorlevel my $rc = $? >> 8; - if ($rc != 0) { + if ($rc != 0 || $@) { log_message ('error', "Error retrieving file: $output"); } diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 32f0cc85ec..b732bcfe4c 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150526 +%define release 150602 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index d2a05eaa5e..76923438e7 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150526 +%define release 150602 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index fcb9631feb..55d48d0900 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150526} +{150602} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index e5f1a8675a..cc0b604f6d 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("6.0dev(Build 150526)") +#define PANDORA_VERSION ("6.0dev(Build 150602)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 0a49c0da11..9af9dafcce 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(6.0dev(Build 150526))" + VALUE "ProductVersion", "(6.0dev(Build 150602))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 5ab1972d63..f4f0ae4843 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150527 +Version: 6.0dev-150602 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 12f90b9874..67d44f16f7 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150527" +pandora_version="6.0dev-150602" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql index 314bb4e7d7..daa8e10686 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql @@ -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', + `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'; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql index 13a42d2efb..c56620dda7 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql @@ -57,7 +57,7 @@ ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5, 0) DEFAULT 0; -- --------------------------------------------------------------------- -- Table `talert_commands` -- --------------------------------------------------------------------- -UPDATE talert_commands SET fields_descriptions = '[\"Destination address\",\"Subject\",\"Text\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]', fields_values = '[\"\",\"\",\"_html_editor_\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id = 1 AND name = 'eMail'; +UPDATE talert_commands SET fields_descriptions = '["Destination address","Subject","Text","","","","","","",""]', fields_values = '["\",\"\",\"_html_editor_\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id = 1 AND name = 'eMail'; -- --------------------------------------------------------------------- -- Table `tconfig` @@ -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', + 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'; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql index 6d6fd8eec3..04dae5f4f7 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql @@ -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\":\"\"}}', + "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', + "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'; diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php index 99d4619950..e3aa54b61b 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php @@ -309,12 +309,12 @@ if ($create_modules) { $interfaces_list = array(); foreach ($interfaces as $interface) { // Get the interface name, removing " " characters and avoid "blank" interfaces - if (isset($interface['ifName']) && $interface['ifName']['value'] != "") { - $ifname = $interface['ifName']['value']; - } - else if (isset($interface['ifDescr']) && $interface['ifDescr']['value'] != "") { + if (isset($interface['ifDescr']) && $interface['ifDescr']['value'] != "") { $ifname = $interface['ifDescr']['value']; } + else if (isset($interface['ifName']) && $interface['ifName']['value'] != "") { + $ifname = $interface['ifName']['value']; + } else { continue; } diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 71f3872fce..e93bd3df3e 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -89,7 +89,7 @@ $form_filter .= ""; $all_groups = db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); -$groups_user = users_get_groups($config['id_user'], 'AR', $all_groups); +$groups_user = users_get_groups($config['id_user'], 'LW', $all_groups); if ($groups_user === false) { $groups_user = array(); } diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index c081dad769..a59187116c 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -112,7 +112,7 @@ if (is_ajax ()) { // if group ID doesn't matter and $privilege is specified (like 'AW'), // retruns all agents that current user has $privilege privilege for. $agents = agents_get_group_agents( - array_keys (users_get_groups ($config["id_user"], $privilege, false))); + array_keys (users_get_groups ($config["id_user"], $privilege, false)),$filter,"none",false,$recursion); } else { $agents = agents_get_group_agents($id_group, $filter, "none", diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index e0196e4cbc..38c986022e 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -33,30 +33,30 @@ $tab = (string) get_parameter ('tab', 'massive_agents'); $option = (string) get_parameter ('option', ''); $options_alerts = array( - 'add_alerts' => __('Massive alerts addition'), - 'delete_alerts' => __('Massive alerts deletion'), - 'add_action_alerts' => __('Massive alert actions addition'), - 'delete_action_alerts' => __('Massive alert actions deletion'), - 'enable_disable_alerts' => __('Massive alert enable/disable'), - 'standby_alerts' => __('Massive alert setting standby')); + 'add_alerts' => __('Bulk alert add'), + 'delete_alerts' => __('Bulk alert delete'), + 'add_action_alerts' => __('Bulk alert actions add'), + 'delete_action_alerts' => __('Bulk alert actions delete'), + 'enable_disable_alerts' => __('Bulk alert enable/disable'), + 'standby_alerts' => __('Bulk alert setting standby')); $options_agents = array( - 'edit_agents' => __('Massive agents edition'), - 'delete_agents' => __('Massive agents deletion')); + 'edit_agents' => __('Bulk agent edit'), + 'delete_agents' => __('Bulk agent delete')); if (check_acl ($config['id_user'], 0, "PM")) { $options_users = array( - 'add_profiles' => __('Massive profiles addition'), - 'delete_profiles' => __('Massive profiles deletion')); + 'add_profiles' => __('Bulk profile add'), + 'delete_profiles' => __('Bulk profile delete')); } else { $options_users = array(); } $options_modules = array( - 'delete_modules' => __('Massive modules deletion'), - 'edit_modules' => __('Massive modules edition'), - 'copy_modules' => __('Massive modules copy')); + 'delete_modules' => __('Bulk module delete'), + 'edit_modules' => __('Bulk module edit'), + 'copy_modules' => __('Bulk module copy')); if (! check_acl ($config['id_user'], 0, "PM")) { unset($options_modules['edit_modules']); diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 0e1b39b6bf..537227ffc4 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -99,7 +99,7 @@ if (check_acl ($config['id_user'], 0, "PM")) { } enterprise_hook('agents_submenu'); if (check_acl ($config['id_user'], 0, "AW")) { - $sub["gmassive"]["text"] = __('Massive operations'); + $sub["gmassive"]["text"] = __('Bulk operations'); $sub["gmassive"]["type"] = "direct"; $sub["gmassive"]["subtype"] = "nolink"; $sub2 = array (); diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 0eaebc493d..4d99fcb96c 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -524,6 +524,9 @@ switch ($action) { break; default: if (enterprise_installed()) { + if ($image !== null) { + $values['image'] = $image; + } enterprise_ajax_update_values($action, $type, $values); } break; diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 03cd621192..da57c157a3 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150527'; +$build_version = 'PC150602'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/db/oracle.php b/pandora_console/include/db/oracle.php index b12d4674f0..0ff02a36f6 100644 --- a/pandora_console/include/db/oracle.php +++ b/pandora_console/include/db/oracle.php @@ -14,7 +14,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -function oracle_connect_db($host = null, $db = null, $user = null, $pass = null, $port = null) { +function oracle_connect_db($host = null, $db = null, $user = null, $pass = null, $port = null, $new_connection = true) { global $config; if ($host === null) @@ -30,7 +30,11 @@ function oracle_connect_db($host = null, $db = null, $user = null, $pass = null, // Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems // If you want persistent connections change it to oci_pconnect(). - $connect_id = oci_new_connect($user, $pass, '//' . $host . ':' . $port . '/' . $db); + if ($new_connection) + $connect_id = oci_new_connect($user, $pass, '//' . $host . ':' . $port . '/' . $db); + else + $connect_id = oci_connect($user, $pass, '//' . $host . ':' . $port . '/' . $db); + if (! $connect_id) { return false; } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index abb2348bd3..4421841f45 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -464,29 +464,19 @@ function human_time_description_raw ($seconds, $exactly = false, $units = 'large $returnTime .= "$hours $hoursString "; } - $mins = floor($seconds / SECONDS_1MINUTE); + $mins = floor($seconds / 60); if ($mins != 0) { - $seconds = $seconds - ($mins * SECONDS_1MINUTE); + $seconds = $seconds - ($mins * 60); + + $returnTime .= "$mins $minutesString "; - if ($hours == 0) { - $returnTime .= "$mins $minutesString "; - } - else { - $returnTime = sprintf("%02d",$hours) . ':' . - sprintf("%02d",$mins); - } } + $seconds = (int) $seconds; + if ($seconds != 0) { - if ($hours == 0) { - $returnTime .= "$seconds $secondsString "; - } - else { - $returnTime = sprintf("%02d",$hours) . ':' . - sprintf("%02d",$mins) . ':' . - sprintf("%02d",$seconds); - } + $returnTime .= "$seconds $secondsString "; } $return = ' '; @@ -1507,7 +1497,7 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', switch ($snmp3_security_level) { case "authNoPriv": $command_str = $snmpwalk_bin . - ' -m ALL -v 3' . + ' -m ALL -Oa -v 3' . ' -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . @@ -1518,7 +1508,7 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', break; case "noAuthNoPriv": $command_str = $snmpwalk_bin . - ' -m ALL -v 3' . + ' -m ALL -Oa -v 3' . ' -u ' . escapeshellarg($snmp3_auth_user) . ' -l ' . escapeshellarg($snmp3_security_level) . ' ' . escapeshellarg($ip_target) . @@ -1527,7 +1517,7 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', break; default: $command_str = $snmpwalk_bin . - ' -m ALL -v 3' . + ' -m ALL -Oa -v 3' . ' -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . @@ -1544,7 +1534,7 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', case '2c': case '1': default: - $command_str = $snmpwalk_bin . ' -m ALL -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir; + $command_str = $snmpwalk_bin . ' -m ALL -Oa -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir; break; } @@ -2386,6 +2376,17 @@ function set_unless_defined (&$var, $default) { } } +function set_when_empty (&$var, $default) { + if (empty($var)) { + $var = $default; + + return true; + } + else { + return false; + } +} + function sort_by_column (&$array_ref, $column) { if (!empty($column)) { usort($array_ref, function ($a, $b) { diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 540df57070..9e6f11b989 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -845,7 +845,8 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower $filter[] = "(critical_count = 0 AND warning_count = 0 AND unknown_count > 0)"; break; case AGENT_STATUS_NOT_NORMAL: - $filter[] = "normal_count <> total_count"; + $filter[] = "normal_count <> total_count + AND critical_count = 0 AND warning_count = 0"; break; case AGENT_STATUS_NOT_INIT: $filter[] = "notinit_count = total_count"; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 2bcde75172..5207ba9ef8 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -747,6 +747,11 @@ function reporting_SLA($report, $content, $type = 'dinamic', } if (modules_is_disable_agent($sla['id_agent_module'])) { + if (($config ['metaconsole'] == 1) && defined('METACONSOLE')) { + //Restore db connection + metaconsole_restore_db(); + } + continue; } @@ -3712,6 +3717,11 @@ function reporting_availability($report, $content) { } if (modules_is_disable_agent($item['id_agent_module'])) { + //Restore dbconnection + if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + metaconsole_restore_db(); + } + continue; } @@ -3755,12 +3765,11 @@ function reporting_availability($report, $content) { $percent_ok = 0; } else { - $count_fails = count( - modules_get_data_with_value( - $item['id_agent_module'], - $report["datetime"] - $content['period'], - $report["datetime"], - 0, true)); + $count_fails = modules_get_count_data_with_value( + $item['id_agent_module'], + $report["datetime"] - $content['period'], + $report["datetime"], + 0); $percent_ok = (($count_checks - $count_fails) * 100) / $count_checks; $percent_fail = 100 - $percent_ok; diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php index b86133c10c..1c03d65912 100755 --- a/pandora_console/include/functions_update_manager.php +++ b/pandora_console/include/functions_update_manager.php @@ -497,18 +497,20 @@ function update_manager_set_current_package($current_package) { $token = 'current_package'; } - $value = db_get_value('`value`', - 'tupdate_settings', '`key`', $token); + $col_value = db_encapsule_fields_with_same_name_to_instructions('value'); + $col_key = db_encapsule_fields_with_same_name_to_instructions('key'); + + $value = db_get_value($col_value, + 'tupdate_settings', $col_key, $token); if ($value === false) { db_process_sql_insert('tupdate_settings', - array('`value`' => $current_package, - '`key`' => $token)); + array($col_value => $current_package, $col_key => $token)); } else { db_process_sql_update('tupdate_settings', - array('`value`' => $current_package), - array('`key`' => $token)); + array($col_value => $current_package), + array($col_key => $token)); } } diff --git a/pandora_console/install.php b/pandora_console/install.php index f53beae01d..ea8ab9fd5d 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@
'comentarios', + 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); + break; + case 'down': + $selectLastContactDown = $selected; + $order = array('field' => 'comentarios', + 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); + break; + } + break; default: $selectNameUp = $selected; $selectNameDown = ''; @@ -432,7 +446,10 @@ $table->head[0] = __('Agent'). ' ' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; $table->size[0] = "10%"; -$table->head[1] = __('Description'); +$table->head[1] = __('Description'). ' ' . + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; + $table->size[1] = "30%"; $table->head[2] = __('OS'). ' ' . diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 53398fd099..53655cb660 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -302,17 +302,17 @@ $tag_with_temp = array(); $tag_without_temp = array(); foreach ($tags as $id_tag => $tag) { if (array_search($id_tag, $tag_with) === false) { - $tags_select_with[$id_tag] = $tag; + $tags_select_with[$id_tag] = ui_print_truncate_text ($tag, 16, false); } else { - $tag_with_temp[$id_tag] = $tag; + $tag_with_temp[$id_tag] = ui_print_truncate_text ($tag, 16, false); } if (array_search($id_tag, $tag_without) === false) { - $tags_select_without[$id_tag] = $tag; + $tags_select_without[$id_tag] = ui_print_truncate_text ($tag, 16, false); } else { - $tag_without_temp[$id_tag] = $tag; + $tag_without_temp[$id_tag] = ui_print_truncate_text ($tag, 16, false); } } @@ -372,23 +372,13 @@ if (defined('METACONSOLE')) { $tabletags_without->styleTable = 'border: 0px;'; $data = array(); -if (!defined("METACONSOLE")) - $data[0] = html_print_select ($tags_select_without, 'select_without', '', '', '', 0, - true, true, true, '', false, 'width: 120px; height: 70px;') . '
'; -else - $data[0] = html_print_select ($tags_select_without, 'select_without', '', '', '', 0, - true, true, true, '', false, 'width: auto; height: 70px;') . '
'; - +$data[0] = html_print_select ($tags_select_without, 'select_without', '', '', '', 0, + true, true, true, '', false, 'width: 200px; height: 70px;') . '
'; $data[1] = html_print_image('images/darrowright.png', true, array('id' => 'button-add_without', 'style' => 'cursor: pointer;', 'title' => __('Add'))); $data[1] .= html_print_input_hidden('tag_without', $tag_without_base64, true); $data[1] .= '

' . html_print_image('images/darrowleft.png', true, array('id' => 'button-remove_without', 'style' => 'cursor: pointer;', 'title' => __('Remove'))); - -if (!defined("METACONSOLE")) - $data[2] = html_print_select ($tag_without_temp, 'tag_without_temp', array(), '', '', - 0, true, true, true, '', false, "width: 120px; height: 70px;"); -else - $data[2] = html_print_select ($tag_without_temp, 'tag_without_temp', array(), '', '', - 0, true, true, true, '', false, "width: auto; height: 70px;"); +$data[2] = html_print_select ($tag_without_temp, 'tag_without_temp', array(), '', '', + 0, true, true, true, '', false, "width: 200px; height: 70px;"); $tabletags_without->data[] = $data; $tabletags_without->rowclass[] = ''; diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index d769a10d96..c29fed8b26 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 6.0dev -%define release 150526 +%define release 150602 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index f24f0eabd8..0914099423 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 6.0dev -%define release 150526 +%define release 150602 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.data.oracle.sql b/pandora_console/pandoradb.data.oracle.sql index 2b1cd379ef..d77f8239ab 100644 --- a/pandora_console/pandoradb.data.oracle.sql +++ b/pandora_console/pandoradb.data.oracle.sql @@ -1317,7 +1317,7 @@ LOCK TABLE trecon_script IN EXCLUSIVE MODE; EXECUTE IMMEDIATE 'ALTER TRIGGER trecon_script_inc DISABLE'; -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":""}}'); @@ -1334,7 +1334,7 @@ LOCK TABLE tplugin IN EXCLUSIVE MODE; EXECUTE IMMEDIATE 'ALTER TRIGGER tplugin_inc DISABLE'; -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_'); INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (3,'UDP port check','Check a remote UDP port (by using NMAP). Use IP address and Port options.',5,'/usr/share/pandora_server/util/plugin/udp_nmap_plugin.sh',0,'{1:{macro:"_field1_",desc:Target IP,help:"",value:""},2:{macro:"_field2_",desc:Port,help:"",value:""}}','-t _field1_-p _field2_'); INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (4,'SMTP Check','This plugin is used to send a mail to a SMTP server and check if works. Parameters in the plugin: IP Address - SMTP Server IP address User - AUTH login Pass - AUTH password Port - SMTP port (optional) Optional parameters: -d Destination email -f Email of the sender -a Authentication system. Could be LOGIN, PLAIN, CRAM-MD5 or DIGEST-MD',10,'/usr/share/pandora_server/util/plugin/SMTP_check.pl',0,'{1:{macro:"_field1_",desc:Target IP,help:"",value:""},2:{macro:"_field2_",desc:Port,help:"",value:""},3:{macro:"_field3_",desc:Username,help:"",value:""},4:{macro:"_field4_",desc:Password,help:"",value:""},5:{macro:"_field5_",desc:Optional parameters,help:"",value:""}}','-h _field1_ -o _field2_ -u _field3_ -p _field4_ _field5_'); diff --git a/pandora_console/pandoradb.data.postgreSQL.sql b/pandora_console/pandoradb.data.postgreSQL.sql index 8abccd16c4..71f6d3a6ec 100644 --- a/pandora_console/pandoradb.data.postgreSQL.sql +++ b/pandora_console/pandoradb.data.postgreSQL.sql @@ -1018,11 +1018,11 @@ INSERT INTO "treport_custom_sql" ("id", "name", "sql") VALUES (3, 'Monitoring&#x 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)'); SELECT setval('treport_custom_sql_id_seq', (SELECT (SELECT MAX(id) FROM treport_custom_sql))); -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_'),(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_'),(3,'UDP port check','Check a remote UDP port (by using NMAP). Use IP address and Port options.',5,'/usr/share/pandora_server/util/plugin/udp_nmap_plugin.sh',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Port","help":"","value":""}}','-t _field1_-p _field2_'),(4,'SMTP Check','This plugin is used to send a mail to a SMTP server and check if works. Parameters in the plugin: IP Address - SMTP Server IP address User - AUTH login Pass - AUTH password Port - SMTP port (optional) Optional parameters: -d Destination email -f Email of the sender -a Authentication system. Could be LOGIN, PLAIN, CRAM-MD5 or DIGEST-MD',10,'/usr/share/pandora_server/util/plugin/SMTP_check.pl',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Port","help":"","value":""},"3":{"macro":"_field3_","desc":"Username","help":"","value":""},"4":{"macro":"_field4_","desc":"Password","help":"","value":""},"5":{"macro":"_field5_","desc":"Optional parameters","help":"","value":""}}','-h _field1_ -o _field2_ -u _field3_ -p _field4_ _field5_'), (6,'MySQL Plugin','Samples: ./mysql_plugin.sh -u root -p none -s localhost -q Com_select ./mysql_plugin.sh -u root -p none -s localhost -q Com_update ./mysql_plugin.sh -u root -p none -s localhost -q Connections ./mysql_plugin.sh -u root -p anypass -s 192.168.50.24 -q Innodb_rows_read ',15,'/usr/share/pandora_server/util/plugin/mysql_plugin.sh',0,'{"1":{"macro":"_field1_","desc":"IP address","help":"IP address","value":""},"2":{"macro":"_field2_","desc":"Username","help":"Username to access to database","value":""},"3":{"macro":"_field3_","desc":"Password","help":"Password to access to database","value":""},"4":{"macro":"_field4_","desc":"Query string","help":"Query string of global status. For example 'Aborted_connects' or 'Innodb_rows_read'","value":""}}', '-s _field1_ -u _field2_ -p _field3_ -q _field4_'), (8,'SNMP remote','Plugin that gets remotely, using SNMP, values such as the percentage of disk or memory used, the status of a process or the CPU load',0,'perl /usr/share/pandora_server/util/plugin/snmp_remote.pl',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":"_address_"},"2":{"macro":"_field2_","desc":"Community","help":"","value":"public"},"3":{"macro":"_field3_","desc":"Plug-in Parameters","help":"Memory use (%) -m memuse Disk use (%) -m diskuse -d [disk name] Status of a process (0/1) -m process -p [process_name] Average of CPUs Load (%) -m cpuload","value":""}}', '-H _field1_ -c _field2_ _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_'),(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_'),(3,'UDP port check','Check a remote UDP port (by using NMAP). Use IP address and Port options.',5,'/usr/share/pandora_server/util/plugin/udp_nmap_plugin.sh',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Port","help":"","value":""}}','-t _field1_-p _field2_'),(4,'SMTP Check','This plugin is used to send a mail to a SMTP server and check if works. Parameters in the plugin: IP Address - SMTP Server IP address User - AUTH login Pass - AUTH password Port - SMTP port (optional) Optional parameters: -d Destination email -f Email of the sender -a Authentication system. Could be LOGIN, PLAIN, CRAM-MD5 or DIGEST-MD',10,'/usr/share/pandora_server/util/plugin/SMTP_check.pl',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Port","help":"","value":""},"3":{"macro":"_field3_","desc":"Username","help":"","value":""},"4":{"macro":"_field4_","desc":"Password","help":"","value":""},"5":{"macro":"_field5_","desc":"Optional parameters","help":"","value":""}}','-h _field1_ -o _field2_ -u _field3_ -p _field4_ _field5_'), (6,'MySQL Plugin','Samples: ./mysql_plugin.sh -u root -p none -s localhost -q Com_select ./mysql_plugin.sh -u root -p none -s localhost -q Com_update ./mysql_plugin.sh -u root -p none -s localhost -q Connections ./mysql_plugin.sh -u root -p anypass -s 192.168.50.24 -q Innodb_rows_read ',15,'/usr/share/pandora_server/util/plugin/mysql_plugin.sh',0,'{"1":{"macro":"_field1_","desc":"IP address","help":"IP address","value":""},"2":{"macro":"_field2_","desc":"Username","help":"Username to access to database","value":""},"3":{"macro":"_field3_","desc":"Password","help":"Password to access to database","value":""},"4":{"macro":"_field4_","desc":"Query string","help":"Query string of global status. For example 'Aborted_connects' or 'Innodb_rows_read'","value":""}}', '-s _field1_ -u _field2_ -p _field3_ -q _field4_'), (8,'SNMP remote','Plugin that gets remotely, using SNMP, values such as the percentage of disk or memory used, the status of a process or the CPU load',0,'perl /usr/share/pandora_server/util/plugin/snmp_remote.pl',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":"_address_"},"2":{"macro":"_field2_","desc":"Community","help":"","value":"public"},"3":{"macro":"_field3_","desc":"Plug-in Parameters","help":"Memory use (%) -m memuse Disk use (%) -m diskuse -d [disk name] Status of a process (0/1) -m process -p [process_name] Average of CPUs Load (%) -m cpuload","value":""}}', '-H _field1_ -c _field2_ _field3_'); INSERT INTO "tagent_custom_fields" VALUES (1,'Serial Number',0),(2,'Department',0),(3,'Additional ID',0); diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 9a1462fd82..a42d95e954 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -38,7 +38,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('graph_res','5'), ('step_compact','1'), ('db_scheme_version','6.0dev'), -('db_scheme_build','PD150526'), +('db_scheme_build','PD150602'), ('show_unknown','0'), ('show_lastalerts','1'), ('style','pandora'), @@ -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_'); diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 9cb14152ea..614c0c8dc6 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 6.0dev-150526 +Version: 6.0dev-150602 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 61dbcb53ec..a5559b7b34 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150526" +pandora_version="6.0dev-150602" package_cpan=0 package_pandora=1 diff --git a/pandora_server/bin/tentacle_server b/pandora_server/bin/tentacle_server index 6e888bd713..b7cd6c0961 100755 --- a/pandora_server/bin/tentacle_server +++ b/pandora_server/bin/tentacle_server @@ -30,7 +30,7 @@ tentacle_server - Tentacle Server =head1 VERSION -Version 0.4.0 +Version 0.5.0 =head1 USAGE @@ -86,8 +86,11 @@ my $SOCKET_MODULE = # Service name for Win32. my $SERVICE_NAME="Tentacle Server"; +# Service parameters. +my $SERVICE_PARAMS=join(' ', @ARGV); + # Program version -our $VERSION = '0.4.0'; +our $VERSION = '0.5.0'; # IPv4 address to listen on my @t_addresses = ('0', '0.0.0.0'); @@ -139,7 +142,9 @@ my $t_sem :shared; # Server socket my @t_server_sockets; -my $select; + +# Server select handler +my $t_server_select; # Use SSL, 1 true, 0 false my $t_ssl = 0; @@ -159,10 +164,10 @@ my $t_ssl_pwd = ''; # Timeout for socket read/write operations in seconds my $t_timeout = 1; -#Bridge IP to actuate as a proxy +# Address to proxy client requests to my $t_proxy_ip = undef; -# Proxy port by default 41121 +# Port to proxy client requests to my $t_proxy_port = 41121; # Proxy socket @@ -189,7 +194,7 @@ sub print_help { print ("Tentacle server v$VERSION. See http://www.openideas.info/wiki for protocol description.\n\n"); print ("Options:\n"); print ("\t-a ip_addresses\tIP addresses to listen on (default @t_addresses).\n"); - print ("\t\t(Multiple addresses separated by comma can be defined.)\n"); + print ("\t \t(Multiple addresses separated by comma can be defined.)\n"); print ("\t-c number\tMaximum number of simultaneous connections (default $t_max_conn).\n"); print ("\t-d\t\tRun as daemon.\n"); print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n"); @@ -206,11 +211,11 @@ sub print_help { print ("\t-t time\t\tTime-out for network operations in seconds (default ${t_timeout}s).\n"); print ("\t-v\t\tBe verbose.\n"); print ("\t-w\t\tPrompt for OpenSSL private key password.\n"); - print ("\t-x pwd\t\tServer password.\n\n"); - print ("\t-b proxy_ip_address\t\tProxied server address.\n\n"); - print ("\t-g proxy_port\t\tPort of proxied server.\n\n"); + print ("\t-x pwd\t\tServer password.\n"); + print ("\t-b ip_address\tProxy requests to the given address.\n"); + print ("\t-g port\t\tProxy requests to the given port.\n"); print ("\t-T\t\tEnable tcpwrappers support.\n"); - print ("\t\t(To use this option, 'Authen::Libwrap' should be installed.)\n\n"); + print ("\t \t\t(To use this option, 'Authen::Libwrap' should be installed.)\n\n"); } ################################################################################ @@ -261,6 +266,23 @@ sub parse_options { exit 1; } + # The Win32 service must be installed/uninstalled without checking other parameters. + if (defined ($opts{'S'})) { + my $service_action = $opts{'S'}; + if ($^O ne 'MSWin32') { + error ("Windows services are only available on Win32."); + } else { + eval "use Win32::Daemon"; + die($@) if ($@); + + if ($service_action eq 'install') { + install_service(); + } elsif ($service_action eq 'uninstall') { + uninstall_service(); + } + } + } + # Address if (defined ($opts{'a'})) { @t_addresses = (); @@ -462,11 +484,7 @@ sub parse_options { eval "use Win32::Daemon"; die($@) if ($@); - if ($service_action eq 'install') { - install_service(); - } elsif ($service_action eq 'uninstall') { - uninstall_service(); - } elsif ($service_action eq 'run') { + if ($service_action eq 'run') { Win32::Daemon::RegisterCallbacks({ start => \&callback_start, running => \&callback_running, @@ -483,9 +501,9 @@ sub parse_options { ################################################################################ ## SUB start_proxy -## Open the server socket. +## Open the proxy server socket. ################################################################################ -sub open_proxy { +sub start_proxy { # Connect to server $t_proxy_socket = $SOCKET_MODULE->new ( @@ -498,8 +516,8 @@ sub open_proxy { } # Create proxy selector - $t_proxy_select = IO::Select->new (); - $t_proxy_select->add ($t_proxy_socket); + $t_proxy_select = IO::Select->new (); + $t_proxy_select->add ($t_proxy_socket); } @@ -538,11 +556,11 @@ sub start_server { if (!@t_server_sockets) { error ("Cannot open socket for all addresses on port $t_port: $!."); - } + } - $select = IO::Select->new(); + $t_server_select = IO::Select->new(); foreach my $t_server_socket (@t_server_sockets){ - $select->add($t_server_socket); + $t_server_select->add($t_server_socket); } } @@ -602,8 +620,6 @@ sub send_data_proxy { sub close_proxy { $t_proxy_socket->shutdown (2); $t_proxy_socket->close (); - print_log ("Proxy socket closed"); - } ################################################################################ @@ -668,6 +684,9 @@ sub accept_connections { my $pid; my $t_server_socket; + # Ignore SIGPIPE errors (happens on FreeBSD when SSL is enabled ¿?) + $SIG{PIPE} = 'IGNORE'; + # Start server start_server (); @@ -675,7 +694,7 @@ sub accept_connections { $t_sem = Thread::Semaphore->new ($t_max_conn); while (1) { - my @ready = $select->can_read; + my @ready = $t_server_select->can_read; foreach $t_server_socket (@ready) { # Accept connection @@ -749,40 +768,25 @@ sub serve_client() { ## Actuate as a proxy between its client and other tentacle server. ################################################################################ sub serve_proxy_connection { - my $read; - my $data=1; - # Start a connection with the other Tentacle Server - open_proxy(); - - my $command; + # We are a proxy! Start a connection to the Tentacle Server. + start_proxy(); - # Read commands - while ($command = recv_command ($t_block_size)) { - # Client wants to send a file - if ($command =~ /^SEND <(.*)> SIZE (\d+)$/) { - recv_file_proxy($command, $2); + # Forward data between the client and the server. + eval { + while (1) { + if ($t_select->can_read(0)) { + my ($read, $data) = recv_data($t_block_size); + send_data_proxy($data); + } + if ($t_proxy_select->can_read(0)) { + my ($read, $data) = recv_data_proxy($t_block_size); + send_data($data); + } } - # Client wants to receive a file - elsif ($command =~ /^RECV <(.*)>$/) { - send_file_proxy ($command); - } - # Quit - elsif ($command =~ /^QUIT$/) { - print_log ("Connection closed from " . $t_client_socket->sockhost ()); - - # End proxy connection - send_data_proxy("QUIT\n"); - last; - } - # Unknown command - else { - print_log ("Unknown command '$command' from " . $t_client_socket->sockhost ()); - last; - } - } + }; - # End a connection with the other Tentacle Server + # Close the connection to the Tentacle Server. close_proxy(); } @@ -848,43 +852,6 @@ sub auth_pwd { send_data ("PASS OK\n"); } -################################################################################ -## SUB recv_file_proxy -## Redirect file from agent to proxy -################################################################################ -sub recv_file_proxy ($$) { - my ($command, $size) = @_; - - # Send command to proxy - print_log ("[PROXY] Host: ".$t_client_socket->sockhost()." send ".$command." to ".$t_proxy_socket->sockhost ()); - send_data_proxy($command."\n"); - - # Proxied server response - my $rc = dump_data($t_proxy_socket, $t_client_socket); - - # Check if there was an error - if ($rc == -1) { - return; - } - - # Client send data to server - $rc = dump_data($t_client_socket, $t_proxy_socket, $size); - - # Check if there was an error - if ($rc == -1) { - return; - } - - # Server says if data was recieved or not - $rc = dump_data($t_proxy_socket, $t_client_socket); - - # Check if there was an error - if ($rc == -1) { - return; - } - -} - ################################################################################ ## SUB recv_file ## Receive a file of size $_[1] and save it in $t_directory as $_[0]. @@ -934,45 +901,6 @@ sub recv_file { print_log ("Received file '$base_name' size ${size}b from " . $t_client_socket->sockhost ()); } -################################################################################ -## SUB send_file_proxy -## Redirect file from agent to proxy -################################################################################ -sub send_file_proxy ($) { - my ($command) = @_; - my $size; - # Send command to proxy - print_log ("[PROXY] ".$t_client_socket->sockhost()." send ".$command." to ".$t_proxy_socket->sockhost ()); - send_data_proxy($command."\n"); - - $command = recv_command_proxy($t_block_size); - - if ($command =~ /^RECV SIZE (\d+)$/) { - $size = $1; - } - - print_log ("[PROXY] ".$t_proxy_socket->sockhost()." send ".$command." to ".$t_client_socket->sockhost ()); - - send_data($command."\n"); - - # Client send OK to server - my $rc = dump_data($t_client_socket, $t_proxy_socket); - - # Check if there was an error - if ($rc == -1) { - return; - } - - # Proxied server send the file to client - $rc = dump_data($t_proxy_socket, $t_client_socket, $size); - - # Check if there was an error - if ($rc == -1) { - return; - } - -} - ################################################################################ ## SUB send_file ## Send a file to the client @@ -1181,127 +1109,6 @@ sub send_data { } } -################################################################################ -## SUB dump_data -## Dump data from a socket to another one. Following Tentacle Protocol. -################################################################################ -sub dump_data($$;$) { - my ($from, $to, $size) = @_; - my $read; - my $data; - my $buffer = ""; - my $written; - my $total = $size; - my $t_select_read = undef; - my $t_select_write = undef; - - # Assign the correct selector for each socket - if ($from == $t_proxy_socket) { - # We must read from t_proxy_socket - $t_select_read = $t_proxy_select; - $t_select_write = $t_select; - } else { - # We must read from t_client_socket - $t_select_read = $t_select; - $t_select_write = $t_proxy_select; - } - - while (1) { - - # Ensure we can read from socket - if ($t_select_read->can_read()) { - # Ensure we can write from socket - if ($t_select_write->can_write()) { - - $read = ""; - $read = sysread ($from, $data, $t_block_size); - - # Read error - if (! defined ($read)) { - error ("Read error from " . $from->sockhost () . ": $!."); - return -1; - } - - # EOF - if ($read == 0) { - error ("Connection from " . $from->sockhost () . " unexpectedly closed."); - return -1; - } - - $written = syswrite ($to, $data, $read); - - if ($written != $read) { - error ("Connection from " . $to->sockhost () . " unexpectedly closed."); - return -1; - } - - $buffer .= $data; - - if (! defined ($size)) { - # If no size defined check for \n - # because a command was sent. - - if ($buffer =~ /\n$/) { - - # Delete CHAR \n - chop($buffer); - - print_log ("[PROXY] ".$from->sockhost()." send ".$buffer." to ".$to->sockhost ()); - - # Returns error if proxy returns error to end connection - if ($buffer =~ /SEND ERR/) { - return -1; - } else { - return 0; - } - } - } else { - # If size is defined check if all bytes were sent - $size = $size - $read; - - if ($size == 0) { - print_log ("[PROXY] ".$from->sockhost()." send ".$total."b to ".$to->sockhost()); - - return 0; - } - } - } - } - } -} - -################################################################################ -## SUB recv_command_proxy -## Read a command from the proxied server, ended by a new line character. -################################################################################ -sub recv_command_proxy { - my $buffer; - my $char; - my $command = ''; - my $read; - my $total = 0; - - while (1) { - - ($read, $buffer) = recv_data_proxy ($t_block_size); - $command .= $buffer; - $total += $read; - - # Check if the command is complete - $char = chop ($command); - if ($char eq "\n") { - return $command; - } - - $command .= $char; - - # Avoid overflow - if ($total > $t_block_size) { - error ("Received too much data from " . $t_proxy_socket->sockhost () . "."); - } - } -} - ################################################################################ ## SUB recv_command ## Read a command from the client, ended by a new line character. @@ -1419,7 +1226,10 @@ sub apply_filters ($) { sub install_service() { my $service_path = $0; - my $service_params = "-s \"$t_directory\" -S run"; + my $service_params = $SERVICE_PARAMS; + + # Change the service parameter from 'install' to 'run'. + $service_params =~ s/\-S\s+\S+/\-S run/; my %service_hash = ( machine => '', diff --git a/pandora_server/bin/tentacle_server.exe b/pandora_server/bin/tentacle_server.exe index 84128b70eb..b92652bd7b 100644 Binary files a/pandora_server/bin/tentacle_server.exe and b/pandora_server/bin/tentacle_server.exe differ diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index dbc2cf8d39..da391bf64c 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -43,7 +43,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "6.0dev"; -my $pandora_build = "150526"; +my $pandora_build = "150602"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index c412f4530e..6be6306742 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 6.0dev -%define release 150526 +%define release 150602 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 8cdf75df76..8e60889b56 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 6.0dev -%define release 150526 +%define release 150602 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 0b52fc31e4..147307eff7 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -33,7 +33,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; # version: define current version -my $version = "6.0dev PS150526"; +my $version = "6.0dev PS150602"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 0d5def5807..2d86b2b458 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -35,7 +35,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "6.0dev PS150526"; +my $version = "6.0dev PS150602"; # save program name for logging my $progname = basename($0); diff --git a/pandora_server/util/plugin/ipmi-plugin.pl b/pandora_server/util/plugin/ipmi-plugin.pl index c0991f91c6..fc954e84a5 100755 --- a/pandora_server/util/plugin/ipmi-plugin.pl +++ b/pandora_server/util/plugin/ipmi-plugin.pl @@ -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,16 +45,24 @@ 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 $cmd = "ipmi-sensors -h $host -u $user -p $pass -s $sensor $extraopts --ignore-not-available-sensors --no-header-output --comma-separated-output --output-event-bitmask"; +my $res = `$cmd`; -my @aux = split(/\|/, $res); +if (defined $res and "$res" ne "") { + my ($sensor_id, $name, $type, $value, $units, $eventmask) = split(/,/, $res); -my $value = $aux[3]; - -$value =~ s/\n//; -$value =~ s/^\s+//; -$value =~ s/\s+$//; - -#Output the value -print $value; + #Output the value + if ($value eq 'N/A') { + if ($eventmask =~ /([0-9A-Fa-f]+)h/) { + print hex $1; + } else { + print $eventmask; + } + } else { + print $value; + } +} else { + print STDERR "Error processing command: $cmd\n"; +} diff --git a/pandora_server/util/recon_scripts/ipmi-recon.pl b/pandora_server/util/recon_scripts/ipmi-recon.pl index ce9c2f6ae1..7f1e3f6393 100644 --- a/pandora_server/util/recon_scripts/ipmi-recon.pl +++ b/pandora_server/util/recon_scripts/ipmi-recon.pl @@ -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,7 +44,60 @@ 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 +# Map Sensor type to module type and thresholds +# 0 = numeric, record has thresholds +# 1 = simple flag, 0 normal, > 0 critical +# 2 = complex flags, for now ignore alert settings +# 3 = string or unknown +my %sensor_types = ( + 'Temperature' => 0, + 'Voltage' => 0, + 'Current' => 0, + 'Fan' => 0, + 'Physical Security' => 1, + 'Platform Security Violation Attempt' => 1, + 'Processor' => 2, + 'Power Supply' => 2, + 'Power Unit' => 2, + 'Cooling Device' => 0, + 'Other Units Based Sensor' => 0, + 'Memory' => 2, + 'Drive Slot' => 3, + 'POST Memory Resize' => 3, + 'System Firmware Progress' => 1, + 'Event Logging Disabled' => 2, + 'Watchdog 1' => 2, + 'System Event' => 2, + 'Critical Interrupt' => 1, + 'Button Switch' => 2, + 'Module Board' => 3, + 'Microcontroller Coprocessor' => 3, + 'Add In Card' => 3, + 'Chassis' => 3, + 'Chip Set' => 3, + 'Other Fru' => 3, + 'Cable Interconnect' => 3, + 'Terminator' => 3, + 'System Boot Initiated' => 2, + 'Boot Error' => 1, + 'OS Boot' => 2, + 'OS Critical Stop' => 1, + 'Slot Connector' => 2, + 'System ACPI Power State' => 2, + 'Watchdog 2' => 2, + 'Platform Alert' => 2, + 'Entity Presence' => 2, + 'Monitor ASIC IC' => 3, + 'LAN' => 2, + 'Management Subsystem Health' => 1, + 'Battery' => 2, + 'Session Audit' => 3, + 'Version Change' => 3, + 'FRU State' => 3, + 'OEM Reserved' => 3 +); ########################################################################## # Update recon task status. @@ -62,10 +115,11 @@ sub show_help { print "\nSpecific Pandora FMS Intel DCM Discovery\n"; print "(c) Artica ST 2011 \n\n"; print "Usage:\n\n"; - print " $0 \n\n"; + print " $0 \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; } @@ -81,65 +135,91 @@ sub ipmi_ping ($$$) { my $res = `$cmd`; - if ($res =~ /100\.0% packet loss/) { - return 0; - } - - return 1; + if ($res =~ / (\d+\.\d+)% packet loss/) { + if ($1 ne '100.0') { + return 1; + } + } + + return 0; } -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 --ignore-not-available-sensors --no-header-output --comma-separated-output --non-abbreviated-units --output-sensor-thresholds --output-event-bitmask"; - my $res = `$cmd`; + my $res = `$cmd`; my @lines = split(/\n/, $res); my $ipmi_plugin_id = get_db_value($dbh, "SELECT id FROM tplugin WHERE name = '".safe_input("IPMI Plugin")."'"); - - for(my $i=1; $i < $#lines; $i++) { + for (my $i=0; $i <= $#lines; $i++) { my $line = $lines[$i]; - my @aux = split(/\|/, $line); + my ($sensor, $name, $type, $value, $units, $lowerNR, $lowerC, $lowerNC, $upperNC, $upperC, $upperNR, $eventmask) = split(/,/, $line); - my $name = $aux[1]; + my $module_name = $type.': '.$name; - #Trim name - $name =~ s/^\s+//; - $name =~ s/\s+$//; - - my $module_type = "generic_data_string"; - - my $value_read = $aux[3]; - - #Trim name - $value_read =~ s/^\s+//; - $value_read =~ s/\s+$//; - - #Check if value read is integer or boolean - if ($value_read =~ m/^\d+.\d+$/ || $value_read =~ m/^\d+$/) { + my $module_type; + my $module_warn_min; + my $module_warn_max; + my $module_warn_invert; + my $module_critical_min; + my $module_critical_max; + my $module_critical_invert; + + if ($sensor_types{$type} == 0) { $module_type = "generic_data"; - } + if ($lowerC ne 'N/A' and $upperC ne 'N/A') { + $module_critical_min = $lowerC; + $module_critical_max = $upperC; + $module_critical_invert = 1; + } + if ($lowerNC ne 'N/A' and $upperNC ne 'N/A') { + $module_warn_min = $lowerNC; + $module_warn_max = $upperNC; + $module_warn_invert = 1; + } + } elsif ($sensor_types{$type} == 1) { + $module_type = "generic_data"; + $module_critical_min = "1"; + $module_critical_max = "0"; + } elsif ($sensor_types{$type} == 2) { + $module_type = "generic_data"; + } elsif ($sensor_types{$type} == 3) { + $module_type = "generic_data_string"; + } else { + $module_type = "generic_data_string"; + } 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":"'.$sensor.'","hide":""},'. + '"5":{"macro":"_field5_","desc":"'.safe_input("Additional Options").'","help":"","value":"'.$extraopts.'","hide":""}'. + '}'; + my %parameters; - $parameters{"nombre"} = safe_input($name); + $parameters{"nombre"} = safe_input($module_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{"unit"} = $units if $units ne 'N/A'; + $parameters{"min_warning"} = $module_warn_min if defined $module_warn_min; + $parameters{"max_warning"} = $module_warn_max if defined $module_warn_max; + $parameters{"warning_inverse"} = $module_warn_invert if defined $module_warn_invert; + $parameters{"min_critical"} = $module_critical_min if defined $module_critical_min; + $parameters{"max_critical"} = $module_critical_max if defined $module_critical_max; + $parameters{"critical_inverse"} = $module_critical_invert if defined $module_critical_invert; + $parameters{"macros"} = $macros; pandora_create_module_from_hash ($conf, \%parameters, $dbh); @@ -184,17 +264,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 +298,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