Jay_Henriques_1
Dec 07, 2011Nimbostratus
b load returning parsing error
Line 20591 is this iRule but I can't find why it is the parsing is failing:
Velvet Rope Statistics
This irule monitor the current number of sessions within a velvet rope'd site. It performs an ajax call
to read the session table and compare that against the _manually_ set limit.
Not the most elegant solution, but effective. Apply this to a virtual server (not your main VS) and use
http://_vs-domain_/vrstatsDDE for statistics. (sub in your domain)
when RULE_INIT {
set static::site-identDDE "ddewcsp"
}
when HTTP_REQUEST {
set subtableName "sessionLimit-${static::site-identDDE}"
set sessionCount [table keys -subtable $subtableName -count]
See if we're on the ajax request
if { [HTTP::uri] equals "/updatedSessionCountDDE" } {
HTTP::respond 200 content $sessionCount Cache-Control No-Cache Pragma No-Cache
} elseif { [HTTP::uri] contains "/vrstatsdde" } {
set responseContent "DDE Stats"
append responseContent ""
append responseContent "body { font-family: Sans-Serif; }"
append responseContent "p.headline { font-size:16pt; color: black; }"
append responseContent "p.subtitle { font-size:8pt; color: grey; }"
append responseContent "p.legend { font-size:8pt; color: white; }"
append responseContent "p { font-size:11pt; color: black; }"
append responseContent ""
append responseContent ""
append responseContent "var xmlHttp = null;"
append responseContent "function ajaxGetSessionCount() {"
append responseContent " var ss = document.getElementById('siteStatus');"
append responseContent " ss.innerHTML = 'Updating...';"
append responseContent " loadXmlHttp();"
append responseContent " sendRequest('/updatedSessionCountDDE');"
append responseContent "}"
append responseContent "function loadXmlHttp() {"
append responseContent " if (window.XMLHttpRequest) {"
append responseContent " xmlHttp = new XMLHttpRequest();"
append responseContent " } else if (window.ActiveXObject) {"
append responseContent " try {"
append responseContent " xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');"
append responseContent " } catch(e) {}"
append responseContent " }"
append responseContent "}"
append responseContent "function sendRequest(url) {"
append responseContent " if (xmlHttp) {"
append responseContent " xmlHttp.open('GET', url, true);"
append responseContent " xmlHttp.onreadystatechange = onCallback;"
append responseContent " xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');"
append responseContent " xmlHttp.send(null);"
append responseContent " }"
append responseContent "}"
append responseContent "function onCallback() {"
append responseContent " if (xmlHttp.readyState == 4) {"
append responseContent " if (xmlHttp.status == 200) {"
append responseContent " var result = xmlHttp.responseText;"
append responseContent " updateBar(result);" append responseContent " } else {" append responseContent " alert('Error: ' + xmlHttp.status);"
append responseContent " }"
append responseContent " }"
append responseContent "}"
append responseContent "function updateBar(ajaxSessionCount) {"
append responseContent " var gbb = document.getElementById('guestBarBackground');" append responseContent " var gcb = document.getElementById('guestCounterBar');" append responseContent " var csc = document.getElementById('currentSessionCount');" append responseContent " var ss = document.getElementById('siteStatus');"
append responseContent " if (ajaxSessionCount) {"
append responseContent " sessionCount = ajaxSessionCount;"
append responseContent " } else {"
append responseContent " sessionCount = ${sessionCount};"
append responseContent " }"
append responseContent " csc.innerHTML = 'Current count: ' + sessionCount + '';" append responseContent " var pct_full = sessionCount / ${static::climitDDE};"
append responseContent " var gcbWidth = (parseInt(gbb.style.width) * pct_full);" append responseContent " gcb.style.width = gcbWidth;"
append responseContent " if (gcbWidth == 0) {"
append responseContent " gcb.innerHTML = 'Empty';"
append responseContent " } else {"
append responseContent " gcb.innerHTML = '' + sessionCount + '';"
append responseContent " }"
append responseContent " if (pct_full >= 100) {"
append responseContent " ss.innerHTML = 'Site at Full Capacity: ' + Math.round((pct_full*100)*1000)/1000 + '%';"
append responseContent " } else {"
append responseContent " ss.innerHTML = 'Site at Capacity: ' + Math.round((pct_full*100)*1000)/1000 + '%';"
append responseContent " }"
append responseContent "}"
append responseContent ""
append responseContent ""
append responseContent "Velvet Rule - Current Store Statistics"
append responseContent "Instance: ${static::site-identDDE}"
append responseContent "Current limit: ${static::climitDDE}"
append responseContent ""
append responseContent ""
append responseContent ""
append responseContent ""
append responseContent ""
append responseContent ""
append responseContent "Legend:"
append responseContent "Used Slots"
append responseContent "Available Slots"
append responseContent "subtable name: ${subtableName} "
HTTP::respond 200 content $responseContent Cache-Control No-Cache Pragma No-Cache }
}