Page 1 of 2

Long actions make browser hang

Posted: Tue Nov 04, 2014 8:30 am
by WillemDH
As I already discussed in thread http://support.nagios.com/forum/viewtop ... it=+action, My webbrowser (Firefox) hangs when executing actions that take a while to finish. See screenshot. As you can see the top left webpage hangs while my quick action to update all Windows hosts is running. So at this time I'm preferring to start longer quick actions from cli, as they make the browser unusable while the script is running.
I thought it was solved, by using the last version of the action component, but noticed this week it is not solved. The nagios XI webpage hangs untill the quick action stops running.

In order to use the actions component instead of the Nagios XI cli for scripts that take longer then 5 seconds, I would need some solution for this. Any tips?

Re: Long actions make browser hang

Posted: Tue Nov 04, 2014 2:23 pm
by tmcdonald
How important is it that you see the output? I'm thinking this is a combination of PHP timeouts, AJAX handling, and the script itself. If the script forked itself and exited, the upgrade might still run in the background and the page can "complete", then you could maybe save the output to a file and view that in the web interface later.

Re: Long actions make browser hang

Posted: Tue Nov 04, 2014 4:27 pm
by WillemDH
Hmm it's important to see the final output, so if you would have some way to display the output in the browser when the script ends, that would be ok for me. The script is already outputting to a logfile to. I'm not really sure how I should proceed in doing what you propose.

Grtz

Willem

Re: Long actions make browser hang

Posted: Tue Nov 04, 2014 5:45 pm
by abrist
What if the output appeared down in the footer as a "notice", would that be ok?

Re: Long actions make browser hang

Posted: Wed Nov 05, 2014 2:35 am
by WillemDH
Hey Andy,

Thanks for your input. I'm not exactly sure what you mean with the footer, as at this time it's just one blank page. But I think it would be ok, as long as I can see or during the script execution or when the script end, if all hosts updates went fine. I will edit my script to summarize at the end how many have failed.

Grtz

Re: Long actions make browser hang

Posted: Wed Nov 05, 2014 5:25 pm
by tmcdonald
The way I would do this is have the action link to a second page that kicks off/forks the script in the background which logs to a file. Then some AJAX could periodically refresh a view of the log for output.

http://stackoverflow.com/questions/1455 ... ess-issues

Re: Long actions make browser hang

Posted: Thu Nov 06, 2014 3:19 am
by WillemDH
Hmmm Trevor,

You kind of made my head spin... The action is linking to a Bash script at this time that will get all the members of a hostgroup and then call three or four Powershell scripts, one optional to install the NSClient latest allowed version, one to update the NSClient scripts folder, one to generate the nsclient.ini and one to push the downtime tool to the desktop of the server.
The output I get comes from the error handling of the Powershell script and some of the Bash scripts.
So i'm not really sure where to link to the second page that would kick off or fork the scripts in the background. I would also prefer to not have two tabs opened for each action I click.

Grtz

Willem

Re: Long actions make browser hang

Posted: Thu Nov 06, 2014 5:54 pm
by tmcdonald
I guess "second page" wasn't the right phrase. It could all be done on the same "page" but kick off the bash process in the background. The link I posted should work for backgrounding in this manner, but I would have to test it myself to know for sure. If it does work that way, then having the scripts write to a single logfile would work then the action component could have the AJAX that displays the logfile in realtime.

Re: Long actions make browser hang

Posted: Fri Nov 14, 2014 4:08 pm
by WillemDH
So I would have to call my update script like this from a wrapper script?

Code: Select all

file=/user/local/nagios/libexec/naf/tempfile.log
exec("naf_mass_update_host_windows_01.sh $file > /dev/null &");
And how would I enable AJAX to display this log with the actions component?

Grtz

Willem

Re: Long actions make browser hang

Posted: Mon Nov 17, 2014 2:07 pm
by abrist
Well, as you are piping it to /dev/null, I don't think you see the output anywhere. You could create one quick action script to run the action in the background and write the output to a file. Then write another quick action to display that file.