From 623afea5fe6b43e14139b77e232d1d2bc7eb1ca6 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 27 Jun 2018 12:21:21 +0200 Subject: [PATCH] Minor changes in PluginTools Added missing plugins to update_version --- extras/pandora_update_version.sh | 19 ++++--- pandora_server/lib/PandoraFMS/PluginTools.pm | 55 ++++++++++++++------ 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/extras/pandora_update_version.sh b/extras/pandora_update_version.sh index 1953c7c834..6716f06701 100755 --- a/extras/pandora_update_version.sh +++ b/extras/pandora_update_version.sh @@ -54,22 +54,25 @@ AGENT_WIN_FILE="$CODEHOME/pandora_agents/win32/pandora.cc" AGENT_WIN_MPI_FILE="$CODEHOME/pandora_agents/win32/installer/pandora.mpi" AGENT_WIN_RC_FILE="$CODEHOME/pandora_agents/win32/versioninfo.rc" SATELLITE_FILE="$PANDHOME_ENT/satellite_server/satellite_server.pl" -PERL_PLUGIN_FILES="$PANDHOME_ENT/pandora_plugins/NGINX/nginx_requests_queued.pl \ +PERL_PLUGIN_FILES="$PANDHOME_ENT/pandora_server/util/plugin/vmware-plugin.pl \ +$PANDHOME_ENT/pandora_plugins/NGINX/nginx_requests_queued.pl \ $PANDHOME_ENT/pandora_plugins/Sybase/sybase_plugin.pl \ -$PANDHOME_ENT/pandora_plugins/JMX/pandora_plugin_jmx.pl \ +$PANDHOME_ENT/pandora_plugins/SNMP/dynamic_snmp.pl \ +$PANDHOME_ENT/pandora_plugins/SNMP/snmp_bandwith.pl \ +$PANDHOME_ENT/pandora_plugins/laboratory/cacti/cacti2pandora.pl \ $PANDHOME_ENT/pandora_plugins/MarkLogic/pandora_marklogic.pl \ +$PANDHOME_ENT/pandora_plugins/MySQL/pandora_mysql.pl \ +$PANDHOME_ENT/pandora_plugins/JMX/pandora_plugin_jmx.pl \ $PANDHOME_ENT/pandora_plugins/Apache/pandora_apache.pl \ +$PANDHOME_ENT/pandora_plugins/UX/pandora_ux.pl \ $PANDHOME_ENT/pandora_plugins/Oracle/Database/pandora_oracle.pl \ $PANDHOME_ENT/pandora_plugins/OpenNebula/pandora_opennebula.pl \ $PANDHOME_ENT/pandora_plugins/Nutanix/pandora_nutanix.pl \ $PANDHOME_ENT/pandora_plugins/MTL/pandora_mtl.pl \ $PANDHOME_ENT/pandora_plugins/Informix/informix.pl \ -$PANDHOME_ENT/pandora_plugins/Ruckus/ruckus.pl \ -$PANDHOME_ENT/pandora_plugins/UX/pandora_ux.pl \ -$PANDHOME_ENT/pandora_plugins/JMX/pandora_plugin_jmx.pl \ -$PANDHOME_ENT/pandora_plugins/SNMP/dynamic_snmp.pl \ -$PANDHOME_ENT/pandora_plugins/MySQL/pandora_mysql.pl \ -$PANDHOME_ENT/pandora_server/util/plugin/vmware-plugin.pl " +$PANDHOME_ENT/pandora_plugins/Docker/docker_services.pl \ +$PANDHOME_ENT/pandora_plugins/Docker/docker_stats.pl \ +$PANDHOME_ENT/pandora_plugins/Ruckus/ruckus.pl " PLUGIN_LIB_FILE="$CODEHOME/pandora_server/lib/PandoraFMS/PluginTools.pm" # Update version in spec files diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 80155414ee..e8d6d1f13d 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -46,6 +46,7 @@ our @EXPORT = qw( api_create_tag api_create_group call_url + check_lib_version decrypt empty encrypt @@ -95,12 +96,34 @@ our @EXPORT = qw( my $DevNull = ($^O =~ /win/i)?'/NUL':'/dev/null'; ################################################################################ -# +# Returns current library version ################################################################################ sub get_lib_version { return $VERSION; } +################################################################################ +# Check version compatibility +################################################################################ +sub check_lib_version { + my ($plugin_version) = @_; + + $plugin_version = "0NG.0" if empty($plugin_version); + + my ($main,$oum) = split /NG./, $plugin_version; + + $main = 0 if empty($main) || !looks_like_number($main); + $oum = 0 if empty($oum) || !looks_like_number($oum); + + my ($libmain,$liboum) = split /NG./, $pandora_version; + + if (($liboum < $oum) + || ($libmain != $main)) { + return 0; + } + + return 1; +} ################################################################################ # Get current time (milis) @@ -1409,7 +1432,7 @@ sub process_performance { $instances = trim (head(`$_PluginTools_system->{ps} | $_PluginTools_system->{grep} "$process"| $_PluginTools_system->{wcl}`, 1)); - } + } elsif ($^O =~ /linux/i ){ $cpu = trim(`$_PluginTools_system->{ps} | $_PluginTools_system->{grep} -w "$process" | $_PluginTools_system->{grep} -v grep | awk 'BEGIN {sum=0} {sum+=\$2} END{print sum}'`); $mem = trim(`$_PluginTools_system->{ps} | $_PluginTools_system->{grep} -w "$process" | $_PluginTools_system->{grep} -v grep | awk 'BEGIN {sum=0} {sum+=\$1} END{print sum}'`); @@ -1834,13 +1857,13 @@ sub api_create_group { # $snmp{host} # $snmp{oid} # $snmp{port} -# $snmp{securityName} -# $snmp{context -# $snmp{securityLevel} -# $snmp{authProtocol} -# $snmp{authKey} -# $snmp{privProtocol} -# $snmp{privKey} +# $snmp{securityName} +# $snmp{context +# $snmp{securityLevel} +# $snmp{authProtocol} +# $snmp{authKey} +# $snmp{privProtocol} +# $snmp{privKey} ################################################################################ sub snmp_walk { my $snmp = shift; @@ -1940,13 +1963,13 @@ sub snmp_walk { # $snmp{host} # $snmp{oid} # $snmp{port} -# $snmp{securityName} -# $snmp{context -# $snmp{securityLevel} -# $snmp{authProtocol} -# $snmp{authKey} -# $snmp{privProtocol} -# $snmp{privKey} +# $snmp{securityName} +# $snmp{context +# $snmp{securityLevel} +# $snmp{authProtocol} +# $snmp{authKey} +# $snmp{privProtocol} +# $snmp{privKey} ################################################################################ sub snmp_get { my $snmp = shift;