Alert Method: execute scrip (Arguments)

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
fscinfra
Posts: 4
Joined: Tue Jan 30, 2018 5:22 pm

Alert Method: execute scrip (Arguments)

Post 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
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Alert Method: execute scrip (Arguments)

Post 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
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
fscinfra
Posts: 4
Joined: Tue Jan 30, 2018 5:22 pm

Re: Alert Method: execute scrip (Arguments)

Post 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!
You do not have the required permissions to view the files attached to this post.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Alert Method: execute scrip (Arguments)

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
fscinfra
Posts: 4
Joined: Tue Jan 30, 2018 5:22 pm

Re: Alert Method: execute scrip (Arguments)

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Alert Method: execute scrip (Arguments)

Post by scottwilkerson »

Unfortunately, this is not possible.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
fscinfra
Posts: 4
Joined: Tue Jan 30, 2018 5:22 pm

Re: Alert Method: execute scrip (Arguments)

Post by fscinfra »

Hi,

mmm ok Thanks :( for you help.
Locked