2010-10-15 SAncho Lerena <slerena@artica.es>

* plugins/nagios_plugin_wrapper: Added new plugin.

        * pandora_agent: Version update.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3408 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2010-10-15 10:56:56 +00:00
parent 5c2707a0fb
commit 636ad58d41
3 changed files with 80 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2010-10-15 SAncho Lerena <slerena@artica.es>
* plugins/nagios_plugin_wrapper: Added new plugin.
* pandora_agent: Version update.
2010-10-08 Ramon Novoa <rnovoa@artica.es>
* pandora_agent: Pass server_pwd and server_ssl configuration tokens

View File

@ -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'});
}

View File

@ -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 <module_name> <nagios plugin execution with its parameters>
##########################################################################
# 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 "<module>";
print "<name>".$module_name."</name>\n";
print "<type>generic_proc</type>\n";
print "<data>".$module_data."</data>\n";
print "<description><![CDATA[" . $module_description . "]]></description>\n";
print "</module>\n";
}