Re: [Nagios-devel] 2.0b3 hacks: checks.c - failure message from one

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] 2.0b3 hacks: checks.c - failure message from one

Post by Guest »

I can only guess that this is another issue with embedded perl. The code
checks out OK, so it sort of has to be something concerning perl and the
way it works in threads.

Stanley Hopcroft wrote:
>
> Dear Folks,
>
> I hoping for some enlightenment on what I may have done to checks.c to
> cause one plugins output to appear in the logs as the output of another
> (couple) of plugins.
>
> [1113611613] EXTERNAL COMMAND: DISABLE_SVC_NOTIFICATIONS;external;ATMOSS
> search
> [1113611627] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;external;ATMOSS
> search;1113611624
>
> .. modified Perl plugin 'check_atmoss' to raise a syntax error (to
> check that checks.c reports it and recovers when the error is
> corrected)
>
> [1113611638] SERVICE ALERT: external;ATMOSS search;UNKNOWN;SOFT;1;"**ePN
> failed to compile "/usr/local/nagios/libexec/check_atmoss": "syntax
> error at (eval 68) line 50, near "use Getopt::Long"" at
> /usr/local/nagios/bin/p1.pl line 255, line 225.
>
>
> .. Ok so far.
>
> [1113611638] SERVICE ALERT: foo-internet;Internet access to
> foo;UNKNOWN;SOFT;1;"**ePN failed to compile
> "/usr/local/nagios/libexec/check_atmoss": "syntax error at (eval 68)
> line 50, near "use Getopt::Long"" at /usr/local/nagios/bin/p1.pl line
> 255, line 225.
>
> [1113611638] SERVICE ALERT: foo-prod;prod access to
> foo;UNKNOWN;SOFT;1;"**ePN failed to compile
> "/usr/local/nagios/libexec/check_atmoss": "syntax error at (eval 68)
> line 50, near "use Getopt::Long"" at /usr/local/nagios/bin/p1.pl line
> 255, line 225.
>
> .. Whoops ! foo-internet and foo-prod are both check_tcp ! The normal
> plugin output of check_tcp has been replaced by that from the
> Perl plugin check_atmoss.
>
> [1113611698] SERVICE ALERT: foo-internet;Internet access to
> foo;OK;SOFT;2;TCP OK - 0 second response time on port 514
> [1113611698] SERVICE ALERT: foo-prod;prod access to
> foo;OK;SOFT;2;TCP OK - 0 second response time on port 514
>
> .. Now back to normal.
>
> [1113611818] SERVICE ALERT: external;ATMOSS search;UNKNOWN;SOFT;2;**ePN
> "/usr/local/nagios/libexec/check_atmoss": "syntax error at (eval 68)
> line 50, near "use Getopt::Long"".
> [1113611998] SERVICE ALERT: external;ATMOSS search;UNKNOWN;HARD;3;**ePN
> "/usr/local/nagios/libexec/check_atmoss": "syntax error at (eval 68)
> line 50, near "use Getopt::Long"".
> [1113612066] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;external;ATMOSS
> search;1113612062
> [1113612068] SERVICE ALERT: external;ATMOSS search;OK;HARD;3;ATMOSS
> Transaction completed Ok.
>
>
> The context of these remarks is embedded Perl.
>
> I have changed checks.c to return immediately after a failure of
> perl_call_argv(). In other words, when Perl reports that a plugin fails
> to compile, it sets ERRSV (to report the syntax error) and this causes
> checks.c to
>
> - fill out the remaining fields in struct svc_msg
>
> - write the struct to the IPC pipe
>
> - return
>
> This saves the futile running of a plugin with syntax errors in the
> grandchild process (and an equally futile extra call to Perl to run the
> plugin in perl_call_pv()). Currently, checks.c caches the error in
> memory and when the grandchild calls perl_call_pv() to run it, Perl
> inspects the cached error and either returns immediately or runs and
> returns the plugin output).
>
> Obviously I fail to understand something here, so any clues are
> welcome.
>
> Here is the hacked checks.c
>
> if ( SvTRUE(ERRSV) ) {
> /*
> * if
> SvTRUE(ERRSV)
> * write
> failure to IPC pipe
> * return
> */
>
> pclose_result=STATE_UNKNOWN;
> perl_plugin_output=SvPVX(ERRSV);
> #ifdef DEBUG1
> printf("embedded perl ran %s with compile error
> %s - skipping plugin\n",fname,

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked