Forum Discussion
hooleylist
Dec 07, 2011Cirrostratus
Can you try testing this to make sure it loads and functions properly?
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"
set static::responseContent {
DDE Stats
body { font-family: Sans-Serif; }
p.headline { font-size:16pt; color: black; }
p.subtitle { font-size:8pt; color: grey; }
p.legend { font-size:8pt; color: white; }
p { font-size:11pt; color: black; }
var xmlHttp = null;
function ajaxGetSessionCount() {
var ss = document.getElementById('siteStatus');
ss.innerHTML = 'Updating...';
loadXmlHttp();
sendRequest('/updatedSessionCountDDE');
}
function loadXmlHttp() {
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
} catch(e) {}
}
}
function sendRequest(url) {
if (xmlHttp) {
xmlHttp.open('GET', url, true);
xmlHttp.onreadystatechange = onCallback;
xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlHttp.send(null);
}
}
function onCallback() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var result = xmlHttp.responseText;
updateBar(result);"
} else {
alert('Error: ' + xmlHttp.status);
}
}
}
function updateBar(ajaxSessionCount) {
var gbb = document.getElementById('guestBarBackground');"
var gcb = document.getElementById('guestCounterBar');"
var csc = document.getElementById('currentSessionCount');"
var ss = document.getElementById('siteStatus');
if (ajaxSessionCount) {
sessionCount = ajaxSessionCount;
} else {
sessionCount = \${sessionCount};
}
csc.innerHTML = 'Current count: ' + sessionCount + '';"
var pct_full = sessionCount / \${static::climitDDE};
var gcbWidth = (parseInt(gbb.style.width) * pct_full);"
gcb.style.width = gcbWidth;
if (gcbWidth == 0) {
gcb.innerHTML = 'Empty';
} else {
gcb.innerHTML = '' + sessionCount + '';
}
if (pct_full >= 100) {
ss.innerHTML = 'Site at Full Capacity: ' + Math.round((pct_full*100)*1000)/1000 + '%';
} else {
ss.innerHTML = 'Site at Capacity: ' + Math.round((pct_full*100)*1000)/1000 + '%';
}
}
Velvet Rule - Current Store Statistics
Instance: \${static::site-identDDE}
Current limit: \${static::climitDDE}
Legend:
Used Slots
Available Slots
subtable name: \${subtableName}
}
}
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" } {
HTTP::respond 200 content [subst $static::responseContent] Cache-Control No-Cache Pragma No-Cache
}
}
Aaron