Realtime "Req in Processing"

Discussion in 'PHP' started by nullx8, May 4, 2012.

  1. nullx8

    nullx8 Active Member

    is it possible with lsphp5 to get somehow access to the realtime stats ?
    specially the value of "Requests in Processing"

    the idea is simply to do some recovery if the server has too much backlog.

    sometimes we have a bout 1000 Requests in processing resulting of poor database connections. (not a laws fault)

    so the idea is to read this queue value somehow and adjust the scripts running if the backlog is getting too high.
  2. webizen

    webizen Well-Known Member

    EAProc In use/WaitQ in real-time stats is the one you look for. They reside in /tmp/lshttpd/.rtreport*
  3. nullx8

    nullx8 Active Member

    awesome ... thats even better than API ... (not requires additional reccources)

    can you shortly explain why there are multiple files are beeing created ?

    i had 1 yesterday now there are 2
    with same date ...

    is /tmp/lshttpd/.rtreport always the current one ?
  4. webizen

    webizen Well-Known Member

    rtreport* get generated by each CPU/core. you have 2-CPU license, so you see .rtreport and .rtreport.2. you should total the numbers from each rtreport for your report.
  5. nullx8

    nullx8 Active Member

    ah great.. thanks that makes more sense .

    here what i have done to put some "use" in this numbers

    if (is_file("/tmp/lshttpd/.rtreport")) {
    	$lsload = file('/tmp/lshttpd/.rtreport');
    	$lsload = explode(",",$lsload[4]);
    	$Site['health']['http_queue'] = intval(preg_replace("/[^\d]/", "", $lsload[0]));
    	$Site['health']['http_requests'] = intval(preg_replace("/[^\d]/", "", $lsload[1]));
    	if (is_file("/tmp/lshttpd/.rtreport.2")) { // core 2
    		$lsload = file('/tmp/lshttpd/.rtreport');
    		$lsload = explode(",",$lsload[4]);
    		$Site['health']['http_queue'] = ($Site['health']['http_queue'] + intval(preg_replace("/[^\d]/", "", $lsload[0])));
    		$Site['health']['http_requests'] = ($Site['health']['http_queue'] + intval(preg_replace("/[^\d]/", "", $lsload[1])));
    // redirect to TMP page on other machine if load is too high
    if (($Site['health']['http_queue'] > 400 )) {
    	header ("Location: ".$Site['paths']['staticserver2']."/pages/v3p/?for=".$_SERVER['REQUEST_URI']);	
  6. webizen

    webizen Well-Known Member

    Thanks for sharing that, nullx8.

Share This Page