Page 1 of 1

submit_check_result

Posted: Fri Jan 20, 2017 7:46 am
by tarzan
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

Re: submit_check_result

Posted: Fri Jan 20, 2017 12:13 pm
by mcapra
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.

Re: submit_check_result

Posted: Thu Feb 02, 2017 7:21 am
by tarzan
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

Re: submit_check_result

Posted: Thu Feb 02, 2017 3:42 pm
by mcapra
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'");
}

Re: submit_check_result

Posted: Mon Feb 06, 2017 6:07 am
by tarzan
I'll do a test and I will update you
Thank you

Elvino

Re: submit_check_result

Posted: Mon Feb 06, 2017 11:44 am
by dwhitfield
Fantastic! Let us know how it goes!

Re: submit_check_result

Posted: Wed Mar 01, 2017 2:51 am
by tarzan
thanks dwhitfield, everything works fine!!!!

Tarzan

Re: submit_check_result

Posted: Wed Mar 01, 2017 10:32 am
by dwhitfield
Fantastic news! Is it okay if we lock this thread? Thanks for choosing the Nagios forums!

Re: submit_check_result

Posted: Thu Mar 02, 2017 7:27 am
by tarzan
Okay we close the thread.
Thank you and greetings

Tarzan