submit_check_result

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
tarzan
Posts: 17
Joined: Thu Sep 08, 2016 9:09 am

submit_check_result

Post 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
Last edited by dwhitfield on Thu Mar 02, 2017 10:17 am, edited 1 time in total.
Reason: marking with green check mark
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: submit_check_result

Post 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.
Former Nagios employee
https://www.mcapra.com/
tarzan
Posts: 17
Joined: Thu Sep 08, 2016 9:09 am

Re: submit_check_result

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: submit_check_result

Post 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'");
}
Former Nagios employee
https://www.mcapra.com/
tarzan
Posts: 17
Joined: Thu Sep 08, 2016 9:09 am

Re: submit_check_result

Post by tarzan »

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

Elvino
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: submit_check_result

Post by dwhitfield »

Fantastic! Let us know how it goes!
tarzan
Posts: 17
Joined: Thu Sep 08, 2016 9:09 am

Re: submit_check_result

Post by tarzan »

thanks dwhitfield, everything works fine!!!!

Tarzan
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: submit_check_result

Post by dwhitfield »

Fantastic news! Is it okay if we lock this thread? Thanks for choosing the Nagios forums!
tarzan
Posts: 17
Joined: Thu Sep 08, 2016 9:09 am

Re: submit_check_result

Post by tarzan »

Okay we close the thread.
Thank you and greetings

Tarzan
Locked