2009-09-02 Sancho Lerena <slerena@artica.es>

*  lib/PandoraFMS/PluginServer.pm, util/pandora_exec: Nagis plugin 
        support implemented and working.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1906 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2009-09-02 14:00:44 +00:00
parent fe65d1b3d8
commit 28b76ef4f0
3 changed files with 40 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2009-09-02 Sancho Lerena <slerena@artica.es>
* lib/PandoraFMS/PluginServer.pm, util/pandora_exec: Nagis plugin
support implemented and working.
2009-09-02 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Fixed the matches_value alert option (was not

View File

@ -167,6 +167,37 @@ sub data_consumer ($$) {
# Execute command
$command = $pa_config->{'plugin_exec'} . ' ' . $timeout . ' ' . $command;
my $module_data = `$command`;
my $ReturnCode = ($? >> 8) & 0xff;
if ($plugin->{'plugin_type'} == 1) {
# Get the errorlevel if is a Nagios plugin type (parsing the errorlevel)
# Nagios errorlevels:
#('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# Numerical modules (Data) or Alphanumeric modules (String)
# get reported data as is, ignoring return code.
# Boolean data, transform module data depending on returning error code.
if ($module->{'id_tipo_modulo'} == 2){
if ($ReturnCode == 0){
$module_data = 1;
}
elsif ($ReturnCode == 1){
$module_data = -1;
}
elsif ($ReturnCode == 2){
$module_data = 0;
}
elsif ($ReturnCode == 3){
$module_data = ''; # not defined = Uknown
}
elsif ($ReturnCode == 4){
$module_data = 1;
}
}
}
if (! defined $module_data || $module_data eq '') {
pandora_update_module_on_error ($pa_config, $module_id, $dbh);
return;

View File

@ -37,6 +37,8 @@ my $timeout = shift(@opts);
my $command = quotemeta(shift(@opts));
my $arguments = join(' ', @opts);
my $output = '';
my $ReturnCode = 0;
# Check that the command exists
if (system("$command >/dev/null 2>&1") == 32512) {
@ -49,6 +51,7 @@ eval {
alarm $timeout;
$output = `$command $arguments`;
$ReturnCode = ($? >> 8) & 0xff;
alarm 0;
};
@ -59,4 +62,4 @@ if ($@ eq "alarm\n") {
print $output;
exit 0;
exit $ReturnCode;