Page 1 of 1
Alert Method: execute scrip (Arguments)
Posted: Fri Feb 23, 2018 2:28 pm
by fscinfra
I need to pass arguments to script sh, the variables that I need to pass are "host" and "message" only, I dont need anything other.
any idea how to do it?
Thanks
Re: Alert Method: execute scrip (Arguments)
Posted: Fri Feb 23, 2018 4:50 pm
by lmiltchev
Can you show us the "auto.sh" script? Normally, you would just type in the arguments in the "Arguments" text-box. Here's a simple example:
My script: /usr/local/nagioslogserver/scripts/myscript3.sh
Code: Select all
#!/bin/bash
echo "Host is $1
Message is $2" >> /tmp/args.txt
My Alert (with 2 arguments added):
example01.PNG
The args.txt file that was created after running the alert:
Code: Select all
[root@localhost tmp]# cat args.txt
Host is myhost
Message is test
Re: Alert Method: execute scrip (Arguments)
Posted: Mon Feb 26, 2018 7:49 am
by fscinfra
hi lmiltchev,
thank you, it worked!!
I think it was not working for me because I was runing the script sh in another folder....
but do you know how to pass el "host" and the "message"?
host.PNG
message.PNG
I need to pass the host that ran the alert and the message sended to Nagios Log Server in the script in the arguments, in the same alert. To run the script with the arguments.
Thanks regards!
Re: Alert Method: execute scrip (Arguments)
Posted: Mon Feb 26, 2018 2:18 pm
by scottwilkerson
fscinfra wrote:but do you know how to pass el "host" and the "message"?
Unfortunately, this is not possible as the alert is based on a count of logs... the results could contain 10,000 different hosts and messages
Re: Alert Method: execute scrip (Arguments)
Posted: Wed Feb 28, 2018 7:12 am
by fscinfra
hi,
I dont know to pass the arguments. But I only want to pass a only host, beacuse I will configure a alert in a determined host.
Re: Alert Method: execute scrip (Arguments)
Posted: Wed Feb 28, 2018 10:34 am
by scottwilkerson
Unfortunately, this is not possible.
Re: Alert Method: execute scrip (Arguments)
Posted: Thu Mar 01, 2018 8:18 am
by fscinfra
Hi,
mmm ok Thanks

for you help.