I have a page that collects data that is passed to it via http querystring and parses it and stores it in SQL. The data includes drive data about the server checking in. The check in occurs with a custom VB service.
What seems to happen intermittently, is drive data from one server seems to end up stored under another server. Here's a meta representation of the mix-up:
SERVER--TIME--CDRIVE--DDRIVE--NOTE
SERVER-A--1215--355--126--This is a normal check-in for Server-A
SERVER-B--1215--1267--426--This is a normal check-in for Server-B
SERVER-A--1230--1267--426--This is a garbled check-in with B's data instead of A's
SERVER-B--1230--1267--426--This is normal, but is where the bad data comes from
The mix-up does not occur between any particular servers, just between two servers that happened to check in at the same moment. I have tried disabling output caching and most recently I have tried adding "session.abandon" to my code.
Any guidance would be greatly appreciated. I don't do web development as my primary task. I didn't even notice the issue until I set the drive data to loop after 7 days instead of looping every 24 hours.
Here's the code - the include just creates an "oconn" sql object.
<%language=vbscript%>
<!--#include file="includes/db.inc"-->
<%
'Variable Declaration
'---------------------
Private hsid
'COMMON SECTION
'--------------
hsid = request.querystring("hsid")
if isnumeric(hsid) then
hsid = cint(hsid)
else
oconn.close
session.abandon
response.end
end if
sessionid = now() & hsid
Session("SessionID") = sessionid
response.write(Session("SessionID") & "<br/>")
htime = now()
hdate = datevalue(htime)
hhour = hour(htime)
hminute = minute(htime)
hdur = 300
hver = request.querystring("hver")
if hver = "" then
hver = "Legacy"
end if
hupver = request.querystring("hupver")
if hupver = "" then
hupver = "Legacy"
end if
response.write("hupver = *" & hupver & "*<br/>")
'Stop processing if the server is not supported or the Company is not Icon.
sql = "select u.txtUserFirstName from users u inner join site s on u.fkySiteID = s.keySiteID inner join Company c on s.fkyCompanyID = c.keyCompanyID where u.keyUserID = " & hsid & " and u.binUserSupport = 1 and c.binCompanyIcon = 1"
set rs = oconn.execute(sql)
if rs.eof then
response.write("No Support")
session.abandon
response.end
end if
rs.close
set rs = nothing
function getfree(inputstring)
gfindex = instr(inputstring,"-")
' response.write(gfindex & "<br/>")
outputstring = mid(inputstring, 1, gfindex-1)
getfree = outputstring
end function
function getfull(inputstring)
gfindex = instr(inputstring,"-")
outputstring = mid(inputstring, gfindex+1, len(inputstring)-gfindex)
getfull = outputstring
end function
'DRIVES SECTION
'--------------
drivelow = 0 'captures whether any drive is below 1 GB free space for later use
Private drivearr(3,26)
'drivearr(1,x) is for thresholds, (2,x) is for free space, (3,x) is for total capacity
'all drives will actually count from 3 (c) to 26 (z)
'we collect drive threshold settings from the DriveThreshold table, or otherwise generate a default entry for it.
sql = "select * from DriveThreshold where fkyUserID = " & hsid
set rs = oconn.execute(sql)
if not rs.eof then
drivearr(1,3) = cdbl(rs("intcdrive"))*1024
drivearr(1,4) = cdbl(rs("intddrive"))*1024
drivearr(1,5) = cdbl(rs("intedrive"))*1024
drivearr(1,6) = cdbl(rs("intfdrive"))*1024
drivearr(1,7) = cdbl(rs("intgdrive"))*1024
drivearr(1,8) = cdbl(rs("inthdrive"))*1024
drivearr(1,9) = cdbl(rs("intidrive"))*1024
drivearr(1,10) = cdbl(rs("intjdrive"))*1024
drivearr(1,11) = cdbl(rs("intkdrive"))*1024
drivearr(1,12) = cdbl(rs("intldrive"))*1024
drivearr(1,13) = cdbl(rs("intmdrive"))*1024
drivearr(1,14) = cdbl(rs("intndrive"))*1024
drivearr(1,15) = cdbl(rs("intodrive"))*1024
drivearr(1,16) = cdbl(rs("intpdrive"))*1024
drivearr(1,17) = cdbl(rs("intqdrive"))*1024
drivearr(1,18) = cdbl(rs("intrdrive"))*1024
drivearr(1,19) = cdbl(rs("intsdrive"))*1024
drivearr(1,20) = cdbl(rs("inttdrive"))*1024
drivearr(1,21) = cdbl(rs("intudrive"))*1024
drivearr(1,22) = cdbl(rs("intvdrive"))*1024
drivearr(1,23) = cdbl(rs("intwdrive"))*1024
drivearr(1,24) = cdbl(rs("intxdrive"))*1024
drivearr(1,25) = cdbl(rs("intydrive"))*1024
drivearr(1,26) = cdbl(rs("intzdrive"))*1024
else
sql = "insert into DriveThreshold (fkyUserID, intCDrive, intDDrive, intEDrive, intFDrive, intGDrive, intHDrive, intIDrive, intJDrive, intKDrive, intLDrive, intMDrive, intNDrive, intODrive, intPDrive, intQDrive, intRDrive, intSDrive, intTDrive, intUDrive, intVDrive, intWDrive, intXDrive, intYDrive, intZDrive) values (" & hsid & ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)"
oconn.execute(sql)
for i = 3 to 26
drivearr(1,i) = 1*1024
next
end if
rs.close
set rs = nothing
'Load the null value (-1) for all positions in the drivearr for free spacce (2,x) and total capacity (3,x)
for i = 3 to 26
drivearr(2,i) = -1
drivearr(3,i) = -1
next
cdrive = request.querystring("c") 'collect C Drive data
' response.write("cdrive=" & cdrive & "<br/>")
if len(cdrive) > 3 then
drivearr(2,3) = getfree(cdrive)
drivearr(3,3) = getfull(cdrive)
end if
if drivearr(2,3) > -1 then 'only if C Drive is being monitored do we do the rest of the work
ddrive = request.querystring("d")
' response.write("ddrive=" & ddrive & "<br/>")
if len(ddrive) > 3 then
drivearr(2,4) = getfree(ddrive)
drivearr(3,4) = getfull(ddrive)
end if
edrive = request.querystring("e")
' response.write("edrive=" & edrive & "<br/>")
if len(edrive) > 3 then
drivearr(2,5) = getfree(edrive)
drivearr(3,5) = getfull(edrive)
end if
fdrive = request.querystring("f")
if len(fdrive) > 3 then
drivearr(2,6) = getfree(fdrive)
drivearr(3,6) = getfull(fdrive)
end if
gdrive = request.querystring("g")
if len(gdrive) > 3 then
drivearr(2,7) = getfree(gdrive)
drivearr(3,7) = getfull(gdrive)
end if
hdrive = request.querystring("h")
if len(hdrive) > 3 then
drivearr(2,8) = getfree(hdrive)
drivearr(3,8) = getfull(hdrive)
end if
idrive = request.querystring("i")
if len(idrive) > 3 then
drivearr(2,9) = getfree(idrive)
drivearr(3,9) = getfull(idrive)
end if
jdrive = request.querystring("j")
if len(jdrive) > 3 then
drivearr(2,10) = getfree(jdrive)
drivearr(3,10) = getfull(jdrive)
end if
kdrive = request.querystring("k")
if len(kdrive) > 3 then
drivearr(2,11) = getfree(kdrive)
drivearr(3,11) = getfull(kdrive)
end if
ldrive = request.querystring("l")
if len(ldrive) > 3 then
drivearr(2,12) = getfree(ldrive)
drivearr(3,12) = getfull(ldrive)
end if
mdrive = request.querystring("m")
if len(mdrive) > 3 then
drivearr(2,13) = getfree(mdrive)
drivearr(3,13) = getfull(mdrive)
end if
ndrive = request.querystring("n")
if len(ndrive) > 3 then
drivearr(2,14) = getfree(ndrive)
drivearr(3,14) = getfull(ndrive)
end if
odrive = request.querystring("o")
if len(odrive) > 3 then
drivearr(2,15) = getfree(odrive)
drivearr(3,15) = getfull(odrive)
end if
pdrive = request.querystring("p")
if len(pdrive) > 3 then
drivearr(2,16) = getfree(pdrive)
drivearr(3,16) = getfull(pdrive)
end if
qdrive = request.querystring("q")
if len(qdrive) > 3 then
drivearr(2,17) = getfree(qdrive)
drivearr(3,17) = getfull(qdrive)
end if
rdrive = request.querystring("r")
if len(rdrive) > 3 then
drivearr(2,18) = getfree(rdrive)
drivearr(3,18) = getfull(rdrive)
end if
sdrive = request.querystring("s")
if len(sdrive) > 3 then
drivearr(2,19) = getfree(sdrive)
drivearr(3,19) = getfull(sdrive)
end if
tdrive = request.querystring("t")
if len(tdrive) > 3 then
drivearr(2,20) = getfree(tdrive)
drivearr(3,20) = getfull(tdrive)
end if
udrive = request.querystring("u")
if len(udrive) > 3 then
drivearr(2,21) = getfree(udrive)
drivearr(3,21) = getfull(udrive)
end if
vdrive = request.querystring("v")
if len(vdrive) > 3 then
drivearr(2,22) = getfree(vdrive)
drivearr(3,22) = getfull(vdrive)
end if
wdrive = request.querystring("w")
if len(wdrive) > 3 then
drivearr(2,23) = getfree(wdrive)
drivearr(3,23) = getfull(wdrive)
end if
xdrive = request.querystring("x")
if len(xdrive) > 3 then
drivearr(2,24) = getfree(xdrive)
drivearr(3,24) = getfull(xdrive)
end if
ydrive = request.querystring("y")
if len(ydrive) > 3 then
drivearr(2,25) = getfree(ydrive)
drivearr(3,25) = getfull(ydrive)
end if
zdrive = request.querystring("z")
if len(zdrive) > 3 then
drivearr(2,26) = getfree(zdrive)
drivearr(3,26) = getfull(zdrive)
end if
'Test to see if any of the drives are low
for i = 3 to 26
if drivearr(2,i) > -1 then
if cdbl(drivearr(2,i)) < cdbl(drivearr(1,i)) then drivelow = 1
end if
next
if drivelow = 1 then 'we set the toggle for the server having 1+ drives low in the Users table.
sql = "update Users set binServerDriveLow = 1 where keyUserID = " & hsid
oconn.execute(sql)
else
sql = "update Users set binServerDriveLow = 0 where keyUserID = " & hsid
oconn.execute(sql)
end if
'----This section determines which of 2016 5-minute-intervals the check-in time matches and rounds the check-in time
rdate = hdate
rdayofweek = weekday(hdate)
rhour = hhour
rsequence = round(hminute/5,0)
if rsequence = 12 then
rsequence = 0
rhour = rhour + 1
if rhour = 24 then
rhour = 0
rdate = dateadd("d", 1, rdate)
rdayofweek = weekday(rdate)
end if
end if
rminute = rsequence * 5
rindex = ((rdayofweek-1) * 288) + (rhour * 12) + rsequence + 1
rtime = rdate & " " & timeserial(rhour, rminute, 0)
response.write("rindex: " & rindex & "<br />")
'----Determines which key value matches the sequence number in the DailyDrive table for use in data punch-down.
sql = "select keyDriveDailyID from DriveDaily where intDriveDailyIndex = " & rindex & " and fkyUserID = " & hsid
set rs = oconn.execute(sql)
if not rs.eof then 'if the sequence is found in the table and has a key value then update the table, otherwise....
ddkey = rs("keyDriveDailyID")
sql = "update DriveDaily set datDriveDailyTime = '" & rtime & "', CDrive = " & drivearr(2,3) & ", CDriveCap = " & drivearr(3,3) & ", DDrive = " & drivearr(2,4) & ", DDriveCap = " & drivearr(3,4) & ", EDrive = " & drivearr(2,5) & ", EDriveCap = " & drivearr(3,5) & ", FDrive = " & drivearr(2,6) & ", FDriveCap = " & drivearr(3,6) & ", GDrive = " & drivearr(2,7) & ", GDriveCap = " & drivearr(3,7) & ", HDrive = " & drivearr(2,8) & ", HDriveCap = " & drivearr(3,8) & ", IDrive = " & drivearr(2,9) & ", IDriveCap = " & drivearr(3,9) & ", JDrive = " & drivearr(2,10) & ", JDriveCap = " & drivearr(3,10) & ", KDrive = " & drivearr(2,11) & ", KDriveCap = " & drivearr(3,11) & ", LDrive = " & drivearr(2,12) & ", LDriveCap = " & drivearr(3,12) & ", MDrive = " & drivearr(2,13) & ", MDriveCap = " & drivearr(3,13) & ", NDrive = " & drivearr(2,14) & ", NDriveCap = " & drivearr(3,14) & ", ODrive = " & drivearr(2,15) & ", ODriveCap = " & drivearr(3,15) & ", PDrive = " & drivearr(2,16) & ", PDriveCap = " & drivearr(3,16) & ", QDrive = " & drivearr(2,17) & ", QDriveCap = " & drivearr(3,17) & ", RDrive = " & drivearr(2,18) & ", RDriveCap = " & drivearr(3,18) & ", SDrive = " & drivearr(2,19) & ", SDriveCap = " & drivearr(3,19) & ", TDrive = " & drivearr(2,20) & ", TDriveCap = " & drivearr(3,20) & ", UDrive = " & drivearr(2,21) & ", UDriveCap = " & drivearr(3,21) & ", VDrive = " & drivearr(2,22) & ", VDriveCap = " & drivearr(3,22) & ", WDrive = " & drivearr(2,23) & ", WDriveCap = " & drivearr(3,23) & ", XDrive = " & drivearr(2,24) & ", XDriveCap = " & drivearr(3,24) & ", YDrive = " & drivearr(2,25) & ", YDriveCap = " & drivearr(3,25) & ", ZDrive = " & drivearr(2,26) & ", ZDriveCap = " & drivearr(3,26) & " where keyDriveDailyID = " & ddkey
' response.write(sql)
' response.write("<br />")
' response.end
oconn.execute(sql)
else '...otherwise add a new entry to the table.
sql = "select numCounter from Counter where txtTableName = 'DriveDaily'"
set cs = oconn.execute(sql)
if not cs.eof then
ddkey = cdbl(cs("numCounter"))
end if
cs.close
set cs = nothing
sql = "insert into DriveDaily(keyDriveDailyID, fkyUserID, datDriveDailyTime, intDriveDailyIndex, CDrive, CDriveCap, DDrive, DDriveCap, EDrive, EDriveCap, FDrive, FDriveCap, GDrive, GDriveCap, HDrive, HDriveCap, IDrive, IDriveCap, JDrive, JDriveCap, KDrive, KDriveCap, LDrive, LDriveCap, MDrive, MDriveCap, NDrive, NDriveCap, ODrive, ODriveCap, PDrive, PDriveCap, QDrive, QDriveCap, RDrive, RDriveCap, SDrive, SDriveCap, TDrive, TDriveCap, UDrive, UDriveCap, VDrive, VDriveCap, WDrive, WDriveCap, XDrive, XDriveCap, YDrive, YDriveCap, ZDrive, ZDriveCap) values (" & ddkey & ", " & hsid & ", '" & rtime & "', " & rindex & ", " & drivearr(2,3) & ", " & drivearr(3,3) & ", " & drivearr(2,4) & ", " & drivearr(3,4) & ", " & drivearr(2,5) & ", " & drivearr(3,5) & ", " & drivearr(2,6) & ", " & drivearr(3,6) & ", " & drivearr(2,7) & ", " & drivearr(3,7) & ", " & drivearr(2,8) & ", " & drivearr(3,8) & ", " & drivearr(2,9) & ", " & drivearr(3,9) & ", " & drivearr(2,10) & ", " & drivearr(3,10) & ", " & drivearr(2,11) & ", " & drivearr(3,11) & ", " & drivearr(2,12) & ", " & drivearr(3,12) & ", " & drivearr(2,13) & ", " & drivearr(3,13) & ", " & drivearr(2,14) & ", " & drivearr(3,14) & ", " & drivearr(2,15) & ", " & drivearr(3,15) & ", " & drivearr(2,16) & ", " & drivearr(3,16) & ", " & drivearr(2,17) & ", " & drivearr(3,17) & ", " & drivearr(2,18) & ", " & drivearr(3,18) & ", " & drivearr(2,19) & ", " & drivearr(3,19) & ", " & drivearr(2,20) & ", " & drivearr(3,20) & ", " & drivearr(2,21) & ", " & drivearr(3,21) & ", " & drivearr(2,22) & ", " & drivearr(3,22) & ", " & drivearr(2,23) & ", " & drivearr(3,23) & ", " & drivearr(2,24) & ", " & drivearr(3,24) & ", " & drivearr(2,25) & ", " & drivearr(3,25) & ", " & drivearr(2,26) & ", " & drivearr(3,26) & ")"
' response.write(sql)
' response.end
oconn.execute(sql)
sql = "update Counter set numCounter = " & ddkey+1 & " where txtTableName = 'DriveDaily'"
oconn.execute(sql)
end if
rs.close
set rs = nothing
end if
'HEARTBEAT SECTION-------------------------------------------------------------
' DATETIME SUBSECTION
' -------------------
dt = request.querystring("dt")
if dt = "" then
' do nothing
else
dtyear = mid(dt,1,4)
dtmonth = mid(dt,5,2)
dtday = mid(dt,7,2)
dthour = mid(dt,9,2)
dtminute = mid(dt,11,2)
dtstring = dtmonth & "/" & dtday & "/" & dtyear & " " & dthour & ":" & dtminute
end if
sql = "select datHeartLast, intHeartNext from Users where keyUserID = " & hsid
set rs = oconn.execute(sql)
if not rs.eof then
hlast = rs("datHeartLast")
hnext = rs("intHeartNext")
end if
rs.close
set rs = nothing
response.write("<br />hlast = " & hlast & "<br />hnext = " & hnext)
if hnext > 0 then
hgap = datediff("s",hlast,htime)
if hnext + 60 < hgap then
sql = "select numCounter from Counter where txtTableName = 'Heart'"
set rs = oconn.execute(sql)
if not rs.eof then
heartid = cdbl(rs("numCounter"))
end if
rs.close
set rs = nothing
sql = "insert into Heart (keyHeartID, fkyServerID, datHeartDownStart, datHeartDownEnd) values (" & heartid & ", " & hsid & ", '" & hlast & "', '" & htime & "')"
oconn.execute(sql)
sql = "update Counter set numCounter = " & heartid + 1 & " where txtTableName = 'Heart'"
oconn.execute(sql)
end if
else
sql = "update Users set datHeartFirst = '" & htime & "' where keyUserID = " & hsid
oconn.execute(sql)
end if
sql = "update Users set datHeartLast = '" & htime & "', intHeartNext = " & hdur & ", datHeartDT = '" & dtstring & "', fkyHeartTicketID = null, binHeartEmailSent = 0, txtHeartVersion = '" & hver & "', txtHeartUpVersion = '" & hupver & "' where keyUserID = " & hsid
oconn.execute(sql)
oconn.close
set oconn = nothing
response.write(rindex & " " & htime & " " & rtime)
session.abandon
%>