submit_check_result

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

submit_check_result

Postby tarzan » Fri Jan 20, 2017 7:46 am

Hello,

I wrote a perl program that reads messages from a mail box and then subsequently change the status of some services in nagios.

I Use submit_check_result, but does not accept variables ($ ServerName $ ServiceName $ Status $ Messagges) but only direct values (Srv_15 Svc_tcp_2365 0 "Alert On"). Is there a way to pass variables to submit_check_result?

Thank you
Last edited by dwhitfield on Thu Mar 02, 2017 10:17 am, edited 1 time in total.
Reason: marking with green check mark
tarzan
 
Posts: 11
Joined: Thu Sep 08, 2016 9:09 am

Re: submit_check_result

Postby mcapra » Fri Jan 20, 2017 12:13 pm

If you're using the submit_check_result provided by Nagios Core, yes that should accept arguments. More info about the underlying command that this script uses:
https://old.nagios.org/developerinfo/ex ... and_id=114

How are you passing these variables to submit_check_result? If you could post the section of your Perl script that is responsible for that bit, it would be helpful.
Be sure to check out our Knowledgebase for helpful articles and solutions!

https://github.com/mcapra/
User avatar
mcapra
Support Tech
 
Posts: 2310
Joined: Thu May 05, 2016 3:54 pm
Location: Nagios Enterprises

Re: submit_check_result

Postby tarzan » Thu Feb 02, 2017 7:21 am

Thanks mcapra,

Now in my program I write something like:
if ($EventStatus == 0){
system('/usr/local/nagios/libexec/eventhandlers/submit_check_result SRV_LNX1 MAIL 0 "Text describing the event"');

you can instead use the defined variables in Perl?

my EventStatus = (regex for find evet status ( ... ));
my hostname = (regex for find hostname ( ... ));
my servicename (regex for servicename ( ... ));
my alert = (regex for string describing the event( ... ));

if ($Status == 0){
system('/usr/local/nagios/libexec/eventhandlers/submit_check_result hostname servicename EventStatus alert);

Thanks
tarzan
 
Posts: 11
Joined: Thu Sep 08, 2016 9:09 am

Re: submit_check_result

Postby mcapra » Thu Feb 02, 2017 3:42 pm

Sure, I would just wrap them in quotes or use a Perl function to escape them for the CLI to be safe. That aside, something like this should work:

Code: Select all
my $EventStatus = /*regex result goes here*/;
my $hostname = /*regex result goes here*/;
my $servicename = /*regex result goes here*/;
my $alert = /*regex result goes here*/;

if ($Status == 0) {
   system("/usr/local/nagios/libexec/eventhandlers/submit_check_result '$EventStatus' '$hostname' '$servicename' '$alert'");
}
Be sure to check out our Knowledgebase for helpful articles and solutions!

https://github.com/mcapra/
User avatar
mcapra
Support Tech
 
Posts: 2310
Joined: Thu May 05, 2016 3:54 pm
Location: Nagios Enterprises

Re: submit_check_result

Postby tarzan » Mon Feb 06, 2017 6:07 am

I'll do a test and I will update you
Thank you

Elvino
tarzan
 
Posts: 11
Joined: Thu Sep 08, 2016 9:09 am

Re: submit_check_result

Postby dwhitfield » Mon Feb 06, 2017 11:44 am

Fantastic! Let us know how it goes!
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
dwhitfield
The Doctor
 
Posts: 2330
Joined: Wed Sep 21, 2016 10:29 am
Location: Nagios Enterprises, LLC

Re: submit_check_result

Postby tarzan » Wed Mar 01, 2017 2:51 am

thanks dwhitfield, everything works fine!!!!

Tarzan
tarzan
 
Posts: 11
Joined: Thu Sep 08, 2016 9:09 am

Re: submit_check_result

Postby dwhitfield » Wed Mar 01, 2017 10:32 am

Fantastic news! Is it okay if we lock this thread? Thanks for choosing the Nagios forums!
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
dwhitfield
The Doctor
 
Posts: 2330
Joined: Wed Sep 21, 2016 10:29 am
Location: Nagios Enterprises, LLC

Re: submit_check_result

Postby tarzan » Thu Mar 02, 2017 7:27 am

Okay we close the thread.
Thank you and greetings

Tarzan
tarzan
 
Posts: 11
Joined: Thu Sep 08, 2016 9:09 am


Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 2 guests