From 63e649be85fe3e67fde2ccae316869516180cd6f Mon Sep 17 00:00:00 2001 From: KANAYAMA Akihiro Date: Wed, 7 Dec 2022 19:25:27 +0900 Subject: [PATCH 1/5] Removed unnecessary escape of ampersand. --- pandora_console/godmode/menu.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index d63595d553..7d26d69d2a 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -200,14 +200,14 @@ if ($access_console_node === true) { $sub['gmassive']['type'] = 'direct'; $sub['gmassive']['subtype'] = 'nolink'; $sub2 = []; - $sub2['godmode/massive/massive_operations&tab=massive_agents']['text'] = __('Agents operations'); - $sub2['godmode/massive/massive_operations&tab=massive_modules']['text'] = __('Modules operations'); - $sub2['godmode/massive/massive_operations&tab=massive_plugins']['text'] = __('Plugins operations'); + $sub2['godmode/massive/massive_operations&tab=massive_agents']['text'] = __('Agents operations'); + $sub2['godmode/massive/massive_operations&tab=massive_modules']['text'] = __('Modules operations'); + $sub2['godmode/massive/massive_operations&tab=massive_plugins']['text'] = __('Plugins operations'); if ((bool) check_acl($config['id_user'], 0, 'UM') === true) { - $sub2['godmode/massive/massive_operations&tab=massive_users']['text'] = __('Users operations'); + $sub2['godmode/massive/massive_operations&tab=massive_users']['text'] = __('Users operations'); } - $sub2['godmode/massive/massive_operations&tab=massive_alerts']['text'] = __('Alerts operations'); + $sub2['godmode/massive/massive_operations&tab=massive_alerts']['text'] = __('Alerts operations'); enterprise_hook('massivepolicies_submenu'); enterprise_hook('massivesnmp_submenu'); enterprise_hook('massivesatellite_submenu'); From 8f14cac9a72c27c32d5fad2eb2e4d439391345de Mon Sep 17 00:00:00 2001 From: KANAYAMA Akihiro Date: Wed, 7 Dec 2022 19:38:43 +0900 Subject: [PATCH 2/5] revert unrelated changes --- .../util/plugin/pandora_snmp_bandwidth.pl | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl index 9b28848b48..8b5d505116 100755 --- a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl +++ b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl @@ -66,7 +66,7 @@ e.g. -v is equal to -version, -c to -community, etc. EO_HELP use constant { - UNKNOWN_DUPLEX => 1, + UNKNOWN_DUPLEX => 0, HALF_DUPLEX => 2, FULL_DUPLEX => 3, }; @@ -133,9 +133,9 @@ sub update_config_key ($) { if ($arg eq 'inUsage') { return "inUsage"; } - if ($arg eq 'outUsage') { - return "outUsage"; - } + if ($arg eq 'outUsage') { + return "outUsage"; + } } ################################################################################ @@ -188,7 +188,7 @@ sub prepare_tree { my $inOctets = snmp_get(\%inOctets_call); if (ref($inOctets) eq "HASH") { - if (! exists($inOctets->{'data'}) || $inOctets->{'data'} eq '') { + if ($inOctets->{'data'} eq '') { $inOctets = 0; } else { $inOctets = int $inOctets->{'data'}; @@ -198,18 +198,18 @@ sub prepare_tree { next; } - my %outOctets_call = %{$config}; - if (is_enabled($config->{'use_x64'})) { - $outOctets_call{'oid'} = $config->{'oid_base'}; - $outOctets_call{'oid'} .= $config->{'x64_indexes'}{'outOctets'}.$ifIndex; - } else { - $outOctets_call{'oid'} = $config->{'oid_base'}; - $outOctets_call{'oid'} .= $config->{'x86_indexes'}{'outOctets'}.$ifIndex; - } + my %outOctets_call = %{$config}; + if (is_enabled($config->{'use_x64'})) { + $outOctets_call{'oid'} = $config->{'oid_base'}; + $outOctets_call{'oid'} .= $config->{'x64_indexes'}{'outOctets'}.$ifIndex; + } else { + $outOctets_call{'oid'} = $config->{'oid_base'}; + $outOctets_call{'oid'} .= $config->{'x86_indexes'}{'outOctets'}.$ifIndex; + } my $outOctets = snmp_get(\%outOctets_call); if (ref($outOctets) eq "HASH") { - if (! exists($outOctets->{'data'}) || $outOctets->{'data'} eq '') { + if ($outOctets->{'data'} eq '') { $outOctets = 0; } else { $outOctets = int $outOctets->{'data'}; @@ -220,27 +220,28 @@ sub prepare_tree { } my %duplex_call = %{$config}; - if (is_enabled($config->{'use_x64'})) { - $duplex_call{'oid'} = $config->{'oid_base'}; - $duplex_call{'oid'} .= $config->{'x64_indexes'}{'duplex'}.$ifIndex; - } else { - $duplex_call{'oid'} = $config->{'oid_base'}; - $duplex_call{'oid'} .= $config->{'x86_indexes'}{'duplex'}.$ifIndex; - } + if (is_enabled($config->{'use_x64'})) { + $duplex_call{'oid'} = $config->{'oid_base'}; + $duplex_call{'oid'} .= $config->{'x64_indexes'}{'duplex'}.$ifIndex; + } else { + $duplex_call{'oid'} = $config->{'oid_base'}; + $duplex_call{'oid'} .= $config->{'x86_indexes'}{'duplex'}.$ifIndex; + } my $duplex = snmp_get(\%duplex_call); if (ref($duplex) eq "HASH") { - if (! exists($duplex->{'data'}) || $duplex->{'data'} eq '') { + if ($duplex->{'data'} eq '') { $duplex = 0; } else { $duplex = int $duplex->{'data'}; } + } else { # Ignore, cannot retrieve inOctets. next; } - my %speed = %{$config}; + my %speed = %{$config}; if (is_enabled($config->{'use_x64'})) { $speed{'oid'} = $config->{'oid_base'}; $speed{'oid'} .= $config->{'x64_indexes'}{'ifSpeed'}.$ifIndex; @@ -510,7 +511,7 @@ if ( defined($sysobjectid->{'error'}) || $sysobjectid->{'data'} eq '' ) { # Check SNMP x64 interfaces my $walk64 = snmp_walk({%{$config}, 'oid' => '.1.3.6.1.2.1.31.1.1.1.6'}); -if ( $walk64 !~ /.*\.[0-9]+ = Counter64: [0-9]+/ ) { +if ( $walk64 =~ 'No Such Instance currently exists at this OID' || $walk64 =~ 'No more variables left in this MIB View' || $walk64 =~ 'No Such Object available on this agent at this OID') { $config->{'use_x64'} = 0; } else { $config->{'use_x64'} = 1; @@ -556,34 +557,34 @@ my $k = 0; foreach my $iface (keys %{$analysis_tree}) { # Calculate summary; if (is_enabled($analysis_tree->{$iface}{'bandwidth'}) || $analysis_tree->{$iface}{'bandwidth'} == 0) { - $bandwidth += $analysis_tree->{$iface}{'bandwidth'}; + $bandwidth = $analysis_tree->{$iface}{'bandwidth'}; $i++; } if (is_enabled($analysis_tree->{$iface}{'inUsage'}) || $analysis_tree->{$iface}{'inUsage'} == 0) { - $inUsage += $analysis_tree->{$iface}{'inUsage'}; + $inUsage = $analysis_tree->{$iface}{'inUsage'}; $j++; } if (is_enabled($analysis_tree->{$iface}{'outUsage'}) || $analysis_tree->{$iface}{'inUsage'} == 0) { - $outUsage += $analysis_tree->{$iface}{'outUsage'}; + $outUsage = $analysis_tree->{$iface}{'outUsage'}; $k++; } } if ($j > 0 && is_enabled($config->{'inUsage'})) { - $inUsage /= $j; - print sprintf("%.9f\n", $inUsage); + $inUsage /= $j; + print sprintf("%.9f\n", $inUsage); } elsif ($k > 0 && is_enabled($config->{'outUsage'})) { - $outUsage /= $k; - print sprintf("%.9f\n", $outUsage); + $outUsage /= $k; + print sprintf("%.9f\n", $outUsage); } if ($i > 0 && !is_enabled($config->{'inUsage'}) && !is_enabled($config->{'outUsage'}) ) { - $bandwidth /= $i; - print sprintf("%.9f\n", $bandwidth); + $bandwidth /= $i; + print sprintf("%.9f\n", $bandwidth); } logger($config, 'info', "Plugin ends") if (is_enabled($config->{'debug'})); From 0c520aed962a2bb38409cf1963c48e85139e4ace Mon Sep 17 00:00:00 2001 From: KANAYAMA Akihiro Date: Wed, 7 Dec 2022 19:41:57 +0900 Subject: [PATCH 3/5] Revert unrelated changes. --- .../util/plugin/pandora_snmp_bandwidth.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl index 8b5d505116..3eb2b4fb53 100755 --- a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl +++ b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl @@ -2,7 +2,7 @@ # ################################################################################ # -# Bandwidth usage plugin +# Bandwith usage plugin # # Requirements: # snmpget @@ -55,7 +55,7 @@ Where OPTIONS could be: [EXTRA] -ifIndex Target interface to retrieve, if not specified, total - bandwidth will be reported. + bandwith will be reported. -uniqid Use custom temporary file name. -inUsage Show only input usage (in percentage) - 1, or not 0. -outUsage Show only output usage (in percentage) - 1, or not 0. @@ -492,9 +492,9 @@ $config->{'tmp_separator'} = ';' if empty($config->{'tmp_separator'}); $config->{'tmp'} = (($^O =~ /win/)?$ENV{'TMP'}:'/tmp') if empty($config->{'tmp'}); # Create unique name for tmp and log file for host -my $filename = $config->{'tmp'}.'/pandora_bandwidth_'.$config->{'host'}; +my $filename = $config->{'tmp'}.'/pandora_bandwith_'.$config->{'host'}; if (!empty($config->{'uniqid'})) { - $filename = $config->{'tmp'}.'/pandora_bandwidth_'.$config->{'uniqid'}; + $filename = $config->{'tmp'}.'/pandora_bandwith_'.$config->{'uniqid'}; } # Replace every dot for underscore $filename =~ tr/./_/; @@ -511,7 +511,7 @@ if ( defined($sysobjectid->{'error'}) || $sysobjectid->{'data'} eq '' ) { # Check SNMP x64 interfaces my $walk64 = snmp_walk({%{$config}, 'oid' => '.1.3.6.1.2.1.31.1.1.1.6'}); -if ( $walk64 =~ 'No Such Instance currently exists at this OID' || $walk64 =~ 'No more variables left in this MIB View' || $walk64 =~ 'No Such Object available on this agent at this OID') { +if ( $walk64 =~ 'No Such Instance currently exists at this OID' || $walk64 =~ 'No more variables left in this MIB View') { $config->{'use_x64'} = 0; } else { $config->{'use_x64'} = 1; @@ -556,15 +556,15 @@ my $j = 0; my $k = 0; foreach my $iface (keys %{$analysis_tree}) { # Calculate summary; - if (is_enabled($analysis_tree->{$iface}{'bandwidth'}) || $analysis_tree->{$iface}{'bandwidth'} == 0) { + if (is_enabled($analysis_tree->{$iface}{'bandwidth'})) { $bandwidth = $analysis_tree->{$iface}{'bandwidth'}; $i++; } - if (is_enabled($analysis_tree->{$iface}{'inUsage'}) || $analysis_tree->{$iface}{'inUsage'} == 0) { + if (is_enabled($analysis_tree->{$iface}{'inUsage'})) { $inUsage = $analysis_tree->{$iface}{'inUsage'}; $j++; } - if (is_enabled($analysis_tree->{$iface}{'outUsage'}) || $analysis_tree->{$iface}{'inUsage'} == 0) { + if (is_enabled($analysis_tree->{$iface}{'outUsage'})) { $outUsage = $analysis_tree->{$iface}{'outUsage'}; $k++; } From 1c032e0b6713132bf1130f9e518f2ee94710f583 Mon Sep 17 00:00:00 2001 From: KANAYAMA Akihiro Date: Tue, 20 Dec 2022 09:57:23 +0900 Subject: [PATCH 4/5] pull new changes to pandora_snmp_bandwidth.pl --- .../util/plugin/pandora_snmp_bandwidth.pl | 81 +++++++++---------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl index 3eb2b4fb53..db38b8444d 100755 --- a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl +++ b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl @@ -2,7 +2,7 @@ # ################################################################################ # -# Bandwith usage plugin +# Bandwidth usage plugin # # Requirements: # snmpget @@ -55,7 +55,7 @@ Where OPTIONS could be: [EXTRA] -ifIndex Target interface to retrieve, if not specified, total - bandwith will be reported. + bandwidth will be reported. -uniqid Use custom temporary file name. -inUsage Show only input usage (in percentage) - 1, or not 0. -outUsage Show only output usage (in percentage) - 1, or not 0. @@ -66,7 +66,7 @@ e.g. -v is equal to -version, -c to -community, etc. EO_HELP use constant { - UNKNOWN_DUPLEX => 0, + UNKNOWN_DUPLEX => 1, HALF_DUPLEX => 2, FULL_DUPLEX => 3, }; @@ -133,9 +133,9 @@ sub update_config_key ($) { if ($arg eq 'inUsage') { return "inUsage"; } - if ($arg eq 'outUsage') { - return "outUsage"; - } + if ($arg eq 'outUsage') { + return "outUsage"; + } } ################################################################################ @@ -188,7 +188,7 @@ sub prepare_tree { my $inOctets = snmp_get(\%inOctets_call); if (ref($inOctets) eq "HASH") { - if ($inOctets->{'data'} eq '') { + if (! exists($inOctets->{'data'}) || $inOctets->{'data'} eq '') { $inOctets = 0; } else { $inOctets = int $inOctets->{'data'}; @@ -198,18 +198,18 @@ sub prepare_tree { next; } - my %outOctets_call = %{$config}; - if (is_enabled($config->{'use_x64'})) { - $outOctets_call{'oid'} = $config->{'oid_base'}; - $outOctets_call{'oid'} .= $config->{'x64_indexes'}{'outOctets'}.$ifIndex; - } else { - $outOctets_call{'oid'} = $config->{'oid_base'}; - $outOctets_call{'oid'} .= $config->{'x86_indexes'}{'outOctets'}.$ifIndex; - } + my %outOctets_call = %{$config}; + if (is_enabled($config->{'use_x64'})) { + $outOctets_call{'oid'} = $config->{'oid_base'}; + $outOctets_call{'oid'} .= $config->{'x64_indexes'}{'outOctets'}.$ifIndex; + } else { + $outOctets_call{'oid'} = $config->{'oid_base'}; + $outOctets_call{'oid'} .= $config->{'x86_indexes'}{'outOctets'}.$ifIndex; + } my $outOctets = snmp_get(\%outOctets_call); if (ref($outOctets) eq "HASH") { - if ($outOctets->{'data'} eq '') { + if (! exists($outOctets->{'data'}) || $outOctets->{'data'} eq '') { $outOctets = 0; } else { $outOctets = int $outOctets->{'data'}; @@ -220,28 +220,27 @@ sub prepare_tree { } my %duplex_call = %{$config}; - if (is_enabled($config->{'use_x64'})) { - $duplex_call{'oid'} = $config->{'oid_base'}; - $duplex_call{'oid'} .= $config->{'x64_indexes'}{'duplex'}.$ifIndex; - } else { - $duplex_call{'oid'} = $config->{'oid_base'}; - $duplex_call{'oid'} .= $config->{'x86_indexes'}{'duplex'}.$ifIndex; - } + if (is_enabled($config->{'use_x64'})) { + $duplex_call{'oid'} = $config->{'oid_base'}; + $duplex_call{'oid'} .= $config->{'x64_indexes'}{'duplex'}.$ifIndex; + } else { + $duplex_call{'oid'} = $config->{'oid_base'}; + $duplex_call{'oid'} .= $config->{'x86_indexes'}{'duplex'}.$ifIndex; + } my $duplex = snmp_get(\%duplex_call); if (ref($duplex) eq "HASH") { - if ($duplex->{'data'} eq '') { + if (! exists($duplex->{'data'}) || $duplex->{'data'} eq '') { $duplex = 0; } else { $duplex = int $duplex->{'data'}; } - } else { # Ignore, cannot retrieve inOctets. next; } - my %speed = %{$config}; + my %speed = %{$config}; if (is_enabled($config->{'use_x64'})) { $speed{'oid'} = $config->{'oid_base'}; $speed{'oid'} .= $config->{'x64_indexes'}{'ifSpeed'}.$ifIndex; @@ -492,9 +491,9 @@ $config->{'tmp_separator'} = ';' if empty($config->{'tmp_separator'}); $config->{'tmp'} = (($^O =~ /win/)?$ENV{'TMP'}:'/tmp') if empty($config->{'tmp'}); # Create unique name for tmp and log file for host -my $filename = $config->{'tmp'}.'/pandora_bandwith_'.$config->{'host'}; +my $filename = $config->{'tmp'}.'/pandora_bandwidth_'.$config->{'host'}; if (!empty($config->{'uniqid'})) { - $filename = $config->{'tmp'}.'/pandora_bandwith_'.$config->{'uniqid'}; + $filename = $config->{'tmp'}.'/pandora_bandwidth_'.$config->{'uniqid'}; } # Replace every dot for underscore $filename =~ tr/./_/; @@ -511,7 +510,7 @@ if ( defined($sysobjectid->{'error'}) || $sysobjectid->{'data'} eq '' ) { # Check SNMP x64 interfaces my $walk64 = snmp_walk({%{$config}, 'oid' => '.1.3.6.1.2.1.31.1.1.1.6'}); -if ( $walk64 =~ 'No Such Instance currently exists at this OID' || $walk64 =~ 'No more variables left in this MIB View') { +if ( $walk64 !~ /.*\.[0-9]+ = Counter64: [0-9]+/ ) { $config->{'use_x64'} = 0; } else { $config->{'use_x64'} = 1; @@ -556,35 +555,35 @@ my $j = 0; my $k = 0; foreach my $iface (keys %{$analysis_tree}) { # Calculate summary; - if (is_enabled($analysis_tree->{$iface}{'bandwidth'})) { - $bandwidth = $analysis_tree->{$iface}{'bandwidth'}; + if (is_enabled($analysis_tree->{$iface}{'bandwidth'}) || $analysis_tree->{$iface}{'bandwidth'} == 0) { + $bandwidth += $analysis_tree->{$iface}{'bandwidth'}; $i++; } - if (is_enabled($analysis_tree->{$iface}{'inUsage'})) { - $inUsage = $analysis_tree->{$iface}{'inUsage'}; + if (is_enabled($analysis_tree->{$iface}{'inUsage'}) || $analysis_tree->{$iface}{'inUsage'} == 0) { + $inUsage += $analysis_tree->{$iface}{'inUsage'}; $j++; } - if (is_enabled($analysis_tree->{$iface}{'outUsage'})) { - $outUsage = $analysis_tree->{$iface}{'outUsage'}; + if (is_enabled($analysis_tree->{$iface}{'outUsage'}) || $analysis_tree->{$iface}{'outUsage'} == 0) { + $outUsage += $analysis_tree->{$iface}{'outUsage'}; $k++; } } if ($j > 0 && is_enabled($config->{'inUsage'})) { - $inUsage /= $j; - print sprintf("%.9f\n", $inUsage); + $inUsage /= $j; + print sprintf("%.9f\n", $inUsage); } elsif ($k > 0 && is_enabled($config->{'outUsage'})) { - $outUsage /= $k; - print sprintf("%.9f\n", $outUsage); + $outUsage /= $k; + print sprintf("%.9f\n", $outUsage); } if ($i > 0 && !is_enabled($config->{'inUsage'}) && !is_enabled($config->{'outUsage'}) ) { - $bandwidth /= $i; - print sprintf("%.9f\n", $bandwidth); + $bandwidth /= $i; + print sprintf("%.9f\n", $bandwidth); } logger($config, 'info', "Plugin ends") if (is_enabled($config->{'debug'})); From c56343b76eeb787cabb8fe99fe7ae9b87d8c835e Mon Sep 17 00:00:00 2001 From: KANAYAMA Akihiro Date: Tue, 20 Dec 2022 11:54:17 +0900 Subject: [PATCH 5/5] adjust pandora_snmp_bandwidth.pl to current content --- pandora_server/util/plugin/pandora_snmp_bandwidth.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl index db38b8444d..9b28848b48 100755 --- a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl +++ b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl @@ -563,7 +563,7 @@ foreach my $iface (keys %{$analysis_tree}) { $inUsage += $analysis_tree->{$iface}{'inUsage'}; $j++; } - if (is_enabled($analysis_tree->{$iface}{'outUsage'}) || $analysis_tree->{$iface}{'outUsage'} == 0) { + if (is_enabled($analysis_tree->{$iface}{'outUsage'}) || $analysis_tree->{$iface}{'inUsage'} == 0) { $outUsage += $analysis_tree->{$iface}{'outUsage'}; $k++; }