Page 1 of 1

Command quick actions blocking all browser tabs

Posted: Thu Sep 29, 2016 1:54 am
by WillemDH
Hello,

I've had this problem in the past with Reactor chains when it was just released. When clicking a quick action, all browser tabs become unresponsive. As I'm now almost finished migrating my Reactor chains to commands which start a Rundeck bash script, it seem like this problem was never solved for commands.
So how to reproduce =>
- Create a Bash script which takes 2-3 minutes to finish
- Create a quick action with a command which starts this Bash script
- Open Nagios XI and click the quick action. The quick action output of the bash script should appear in a newly opened tab
- The Nagios XI page where the quick action was clicked hangs untill the quick action finishes

Hopefully there is an easy fix for this.

Grtz

Willem

Re: Command quick actions blocking all browser tabs

Posted: Thu Sep 29, 2016 12:12 pm
by mcapra
The solution will likely be using an asynchronous request over jQuery instead of opening a new browser window/tab to run the command/script.

Going to play around with some things and get back to you. Shouldn't take too long :)

Re: Command quick actions blocking all browser tabs

Posted: Thu Sep 29, 2016 12:50 pm
by mcapra
I was able to replicate this issue on XI 5.2.9 / Actions 1.6.6 for Firefox and Chrome. All I did was write a dummy PHP script that runs for 3 minutes and prints a number:

Code: Select all

<?php
$count = 0;

while ($count < 180) {
        echo $count . PHP_EOL;
        $count++;
        sleep(1);
}
?>
Which locked up the main Nagios XI tab. It looks like this is an issue with system/exec calls that has been reported fixed as of PHP 5.6:
https://bugs.php.net/bug.php?id=44942

If you'd prefer a more short-form solution, I modified /usr/local/nagiosxi/html/includes/components/actions/runcmd.php around line 123 to the following:

Code: Select all

session_write_close();
system($cmdline);
Adding a session_write_close call before the system call seems to have fixed the issue. Unsure about the possible repercussions with the $_SESSION itself, but my XI machine isn't doing anything terribly weird yet.

Re: Command quick actions blocking all browser tabs

Posted: Wed Oct 12, 2016 9:27 am
by WillemDH
Adding a session_write_close call before the system call seems to have fixed the issue for me too.

Thanks for this tip. This is a big improvement and should get in some future XI release.

Re: Command quick actions blocking all browser tabs

Posted: Wed Oct 12, 2016 12:20 pm
by SteveBeauchemin
Thank you... I'm starting to depend on Quick Actions more and was wondering what 'Normal' was for it.
I now see that the browser freeze was normal, but avoidable.
I have also added that line to my system.

Steve B

Re: Command quick actions blocking all browser tabs

Posted: Wed Oct 12, 2016 1:54 pm
by mcapra
I have filed a bug report for this issue (ID 9752). The official solution will probably be a bit more elegant than my hotfix.