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
submit_check_result
submit_check_result
Last edited by dwhitfield on Thu Mar 02, 2017 10:17 am, edited 1 time in total.
Reason: marking with green check mark
Reason: marking with green check mark
Re: submit_check_result
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.
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/
https://www.mcapra.com/
Re: submit_check_result
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
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
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/
https://www.mcapra.com/
Re: submit_check_result
I'll do a test and I will update you
Thank you
Elvino
Thank you
Elvino
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: submit_check_result
Fantastic! Let us know how it goes!
Re: submit_check_result
thanks dwhitfield, everything works fine!!!!
Tarzan
Tarzan
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: submit_check_result
Fantastic news! Is it okay if we lock this thread? Thanks for choosing the Nagios forums!
Re: submit_check_result
Okay we close the thread.
Thank you and greetings
Tarzan
Thank you and greetings
Tarzan