Page 2 of 4

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

Posted: Tue Oct 22, 2013 2:57 pm
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

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

Posted: Wed Oct 23, 2013 2:39 am
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).

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

Posted: Wed Oct 23, 2013 11:11 am
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>';

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

Posted: Wed Oct 23, 2013 11:50 am
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..

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

Posted: Wed Oct 23, 2013 11:54 am
by abrist
Do you get any error is the logs?

Code: Select all

tail -25 /var/log/httpd/error_log

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

Posted: Wed Oct 23, 2013 12:05 pm
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

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

Posted: Wed Oct 23, 2013 12:20 pm
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?)

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

Posted: Wed Oct 23, 2013 12:44 pm
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.

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

Posted: Wed Oct 23, 2013 1:15 pm
by abrist
Was the exact configuration working before my php edits?

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

Posted: Wed Oct 23, 2013 2:21 pm
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..