Custom action url doesn't seem to accept macro's

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom action url doesn't seem to accept macro's

Post by abrist »

That is actually one line . . .

Code: Select all

#!/bin/bash
# This is a sample shell script showing how you can submit the PROCESS_SERVICE_CHECK_RESULT command
# to Nagios.  Adjust variables to fit your environment as necessary.

HOSTNAME=$1
SERVICENAME=$2
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'

/usr/bin/printf "[%lu] PROCESS_SERVICE_CHECK_RESULT;$HOSTNAME;$SERVICENAME;0;OK - Manual Reset\n" $now > $commandfile
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Custom action url doesn't seem to accept macro's

Post by WillemDH »

Indeed, it's working now. Is there a way to prevent the webpage from popping up that is only saying the script is running? We would really just want to the script to execute silently (in the background).
Nagios XI 5.8.1
https://outsideit.net
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom action url doesn't seem to accept macro's

Post by abrist »

WillemDH wrote:Is there a way to prevent the webpage from popping up that is only saying the script is running?
Yes, though you need to edit the php to target a hidden iframe:

Code: Select all

/usr/local/nagiosxi/html/includes/components/actions/actions.inc.php
Change line #475 from:

Code: Select all

$target="_blank";
To:

Code: Select all

$target="hidden_action_div";
Then change line #502 from:

Code: Select all

$cbargs["actions"][]='<li><div class="commandimage"><a href="'.$url.'" target="'.$target.'" '.$hrefopts.'><img src="'.$img.'" alt="'.htmlentities($text).'" title="'.htmlentities($text).'"></a></div><div class="commandtext"><a href="'.$url.'" target="'.$target.'" '.$hrefopts.'>'.htmlentities($text).'</a></div> </li>';
To:

Code: Select all

$cbargs["actions"][]='<li><div class="commandimage"><a href="'.$url.'" target="'.$target.'" '.$hrefopts.'><img src="'.$img.'" alt="'.htmlentities($text).'" title="'.htmlentities($text).'"></a></div><div class="commandtext"><a href="'.$url.'" target="'.$target.'" '.$hrefopts.'>'.htmlentities($text).'</a></div><iframe name="hidden_action_div" style="display:none;"></iframe> </li>';
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Custom action url doesn't seem to accept macro's

Post by WillemDH »

I made the changes you asked and did a service httpd restart, flushed cache, but it's not working yet. Attached some screenshots. Anything else I'm supposed to do? I made a backup first and had to put the $cbargs line with two enters to get it in the screenshot, but it's still in one line in the file..
You do not have the required permissions to view the files attached to this post.
Nagios XI 5.8.1
https://outsideit.net
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom action url doesn't seem to accept macro's

Post by abrist »

Do you get any error is the logs?

Code: Select all

tail -25 /var/log/httpd/error_log
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Custom action url doesn't seem to accept macro's

Post by WillemDH »

PHP Warning: Missing argument 3 for actions_component_get_service_vars(), called in /usr/local/nagiosxi/html/includes/components/actions/runcmd.php on line 100 and defined in /usr/local/nagiosxi/html/includes/components/actions/actions.inc.php on line 685, referer: http://srvnagios01/nagiosxi/includes/co ... &dest=auto

PHP Warning: Missing argument 4 for actions_component_get_service_vars(), called in /usr/local/nagiosxi/html/includes/components/actions/runcmd.php on line 100 and defined in /usr/local/nagiosxi/html/includes/components/actions/actions.inc.php on line 685, referer: http://srvnagios01/nagiosxi/includes/co ... &dest=auto
Nagios XI 5.8.1
https://outsideit.net
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom action url doesn't seem to accept macro's

Post by abrist »

The options from the component are not getting passed to the php correctly. This is strange as what I had you change would not effect that at all. What does your actions component configuration for the action look like? (screenshot?)
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Custom action url doesn't seem to accept macro's

Post by WillemDH »

I'm still testing, so I have one action for nrdp, one with the external command interface (web) and one with bash script. See screenshot:
I only tested the bash script action, so the error log comes from the 4th action.
You do not have the required permissions to view the files attached to this post.
Nagios XI 5.8.1
https://outsideit.net
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom action url doesn't seem to accept macro's

Post by abrist »

Was the exact configuration working before my php edits?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Custom action url doesn't seem to accept macro's

Post by WillemDH »

The configuration was working before the php edits and in fact it's still working now. So maybe I already got the errors before the edit..
Nagios XI 5.8.1
https://outsideit.net
Locked