diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index 7316e9ca1f..80c57e9ba7 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,9 @@ +2010-10-15 SAncho Lerena + + * plugins/nagios_plugin_wrapper: Added new plugin. + + * pandora_agent: Version update. + 2010-10-08 Ramon Novoa * pandora_agent: Pass server_pwd and server_ssl configuration tokens diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 3ef43d6aa4..db6fbf3b12 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1,6 +1,6 @@ #!/usr/bin/perl # ********************************************************************** -# Pandora FMS Generic Linux Agent +# Pandora FMS Generic Unix/Perl Agent # (c) 2010 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 3.1 +Version 3.2 =head1 USAGE @@ -57,7 +57,7 @@ if (!$@) { } use constant AGENT_VERSION => '3.2dev'; -use constant AGENT_BUILD => '101008'; +use constant AGENT_BUILD => '101015'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { @@ -1423,6 +1423,7 @@ while (1) { } # Go to sleep + # sleep ($Conf{'interval'}); } diff --git a/pandora_agents/unix/plugins/nagios_plugin_wrapper b/pandora_agents/unix/plugins/nagios_plugin_wrapper new file mode 100755 index 0000000000..63b9058380 --- /dev/null +++ b/pandora_agents/unix/plugins/nagios_plugin_wrapper @@ -0,0 +1,70 @@ +#!/usr/bin/perl +########################################################################## +# nagios_plugin_wrapper +# +# Executes the given nagios plugin and produces an XML with data for pandora +# to be used as agent plugin. This allows to have DATA based on the errorlevel +# and use the descriptive information on description for the module +# +# Usage: nagios_plugin_wrapper +########################################################################## +# Copyright (c) 2010 Artica Soluciones Tecnologicas S.L +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; version 2. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +########################################################################## + +use strict; +use warnings; + +my $command = ""; +my @opts = @ARGV; +my $module_name = shift(@opts); +$command = join(' ', @opts); + +if ($command ne ""){ + my $module_data = `$command`; + my $module_description = $module_data; + my $ReturnCode = ($? >> 8) & 0xff; + + + # Get the errorlevel if is a Nagios plugin type (parsing the errorlevel) + # Nagios errorlevels: + #('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); + + # By default is unknown + $module_data = ""; + + if ($ReturnCode == 2){ + $module_data = 0; + } + elsif ($ReturnCode == 3){ + $module_data = ''; # not defined = Uknown + } + elsif ($ReturnCode == 0){ + $module_data = 1; + } + elsif ($ReturnCode == 1){ + $module_data = 2; # need to be managed on module thresholds + } + elsif ($ReturnCode == 4){ + $module_data = 3; # need to be managed on module thresholds + } + + print ""; + print "".$module_name."\n"; + print "generic_proc\n"; + print "".$module_data."\n"; + print "\n"; + print "\n"; + +}