Project

General

Profile

Actions

Bug #6166

closed

requests to diag_system_activity.php can pile up on slow systems

Added by Chris Buechler almost 8 years ago. Updated almost 8 years ago.

Status:
Resolved
Priority:
Normal
Category:
Web Interface
Target version:
Start date:
04/15/2016
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.3
Affected Architecture:

Description

from mailing list:
https://lists.pfsense.org/pipermail/list/2016-April/009646.html

Just upgraded my embedded pfsense to 2.3.
I have problems getting to the box (web or ssh) it just time outs.
On the web I sometime I get Nginx 504, sometime, just nothing.
Eventually I got logged in, try to check what's going on.
I have open Diagnostics->System Activity page, and start monitoring the network traffic.

There is Java Script that updates the page content every 2.5, but actual response in my case was more then 15 sec.
So I ended up with +20 pending requests to /diag_system_activity.php.

I don't think that setInterval is a good option here. Especially when you don't know how long it will take for the request to complete.

My suggestion is to use setTimeout like this:

<script type="text/javascript">
//<![CDATA[
function getcpuactivity() {
    $.ajax(
        '/diag_system_activity.php',
        {
            method: 'post',
            data: {
                getactivity: 'yes'
            },
            dataType: "html",
            success: function (data) {
                $('#xhrOutput').html(data);
+              setTimeout('getcpuactivity()', 2500);
            },
        }
    );
}

events.push(function() {
-    setInterval('getcpuactivity()', 2500);
+   setTimeout('getcpuactivity()', 2500);
    getcpuactivity();
});
//]]>
</script>

2.2.x and prior used setTimeout there so that seems reasonable but would like sbeaver to confirm.

Actions #1

Updated by Anonymous almost 8 years ago

There are a number of problems here. setTimeout is the appropriate function but the call is not quite formatted correctly.

It really needs a mutex to prevent AJAX calls being stacked up.

I will fix these items in a few minutes.

Actions #2

Updated by Anonymous almost 8 years ago

  • Status changed from Confirmed to Feedback
  • Assignee changed from Anonymous to Chris Buechler

AJAX function re-formatted to pfSense style

Added mutex to ensure only one AJAX call is made at a time

Actions #3

Updated by Anonymous almost 8 years ago

  • % Done changed from 0 to 100
Actions #4

Updated by Chris Buechler almost 8 years ago

  • Status changed from Feedback to Resolved

fixed

Actions

Also available in: Atom PDF